diff options
Diffstat (limited to 'src/kvilib/tal')
79 files changed, 7103 insertions, 0 deletions
diff --git a/src/kvilib/tal/Makefile.am b/src/kvilib/tal/Makefile.am new file mode 100644 index 00000000..c84487eb --- /dev/null +++ b/src/kvilib/tal/Makefile.am @@ -0,0 +1,5 @@ +############################################################################### +# KVirc IRC client Makefile - 16.12.98 Szymon Stefanek <stefanek@tin.it> +############################################################################### + +EXTRA_DIST = *.cpp *.h diff --git a/src/kvilib/tal/kvi_tal_application.cpp b/src/kvilib/tal/kvi_tal_application.cpp new file mode 100644 index 00000000..4d8bd0d5 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_application.cpp @@ -0,0 +1,69 @@ +// +// File : kvi_tal_application.coo +// Creation date : Sun Aug 12 2001 04:34:21 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#define __KVILIB__ + + +#include "kvi_tal_application.h" + +#ifdef COMPILE_KDE_SUPPORT + + // The constructor below triggers a warning + // ../tal/kvi_tal_application.cpp: In constructor + // `KviTalApplication::KviTalApplication(int, char**)': + // ../tal/kvi_tal_application.cpp:31: warning: `__base_ctor' is deprecated + // (declared at /opt/kde/include/kapplication.h:198) + // + // The KApplication constructor has been declared as deprecated + // in favor of a complexier initialization that uses KCmdLineArgs + // and can't be abstracted easily. + // The other constructors are not "old" and "stable" enough + // to be safely used at this time. We'll rethink this when KDE 4 is out. + + KviTalApplication::KviTalApplication(int &argc,char ** argv) + : KApplication(argc,argv,"kvirc") + { + + + + } + + KviTalApplication::~KviTalApplication() + { + } + + #include "kvi_tal_application_kde.moc" + +#else + + KviTalApplication::KviTalApplication(int &argc,char ** argv) + : QApplication(argc,argv) + { + } + + KviTalApplication::~KviTalApplication() + { + } + + #include "kvi_tal_application_qt.moc" + +#endif diff --git a/src/kvilib/tal/kvi_tal_application.h b/src/kvilib/tal/kvi_tal_application.h new file mode 100644 index 00000000..4f9e96df --- /dev/null +++ b/src/kvilib/tal/kvi_tal_application.h @@ -0,0 +1,34 @@ +#ifndef _KVI_TAL_APPLICATION_H_ +#define _KVI_TAL_APPLICATION_H_ + +// +// File : kvi_appbase_kde.h +// Creation date : Sun Jun 18 2000 12:53:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include "kvi_settings.h" + +#ifdef COMPILE_KDE_SUPPORT + #include "kvi_tal_application_kde.h" +#else + #include "kvi_tal_application_qt.h" +#endif + +#endif // _KVI_TAL_APPLICATION_H_ diff --git a/src/kvilib/tal/kvi_tal_application_kde.h b/src/kvilib/tal/kvi_tal_application_kde.h new file mode 100644 index 00000000..05d6e87f --- /dev/null +++ b/src/kvilib/tal/kvi_tal_application_kde.h @@ -0,0 +1,37 @@ +#ifndef _KVI_TAL_APPLICATION_KDE_H_ +#define _KVI_TAL_APPLICATION_KDE_H_ + +// +// File : kvi_tal_application_kde.h +// Creation date : Sun Aug 12 2001 04:32:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include <kapp.h> + + +class KVILIB_API KviTalApplication : public KApplication +{ + Q_OBJECT +public: + KviTalApplication(int &argc,char ** argv); + ~KviTalApplication(); +}; + +#endif // _KVI_TAL_APPLICATION_KDE_H_ diff --git a/src/kvilib/tal/kvi_tal_application_qt.h b/src/kvilib/tal/kvi_tal_application_qt.h new file mode 100644 index 00000000..953608fe --- /dev/null +++ b/src/kvilib/tal/kvi_tal_application_qt.h @@ -0,0 +1,37 @@ +#ifndef _KVI_TAL_APPLICATION_QT_H_ +#define _KVI_TAL_APPLICATION_QT_H_ + +// +// File : kvi_tal_application_qt.h +// Creation date : Sun Aug 12 2001 04:33:21 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include <qapplication.h> + + +class KVILIB_API KviTalApplication : public QApplication +{ + Q_OBJECT +public: + KviTalApplication(int &argc,char ** argv); + ~KviTalApplication(); +}; + +#endif // _KVI_TAL_APPLICATION_QT_H_ diff --git a/src/kvilib/tal/kvi_tal_filedialog.cpp b/src/kvilib/tal/kvi_tal_filedialog.cpp new file mode 100644 index 00000000..b345fd0b --- /dev/null +++ b/src/kvilib/tal/kvi_tal_filedialog.cpp @@ -0,0 +1,176 @@ +//============================================================================= +// +// File : kvi_tal_filedialog.coo +// Creation date : Thu Sep 11 2003 04:09:24 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2003-2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ + + +#include "kvi_tal_filedialog.h" + +#ifdef COMPILE_USE_QT4 + + #include <qdir.h> + + KviTalFileDialog::KviTalFileDialog(const QString &dirName,const QString &filter,QWidget *parent,const char *name,bool modal) + : QFileDialog(parent,"",dirName,filter) + { + setModal(modal); + } + + KviTalFileDialog::~KviTalFileDialog() + { + } + + void KviTalFileDialog::setFileMode(FileMode m) + { + switch(m) + { + case AnyFile: + QFileDialog::setFileMode(QFileDialog::AnyFile); + break; + case ExistingFile: + QFileDialog::setFileMode(QFileDialog::ExistingFile); + break; + case ExistingFiles: + QFileDialog::setFileMode(QFileDialog::ExistingFiles); + break; + case Directory: + QFileDialog::setFileMode(QFileDialog::Directory); + break; + case DirectoryOnly: + QFileDialog::setFileMode(QFileDialog::DirectoryOnly); + break; + default: + QFileDialog::setFileMode(QFileDialog::AnyFile); + break; + } + } + + void KviTalFileDialog::setDirectory(const QString &szDirectory) + { + QFileDialog::setDirectory(szDirectory); + } + + + #include "kvi_tal_filedialog_qt4.moc" + +#else + + #ifdef COMPILE_KDE_SUPPORT + + KviTalFileDialog::KviTalFileDialog(const QString &dirName,const QString &filter,QWidget *parent,const char *name,bool modal) + : KFileDialog(dirName,filter,parent,name,modal) + { + clearWFlags(WDestructiveClose); + } + + KviTalFileDialog::~KviTalFileDialog() + { + } + + void KviTalFileDialog::setFileMode(FileMode m) + { + switch(m) + { + case AnyFile: + setMode(KFile::File | KFile::LocalOnly); + setOperationMode(Saving); + break; + case ExistingFile: + setMode(KFile::File | KFile::ExistingOnly | KFile::LocalOnly); + setOperationMode(Opening); + break; + case ExistingFiles: + setMode(KFile::Files | KFile::ExistingOnly | KFile::LocalOnly); + setOperationMode(Opening); + break; + case Directory: + setMode(KFile::Directory); + break; + case DirectoryOnly: + setMode(KFile::Directory); + break; + default: + setMode(KFile::File | KFile::LocalOnly); + setOperationMode(Saving); + break; + } + } + + void KviTalFileDialog::setDirectory(const QString &szDirectory) + { + setURL(szDirectory); + } + + + #include "kvi_tal_filedialog_kde.moc" + + #else + + #include <qdir.h> + + KviTalFileDialog::KviTalFileDialog(const QString &dirName,const QString &filter,QWidget *parent,const char *name,bool modal) + : QFileDialog(dirName,filter,parent,name,modal) + { + clearWFlags(WDestructiveClose); + } + + KviTalFileDialog::~KviTalFileDialog() + { + } + + void KviTalFileDialog::setFileMode(FileMode m) + { + switch(m) + { + case AnyFile: + setMode(QFileDialog::AnyFile); + break; + case ExistingFile: + setMode(QFileDialog::ExistingFile); + break; + case ExistingFiles: + setMode(QFileDialog::ExistingFiles); + break; + case Directory: + setMode(QFileDialog::Directory); + break; + case DirectoryOnly: + setMode(QFileDialog::DirectoryOnly); + break; + default: + setMode(QFileDialog::AnyFile); + break; + } + } + + void KviTalFileDialog::setDirectory(const QString &szDirectory) + { + setDir(QDir(szDirectory)); + } + + + #include "kvi_tal_filedialog_qt.moc" + + #endif +#endif diff --git a/src/kvilib/tal/kvi_tal_filedialog.h b/src/kvilib/tal/kvi_tal_filedialog.h new file mode 100644 index 00000000..eac2e645 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_filedialog.h @@ -0,0 +1,40 @@ +#ifndef _KVI_TAL_FILEDIALOG_H_ +#define _KVI_TAL_FILEDIALOG_H_ + +//============================================================================= +// +// File : kvi_tal_filedialog.h +// Creation date : Thu Sep 11 2003 04:41:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2003-2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_filedialog_qt4.h" +#else + #ifdef COMPILE_KDE_SUPPORT + #include "kvi_tal_filedialog_kde.h" + #else + #include "kvi_tal_filedialog_qt.h" + #endif +#endif + +#endif // _KVI_TAL_FILEDIALOG_H_ diff --git a/src/kvilib/tal/kvi_tal_filedialog_kde.h b/src/kvilib/tal/kvi_tal_filedialog_kde.h new file mode 100644 index 00000000..0f04a80c --- /dev/null +++ b/src/kvilib/tal/kvi_tal_filedialog_kde.h @@ -0,0 +1,50 @@ +#ifndef _KVI_TAL_FILEDIALOG_KDE_H_ +#define _KVI_TAL_FILEDIALOG_KDE_H_ + +// +// File : kvi_tal_filedialog_kde.h +// Creation date : Thu Aug 11 2003 04:43:58 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2003 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include <kfiledialog.h> +#include <qfiledialog.h> + +class KVILIB_API KviTalFileDialog : public KFileDialog +{ + Q_OBJECT +public: + KviTalFileDialog(const QString &dirName,const QString &filter = QString::null,QWidget *parent = 0,const char *name = 0,bool modal = FALSE); + ~KviTalFileDialog(); +public: + enum FileMode { AnyFile, ExistingFile, ExistingFiles, Directory, DirectoryOnly }; + + void setFileMode(FileMode m); + void setDirectory(const QString &szDirectory); + + + static QString getExistingDirectoryPath(const QString &dir = QString::null,const QString &caption = QString::null,QWidget *parent = 0) + { + // QFileDialog allows making new directories...kfiledialog not :/ + return QFileDialog::getExistingDirectory(dir,parent,0,caption); + //return getExistingDirectory(dir,parent,caption); + }; +}; + +#endif // _KVI_TAL_FILEDIALOG_KDE_H_ diff --git a/src/kvilib/tal/kvi_tal_filedialog_qt.h b/src/kvilib/tal/kvi_tal_filedialog_qt.h new file mode 100644 index 00000000..14a24854 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_filedialog_qt.h @@ -0,0 +1,44 @@ +#ifndef _KVI_TAL_FILEDIALOG_QT_H_ +#define _KVI_TAL_FILEDIALOG_QT_H_ + +// +// File : kvi_tal_filedialog_qt.h +// Creation date : Thu Aug 11 2003 04:43:58 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2003 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include <qfiledialog.h> + +class KVILIB_API KviTalFileDialog : public QFileDialog +{ + Q_OBJECT +public: + KviTalFileDialog(const QString &dirName,const QString &filter = QString::null,QWidget *parent = 0,const char *name = 0,bool modal = FALSE); + ~KviTalFileDialog(); +public: + enum FileMode { AnyFile, ExistingFile, ExistingFiles, Directory, DirectoryOnly }; + + void setFileMode(FileMode m); + void setDirectory(const QString &szDirectory); + + static QString getExistingDirectoryPath(const QString &dir = QString::null,const QString &caption = QString::null,QWidget *parent = 0) + { return getExistingDirectory(dir,parent,0 /* name */,caption); }; +}; + +#endif // _KVI_TAL_FILEDIALOG_QT_H_ diff --git a/src/kvilib/tal/kvi_tal_filedialog_qt4.h b/src/kvilib/tal/kvi_tal_filedialog_qt4.h new file mode 100644 index 00000000..eb5f7ab6 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_filedialog_qt4.h @@ -0,0 +1,46 @@ +#ifndef _KVI_TAL_FILEDIALOG_QT4_H_ +#define _KVI_TAL_FILEDIALOG_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_filedialog_qt4.h +// Creation date : Fri 19 Jan 2007 02:17:12 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include <qfiledialog.h> + +class KVILIB_API KviTalFileDialog : public QFileDialog +{ + Q_OBJECT +public: + KviTalFileDialog(const QString &dirName,const QString &filter = QString::null,QWidget *parent = 0,const char *name = 0,bool modal = FALSE); + ~KviTalFileDialog(); +public: + enum FileMode { AnyFile, ExistingFile, ExistingFiles, Directory, DirectoryOnly }; + + void setFileMode(FileMode m); + void setDirectory(const QString &szDirectory); + + static QString getExistingDirectoryPath(const QString &dir = QString::null,const QString &caption = QString::null,QWidget *parent = 0) + { return getExistingDirectory(parent,caption,dir); }; +}; + +#endif // _KVI_TAL_FILEDIALOG_QT_H_ diff --git a/src/kvilib/tal/kvi_tal_grid.cpp b/src/kvilib/tal/kvi_tal_grid.cpp new file mode 100644 index 00000000..472af5a0 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_grid.cpp @@ -0,0 +1,34 @@ +//============================================================================= +// +// File : kvi_tal_grid.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_grid.h" + + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_grid_qt4.moc" +#else + #include "kvi_tal_grid_qt3.moc" +#endif + diff --git a/src/kvilib/tal/kvi_tal_grid.h b/src/kvilib/tal/kvi_tal_grid.h new file mode 100644 index 00000000..18c4af98 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_grid.h @@ -0,0 +1,36 @@ +#ifndef _KVI_TAL_GRID_H_ +#define _KVI_TAL_GRID_H_ + +//============================================================================= +// +// File : kvi_tal_grid.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_grid_qt4.h" +#else + #include "kvi_tal_grid_qt3.h" +#endif + +#endif // _KVI_TAL_GRID_H_ diff --git a/src/kvilib/tal/kvi_tal_grid_qt3.h b/src/kvilib/tal/kvi_tal_grid_qt3.h new file mode 100644 index 00000000..fd77d15c --- /dev/null +++ b/src/kvilib/tal/kvi_tal_grid_qt3.h @@ -0,0 +1,39 @@ +#ifndef _KVI_TAL_GRID_QT3_H_ +#define _KVI_TAL_GRID_QT3_H_ + +//============================================================================= +// +// File : kvi_tal_grid_qt3.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include <qgrid.h> + +class KVILIB_API KviTalGrid : public QGrid +{ + Q_OBJECT +public: + KviTalGrid(int n,Qt::Orientation orient,QWidget * pParent = 0) + : QGrid(n,orient,pParent) {}; + ~KviTalGrid() {}; +}; + +#endif // _KVI_TAL_GRID_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_grid_qt4.h b/src/kvilib/tal/kvi_tal_grid_qt4.h new file mode 100644 index 00000000..57612b3c --- /dev/null +++ b/src/kvilib/tal/kvi_tal_grid_qt4.h @@ -0,0 +1,41 @@ +#ifndef _KVI_TAL_GRID_QT4_H_ +#define _KVI_TAL_GRID_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_grid_qt4.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include <q3grid.h> + +class KVILIB_API KviTalGrid : public Q3Grid +{ + Q_OBJECT +public: + KviTalGrid(int n,Qt::Orientation orient,QWidget * pParent = 0) + : Q3Grid(n,orient,pParent) {}; + ~KviTalGrid() {}; +}; + +#endif // _KVI_TAL_GRID_QT4_H_ diff --git a/src/kvilib/tal/kvi_tal_groupbox.cpp b/src/kvilib/tal/kvi_tal_groupbox.cpp new file mode 100644 index 00000000..bf2f5689 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_groupbox.cpp @@ -0,0 +1,34 @@ +//============================================================================= +// +// File : kvi_tal_groupbox.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_groupbox.h" + + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_groupbox_qt4.moc" +#else + #include "kvi_tal_groupbox_qt3.moc" +#endif + diff --git a/src/kvilib/tal/kvi_tal_groupbox.h b/src/kvilib/tal/kvi_tal_groupbox.h new file mode 100644 index 00000000..ae82519b --- /dev/null +++ b/src/kvilib/tal/kvi_tal_groupbox.h @@ -0,0 +1,36 @@ +#ifndef _KVI_TAL_GROUPBOX_H_ +#define _KVI_TAL_GROUPBOX_H_ + +//============================================================================= +// +// File : kvi_tal_groupbox.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_groupbox_qt4.h" +#else + #include "kvi_tal_groupbox_qt3.h" +#endif + +#endif // _KVI_TAL_GROUPBOX_H_ diff --git a/src/kvilib/tal/kvi_tal_groupbox_qt3.h b/src/kvilib/tal/kvi_tal_groupbox_qt3.h new file mode 100644 index 00000000..be3340a3 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_groupbox_qt3.h @@ -0,0 +1,47 @@ +#ifndef _KVI_TAL_GROUPBOX_QT3_H_ +#define _KVI_TAL_GROUPBOX_QT3_H_ + +//============================================================================= +// +// File : kvi_tal_groupbox_qt3.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include <qgroupbox.h> + +class KVILIB_API KviTalGroupBox : public QGroupBox +{ + Q_OBJECT +public: + KviTalGroupBox(QWidget * parent = 0) + : QGroupBox(parent) {}; + KviTalGroupBox(const QString & title,QWidget * parent = 0) + : QGroupBox(title,parent) {}; + KviTalGroupBox(int strips,Qt::Orientation orientation,QWidget * parent = 0) + : QGroupBox(strips,orientation,parent) {}; + KviTalGroupBox(int strips,Qt::Orientation orientation,const QString & title,QWidget * parent = 0) + : QGroupBox(strips,orientation,title,parent) {}; + ~KviTalGroupBox() {}; +}; + + + +#endif // _KVI_TAL_GROUPBOX_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_groupbox_qt4.h b/src/kvilib/tal/kvi_tal_groupbox_qt4.h new file mode 100644 index 00000000..c8917385 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_groupbox_qt4.h @@ -0,0 +1,47 @@ +#ifndef _KVI_TAL_GROUPBOX_QT4_H_ +#define _KVI_TAL_GROUPBOX_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_groupbox_qt4.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include <q3groupbox.h> + +class KVILIB_API KviTalGroupBox : public Q3GroupBox +{ + Q_OBJECT +public: + KviTalGroupBox(QWidget * parent = 0) + : Q3GroupBox(parent) {}; + KviTalGroupBox(const QString & title,QWidget * parent = 0) + : Q3GroupBox(title,parent) {}; + KviTalGroupBox(int strips,Qt::Orientation orientation,QWidget * parent = 0) + : Q3GroupBox(strips,orientation,parent) {}; + KviTalGroupBox(int strips,Qt::Orientation orientation,const QString & title,QWidget * parent = 0) + : Q3GroupBox(strips,orientation,title,parent) {}; + ~KviTalGroupBox() {}; +}; + + + +#endif // _KVI_TAL_GROUPBOX_QT4_H_ diff --git a/src/kvilib/tal/kvi_tal_hbox.cpp b/src/kvilib/tal/kvi_tal_hbox.cpp new file mode 100644 index 00000000..6df56ee8 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_hbox.cpp @@ -0,0 +1,32 @@ +//============================================================================= +// +// File : kvi_tal_hbox.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_hbox.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_hbox_qt4.moc" +#else + #include "kvi_tal_hbox_qt3.moc" +#endif diff --git a/src/kvilib/tal/kvi_tal_hbox.h b/src/kvilib/tal/kvi_tal_hbox.h new file mode 100644 index 00000000..6f955ed6 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_hbox.h @@ -0,0 +1,36 @@ +#ifndef _KVI_TAL_HBOX_H_ +#define _KVI_TAL_HBOX_H_ + +//============================================================================= +// +// File : kvi_tal_hbox.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_hbox_qt4.h" +#else + #include "kvi_tal_hbox_qt3.h" +#endif + +#endif // _KVI_TAL_HBOX_H_ diff --git a/src/kvilib/tal/kvi_tal_hbox_qt3.h b/src/kvilib/tal/kvi_tal_hbox_qt3.h new file mode 100644 index 00000000..992ca03a --- /dev/null +++ b/src/kvilib/tal/kvi_tal_hbox_qt3.h @@ -0,0 +1,41 @@ +#ifndef _KVI_TAL_HBOX_QT3_H_ +#define _KVI_TAL_HBOX_QT3_H_ + +//============================================================================= +// +// File : kvi_tal_hbox_qt3.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include <qhbox.h> + +class KVILIB_API KviTalHBox : public QHBox +{ + Q_OBJECT +public: + KviTalHBox(QWidget * pParent) + : QHBox(pParent) {}; + virtual ~KviTalHBox() {}; +}; + +#endif // _KVI_TAL_HBOX_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_hbox_qt4.h b/src/kvilib/tal/kvi_tal_hbox_qt4.h new file mode 100644 index 00000000..384910c2 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_hbox_qt4.h @@ -0,0 +1,41 @@ +#ifndef _KVI_TAL_HBOX_QT4_H_ +#define _KVI_TAL_HBOX_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_hbox_qt4.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include <q3hbox.h> + +class KVILIB_API KviTalHBox : public Q3HBox +{ + Q_OBJECT +public: + KviTalHBox(QWidget * pParent,char* name=0) + : Q3HBox(pParent,name) {}; + virtual ~KviTalHBox() {}; +}; + +#endif // _KVI_TAL_HBOX_QT4_H_ diff --git a/src/kvilib/tal/kvi_tal_iconview.cpp b/src/kvilib/tal/kvi_tal_iconview.cpp new file mode 100644 index 00000000..2f63388c --- /dev/null +++ b/src/kvilib/tal/kvi_tal_iconview.cpp @@ -0,0 +1,215 @@ +//============================================================================= +// +// File : kvi_tal_iconview.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_iconview.h" + +#ifdef COMPILE_USE_QT4 + + KviTalIconView::KviTalIconView(QWidget * pParent,Qt::WFlags f) + : Q3IconView(pParent,0,f) + { + connect(this,SIGNAL(selectionChanged(Q3IconViewItem *)),this,SLOT(redirect_selectionChanged(Q3IconViewItem *))); + connect(this,SIGNAL(currentChanged(Q3IconViewItem *)),this,SLOT(redirect_currentChanged(Q3IconViewItem *))); + connect(this,SIGNAL(clicked(Q3IconViewItem *)),this,SLOT(redirect_clicked(Q3IconViewItem *))); + connect(this,SIGNAL(clicked(Q3IconViewItem *,const QPoint &)),this,SLOT(redirect_clicked(Q3IconViewItem *,const QPoint &))); + connect(this,SIGNAL(pressed(Q3IconViewItem *)),this,SLOT(redirect_pressed(Q3IconViewItem *))); + connect(this,SIGNAL(pressed(Q3IconViewItem *,const QPoint &)),this,SLOT(redirect_pressed(Q3IconViewItem *,const QPoint &))); + connect(this,SIGNAL(doubleClicked(Q3IconViewItem *)),this,SLOT(redirect_doubleClicked(Q3IconViewItem *))); + connect(this,SIGNAL(returnPressed(Q3IconViewItem *)),this,SLOT(redirect_returnPressed(Q3IconViewItem *))); + connect(this,SIGNAL(rightButtonClicked(Q3IconViewItem *,const QPoint &)),this,SLOT(redirect_rightButtonClicked(Q3IconViewItem *,const QPoint &))); + connect(this,SIGNAL(rightButtonPressed(Q3IconViewItem *,const QPoint &)),this,SLOT(redirect_rightButtonPressed(Q3IconViewItem *,const QPoint &))); + connect(this,SIGNAL(mouseButtonClicked(int,Q3IconViewItem *,const QPoint &)),this,SLOT(redirect_mouseButtonClicked(int,Q3IconViewItem *,const QPoint &))); + connect(this,SIGNAL(mouseButtonPressed(int,Q3IconViewItem *,const QPoint &)),this,SLOT(redirect_mouseButtonPressed(int,Q3IconViewItem *,const QPoint &))); + connect(this,SIGNAL(contextMenuRequested(Q3IconViewItem *,const QPoint &)),this,SLOT(redirect_contextMenuRequested(Q3IconViewItem *,const QPoint &))); + connect(this,SIGNAL(onItem(Q3IconViewItem *)),this,SLOT(redirect_onItem(Q3IconViewItem *))); + } + + void KviTalIconView::redirect_selectionChanged(Q3IconViewItem * pItem) + { + emit selectionChanged((KviTalIconViewItem *)pItem); + } + + void KviTalIconView::redirect_currentChanged(Q3IconViewItem * pItem) + { + emit currentChanged((KviTalIconViewItem *)pItem); + } + + void KviTalIconView::redirect_clicked(Q3IconViewItem * pItem) + { + emit clicked((KviTalIconViewItem *)pItem); + } + + void KviTalIconView::redirect_clicked(Q3IconViewItem * pItem,const QPoint &pnt) + { + emit clicked((KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_pressed(Q3IconViewItem * pItem) + { + emit pressed((KviTalIconViewItem *)pItem); + } + + void KviTalIconView::redirect_pressed(Q3IconViewItem * pItem,const QPoint &pnt) + { + emit pressed((KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_doubleClicked(Q3IconViewItem * pItem) + { + emit doubleClicked((KviTalIconViewItem *)pItem); + } + + void KviTalIconView::redirect_returnPressed(Q3IconViewItem * pItem) + { + emit returnPressed((KviTalIconViewItem *)pItem); + } + + void KviTalIconView::redirect_rightButtonClicked(Q3IconViewItem * pItem,const QPoint &pnt) + { + emit rightButtonClicked((KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_rightButtonPressed(Q3IconViewItem * pItem,const QPoint &pnt) + { + emit rightButtonPressed((KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_mouseButtonClicked(int iButton,Q3IconViewItem * pItem,const QPoint &pnt) + { + emit mouseButtonClicked(iButton,(KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_mouseButtonPressed(int iButton,Q3IconViewItem * pItem,const QPoint &pnt) + { + emit mouseButtonPressed(iButton,(KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_contextMenuRequested(Q3IconViewItem * pItem,const QPoint &pnt) + { + emit contextMenuRequested((KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_onItem(Q3IconViewItem * pItem) + { + emit onItem((KviTalIconViewItem *)pItem); + } + + + #include "kvi_tal_iconview_qt4.moc" +#else + + KviTalIconView::KviTalIconView(QWidget * pParent,Qt::WFlags f) + : QIconView(pParent,0,f) + { + connect(this,SIGNAL(selectionChanged(QIconViewItem *)),this,SLOT(redirect_selectionChanged(QIconViewItem *))); + connect(this,SIGNAL(currentChanged(QIconViewItem *)),this,SLOT(redirect_currentChanged(QIconViewItem *))); + connect(this,SIGNAL(clicked(QIconViewItem *)),this,SLOT(redirect_clicked(QIconViewItem *))); + connect(this,SIGNAL(clicked(QIconViewItem *,const QPoint &)),this,SLOT(redirect_clicked(QIconViewItem *,const QPoint &))); + connect(this,SIGNAL(pressed(QIconViewItem *)),this,SLOT(redirect_pressed(QIconViewItem *))); + connect(this,SIGNAL(pressed(QIconViewItem *,const QPoint &)),this,SLOT(redirect_pressed(QIconViewItem *,const QPoint &))); + connect(this,SIGNAL(doubleClicked(QIconViewItem *)),this,SLOT(redirect_doubleClicked(QIconViewItem *))); + connect(this,SIGNAL(returnPressed(QIconViewItem *)),this,SLOT(redirect_returnPressed(QIconViewItem *))); + connect(this,SIGNAL(rightButtonClicked(QIconViewItem *,const QPoint &)),this,SLOT(redirect_rightButtonClicked(QIconViewItem *,const QPoint &))); + connect(this,SIGNAL(rightButtonPressed(QIconViewItem *,const QPoint &)),this,SLOT(redirect_rightButtonPressed(QIconViewItem *,const QPoint &))); + connect(this,SIGNAL(mouseButtonClicked(int,QIconViewItem *,const QPoint &)),this,SLOT(redirect_mouseButtonClicked(int,QIconViewItem *,const QPoint &))); + connect(this,SIGNAL(mouseButtonPressed(int,QIconViewItem *,const QPoint &)),this,SLOT(redirect_mouseButtonPressed(int,QIconViewItem *,const QPoint &))); + connect(this,SIGNAL(contextMenuRequested(QIconViewItem *,const QPoint &)),this,SLOT(redirect_contextMenuRequested(QIconViewItem *,const QPoint &))); + connect(this,SIGNAL(onItem(QIconViewItem *)),this,SLOT(redirect_onItem(QIconViewItem *))); + } + + void KviTalIconView::redirect_selectionChanged(QIconViewItem * pItem) + { + emit selectionChanged((KviTalIconViewItem *)pItem); + } + + void KviTalIconView::redirect_currentChanged(QIconViewItem * pItem) + { + emit currentChanged((KviTalIconViewItem *)pItem); + } + + void KviTalIconView::redirect_clicked(QIconViewItem * pItem) + { + emit clicked((KviTalIconViewItem *)pItem); + } + + void KviTalIconView::redirect_clicked(QIconViewItem * pItem,const QPoint &pnt) + { + emit clicked((KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_pressed(QIconViewItem * pItem) + { + emit pressed((KviTalIconViewItem *)pItem); + } + + void KviTalIconView::redirect_pressed(QIconViewItem * pItem,const QPoint &pnt) + { + emit pressed((KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_doubleClicked(QIconViewItem * pItem) + { + emit doubleClicked((KviTalIconViewItem *)pItem); + } + + void KviTalIconView::redirect_returnPressed(QIconViewItem * pItem) + { + emit returnPressed((KviTalIconViewItem *)pItem); + } + + void KviTalIconView::redirect_rightButtonClicked(QIconViewItem * pItem,const QPoint &pnt) + { + emit rightButtonClicked((KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_rightButtonPressed(QIconViewItem * pItem,const QPoint &pnt) + { + emit rightButtonPressed((KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_mouseButtonClicked(int iButton,QIconViewItem * pItem,const QPoint &pnt) + { + emit mouseButtonClicked(iButton,(KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_mouseButtonPressed(int iButton,QIconViewItem * pItem,const QPoint &pnt) + { + emit mouseButtonPressed(iButton,(KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_contextMenuRequested(QIconViewItem * pItem,const QPoint &pnt) + { + emit contextMenuRequested((KviTalIconViewItem *)pItem,pnt); + } + + void KviTalIconView::redirect_onItem(QIconViewItem * pItem) + { + emit onItem((KviTalIconViewItem *)pItem); + } + + + #include "kvi_tal_iconview_qt3.moc" +#endif + diff --git a/src/kvilib/tal/kvi_tal_iconview.h b/src/kvilib/tal/kvi_tal_iconview.h new file mode 100644 index 00000000..53b1137b --- /dev/null +++ b/src/kvilib/tal/kvi_tal_iconview.h @@ -0,0 +1,36 @@ +#ifndef _KVI_TAL_ICONVIEW_H_ +#define _KVI_TAL_ICONVIEW_H_ + +//============================================================================= +// +// File : kvi_tal_iconview.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_iconview_qt4.h" +#else + #include "kvi_tal_iconview_qt3.h" +#endif + +#endif // _KVI_TAL_ICONVIEW_H_ diff --git a/src/kvilib/tal/kvi_tal_iconview_qt3.h b/src/kvilib/tal/kvi_tal_iconview_qt3.h new file mode 100644 index 00000000..7cfec586 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_iconview_qt3.h @@ -0,0 +1,100 @@ +#ifndef _KVI_TAL_ICONVIEW_QT3_H_ +#define _KVI_TAL_ICONVIEW_QT3_H_ + +//============================================================================= +// +// File : kvi_tal_iconview_qt3.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" +#include "kvi_qstring.h" + +#include <qiconview.h> + +class KviTalIconViewItem; + + +class KVILIB_API KviTalIconView : public QIconView +{ + Q_OBJECT +public: + KviTalIconView(QWidget * pParent,Qt::WFlags f = 0); + virtual ~KviTalIconView() {}; +signals: + void selectionChanged(KviTalIconViewItem * pItem); + void currentChanged(KviTalIconViewItem * pItem); + void clicked(KviTalIconViewItem * pItem); + void clicked(KviTalIconViewItem * pItem,const QPoint &pnt); + void pressed(KviTalIconViewItem * pItem); + void pressed(KviTalIconViewItem * pItem,const QPoint &pnt); + void doubleClicked(KviTalIconViewItem * pItem); + void returnPressed(KviTalIconViewItem * pItem); + void rightButtonClicked(KviTalIconViewItem * pItem,const QPoint &pnt); + void rightButtonPressed(KviTalIconViewItem * pItem,const QPoint &pnt); + void mouseButtonClicked(int iButton,KviTalIconViewItem * pItem,const QPoint &pnt); + void mouseButtonPressed(int iButton,KviTalIconViewItem * pItem,const QPoint &pnt); + void contextMenuRequested(KviTalIconViewItem * pItem,const QPoint &pnt); + void onItem(KviTalIconViewItem * pItem); +protected slots: + void redirect_selectionChanged(QIconViewItem * pItem); + void redirect_currentChanged(QIconViewItem * pItem); + void redirect_clicked(QIconViewItem * pItem); + void redirect_clicked(QIconViewItem * pItem,const QPoint &pnt); + void redirect_pressed(QIconViewItem * pItem); + void redirect_pressed(QIconViewItem * pItem,const QPoint &pnt); + void redirect_doubleClicked(QIconViewItem * pItem); + void redirect_returnPressed(QIconViewItem * pItem); + void redirect_rightButtonClicked(QIconViewItem * pItem,const QPoint &pnt); + void redirect_rightButtonPressed(QIconViewItem * pItem,const QPoint &pnt); + void redirect_mouseButtonClicked(int iButton,QIconViewItem * pItem,const QPoint &pnt); + void redirect_mouseButtonPressed(int iButton,QIconViewItem * pItem,const QPoint &pnt); + void redirect_contextMenuRequested(QIconViewItem * pItem,const QPoint &pnt); + void redirect_onItem(QIconViewItem * pItem); +public: + KviTalIconViewItem * firstItem() const { return (KviTalIconViewItem *)QIconView::firstItem(); }; + KviTalIconViewItem * lastItem() const { return (KviTalIconViewItem *)QIconView::lastItem(); }; + KviTalIconViewItem * currentItem() const { return (KviTalIconViewItem *)QIconView::currentItem(); }; +}; + +class KVILIB_API KviTalIconViewItem : public QIconViewItem +{ +public: + KviTalIconViewItem(KviTalIconView * parent) + : QIconViewItem(parent) {}; + KviTalIconViewItem(KviTalIconView * parent,KviTalIconViewItem * after) + : QIconViewItem(parent,after) {}; + KviTalIconViewItem(KviTalIconView * parent, const QString & text) + : QIconViewItem(parent,text) {}; + KviTalIconViewItem(KviTalIconView * parent, KviTalIconViewItem * after, const QString & text) + : QIconViewItem(parent,after,text) {}; + KviTalIconViewItem(KviTalIconView * parent, const QString & text, const QPixmap & icon) + : QIconViewItem(parent,text,icon) {}; + KviTalIconViewItem(KviTalIconView * parent, KviTalIconViewItem * after, const QString & text, const QPixmap & icon) + : QIconViewItem(parent,after,text,icon) {}; +public: + KviTalIconView * iconView() const { return (KviTalIconView *)QIconViewItem::iconView(); }; + KviTalIconViewItem * prevItem() const { return (KviTalIconViewItem *)QIconViewItem::prevItem(); }; + KviTalIconViewItem * nextItem() const { return (KviTalIconViewItem *)QIconViewItem::nextItem(); }; +}; + + +#endif // _KVI_TAL_ICONVIEW_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_iconview_qt4.h b/src/kvilib/tal/kvi_tal_iconview_qt4.h new file mode 100644 index 00000000..899acaac --- /dev/null +++ b/src/kvilib/tal/kvi_tal_iconview_qt4.h @@ -0,0 +1,99 @@ +#ifndef _KVI_TAL_ICONVIEW_QT4_H_ +#define _KVI_TAL_ICONVIEW_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_iconview_qt4.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,59 Temple Place - Suite 440, Boston, MA 02111-1407, USA. +// +//============================================================================= + +#include "kvi_settings.h" +#include "kvi_qstring.h" + +#include <q3iconview.h> + +class KviTalIconViewItem; + +class KVILIB_API KviTalIconView : public Q3IconView +{ + Q_OBJECT +public: + KviTalIconView(QWidget * pParent,Qt::WFlags f = 0); + virtual ~KviTalIconView() {}; +signals: + void selectionChanged(KviTalIconViewItem * pItem); + void currentChanged(KviTalIconViewItem * pItem); + void clicked(KviTalIconViewItem * pItem); + void clicked(KviTalIconViewItem * pItem,const QPoint &pnt); + void pressed(KviTalIconViewItem * pItem); + void pressed(KviTalIconViewItem * pItem,const QPoint &pnt); + void doubleClicked(KviTalIconViewItem * pItem); + void returnPressed(KviTalIconViewItem * pItem); + void rightButtonClicked(KviTalIconViewItem * pItem,const QPoint &pnt); + void rightButtonPressed(KviTalIconViewItem * pItem,const QPoint &pnt); + void mouseButtonClicked(int iButton,KviTalIconViewItem * pItem,const QPoint &pnt); + void mouseButtonPressed(int iButton,KviTalIconViewItem * pItem,const QPoint &pnt); + void contextMenuRequested(KviTalIconViewItem * pItem,const QPoint &pnt); + void onItem(KviTalIconViewItem * pItem); +protected slots: + void redirect_selectionChanged(Q3IconViewItem * pItem); + void redirect_currentChanged(Q3IconViewItem * pItem); + void redirect_clicked(Q3IconViewItem * pItem); + void redirect_clicked(Q3IconViewItem * pItem,const QPoint &pnt); + void redirect_pressed(Q3IconViewItem * pItem); + void redirect_pressed(Q3IconViewItem * pItem,const QPoint &pnt); + void redirect_doubleClicked(Q3IconViewItem * pItem); + void redirect_returnPressed(Q3IconViewItem * pItem); + void redirect_rightButtonClicked(Q3IconViewItem * pItem,const QPoint &pnt); + void redirect_rightButtonPressed(Q3IconViewItem * pItem,const QPoint &pnt); + void redirect_mouseButtonClicked(int iButton,Q3IconViewItem * pItem,const QPoint &pnt); + void redirect_mouseButtonPressed(int iButton,Q3IconViewItem * pItem,const QPoint &pnt); + void redirect_contextMenuRequested(Q3IconViewItem * pItem,const QPoint &pnt); + void redirect_onItem(Q3IconViewItem * pItem); +public: + KviTalIconViewItem * firstItem() const { return (KviTalIconViewItem *)Q3IconView::firstItem(); }; + KviTalIconViewItem * lastItem() const { return (KviTalIconViewItem *)Q3IconView::lastItem(); }; + KviTalIconViewItem * currentItem() const { return (KviTalIconViewItem *)Q3IconView::currentItem(); }; +}; + +class KVILIB_API KviTalIconViewItem : public Q3IconViewItem +{ +public: + KviTalIconViewItem(KviTalIconView * parent) + : Q3IconViewItem(parent) {}; + KviTalIconViewItem(KviTalIconView * parent,KviTalIconViewItem * after) + : Q3IconViewItem(parent,after) {}; + KviTalIconViewItem(KviTalIconView * parent, const QString & text) + : Q3IconViewItem(parent,text) {}; + KviTalIconViewItem(KviTalIconView * parent, KviTalIconViewItem * after, const QString & text) + : Q3IconViewItem(parent,after,text) {}; + KviTalIconViewItem(KviTalIconView * parent, const QString & text, const QPixmap & icon) + : Q3IconViewItem(parent,text,icon) {}; + KviTalIconViewItem(KviTalIconView * parent, KviTalIconViewItem * after, const QString & text, const QPixmap & icon) + : Q3IconViewItem(parent,after,text,icon) {}; +public: + KviTalIconView * iconView() const { return (KviTalIconView *)Q3IconViewItem::iconView(); }; + KviTalIconViewItem * prevItem() const { return (KviTalIconViewItem *)Q3IconViewItem::prevItem(); }; + KviTalIconViewItem * nextItem() const { return (KviTalIconViewItem *)Q3IconViewItem::nextItem(); }; +}; + + +#endif // _KVI_TAL_ICONVIEW_QT4_H_ diff --git a/src/kvilib/tal/kvi_tal_listbox.cpp b/src/kvilib/tal/kvi_tal_listbox.cpp new file mode 100644 index 00000000..f5fcc087 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_listbox.cpp @@ -0,0 +1,513 @@ +//============================================================================= +// +// File : kvi_tal_listbox.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_listbox.h" + +#ifdef COMPILE_USE_QT4 + #include <qpainter.h> + #include <qstyle.h> + #include <qapplication.h> + + KviTalListBox::KviTalListBox(QWidget * pParent,Qt::WFlags f) + : Q3ListBox(pParent,0,f) + { + connect(this,SIGNAL(highlighted(Q3ListBoxItem *)),this,SLOT(redirect_highlighted(Q3ListBoxItem *))); + connect(this,SIGNAL(selected(Q3ListBoxItem *)),this,SLOT(redirect_selected(Q3ListBoxItem *))); + connect(this,SIGNAL(selectionChanged(Q3ListBoxItem *)),this,SLOT(redirect_selectionChanged(Q3ListBoxItem *))); + connect(this,SIGNAL(currentChanged(Q3ListBoxItem *)),this,SLOT(redirect_currentChanged(Q3ListBoxItem *))); + connect(this,SIGNAL(clicked(Q3ListBoxItem *)),this,SLOT(redirect_clicked(Q3ListBoxItem *))); + connect(this,SIGNAL(clicked(Q3ListBoxItem *,const QPoint &)),this,SLOT(redirect_clicked(Q3ListBoxItem *,const QPoint &))); + connect(this,SIGNAL(pressed(Q3ListBoxItem *)),this,SLOT(redirect_pressed(Q3ListBoxItem *))); + connect(this,SIGNAL(pressed(Q3ListBoxItem *,const QPoint &)),this,SLOT(redirect_pressed(Q3ListBoxItem *,const QPoint &))); + connect(this,SIGNAL(doubleClicked(Q3ListBoxItem *)),this,SLOT(redirect_doubleClicked(Q3ListBoxItem *))); + connect(this,SIGNAL(returnPressed(Q3ListBoxItem *)),this,SLOT(redirect_returnPressed(Q3ListBoxItem *))); + connect(this,SIGNAL(rightButtonClicked(Q3ListBoxItem *, const QPoint &)),this,SLOT(redirect_rightButtonClicked(Q3ListBoxItem *, const QPoint &))); + connect(this,SIGNAL(rightButtonPressed(Q3ListBoxItem *, const QPoint &)),this,SLOT(redirect_rightButtonPressed(Q3ListBoxItem *, const QPoint &))); + connect(this,SIGNAL(mouseButtonPressed(int,Q3ListBoxItem *,const QPoint &)),this,SLOT(redirect_mouseButtonPressed(int,Q3ListBoxItem *,const QPoint &))); + connect(this,SIGNAL(mouseButtonClicked(int,Q3ListBoxItem *,const QPoint &)),this,SLOT(redirect_mouseButtonClicked(int,Q3ListBoxItem *,const QPoint &))); + connect(this,SIGNAL(contextMenuRequested(Q3ListBoxItem *,const QPoint &)),this,SLOT(redirect_contextMenuRequested(Q3ListBoxItem *,const QPoint &))); + connect(this,SIGNAL(onItem(Q3ListBoxItem *)),this,SLOT(redirect_onItem(Q3ListBoxItem *))); + } + + void KviTalListBox::redirect_highlighted(Q3ListBoxItem *item) + { + emit highlighted((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_selected(Q3ListBoxItem *item) + { + emit selected((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_selectionChanged(Q3ListBoxItem * item) + { + emit selectionChanged((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_currentChanged(Q3ListBoxItem * item) + { + emit currentChanged((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_clicked(Q3ListBoxItem * item) + { + emit clicked((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_clicked(Q3ListBoxItem * item,const QPoint & pnt) + { + emit clicked((KviTalListBoxItem *)item,pnt); + } + + void KviTalListBox::redirect_pressed(Q3ListBoxItem * item) + { + emit pressed((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_pressed(Q3ListBoxItem * item,const QPoint & pnt) + { + emit pressed((KviTalListBoxItem *)item,pnt); + } + + void KviTalListBox::redirect_doubleClicked(Q3ListBoxItem * item) + { + emit doubleClicked((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_returnPressed(Q3ListBoxItem * item) + { + emit returnPressed((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_rightButtonClicked(Q3ListBoxItem * item, const QPoint &pnt) + { + emit rightButtonClicked((KviTalListBoxItem *)item,pnt); + } + + void KviTalListBox::redirect_rightButtonPressed(Q3ListBoxItem * item, const QPoint &pnt) + { + emit rightButtonPressed((KviTalListBoxItem *)item,pnt); + } + + void KviTalListBox::redirect_mouseButtonPressed(int button,Q3ListBoxItem * item,const QPoint & pos) + { + emit mouseButtonPressed(button,(KviTalListBoxItem *)item,pos); + } + + void KviTalListBox::redirect_mouseButtonClicked(int button,Q3ListBoxItem * item,const QPoint & pos) + { + emit mouseButtonClicked(button,(KviTalListBoxItem *)item,pos); + } + + void KviTalListBox::redirect_contextMenuRequested(Q3ListBoxItem * item,const QPoint & pos) + { + emit contextMenuRequested((KviTalListBoxItem *)item,pos); + } + + void KviTalListBox::redirect_onItem(Q3ListBoxItem * i) + { + emit onItem((KviTalListBoxItem *)i); + } + + KviTalListBoxText::KviTalListBoxText(KviTalListBox *listbox, const QString &text) + :KviTalListBoxItem(listbox) + { + setText(text); + } + + KviTalListBoxText::KviTalListBoxText(const QString &text) + :KviTalListBoxItem() + { + setText(text); + } + + KviTalListBoxText::KviTalListBoxText(KviTalListBox* listbox, const QString &text, KviTalListBoxItem *after) + : KviTalListBoxItem(listbox, after) + { + setText(text); + } + + KviTalListBoxText::~KviTalListBoxText() + { + } + + void KviTalListBoxText::paint(QPainter *painter) + { + int itemHeight = height(listBox()); + QFontMetrics fm = painter->fontMetrics(); + int yPos = ((itemHeight - fm.height()) / 2) + fm.ascent(); + painter->drawText(3, yPos, text()); + } + + int KviTalListBoxText::height(const KviTalListBox* lb) const + { + int h = lb ? lb->fontMetrics().lineSpacing() + 2 : 0; + return qMax(h, QApplication::globalStrut().height()); + } + + int KviTalListBoxText::width(const KviTalListBox* lb) const + { + int w = lb ? lb->fontMetrics().width(text()) + 6 : 0; + return qMax(w, QApplication::globalStrut().width()); + } + + int KviTalListBoxText::rtti() const + { + return RTTI; + } + + KviTalListBoxPixmap::KviTalListBoxPixmap(KviTalListBox* listbox, const QPixmap &pixmap) + : KviTalListBoxItem(listbox) + { + pm = pixmap; + } + + KviTalListBoxPixmap::KviTalListBoxPixmap(const QPixmap &pixmap) + : KviTalListBoxItem() + { + pm = pixmap; + } + + KviTalListBoxPixmap::KviTalListBoxPixmap(KviTalListBox* listbox, const QPixmap &pixmap, KviTalListBoxItem *after) + : KviTalListBoxItem(listbox, after) + { + pm = pixmap; + } + + KviTalListBoxPixmap::~KviTalListBoxPixmap() + { + } + + KviTalListBoxPixmap::KviTalListBoxPixmap(KviTalListBox* listbox, const QPixmap &pix, const QString& text) + : KviTalListBoxItem(listbox) + { + pm = pix; + setText(text); + } + + KviTalListBoxPixmap::KviTalListBoxPixmap(const QPixmap & pix, const QString& text) + : KviTalListBoxItem() + { + pm = pix; + setText(text); + } + + KviTalListBoxPixmap::KviTalListBoxPixmap(KviTalListBox* listbox, const QPixmap & pix, const QString& text, + KviTalListBoxItem *after) + : KviTalListBoxItem(listbox, after) + { + pm = pix; + setText(text); + } + + void KviTalListBoxPixmap::paint(QPainter *painter) + { + int itemHeight = height(listBox()); + int yPos; + + const QPixmap *pm = pixmap(); + if (pm && ! pm->isNull()) { + yPos = (itemHeight - pm->height()) / 2; + painter->drawPixmap(3, yPos, *pm); + } + + if (!text().isEmpty()) { + QFontMetrics fm = painter->fontMetrics(); + yPos = ((itemHeight - fm.height()) / 2) + fm.ascent(); + painter->drawText(pm->width() + 5, yPos, text()); + } + } + + int KviTalListBoxPixmap::height(const KviTalListBox* lb) const + { + int h; + if (text().isEmpty()) + h = pm.height(); + else + h = qMax(pm.height(), lb->fontMetrics().lineSpacing() + 2); + return qMax(h, QApplication::globalStrut().height()); + } + + int KviTalListBoxPixmap::width(const KviTalListBox* lb) const + { + if (text().isEmpty()) + return qMax(pm.width() + 6, QApplication::globalStrut().width()); + return qMax(pm.width() + lb->fontMetrics().width(text()) + 6, + QApplication::globalStrut().width()); + } + + int KviTalListBoxPixmap::rtti() const + { + return RTTI; + } + + + #include "kvi_tal_listbox_qt4.moc" +#else + #include <qpainter.h> + #include <qstyle.h> + #include <qapplication.h> + + + KviTalListBox::KviTalListBox(QWidget * pParent,Qt::WFlags f) + : QListBox(pParent,0,f) + { + connect(this,SIGNAL(highlighted(QListBoxItem *)),this,SLOT(redirect_highlighted(QListBoxItem *))); + connect(this,SIGNAL(selected(QListBoxItem *)),this,SLOT(redirect_selected(QListBoxItem *))); + connect(this,SIGNAL(selectionChanged(QListBoxItem *)),this,SLOT(redirect_selectionChanged(QListBoxItem *))); + connect(this,SIGNAL(currentChanged(QListBoxItem *)),this,SLOT(redirect_currentChanged(QListBoxItem *))); + connect(this,SIGNAL(clicked(QListBoxItem *)),this,SLOT(redirect_clicked(QListBoxItem *))); + connect(this,SIGNAL(clicked(QListBoxItem *,const QPoint &)),this,SLOT(redirect_clicked(QListBoxItem *,const QPoint &))); + connect(this,SIGNAL(pressed(QListBoxItem *)),this,SLOT(redirect_pressed(QListBoxItem *))); + connect(this,SIGNAL(pressed(QListBoxItem *,const QPoint &)),this,SLOT(redirect_pressed(QListBoxItem *,const QPoint &))); + connect(this,SIGNAL(doubleClicked(QListBoxItem *)),this,SLOT(redirect_doubleClicked(QListBoxItem *))); + connect(this,SIGNAL(returnPressed(QListBoxItem *)),this,SLOT(redirect_returnPressed(QListBoxItem *))); + connect(this,SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)),this,SLOT(redirect_rightButtonClicked(QListBoxItem *, const QPoint &))); + connect(this,SIGNAL(rightButtonPressed(QListBoxItem *, const QPoint &)),this,SLOT(redirect_rightButtonPressed(QListBoxItem *, const QPoint &))); + connect(this,SIGNAL(mouseButtonPressed(int,QListBoxItem *,const QPoint &)),this,SLOT(redirect_mouseButtonPressed(int,QListBoxItem *,const QPoint &))); + connect(this,SIGNAL(mouseButtonClicked(int,QListBoxItem *,const QPoint &)),this,SLOT(redirect_mouseButtonClicked(int,QListBoxItem *,const QPoint &))); + connect(this,SIGNAL(contextMenuRequested(QListBoxItem *,const QPoint &)),this,SLOT(redirect_contextMenuRequested(QListBoxItem *,const QPoint &))); + connect(this,SIGNAL(onItem(QListBoxItem *)),this,SLOT(redirect_onItem(QListBoxItem *))); + } + + void KviTalListBox::redirect_highlighted(QListBoxItem *item) + { + emit highlighted((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_selected(QListBoxItem *item) + { + emit selected((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_selectionChanged(QListBoxItem * item) + { + emit selectionChanged((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_currentChanged(QListBoxItem * item) + { + emit currentChanged((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_clicked(QListBoxItem * item) + { + emit clicked((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_clicked(QListBoxItem * item,const QPoint & pnt) + { + emit clicked((KviTalListBoxItem *)item,pnt); + } + + void KviTalListBox::redirect_pressed(QListBoxItem * item) + { + emit pressed((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_pressed(QListBoxItem * item,const QPoint & pnt) + { + emit pressed((KviTalListBoxItem *)item,pnt); + } + + void KviTalListBox::redirect_doubleClicked(QListBoxItem * item) + { + emit doubleClicked((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_returnPressed(QListBoxItem * item) + { + emit returnPressed((KviTalListBoxItem *)item); + } + + void KviTalListBox::redirect_rightButtonClicked(QListBoxItem * item, const QPoint &pnt) + { + emit rightButtonClicked((KviTalListBoxItem *)item,pnt); + } + + void KviTalListBox::redirect_rightButtonPressed(QListBoxItem * item, const QPoint &pnt) + { + emit rightButtonPressed((KviTalListBoxItem *)item,pnt); + } + + void KviTalListBox::redirect_mouseButtonPressed(int button,QListBoxItem * item,const QPoint & pos) + { + emit mouseButtonPressed(button,(KviTalListBoxItem *)item,pos); + } + + void KviTalListBox::redirect_mouseButtonClicked(int button,QListBoxItem * item,const QPoint & pos) + { + emit mouseButtonClicked(button,(KviTalListBoxItem *)item,pos); + } + + void KviTalListBox::redirect_contextMenuRequested(QListBoxItem * item,const QPoint & pos) + { + emit contextMenuRequested((KviTalListBoxItem *)item,pos); + } + + void KviTalListBox::redirect_onItem(QListBoxItem * i) + { + emit onItem((KviTalListBoxItem *)i); + } + + KviTalListBoxText::KviTalListBoxText( KviTalListBox *listbox, const QString &text ) + :KviTalListBoxItem( listbox ) + { + setText( text ); + } + + KviTalListBoxText::KviTalListBoxText( const QString &text ) + :KviTalListBoxItem() + { + setText( text ); + } + + KviTalListBoxText::KviTalListBoxText( KviTalListBox* listbox, const QString &text, KviTalListBoxItem *after ) + : KviTalListBoxItem( listbox, after ) + { + setText( text ); + } + + KviTalListBoxText::~KviTalListBoxText() + { + } + + void KviTalListBoxText::paint( QPainter *painter ) + { + int itemHeight = height( listBox() ); + QFontMetrics fm = painter->fontMetrics(); + int yPos = ( ( itemHeight - fm.height() ) / 2 ) + fm.ascent(); + painter->drawText( 3, yPos, text() ); + } + + int KviTalListBoxText::height( const KviTalListBox* lb ) const + { + int h = lb ? lb->fontMetrics().lineSpacing() + 2 : 0; + return QMAX( h, QApplication::globalStrut().height() ); + } + + int KviTalListBoxText::width( const KviTalListBox* lb ) const + { + int w = lb ? lb->fontMetrics().width( text() ) + 6 : 0; + return QMAX( w, QApplication::globalStrut().width() ); + } + + int KviTalListBoxText::RTTI = 1; + + int KviTalListBoxText::rtti() const + { + return RTTI; + } + + KviTalListBoxPixmap::KviTalListBoxPixmap( KviTalListBox* listbox, const QPixmap &pixmap ) + : KviTalListBoxItem( listbox ) + { + pm = pixmap; + } + + KviTalListBoxPixmap::KviTalListBoxPixmap( const QPixmap &pixmap ) + : KviTalListBoxItem() + { + pm = pixmap; + } + + KviTalListBoxPixmap::KviTalListBoxPixmap( KviTalListBox* listbox, const QPixmap &pixmap, KviTalListBoxItem *after ) + : KviTalListBoxItem( listbox, after ) + { + pm = pixmap; + } + + KviTalListBoxPixmap::~KviTalListBoxPixmap() + { + } + + KviTalListBoxPixmap::KviTalListBoxPixmap( KviTalListBox* listbox, const QPixmap &pix, const QString& text) + : KviTalListBoxItem( listbox ) + { + pm = pix; + setText( text ); + } + + KviTalListBoxPixmap::KviTalListBoxPixmap( const QPixmap & pix, const QString& text) + : KviTalListBoxItem() + { + pm = pix; + setText( text ); + } + + KviTalListBoxPixmap::KviTalListBoxPixmap( KviTalListBox* listbox, const QPixmap & pix, const QString& text, + KviTalListBoxItem *after ) + : KviTalListBoxItem( listbox, after ) + { + pm = pix; + setText( text ); + } + + void KviTalListBoxPixmap::paint( QPainter *painter ) + { + int itemHeight = height( listBox() ); + int yPos; + + const QPixmap *pm = pixmap(); + if ( pm && ! pm->isNull() ) { + yPos = ( itemHeight - pm->height() ) / 2; + painter->drawPixmap( 3, yPos, *pm); + } + + if ( !text().isEmpty() ) { + QFontMetrics fm = painter->fontMetrics(); + yPos = ( ( itemHeight - fm.height() ) / 2 ) + fm.ascent(); + painter->drawText( pm->width() + 5, yPos, text() ); + } + } + + int KviTalListBoxPixmap::height( const KviTalListBox* lb ) const + { + int h; + if ( text().isEmpty() ) + h = pm.height(); + else + h = QMAX( pm.height(), lb->fontMetrics().lineSpacing() + 2 ); + return QMAX( h, QApplication::globalStrut().height() ); + } + + int KviTalListBoxPixmap::width( const KviTalListBox* lb ) const + { + if ( text().isEmpty() ) + return QMAX( pm.width() + 6, QApplication::globalStrut().width() ); + return QMAX( pm.width() + lb->fontMetrics().width( text() ) + 6, + QApplication::globalStrut().width() ); + } + + int KviTalListBoxPixmap::RTTI = 2; + + int KviTalListBoxPixmap::rtti() const + { + return RTTI; + } + + #include "kvi_tal_listbox_qt3.moc" +#endif + diff --git a/src/kvilib/tal/kvi_tal_listbox.h b/src/kvilib/tal/kvi_tal_listbox.h new file mode 100644 index 00000000..18594539 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_listbox.h @@ -0,0 +1,50 @@ +#ifndef _KVI_TAL_LISTBOX_H_ +#define _KVI_TAL_LISTBOX_H_ + +//============================================================================= +// +// File : kvi_tal_listbox.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +// +// This is the only reasonable CROSS-QT3-QT4-COMPATIBLE implementation +// of QListBox I've been able to find. +// Note that using macros for the items will NOT work since moc +// doesn't expand them. Note also that KviTalListBoxText must +// be fully reimplemented and not be inherited from QListBoxText +// to build up a consistent item object hierarchy. To complete +// the obscenity, we need TWO COMPLETE implementations: one for Qt3 +// and one for Qt4... bleah :D +// +// The code for KviTalListBoxText is adapted from qlistbox.h/cpp +// present in qt 3.3.6 AND in qt 4.1.2. +// + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_listbox_qt4.h" +#else + #include "kvi_tal_listbox_qt3.h" +#endif + +#endif // _KVI_TAL_LISTBOX_H_ diff --git a/src/kvilib/tal/kvi_tal_listbox_qt3.h b/src/kvilib/tal/kvi_tal_listbox_qt3.h new file mode 100644 index 00000000..d65b7929 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_listbox_qt3.h @@ -0,0 +1,157 @@ +#ifndef _KVI_TAL_LISTBOX_QT3_H_ +#define _KVI_TAL_LISTBOX_QT3_H_ + +//============================================================================= +// +// File : kvi_tal_listbox_qt3.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" +#include "kvi_qstring.h" +#include <qlistbox.h> + +class KviTalListBoxItem; + +class KVILIB_API KviTalListBox : public QListBox +{ + Q_OBJECT +public: + KviTalListBox(QWidget * pParent,Qt::WFlags f = 0); + virtual ~KviTalListBox() {}; +public: + KviTalListBoxItem * firstItem() const { return (KviTalListBoxItem *)QListBox::firstItem(); }; + KviTalListBoxItem * selectedItem() const { return (KviTalListBoxItem *)QListBox::selectedItem(); }; + KviTalListBoxItem * item(int iIndex) const { return (KviTalListBoxItem *)QListBox::item(iIndex); }; +signals: + void highlighted(KviTalListBoxItem *); + void selected(KviTalListBoxItem *); + void selectionChanged(KviTalListBoxItem * item); + void currentChanged(KviTalListBoxItem * item); + void clicked(KviTalListBoxItem * item); + void clicked(KviTalListBoxItem * item,const QPoint & pnt); + void pressed(KviTalListBoxItem * item); + void pressed(KviTalListBoxItem * item,const QPoint & pnt); + void doubleClicked(KviTalListBoxItem * item); + void returnPressed(KviTalListBoxItem * item); + void rightButtonClicked(KviTalListBoxItem *, const QPoint &); + void rightButtonPressed(KviTalListBoxItem *, const QPoint &); + void mouseButtonPressed(int button,KviTalListBoxItem * item,const QPoint & pos); + void mouseButtonClicked(int button,KviTalListBoxItem * item,const QPoint & pos); + void contextMenuRequested(KviTalListBoxItem * item,const QPoint & pos); + void onItem(KviTalListBoxItem * i); +protected slots: + void redirect_highlighted(QListBoxItem *item); + void redirect_selected(QListBoxItem *item); + void redirect_selectionChanged(QListBoxItem * item); + void redirect_currentChanged(QListBoxItem * item); + void redirect_clicked(QListBoxItem * item); + void redirect_clicked(QListBoxItem * item,const QPoint & pnt); + void redirect_pressed(QListBoxItem * item); + void redirect_pressed(QListBoxItem * item,const QPoint & pnt); + void redirect_doubleClicked(QListBoxItem * item); + void redirect_returnPressed(QListBoxItem * item); + void redirect_rightButtonClicked(QListBoxItem * item, const QPoint &pnt); + void redirect_rightButtonPressed(QListBoxItem * item, const QPoint &pnt); + void redirect_mouseButtonPressed(int button,QListBoxItem * item,const QPoint & pos); + void redirect_mouseButtonClicked(int button,QListBoxItem * item,const QPoint & pos); + void redirect_contextMenuRequested(QListBoxItem * item,const QPoint & pos); + void redirect_onItem(QListBoxItem * i); +}; + +class KVILIB_API KviTalListBoxItem : public QListBoxItem +{ +public: + KviTalListBoxItem() + : QListBoxItem() {}; + KviTalListBoxItem(KviTalListBox * pParent) + : QListBoxItem(pParent) {}; + KviTalListBoxItem(KviTalListBox * pParent,KviTalListBoxItem * pAfter) + : QListBoxItem(pParent,pAfter) {}; + virtual ~KviTalListBoxItem() {}; +public: + KviTalListBoxItem * next() const { return (KviTalListBoxItem *)QListBoxItem::next(); }; + KviTalListBoxItem * prev() const { return (KviTalListBoxItem *)QListBoxItem::prev(); }; + KviTalListBox * listBox() const { return (KviTalListBox *)QListBoxItem::listBox(); }; + virtual int height(const KviTalListBox *) const { return 0; }; + int height(const QListBox *lb) const { return height((KviTalListBox *)lb); }; + virtual int width(const KviTalListBox *) const { return 0; }; + int width(const QListBox *lb) const { return width((KviTalListBox *)lb); }; +}; + +class KVILIB_API KviTalListBoxText : public KviTalListBoxItem +{ +public: + KviTalListBoxText( KviTalListBox* listbox, const QString & text=QString::null ); + KviTalListBoxText( const QString & text=QString::null ); + KviTalListBoxText( KviTalListBox* listbox, const QString & text, KviTalListBoxItem *after ); + ~KviTalListBoxText(); + + int height( const KviTalListBox * ) const; + int width( const KviTalListBox * ) const; + + int rtti() const; + static int RTTI; + +protected: + virtual void paint( QPainter * ); + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + KviTalListBoxText( const KviTalListBoxText & ); + KviTalListBoxText &operator=( const KviTalListBoxText & ); +#endif +}; + + +class KVILIB_API KviTalListBoxPixmap : public KviTalListBoxItem +{ +public: + KviTalListBoxPixmap( KviTalListBox* listbox, const QPixmap & ); + KviTalListBoxPixmap( const QPixmap & ); + KviTalListBoxPixmap( KviTalListBox* listbox, const QPixmap & pix, KviTalListBoxItem *after ); + KviTalListBoxPixmap( KviTalListBox* listbox, const QPixmap &, const QString& ); + KviTalListBoxPixmap( const QPixmap &, const QString& ); + KviTalListBoxPixmap( KviTalListBox* listbox, const QPixmap & pix, const QString&, KviTalListBoxItem *after ); + ~KviTalListBoxPixmap(); + + const QPixmap *pixmap() const { return ± } + + int height( const KviTalListBox * ) const; + int width( const KviTalListBox * ) const; + + int rtti() const; + static int RTTI; + +protected: + virtual void paint( QPainter * ); + +private: + QPixmap pm; +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + KviTalListBoxPixmap( const KviTalListBoxPixmap & ); + KviTalListBoxPixmap &operator=( const KviTalListBoxPixmap & ); +#endif +}; + + +#endif // _KVI_TAL_LISTBOX_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_listbox_qt4.h b/src/kvilib/tal/kvi_tal_listbox_qt4.h new file mode 100644 index 00000000..dcb92f4d --- /dev/null +++ b/src/kvilib/tal/kvi_tal_listbox_qt4.h @@ -0,0 +1,152 @@ +#ifndef _KVI_TAL_LISTBOX_QT4_H_ +#define _KVI_TAL_LISTBOX_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_listbox_qt4.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include <q3listbox.h> + +class KviTalListBoxItem; + + +class KVILIB_API KviTalListBox : public Q3ListBox +{ + Q_OBJECT +public: + KviTalListBox(QWidget * pParent,Qt::WFlags f = 0); + virtual ~KviTalListBox() {}; +public: + KviTalListBoxItem * firstItem() const { return (KviTalListBoxItem *)Q3ListBox::firstItem(); }; + KviTalListBoxItem * selectedItem() const { return (KviTalListBoxItem *)Q3ListBox::selectedItem(); }; + KviTalListBoxItem * item(int iIndex) const { return (KviTalListBoxItem *)Q3ListBox::item(iIndex); }; +signals: + void highlighted(KviTalListBoxItem *); + void selected(KviTalListBoxItem *); + void selectionChanged(KviTalListBoxItem * item); + void currentChanged(KviTalListBoxItem * item); + void clicked(KviTalListBoxItem * item); + void clicked(KviTalListBoxItem * item,const QPoint & pnt); + void pressed(KviTalListBoxItem * item); + void pressed(KviTalListBoxItem * item,const QPoint & pnt); + void doubleClicked(KviTalListBoxItem * item); + void returnPressed(KviTalListBoxItem * item); + void rightButtonClicked(KviTalListBoxItem *, const QPoint &); + void rightButtonPressed(KviTalListBoxItem *, const QPoint &); + void mouseButtonPressed(int button,KviTalListBoxItem * item,const QPoint & pos); + void mouseButtonClicked(int button,KviTalListBoxItem * item,const QPoint & pos); + void contextMenuRequested(KviTalListBoxItem * item,const QPoint & pos); + void onItem(KviTalListBoxItem * i); +protected slots: + void redirect_highlighted(Q3ListBoxItem *); + void redirect_selected(Q3ListBoxItem *); + void redirect_selectionChanged(Q3ListBoxItem * item); + void redirect_currentChanged(Q3ListBoxItem * item); + void redirect_clicked(Q3ListBoxItem * item); + void redirect_clicked(Q3ListBoxItem * item,const QPoint & pnt); + void redirect_pressed(Q3ListBoxItem * item); + void redirect_pressed(Q3ListBoxItem * item,const QPoint & pnt); + void redirect_doubleClicked(Q3ListBoxItem * item); + void redirect_returnPressed(Q3ListBoxItem *); + void redirect_rightButtonClicked(Q3ListBoxItem *, const QPoint &); + void redirect_rightButtonPressed(Q3ListBoxItem *, const QPoint &); + void redirect_mouseButtonPressed(int button,Q3ListBoxItem * item,const QPoint & pos); + void redirect_mouseButtonClicked(int button,Q3ListBoxItem * item,const QPoint & pos); + void redirect_contextMenuRequested(Q3ListBoxItem * item,const QPoint & pos); + void redirect_onItem(Q3ListBoxItem * i); +}; + +class KVILIB_API KviTalListBoxItem : public Q3ListBoxItem +{ +public: + KviTalListBoxItem() + : Q3ListBoxItem() {}; + KviTalListBoxItem(KviTalListBox * pParent) + : Q3ListBoxItem(pParent) {}; + KviTalListBoxItem(KviTalListBox * pParent,KviTalListBoxItem * pAfter) + : Q3ListBoxItem(pParent,pAfter) {}; + virtual ~KviTalListBoxItem() {}; +public: + KviTalListBoxItem * next() const { return (KviTalListBoxItem *)Q3ListBoxItem::next(); }; + KviTalListBoxItem * prev() const { return (KviTalListBoxItem *)Q3ListBoxItem::prev(); }; + KviTalListBox * listBox() const { return (KviTalListBox *)Q3ListBoxItem::listBox(); }; + virtual int height(const KviTalListBox *) const { return 0; }; + int height(const Q3ListBox *lb) const { return height((KviTalListBox *)lb); }; + virtual int width(const KviTalListBox *) const { return 0; }; + int width(const Q3ListBox *lb) const { return width((KviTalListBox *)lb); }; +}; + + +class KVILIB_API KviTalListBoxText : public KviTalListBoxItem +{ +public: + KviTalListBoxText(KviTalListBox* listbox, const QString & text=QString()); + KviTalListBoxText(const QString & text=QString()); + KviTalListBoxText(KviTalListBox* listbox, const QString & text, KviTalListBoxItem *after); + ~KviTalListBoxText(); + + int height(const KviTalListBox *) const; + int width(const KviTalListBox *) const; + + int rtti() const; + enum { RTTI = 1 }; + +protected: + virtual void paint(QPainter *); + +private: + Q_DISABLE_COPY(KviTalListBoxText) +}; + + +class KVILIB_API KviTalListBoxPixmap : public KviTalListBoxItem +{ +public: + KviTalListBoxPixmap(KviTalListBox* listbox, const QPixmap &); + KviTalListBoxPixmap(const QPixmap &); + KviTalListBoxPixmap(KviTalListBox* listbox, const QPixmap & pix, KviTalListBoxItem *after); + KviTalListBoxPixmap(KviTalListBox* listbox, const QPixmap &, const QString&); + KviTalListBoxPixmap(const QPixmap &, const QString&); + KviTalListBoxPixmap(KviTalListBox* listbox, const QPixmap & pix, const QString&, KviTalListBoxItem *after); + ~KviTalListBoxPixmap(); + + const QPixmap *pixmap() const { return ± } + + int height(const KviTalListBox *) const; + int width(const KviTalListBox *) const; + + int rtti() const; + enum { RTTI = 2 }; + +protected: + virtual void paint(QPainter *); + +private: + Q_DISABLE_COPY(KviTalListBoxPixmap) + + QPixmap pm; +}; + +#endif // _KVI_TAL_LISTBOX_QT4_H_ diff --git a/src/kvilib/tal/kvi_tal_listview.cpp b/src/kvilib/tal/kvi_tal_listview.cpp new file mode 100644 index 00000000..01b253b3 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_listview.cpp @@ -0,0 +1,1542 @@ +//============================================================================= +// +// File : kvi_tal_listview.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_listview.h" + +#include "kvi_pointerhashtable.h" + + +#ifdef COMPILE_USE_QT4 + #include <qpainter.h> + #include <qstyle.h> + #include <q3header.h> + #include <qapplication.h> + #include <qhash.h> + #include <qstyleoption.h> + #include <qaccessible.h> + + static QStyleOptionQ3ListView getStyleOption(const Q3ListView *lv, const Q3ListViewItem *item) + { + QStyleOptionQ3ListView opt; + opt.init(lv); + opt.subControls = QStyle::SC_None; + opt.activeSubControls = QStyle::SC_None; + QWidget *vp = lv->viewport(); + opt.viewportPalette = vp->palette(); + opt.viewportBGRole = vp->backgroundRole(); + opt.itemMargin = lv->itemMargin(); + opt.sortColumn = 0; + opt.treeStepSize = lv->treeStepSize(); + opt.rootIsDecorated = lv->rootIsDecorated(); + bool firstItem = true; + while (item) { + QStyleOptionQ3ListViewItem lvi; + lvi.height = item->height(); + lvi.totalHeight = item->totalHeight(); + lvi.itemY = item->itemPos(); + lvi.childCount = item->childCount(); + lvi.features = QStyleOptionQ3ListViewItem::None; + lvi.state = QStyle::State_None; + if (item->isEnabled()) + lvi.state |= QStyle::State_Enabled; + if (item->isOpen()) + lvi.state |= QStyle::State_Open; + if (item->isExpandable()) + lvi.features |= QStyleOptionQ3ListViewItem::Expandable; + if (item->multiLinesEnabled()) + lvi.features |= QStyleOptionQ3ListViewItem::MultiLine; + if (item->isVisible()) + lvi.features |= QStyleOptionQ3ListViewItem::Visible; + if (item->parent() && item->parent()->rtti() == 1 + && static_cast<Q3CheckListItem *>(item->parent())->type() == Q3CheckListItem::Controller) + lvi.features |= QStyleOptionQ3ListViewItem::ParentControl; + opt.items.append(lvi); + if (!firstItem) { + item = item->nextSibling(); + } else { + firstItem = false; + item = item->firstChild(); + } + } + return opt; + } + + KviTalListView::KviTalListView(QWidget * pParent) + : Q3ListView(pParent) + { + connect(this,SIGNAL(selectionChanged(Q3ListViewItem *)),this,SLOT(redirect_selectionChanged(Q3ListViewItem *))); + connect(this,SIGNAL(currentChanged(Q3ListViewItem *)),this,SLOT(redirect_currentChanged(Q3ListViewItem *))); + connect(this,SIGNAL(clicked(Q3ListViewItem *)),this,SLOT(redirect_clicked(Q3ListViewItem *))); + connect(this,SIGNAL(clicked(Q3ListViewItem *,const QPoint &,int)),this,SLOT(redirect_clicked(Q3ListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(pressed(Q3ListViewItem *)),this,SLOT(redirect_pressed(Q3ListViewItem *))); + connect(this,SIGNAL(pressed(Q3ListViewItem *,const QPoint &,int)),this,SLOT(redirect_pressed(Q3ListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(doubleClicked(Q3ListViewItem *)),this,SLOT(redirect_doubleClicked(Q3ListViewItem *))); + connect(this,SIGNAL(doubleClicked(Q3ListViewItem *,const QPoint &,int)),this,SLOT(redirect_doubleClicked(Q3ListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(returnPressed(Q3ListViewItem *)),this,SLOT(redirect_returnPressed(Q3ListViewItem *))); + connect(this,SIGNAL(spacePressed(Q3ListViewItem *)),this,SLOT(redirect_spacePressed(Q3ListViewItem *))); + connect(this,SIGNAL(rightButtonClicked(Q3ListViewItem *,const QPoint &,int)),this,SLOT(redirect_rightButtonClicked(Q3ListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(rightButtonPressed(Q3ListViewItem *,const QPoint &,int)),this,SLOT(redirect_rightButtonPressed(Q3ListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(mouseButtonClicked(int,Q3ListViewItem *,const QPoint &,int)),this,SLOT(redirect_mouseButtonClicked(int,Q3ListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(mouseButtonPressed(int,Q3ListViewItem *,const QPoint &,int)),this,SLOT(redirect_mouseButtonPressed(int,Q3ListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(contextMenuRequested(Q3ListViewItem *,const QPoint &,int)),this,SLOT(redirect_contextMenuRequested(Q3ListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(onItem(Q3ListViewItem *)),this,SLOT(redirect_onItem(Q3ListViewItem *))); + connect(this,SIGNAL(expanded(Q3ListViewItem *)),this,SLOT(redirect_expanded(Q3ListViewItem *))); + connect(this,SIGNAL(collapsed(Q3ListViewItem *)),this,SLOT(redirect_collapsed(Q3ListViewItem *))); + } + + void KviTalListView::redirect_selectionChanged(Q3ListViewItem * pItem) + { + emit selectionChanged((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_currentChanged(Q3ListViewItem * pItem) + { + emit currentChanged((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_clicked(Q3ListViewItem * pItem) + { + emit clicked((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_clicked(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit clicked((KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_pressed(Q3ListViewItem * pItem) + { + emit pressed((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_pressed(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit pressed((KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_doubleClicked(Q3ListViewItem * pItem) + { + emit doubleClicked((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_doubleClicked(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit doubleClicked((KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_returnPressed(Q3ListViewItem * pItem) + { + emit returnPressed((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_spacePressed(Q3ListViewItem * pItem) + { + emit spacePressed((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_rightButtonClicked(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit rightButtonClicked((KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_rightButtonPressed(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit rightButtonPressed((KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_mouseButtonClicked(int iButton,Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit mouseButtonClicked(iButton,(KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_mouseButtonPressed(int iButton,Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit mouseButtonPressed(iButton,(KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_contextMenuRequested(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit contextMenuRequested((KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_onItem(Q3ListViewItem * pItem) + { + emit onItem((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_expanded(Q3ListViewItem * pItem) + { + emit expanded((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_collapsed(Q3ListViewItem * pItem) + { + emit collapsed((KviTalListViewItem *)pItem); + } + + + struct KviTalCheckListItemPrivate + { + KviTalCheckListItemPrivate(): + exclusive(0), + currentState(KviTalCheckListItem::Off), + tristate(false) {} + + KviTalCheckListItem *exclusive; + KviTalCheckListItem::ToggleState currentState; + QHash<KviTalCheckListItem *, KviTalCheckListItem::ToggleState> statesDict; + bool tristate; + }; + + KviTalCheckListItem::KviTalCheckListItem(KviTalCheckListItem *parent, const QString &text, + Type tt) + : KviTalListViewItem(parent, text, QString()) + { + myType = tt; + init(); + if (myType == RadioButton) { + if (parent->type() != RadioButtonController) + qWarning("KviTalCheckListItem::KviTalCheckListItem(), radio button must be " + "child of a controller"); + else + d->exclusive = parent; + } + } + + KviTalCheckListItem::KviTalCheckListItem(KviTalCheckListItem *parent, KviTalListViewItem *after, + const QString &text, Type tt) + : KviTalListViewItem(parent, after, text) + { + myType = tt; + init(); + if (myType == RadioButton) { + if (parent->type() != RadioButtonController) + qWarning("KviTalCheckListItem::KviTalCheckListItem(), radio button must be " + "child of a controller"); + else + d->exclusive = parent; + } + } + + KviTalCheckListItem::KviTalCheckListItem(KviTalListViewItem *parent, const QString &text, + Type tt) + : KviTalListViewItem(parent, text, QString()) + { + myType = tt; + if (myType == RadioButton) { + qWarning("KviTalCheckListItem::KviTalCheckListItem(), radio button must be " + "child of a KviTalCheckListItem"); + } + init(); + } + + KviTalCheckListItem::KviTalCheckListItem(KviTalListViewItem *parent, KviTalListViewItem *after, + const QString &text, Type tt) + : KviTalListViewItem(parent, after, text) + { + myType = tt; + if (myType == RadioButton) { + qWarning("KviTalCheckListItem::KviTalCheckListItem(), radio button must be " + "child of a KviTalCheckListItem"); + } + init(); + } + + KviTalCheckListItem::KviTalCheckListItem(KviTalListView *parent, const QString &text, + Type tt) + : KviTalListViewItem(parent, text) + { + myType = tt; + if (tt == RadioButton) + qWarning("KviTalCheckListItem::KviTalCheckListItem(), radio button must be " + "child of a KviTalCheckListItem"); + init(); + } + + KviTalCheckListItem::KviTalCheckListItem(KviTalListView *parent, KviTalListViewItem *after, + const QString &text, Type tt) + : KviTalListViewItem(parent, after, text) + { + myType = tt; + if (tt == RadioButton) + qWarning("KviTalCheckListItem::KviTalCheckListItem(), radio button must be " + "child of a KviTalCheckListItem"); + init(); + } + + int KviTalCheckListItem::rtti() const + { + return RTTI; + } + + KviTalCheckListItem::KviTalCheckListItem(KviTalListView *parent, const QString &text, + const QPixmap & p) + : KviTalListViewItem(parent, text) + { + myType = RadioButtonController; + setPixmap(0, p); + init(); + } + + KviTalCheckListItem::KviTalCheckListItem(KviTalListViewItem *parent, const QString &text, + const QPixmap & p) + : KviTalListViewItem(parent, text) + { + myType = RadioButtonController; + setPixmap(0, p); + init(); + } + + void KviTalCheckListItem::init() + { + d = new KviTalCheckListItemPrivate(); + on = false; // ### remove on ver 4 + // CheckBoxControllers by default have tristate set to true + if (myType == CheckBoxController) + setTristate(true); + } + + KviTalCheckListItem::~KviTalCheckListItem() + { + if (myType == RadioButton + && d->exclusive && d->exclusive->d + && d->exclusive->d->exclusive == this) + d->exclusive->turnOffChild(); + d->exclusive = 0; // so the children won't try to access us. + delete d; + d = 0; + } + + void KviTalCheckListItem::setTristate(bool b) + { + if ((myType != CheckBoxController) && (myType != CheckBox)) { + qWarning("KviTalCheckListItem::setTristate(), has no effect on RadioButton " + "or RadioButtonController."); + return; + } + d->tristate = b; + } + + bool KviTalCheckListItem::isTristate() const + { + return d->tristate; + } + + KviTalCheckListItem::ToggleState KviTalCheckListItem::state() const + { + if (!isTristate() && internalState() == NoChange) + return Off; + else + return d->currentState; + } + + KviTalCheckListItem::ToggleState KviTalCheckListItem::internalState() const + { + return d->currentState; + } + + void KviTalCheckListItem::setState(ToggleState s) + { + if (myType == CheckBoxController && state() == NoChange) + updateStoredState(this); + setState(s, true, true); + } + + void KviTalCheckListItem::setState(ToggleState s, bool update, bool store) + { + + if (s == internalState()) + return; + + if (myType == CheckBox) { + setCurrentState(s); + stateChange(state()); + if (update && parent() && parent()->rtti() == 1 + && ((KviTalCheckListItem*)parent())->type() == CheckBoxController) + ((KviTalCheckListItem*)parent())->updateController(update, store); + } else if (myType == CheckBoxController) { + if (s == NoChange && childCount()) { + restoreState(this); + } else { + KviTalListViewItem *item = firstChild(); + int childCount = 0; + while(item) { + if (item->rtti() == 1 && + (((KviTalCheckListItem*)item)->type() == CheckBox || + ((KviTalCheckListItem*)item)->type() == CheckBoxController)) { + KviTalCheckListItem *checkItem = (KviTalCheckListItem*)item; + checkItem->setState(s, false, false); + childCount++; + } + item = item->nextSibling(); + } + if (update) { + if (childCount > 0) { + ToggleState oldState = internalState(); + updateController(false, false); + if (oldState != internalState() && + parent() && parent()->rtti() == 1 && + ((KviTalCheckListItem*)parent())->type() == CheckBoxController) + ((KviTalCheckListItem*)parent())->updateController(update, store); + + updateController(update, store); + } else { + // if there are no children we simply set the CheckBoxController and update its parent + setCurrentState(s); + stateChange(state()); + if (parent() && parent()->rtti() == 1 + && ((KviTalCheckListItem*)parent())->type() == CheckBoxController) + ((KviTalCheckListItem*)parent())->updateController(update, store); + } + } else { + setCurrentState(s); + stateChange(state()); + } + + } + } else if (myType == RadioButton) { + if (s == On) { + if (d->exclusive && d->exclusive->d->exclusive != this) + d->exclusive->turnOffChild(); + setCurrentState(s); + if (d->exclusive) + d->exclusive->d->exclusive = this; + } else { + if (d->exclusive && d->exclusive->d->exclusive == this) + d->exclusive->d->exclusive = 0; + setCurrentState(Off); + } + stateChange(state()); + } + repaint(); + } + + void KviTalCheckListItem::setCurrentState(ToggleState s) + { + ToggleState old = d->currentState; + d->currentState = s; + if (d->currentState == On) + on = true; + else + on = false; + + //#ifndef QT_NO_ACCESSIBILITY + // if (old != d->currentState && listView()) + // QAccessible::updateAccessibility(listView()->viewport(), indexOfItem(this), QAccessible::StateChanged); + //#else + // Q_UNUSED(old); + //#endif + } + + void KviTalCheckListItem::setStoredState(ToggleState newState, KviTalCheckListItem *key) + { + if (myType == CheckBox || myType == CheckBoxController) + d->statesDict[key] = newState; + } + + KviTalCheckListItem::ToggleState KviTalCheckListItem::storedState(KviTalCheckListItem *key) const + { + QHash<KviTalCheckListItem *, KviTalCheckListItem::ToggleState>::Iterator it = d->statesDict.find(key); + if (it != d->statesDict.end()) + return it.value(); + else + return Off; + } + + void KviTalCheckListItem::turnOffChild() + { + if (myType == RadioButtonController && d->exclusive) + d->exclusive->setOn(false); + } + + void KviTalCheckListItem::activate() + { + KviTalListView * lv = listView(); + + if (lv && !lv->isEnabled() || !isEnabled()) + return; + + QPoint pos; + int boxsize = lv->style()->pixelMetric(QStyle::PM_CheckListButtonSize, 0, lv); + if (activatedPos(pos)) { + bool parentControl = false; + if (parent() && parent()->rtti() == 1 && + ((KviTalCheckListItem*) parent())->type() == RadioButtonController) + parentControl = true; + + int x = parentControl ? 0 : 3; + int align = lv->columnAlignment(0); + int marg = lv->itemMargin(); + int y = 0; + + if (align & Qt::AlignVCenter) + y = ((height() - boxsize) / 2) + marg; + else + y = (lv->fontMetrics().height() + 2 + marg - boxsize) / 2; + + QRect r(x, y, boxsize-3, boxsize-3); + // columns might have been swapped + r.moveBy(lv->header()->sectionPos(0), 0); + if (!r.contains(pos)) + return; + } + if ((myType == CheckBox) || (myType == CheckBoxController)) { + //lv->d->startEdit = FALSE; + switch (internalState()) { + case On: + setState(Off); + break; + case Off: + if (!isTristate() && myType == CheckBox) { + setState(On); + } else { + setState(NoChange); + if (myType == CheckBoxController && internalState() != NoChange) + setState(On); + } + break; + case NoChange: + setState(On); + break; + } + ignoreDoubleClick(); + } else if (myType == RadioButton) { + setOn(true); + ignoreDoubleClick(); + } + } + + void KviTalCheckListItem::setOn(bool b ) + { + if (b) + setState(On , true, true); + else + setState(Off , true, true); + } + + void KviTalCheckListItem::stateChange(bool) + { + } + + void KviTalCheckListItem::stateChange(ToggleState s) + { + stateChange(s == On); + } + + void KviTalCheckListItem::restoreState(KviTalCheckListItem *key, int depth) + { + switch (type()) { + case CheckBox: + setCurrentState(storedState(key)); + stateChange(state()); + repaint(); + break; + case CheckBoxController: { + KviTalListViewItem *item = firstChild(); + int childCount = 0; + while (item) { + // recursively calling restoreState for children of type CheckBox and CheckBoxController + if (item->rtti() == 1 && + (((KviTalCheckListItem*)item)->type() == CheckBox || + ((KviTalCheckListItem*)item)->type() == CheckBoxController)) { + ((KviTalCheckListItem*)item)->restoreState(key , depth+1); + childCount++; + } + item = item->nextSibling(); + } + if (childCount > 0) { + if (depth == 0) + updateController(true); + else + updateController(false); + } else { + // if there are no children we retrieve the CheckBoxController state directly. + setState(storedState(key), true, false); + } + } + break; + default: + break; + } + } + + void KviTalCheckListItem::updateController(bool update , bool store) + { + if (myType != CheckBoxController) + return; + + KviTalCheckListItem *controller = 0; + // checks if this CheckBoxController has another CheckBoxController as parent + if (parent() && parent()->rtti() == 1 + && ((KviTalCheckListItem*)parent())->type() == CheckBoxController) + controller = (KviTalCheckListItem*)parent(); + + ToggleState theState = Off; + bool first = true; + KviTalListViewItem *item = firstChild(); + while(item && theState != NoChange) { + if (item->rtti() == 1 && + (((KviTalCheckListItem*)item)->type() == CheckBox || + ((KviTalCheckListItem*)item)->type() == CheckBoxController)) { + KviTalCheckListItem *checkItem = (KviTalCheckListItem*)item; + if (first) { + theState = checkItem->internalState(); + first = false; + } else { + if (checkItem->internalState() == NoChange || + theState != checkItem->internalState()) + theState = NoChange; + else + theState = checkItem->internalState(); + } + } + item = item->nextSibling(); + } + if (internalState() != theState) { + setCurrentState(theState); + if (store && (internalState() == On || internalState() == Off)) + updateStoredState(this); + stateChange(state()); + if (update && controller) { + controller->updateController(update, store); + } + repaint(); + } + } + + void KviTalCheckListItem::updateStoredState(KviTalCheckListItem *key) + { + if (myType != CheckBoxController) + return; + + KviTalListViewItem *item = firstChild(); + while(item) { + if (item->rtti() == 1) { + KviTalCheckListItem *checkItem = (KviTalCheckListItem*)item; + if (checkItem->type() == CheckBox) + checkItem->setStoredState(checkItem->internalState(), key); + else if (checkItem->type() == CheckBoxController) + checkItem->updateStoredState(key); + } + item = item->nextSibling(); + } + // this state is only needed if the CheckBoxController has no CheckBox / CheckBoxController children. + setStoredState(internalState() , key); + } + + void KviTalCheckListItem::setup() + { + KviTalListViewItem::setup(); + int h = height(); + KviTalListView *lv = listView(); + if (lv) + h = qMax(lv->style()->pixelMetric(QStyle::PM_CheckListButtonSize, 0, lv), + h); + h = qMax(h, QApplication::globalStrut().height()); + setHeight(h); + } + + int KviTalCheckListItem::width(const QFontMetrics& fm, const KviTalListView* lv, int column) const + { + int r = KviTalListViewItem::width(fm, lv, column); + if (column == 0) { + r += lv->itemMargin(); + if (myType == RadioButtonController && pixmap(0)) { + // r += 0; + } else { + r += lv->style()->pixelMetric(QStyle::PM_CheckListButtonSize, 0, lv) + 4; + } + } + return qMax(r, QApplication::globalStrut().width()); + } + + void KviTalCheckListItem::paintCell(QPainter * p, const QColorGroup & cg, + int column, int width, int align) + { + if (!p) + return; + + KviTalListView *lv = listView(); + if (!lv) + return; + + const QPalette::ColorRole crole = lv->foregroundRole(); + if (cg.brush(crole) != lv->palette().brush(crole)) + p->fillRect(0, 0, width, height(), cg.brush(crole)); + else + lv->paintEmptyArea(p, QRect(0, 0, width, height())); + + if (column != 0) { + // The rest is text, or for subclasses to change. + KviTalListViewItem::paintCell(p, cg, column, width, align); + return; + } + + bool parentControl = false; + if (parent() && parent()->rtti() == 1 && + ((KviTalCheckListItem*) parent())->type() == RadioButtonController) + parentControl = true; + + QFontMetrics fm(lv->fontMetrics()); + int boxsize = lv->style()->pixelMetric(myType == RadioButtonController ? QStyle::PM_CheckListControllerSize : + QStyle::PM_CheckListButtonSize, 0, lv); + int marg = lv->itemMargin(); + int r = marg; + + // Draw controller / checkbox / radiobutton --------------------- + QStyle::State styleflags = QStyle::State_None; + if (internalState() == On) { + styleflags |= QStyle::State_On; + } else if (internalState() == NoChange) { + if (myType == CheckBoxController && !isTristate()) + styleflags |= QStyle::State_Off; + else + styleflags |= QStyle::State_NoChange; + } else { + styleflags |= QStyle::State_Off; + } + if (isSelected()) + styleflags |= QStyle::State_Selected; + if (isEnabled() && lv->isEnabled()) + styleflags |= QStyle::State_Enabled; + if (lv->window()->isActiveWindow()) + styleflags |= QStyle::State_Active; + + if (myType == RadioButtonController) { + int x = 0; + if(!parentControl) + x += 3; + if (!pixmap(0)) { + QStyleOptionQ3ListView opt = getStyleOption(lv, this); + opt.rect.setRect(x, 0, boxsize, fm.height() + 2 + marg); + opt.palette = cg; + opt.state = styleflags; + lv->style()->drawPrimitive(QStyle::PE_Q3CheckListController, &opt, p, lv); + r += boxsize + 4; + } + } else { + Q_ASSERT(lv); //### + int x = 0; + int y = 0; + if (!parentControl) + x += 3; + if (align & Qt::AlignVCenter) + y = ((height() - boxsize) / 2) + marg; + else + y = (fm.height() + 2 + marg - boxsize) / 2; + + QStyleOptionQ3ListView opt = getStyleOption(lv, this); + opt.rect.setRect(x, y, boxsize, fm.height() + 2 + marg); + opt.palette = cg; + opt.state = styleflags; + lv->style()->drawPrimitive((myType == CheckBox || myType == CheckBoxController) + ? QStyle::PE_Q3CheckListIndicator + : QStyle::PE_Q3CheckListExclusiveIndicator, &opt, p, lv); + r += boxsize + 4; + } + + // Draw text ---------------------------------------------------- + p->translate(r, 0); + p->setPen(QPen(cg.text())); + KviTalListViewItem::paintCell(p, cg, column, width - r, align); + } + + void KviTalCheckListItem::paintFocus(QPainter *p, const QColorGroup & cg, + const QRect & r) + { + bool intersect = true; + KviTalListView *lv = listView(); + if (lv && lv->header()->mapToActual(0) != 0) { + int xdepth = lv->treeStepSize() * (depth() + (lv->rootIsDecorated() ? 1 : 0)) + lv->itemMargin(); + int p = lv->header()->cellPos(lv->header()->mapToActual(0)); + xdepth += p; + intersect = r.intersects(QRect(p, r.y(), xdepth - p + 1, r.height())); + } + bool parentControl = false; + if (parent() && parent()->rtti() == 1 && + ((KviTalCheckListItem*) parent())->type() == RadioButtonController) + parentControl = true; + if (myType != RadioButtonController && intersect && + (lv->rootIsDecorated() || myType == RadioButton || + (myType == CheckBox && parentControl))) { + QRect rect; + int boxsize = lv->style()->pixelMetric(QStyle::PM_CheckListButtonSize, 0, lv); + if (lv->columnAlignment(0) == Qt::AlignCenter) { + QFontMetrics fm(lv->font()); + int bx = (lv->columnWidth(0) - (boxsize + fm.width(text())))/2 + boxsize; + if (bx < 0) bx = 0; + rect.setRect(r.x() + bx + 5, r.y(), r.width() - bx - 5, + r.height()); + } else + rect.setRect(r.x() + boxsize + 5, r.y(), r.width() - boxsize - 5, + r.height()); + KviTalListViewItem::paintFocus(p, cg, rect); + } else { + KviTalListViewItem::paintFocus(p, cg, r); + } + } + + + #include "kvi_tal_listview_qt4.moc" +#else + #include <qpainter.h> + #include <qstyle.h> + #include <qheader.h> + #include <qapplication.h> + + KviTalListView::KviTalListView(QWidget * pParent) + : QListView(pParent) + { + connect(this,SIGNAL(selectionChanged(QListViewItem *)),this,SLOT(redirect_selectionChanged(QListViewItem *))); + connect(this,SIGNAL(currentChanged(QListViewItem *)),this,SLOT(redirect_currentChanged(QListViewItem *))); + connect(this,SIGNAL(clicked(QListViewItem *)),this,SLOT(redirect_clicked(QListViewItem *))); + connect(this,SIGNAL(clicked(QListViewItem *,const QPoint &,int)),this,SLOT(redirect_clicked(QListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(pressed(QListViewItem *)),this,SLOT(redirect_pressed(QListViewItem *))); + connect(this,SIGNAL(pressed(QListViewItem *,const QPoint &,int)),this,SLOT(redirect_pressed(QListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(doubleClicked(QListViewItem *)),this,SLOT(redirect_doubleClicked(QListViewItem *))); + connect(this,SIGNAL(doubleClicked(QListViewItem *,const QPoint &,int)),this,SLOT(redirect_doubleClicked(QListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(returnPressed(QListViewItem *)),this,SLOT(redirect_returnPressed(QListViewItem *))); + connect(this,SIGNAL(spacePressed(QListViewItem *)),this,SLOT(redirect_spacePressed(QListViewItem *))); + connect(this,SIGNAL(rightButtonClicked(QListViewItem *,const QPoint &,int)),this,SLOT(redirect_rightButtonClicked(QListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)),this,SLOT(redirect_rightButtonPressed(QListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(mouseButtonClicked(int,QListViewItem *,const QPoint &,int)),this,SLOT(redirect_mouseButtonClicked(int,QListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(mouseButtonPressed(int,QListViewItem *,const QPoint &,int)),this,SLOT(redirect_mouseButtonPressed(int,QListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(contextMenuRequested(QListViewItem *,const QPoint &,int)),this,SLOT(redirect_contextMenuRequested(QListViewItem *,const QPoint &,int))); + connect(this,SIGNAL(onItem(QListViewItem *)),this,SLOT(redirect_onItem(QListViewItem *))); + connect(this,SIGNAL(expanded(QListViewItem *)),this,SLOT(redirect_expanded(QListViewItem *))); + connect(this,SIGNAL(collapsed(QListViewItem *)),this,SLOT(redirect_collapsed(QListViewItem *))); + } + + void KviTalListView::redirect_selectionChanged(QListViewItem * pItem) + { + emit selectionChanged((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_currentChanged(QListViewItem * pItem) + { + emit currentChanged((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_clicked(QListViewItem * pItem) + { + emit clicked((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_clicked(QListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit clicked((KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_pressed(QListViewItem * pItem) + { + emit pressed((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_pressed(QListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit pressed((KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_doubleClicked(QListViewItem * pItem) + { + emit doubleClicked((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_doubleClicked(QListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit doubleClicked((KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_returnPressed(QListViewItem * pItem) + { + emit returnPressed((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_spacePressed(QListViewItem * pItem) + { + emit spacePressed((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_rightButtonClicked(QListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit rightButtonClicked((KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_rightButtonPressed(QListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit rightButtonPressed((KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_mouseButtonClicked(int iButton,QListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit mouseButtonClicked(iButton,(KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_mouseButtonPressed(int iButton,QListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit mouseButtonPressed(iButton,(KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_contextMenuRequested(QListViewItem * pItem,const QPoint &pnt,int uColumn) + { + emit contextMenuRequested((KviTalListViewItem *)pItem,pnt,uColumn); + } + + void KviTalListView::redirect_onItem(QListViewItem * pItem) + { + emit onItem((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_expanded(QListViewItem * pItem) + { + emit expanded((KviTalListViewItem *)pItem); + } + + void KviTalListView::redirect_collapsed(QListViewItem * pItem) + { + emit collapsed((KviTalListViewItem *)pItem); + } + + struct KviTalCheckListItemPrivate + { + KviTalCheckListItemPrivate(): + exclusive( 0 ), + currentState( KviTalCheckListItem::Off ), + statesDict( 0 ), + tristate( FALSE ) {} + + KviTalCheckListItem *exclusive; + KviTalCheckListItem::ToggleState currentState; + KviPointerHashTable<void *,KviTalCheckListItem::ToggleState> *statesDict; + bool tristate; + }; + + // ### obscenity is warranted. + + KviTalCheckListItem::KviTalCheckListItem( KviTalCheckListItem *parent, const QString &text, + Type tt ) + : KviTalListViewItem( parent, text, QString::null ) + { + myType = tt; + init(); + if ( myType == RadioButton ) { + if ( parent->type() != RadioButtonController ) + qWarning( "KviTalCheckListItem::KviTalCheckListItem(), radio button must be " + "child of a controller" ); + else + d->exclusive = parent; + } + } + + KviTalCheckListItem::KviTalCheckListItem( KviTalCheckListItem *parent, KviTalListViewItem *after, + const QString &text, Type tt ) + : KviTalListViewItem( parent, after, text ) + { + myType = tt; + init(); + if ( myType == RadioButton ) { + if ( parent->type() != RadioButtonController ) + qWarning( "KviTalCheckListItem::KviTalCheckListItem(), radio button must be " + "child of a controller" ); + else + d->exclusive = parent; + } + } + + KviTalCheckListItem::KviTalCheckListItem( KviTalListViewItem *parent, const QString &text, + Type tt ) + : KviTalListViewItem( parent, text, QString::null ) + { + myType = tt; + if ( myType == RadioButton ) { + qWarning( "KviTalCheckListItem::KviTalCheckListItem(), radio button must be " + "child of a KviTalCheckListItem" ); + } + init(); + } + + KviTalCheckListItem::KviTalCheckListItem( KviTalListViewItem *parent, KviTalListViewItem *after, + const QString &text, Type tt ) + : KviTalListViewItem( parent, after, text ) + { + myType = tt; + if ( myType == RadioButton ) { + qWarning( "KviTalCheckListItem::KviTalCheckListItem(), radio button must be " + "child of a KviTalCheckListItem" ); + } + init(); + } + + KviTalCheckListItem::KviTalCheckListItem( KviTalListView *parent, const QString &text, + Type tt ) + : KviTalListViewItem( parent, text ) + { + myType = tt; + if ( tt == RadioButton ) + qWarning( "KviTalCheckListItem::KviTalCheckListItem(), radio button must be " + "child of a KviTalCheckListItem" ); + init(); + } + + KviTalCheckListItem::KviTalCheckListItem( KviTalListView *parent, KviTalListViewItem *after, + const QString &text, Type tt ) + : KviTalListViewItem( parent, after, text ) + { + myType = tt; + if ( tt == RadioButton ) + qWarning( "KviTalCheckListItem::KviTalCheckListItem(), radio button must be " + "child of a KviTalCheckListItem" ); + init(); + } + + + int KviTalCheckListItem::RTTI = 1; + + int KviTalCheckListItem::rtti() const + { + return RTTI; + } + + KviTalCheckListItem::KviTalCheckListItem( KviTalListView *parent, const QString &text, + const QPixmap & p ) + : KviTalListViewItem( parent, text ) + { + myType = RadioButtonController; + setPixmap( 0, p ); + init(); + } + + KviTalCheckListItem::KviTalCheckListItem( KviTalListViewItem *parent, const QString &text, + const QPixmap & p ) + : KviTalListViewItem( parent, text ) + { + myType = RadioButtonController; + setPixmap( 0, p ); + init(); + } + + void KviTalCheckListItem::init() + { + d = new KviTalCheckListItemPrivate(); + on = FALSE; // ### remove on ver 4 + if ( myType == CheckBoxController || myType == CheckBox ) { + d->statesDict = new KviPointerHashTable<void *,ToggleState>(101); + d->statesDict->setAutoDelete( TRUE ); + } + // CheckBoxControllers by default have tristate set to TRUE + if ( myType == CheckBoxController ) + setTristate( TRUE ); + } + + KviTalCheckListItem::~KviTalCheckListItem() + { + if ( myType == RadioButton + && d->exclusive && d->exclusive->d + && d->exclusive->d->exclusive == this ) + d->exclusive->turnOffChild(); + d->exclusive = 0; // so the children won't try to access us. + if ( d->statesDict ) + delete d->statesDict; + delete d; + d = 0; + } + + void KviTalCheckListItem::setTristate( bool b ) + { + if ( ( myType != CheckBoxController ) && ( myType != CheckBox ) ) { + qWarning( "KviTalCheckListItem::setTristate(), has no effect on RadioButton " + "or RadioButtonController." ); + return; + } + d->tristate = b; + } + + bool KviTalCheckListItem::isTristate() const + { + return d->tristate; + } + + KviTalCheckListItem::ToggleState KviTalCheckListItem::state() const + { + if ( !isTristate() && internalState() == NoChange ) + return Off; + else + return d->currentState; + } + + KviTalCheckListItem::ToggleState KviTalCheckListItem::internalState() const + { + return d->currentState; + } + + void KviTalCheckListItem::setState( ToggleState s ) + { + if ( myType == CheckBoxController && state() == NoChange ) + updateStoredState( (void*) this ); + setState( s, TRUE, TRUE ); + } + + void KviTalCheckListItem::setState( ToggleState s, bool update, bool store) + { + + if ( s == internalState() ) + return; + + if ( myType == CheckBox ) { + setCurrentState( s ); + stateChange( state() ); + if ( update && parent() && parent()->rtti() == 1 + && ((KviTalCheckListItem*)parent())->type() == CheckBoxController ) + ((KviTalCheckListItem*)parent())->updateController( update, store ); + } else if ( myType == CheckBoxController ) { + if ( s == NoChange && childCount()) { + restoreState( (void*) this ); + } else { + KviTalListViewItem *item = firstChild(); + int childCount = 0; + while( item ) { + if ( item->rtti() == 1 && + ( ((KviTalCheckListItem*)item)->type() == CheckBox || + ((KviTalCheckListItem*)item)->type() == CheckBoxController ) ) { + KviTalCheckListItem *checkItem = (KviTalCheckListItem*)item; + checkItem->setState( s, FALSE, FALSE ); + childCount++; + } + item = item->nextSibling(); + } + if ( update ) { + if ( childCount > 0 ) { + ToggleState oldState = internalState(); + updateController( FALSE, FALSE ); + if ( oldState != internalState() && + parent() && parent()->rtti() == 1 && + ((KviTalCheckListItem*)parent())->type() == CheckBoxController ) + ((KviTalCheckListItem*)parent())->updateController( update, store ); + + updateController( update, store ); + } else { + // if there are no children we simply set the CheckBoxController and update its parent + setCurrentState( s ); + stateChange( state() ); + if ( parent() && parent()->rtti() == 1 + && ((KviTalCheckListItem*)parent())->type() == CheckBoxController ) + ((KviTalCheckListItem*)parent())->updateController( update, store ); + } + } else { + setCurrentState( s ); + stateChange( state() ); + } + + } + } else if ( myType == RadioButton ) { + if ( s == On ) { + if ( d->exclusive && d->exclusive->d->exclusive != this ) + d->exclusive->turnOffChild(); + setCurrentState( s ); + if ( d->exclusive ) + d->exclusive->d->exclusive = this; + } else { + if ( d->exclusive && d->exclusive->d->exclusive == this ) + d->exclusive->d->exclusive = 0; + setCurrentState( Off ); + } + stateChange( state() ); + } + repaint(); + } + + void KviTalCheckListItem::setCurrentState( ToggleState s ) + { + ToggleState old = d->currentState; + d->currentState = s; + if (d->currentState == On) + on = TRUE; + else + on = FALSE; + + #if defined(QT_ACCESSIBILITY_SUPPORT) + if ( old != d->currentState && listView() ) + QAccessible::updateAccessibility( listView()->viewport(), indexOfItem( this ), QAccessible::StateChanged ); + #else + Q_UNUSED( old ); + #endif + } + + void KviTalCheckListItem::setStoredState( ToggleState newState, void *key ) + { + if ( myType == CheckBox || myType == CheckBoxController ) + d->statesDict->replace( key, new ToggleState(newState) ); + } + + KviTalCheckListItem::ToggleState KviTalCheckListItem::storedState( void *key ) const + { + if ( !d->statesDict ) + return Off; + + ToggleState *foundState = d->statesDict->find( key ); + if ( foundState ) + return ToggleState( *foundState ); + else + return Off; + } + + void KviTalCheckListItem::turnOffChild() + { + if ( myType == RadioButtonController && d->exclusive ) + d->exclusive->setOn( FALSE ); + } + + void KviTalCheckListItem::activate() + { + KviTalListView * lv = listView(); + + if ( lv && !lv->isEnabled() || !isEnabled() ) + return; + + QPoint pos; + int boxsize = lv->style().pixelMetric(QStyle::PM_CheckListButtonSize, lv); + if ( activatedPos( pos ) ) { + bool parentControl = FALSE; + if ( parent() && parent()->rtti() == 1 && + ((KviTalCheckListItem*) parent())->type() == RadioButtonController ) + parentControl = TRUE; + + int x = parentControl ? 0 : 3; + int align = lv->columnAlignment( 0 ); + int marg = lv->itemMargin(); + int y = 0; + + if ( align & AlignVCenter ) + y = ( ( height() - boxsize ) / 2 ) + marg; + else + y = (lv->fontMetrics().height() + 2 + marg - boxsize) / 2; + + QRect r( x, y, boxsize-3, boxsize-3 ); + // columns might have been swapped + r.moveBy( lv->header()->sectionPos( 0 ), 0 ); + if ( !r.contains( pos ) ) + return; + } + if ( ( myType == CheckBox ) || ( myType == CheckBoxController) ) { + switch ( internalState() ) { + case On: + setState( Off ); + break; + case Off: + if ( !isTristate() && myType == CheckBox ) { + setState( On ); + } else { + setState( NoChange ); + if ( myType == CheckBoxController && internalState() != NoChange ) + setState( On ); + } + break; + case NoChange: + setState( On ); + break; + } + ignoreDoubleClick(); + } else if ( myType == RadioButton ) { + setOn( TRUE ); + ignoreDoubleClick(); + } + } + + void KviTalCheckListItem::setOn( bool b ) + { + if ( b ) + setState( On , TRUE, TRUE ); + else + setState( Off , TRUE, TRUE ); + } + + void KviTalCheckListItem::stateChange( bool ) + { + } + + void KviTalCheckListItem::stateChange( ToggleState s ) + { + stateChange( s == On ); + } + + void KviTalCheckListItem::restoreState( void *key, int depth ) + { + switch ( type() ) { + case CheckBox: + setCurrentState( storedState( key ) ); + stateChange( state() ); + repaint(); + break; + case CheckBoxController: { + KviTalListViewItem *item = firstChild(); + int childCount = 0; + while ( item ) { + // recursively calling restoreState for children of type CheckBox and CheckBoxController + if ( item->rtti() == 1 && + ( ((KviTalCheckListItem*)item)->type() == CheckBox || + ((KviTalCheckListItem*)item)->type() == CheckBoxController ) ) { + ((KviTalCheckListItem*)item)->restoreState( key , depth+1 ); + childCount++; + } + item = item->nextSibling(); + } + if ( childCount > 0 ) { + if ( depth == 0 ) + updateController( TRUE ); + else + updateController( FALSE ); + } else { + // if there are no children we retrieve the CheckBoxController state directly. + setState( storedState( key ), TRUE, FALSE ); + } + } + break; + default: + break; + } + } + + void KviTalCheckListItem::updateController( bool update , bool store ) + { + if ( myType != CheckBoxController ) + return; + + KviTalCheckListItem *controller = 0; + // checks if this CheckBoxController has another CheckBoxController as parent + if ( parent() && parent()->rtti() == 1 + && ((KviTalCheckListItem*)parent())->type() == CheckBoxController ) + controller = (KviTalCheckListItem*)parent(); + + ToggleState theState = Off; + bool first = TRUE; + KviTalListViewItem *item = firstChild(); + while( item && theState != NoChange ) { + if ( item->rtti() == 1 && + ( ((KviTalCheckListItem*)item)->type() == CheckBox || + ((KviTalCheckListItem*)item)->type() == CheckBoxController ) ) { + KviTalCheckListItem *checkItem = (KviTalCheckListItem*)item; + if ( first ) { + theState = checkItem->internalState(); + first = FALSE; + } else { + if ( checkItem->internalState() == NoChange || + theState != checkItem->internalState() ) + theState = NoChange; + else + theState = checkItem->internalState(); + } + } + item = item->nextSibling(); + } + if ( internalState() != theState ) { + setCurrentState( theState ); + if ( store && ( internalState() == On || internalState() == Off ) ) + updateStoredState( (void*) this ); + stateChange( state() ); + if ( update && controller ) { + controller->updateController( update, store ); + } + repaint(); + } + } + + void KviTalCheckListItem::updateStoredState( void *key ) + { + if ( myType != CheckBoxController ) + return; + + KviTalListViewItem *item = firstChild(); + while( item ) { + if ( item->rtti() == 1 ) { + KviTalCheckListItem *checkItem = (KviTalCheckListItem*)item; + if ( checkItem->type() == CheckBox ) + checkItem->setStoredState( checkItem->internalState(), key ); + else if (checkItem->type() == CheckBoxController ) + checkItem->updateStoredState( key ); + } + item = item->nextSibling(); + } + // this state is only needed if the CheckBoxController has no CheckBox / CheckBoxController children. + setStoredState( internalState() , key ); + } + + void KviTalCheckListItem::setup() + { + KviTalListViewItem::setup(); + int h = height(); + KviTalListView *lv = listView(); + if ( lv ) + h = QMAX( lv->style().pixelMetric(QStyle::PM_CheckListButtonSize, lv), + h ); + h = QMAX( h, QApplication::globalStrut().height() ); + setHeight( h ); + } + + int KviTalCheckListItem::width( const QFontMetrics& fm, const KviTalListView* lv, int column) const + { + int r = KviTalListViewItem::width( fm, lv, column ); + if ( column == 0 ) { + r += lv->itemMargin(); + if ( myType == RadioButtonController && pixmap( 0 ) ) { + // r += 0; + } else { + r += lv->style().pixelMetric(QStyle::PM_CheckListButtonSize, lv) + 4; + } + } + return QMAX( r, QApplication::globalStrut().width() ); + } + + void KviTalCheckListItem::paintCell( QPainter * p, const QColorGroup & cg, + int column, int width, int align ) + { + if ( !p ) + return; + + KviTalListView *lv = listView(); + if ( !lv ) + return; + + const BackgroundMode bgmode = lv->viewport()->backgroundMode(); + const QColorGroup::ColorRole crole = QPalette::backgroundRoleFromMode( bgmode ); + if ( cg.brush( crole ) != lv->colorGroup().brush( crole ) ) + p->fillRect( 0, 0, width, height(), cg.brush( crole ) ); + else + lv->paintEmptyArea( p, QRect( 0, 0, width, height() ) ); + + if ( column != 0 ) { + // The rest is text, or for subclasses to change. + KviTalListViewItem::paintCell( p, cg, column, width, align ); + return; + } + + bool parentControl = FALSE; + if ( parent() && parent()->rtti() == 1 && + ((KviTalCheckListItem*) parent())->type() == RadioButtonController ) + parentControl = TRUE; + + QFontMetrics fm( lv->fontMetrics() ); + int boxsize = lv->style().pixelMetric( myType == RadioButtonController ? QStyle::PM_CheckListControllerSize : + QStyle::PM_CheckListButtonSize, lv); + int marg = lv->itemMargin(); + int r = marg; + + // Draw controller / checkbox / radiobutton --------------------- + int styleflags = QStyle::Style_Default; + if ( internalState() == On ) { + styleflags |= QStyle::Style_On; + } else if ( internalState() == NoChange ) { + if ( myType == CheckBoxController && !isTristate() ) + styleflags |= QStyle::Style_Off; + else + styleflags |= QStyle::Style_NoChange; + } else { + styleflags |= QStyle::Style_Off; + } + if ( isSelected() ) + styleflags |= QStyle::Style_Selected; + if ( isEnabled() && lv->isEnabled() ) + styleflags |= QStyle::Style_Enabled; + + if ( myType == RadioButtonController ) { + int x = 0; + if(!parentControl) + x += 3; + if ( !pixmap( 0 ) ) { + lv->style().drawPrimitive(QStyle::PE_CheckListController, p, + QRect(x, 0, boxsize, + fm.height() + 2 + marg), + cg, styleflags, QStyleOption(this)); + r += boxsize + 4; + } + } else { + Q_ASSERT( lv ); //### + int x = 0; + int y = 0; + if ( !parentControl ) + x += 3; + if ( align & AlignVCenter ) + y = ( ( height() - boxsize ) / 2 ) + marg; + else + y = (fm.height() + 2 + marg - boxsize) / 2; + + if ( ( myType == CheckBox ) || ( myType == CheckBoxController ) ) { + lv->style().drawPrimitive(QStyle::PE_CheckListIndicator, p, + QRect(x, y, boxsize, + fm.height() + 2 + marg), + cg, styleflags, QStyleOption(this)); + } else { //radio button look + lv->style().drawPrimitive(QStyle::PE_CheckListExclusiveIndicator, + p, QRect(x, y, boxsize, + fm.height() + 2 + marg), + cg, styleflags, QStyleOption(this)); + } + r += boxsize + 4; + } + + // Draw text ---------------------------------------------------- + p->translate( r, 0 ); + p->setPen( QPen( cg.text() ) ); + KviTalListViewItem::paintCell( p, cg, column, width - r, align ); + } + + void KviTalCheckListItem::paintFocus( QPainter *p, const QColorGroup & cg,const QRect & r ) + { + bool intersect = TRUE; + KviTalListView *lv = listView(); + if ( lv && lv->header()->mapToActual( 0 ) != 0 ) { + int xdepth = lv->treeStepSize() * ( depth() + ( lv->rootIsDecorated() ? 1 : 0) ) + lv->itemMargin(); + int p = lv->header()->cellPos( lv->header()->mapToActual( 0 ) ); + xdepth += p; + intersect = r.intersects( QRect( p, r.y(), xdepth - p + 1, r.height() ) ); + } + bool parentControl = FALSE; + if ( parent() && parent()->rtti() == 1 && + ((KviTalCheckListItem*) parent())->type() == RadioButtonController ) + parentControl = TRUE; + if ( myType != RadioButtonController && intersect && + (lv->rootIsDecorated() || myType == RadioButton || + (myType == CheckBox && parentControl) ) ) { + QRect rect; + int boxsize = lv->style().pixelMetric(QStyle::PM_CheckListButtonSize, lv); + if ( lv->columnAlignment(0) == AlignCenter ) { + QFontMetrics fm( lv->font() ); + int bx = (lv->columnWidth(0) - (boxsize + fm.width(text())))/2 + boxsize; + if ( bx < 0 ) bx = 0; + rect.setRect( r.x() + bx + 5, r.y(), r.width() - bx - 5, + r.height() ); + } else + rect.setRect( r.x() + boxsize + 5, r.y(), r.width() - boxsize - 5, + r.height() ); + KviTalListViewItem::paintFocus(p, cg, rect); + } else { + KviTalListViewItem::paintFocus(p, cg, r); + } + } + + #include "kvi_tal_listview_qt3.moc" +#endif + + + diff --git a/src/kvilib/tal/kvi_tal_listview.h b/src/kvilib/tal/kvi_tal_listview.h new file mode 100644 index 00000000..9b95e2f8 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_listview.h @@ -0,0 +1,51 @@ +#ifndef _KVI_TAL_LISTVIEW_H_ +#define _KVI_TAL_LISTVIEW_H_ + +//============================================================================= +// +// File : kvi_tal_listview.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + + +// +// This is the only reasonable CROSS-QT3-QT4-COMPATIBLE implementation +// of QListView I've been able to find. +// Note that using macros for the items will NOT work since moc +// doesn't expand them. Note also that KviTalCheckListItem must +// be fully reimplemented and not be inherited from QCheckListItem +// to build up a consistent item object hierarchy. To complete +// the obscenity, we need TWO COMPLETE implementations: one for Qt3 +// and one for Qt4... bleah :D +// +// The code for KviTalCheckListItem is adapted from qlistview.h/cpp +// present in qt 3.3.6 AND in qt 4.1.2. +// + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_listview_qt4.h" +#else + #include "kvi_tal_listview_qt3.h" +#endif + +#endif // _KVI_TAL_LISTVIEW_H_ diff --git a/src/kvilib/tal/kvi_tal_listview_qt3.h b/src/kvilib/tal/kvi_tal_listview_qt3.h new file mode 100644 index 00000000..4fe4a766 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_listview_qt3.h @@ -0,0 +1,190 @@ +#ifndef _KVI_TAL_LISTVIEW_QT3_H_ +#define _KVI_TAL_LISTVIEW_QT3_H_ + +//============================================================================= +// +// File : kvi_tal_listview_qt3.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include "kvi_qstring.h" + +#include <qlistview.h> + +class KviTalListViewItem; + +class KVILIB_API KviTalListView : public QListView +{ + friend class KviTalCheckListItem; + Q_OBJECT +public: + KviTalListView(QWidget * pParent); + virtual ~KviTalListView() {}; +public: + // Shadow the internal Qt methods + KviTalListViewItem * firstChild() const { return (KviTalListViewItem *)QListView::firstChild(); }; + KviTalListViewItem * lastItem() const { return (KviTalListViewItem *)QListView::lastItem(); }; + KviTalListViewItem * selectedItem() const { return (KviTalListViewItem *)QListView::selectedItem(); }; + KviTalListViewItem * currentItem() const { return (KviTalListViewItem *)QListView::currentItem(); }; + KviTalListViewItem * itemAt(const QPoint &pnt) const { return (KviTalListViewItem *)QListView::itemAt(pnt); }; +signals: + void selectionChanged(KviTalListViewItem * pItem); + void currentChanged(KviTalListViewItem * pItem); + void clicked(KviTalListViewItem * pItem); + void clicked(KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void pressed(KviTalListViewItem * pItem); + void pressed(KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void doubleClicked(KviTalListViewItem * pItem); + void doubleClicked(KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void returnPressed(KviTalListViewItem * pItem); + void spacePressed(KviTalListViewItem * pItem); + void rightButtonClicked(KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void rightButtonPressed(KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void mouseButtonClicked(int iButton,KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void mouseButtonPressed(int iButton,KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void contextMenuRequested(KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void onItem(KviTalListViewItem * pItem); + void expanded(KviTalListViewItem * pItem); + void collapsed(KviTalListViewItem * pItem); +protected slots: + void redirect_selectionChanged(QListViewItem * pItem); + void redirect_currentChanged(QListViewItem * pItem); + void redirect_clicked(QListViewItem * pItem); + void redirect_clicked(QListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_pressed(QListViewItem * pItem); + void redirect_pressed(QListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_doubleClicked(QListViewItem * pItem); + void redirect_doubleClicked(QListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_returnPressed(QListViewItem * pItem); + void redirect_spacePressed(QListViewItem * pItem); + void redirect_rightButtonClicked(QListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_rightButtonPressed(QListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_mouseButtonClicked(int iButton,QListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_mouseButtonPressed(int iButton,QListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_contextMenuRequested(QListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_onItem(QListViewItem * pItem); + void redirect_expanded(QListViewItem * pItem); + void redirect_collapsed(QListViewItem * pItem); +}; + + +class KVILIB_API KviTalListViewItem : public QListViewItem +{ +public: + KviTalListViewItem(KviTalListView * pParent) + : QListViewItem(pParent) {}; + KviTalListViewItem(KviTalListViewItem * pParent) + : QListViewItem(pParent) {}; + KviTalListViewItem(KviTalListView * pParent,KviTalListViewItem * pAfter) + : QListViewItem(pParent,pAfter) {}; + KviTalListViewItem(KviTalListViewItem * pParent,KviTalListViewItem * pAfter) + : QListViewItem(pParent,pAfter) {}; + KviTalListViewItem(KviTalListView * pParent,const QString &szLabel1,const QString &szLabel2 = KviQString::empty,const QString &szLabel3 = KviQString::empty,const QString &szLabel4 = KviQString::empty,const QString &szLabel5 = KviQString::empty) + : QListViewItem(pParent,szLabel1,szLabel2,szLabel3,szLabel4,szLabel5) {}; + KviTalListViewItem(KviTalListView * pParent,KviTalListViewItem * pAfter,const QString &szLabel1,const QString &szLabel2 = KviQString::empty,const QString &szLabel3 = KviQString::empty,const QString &szLabel4 = KviQString::empty,const QString &szLabel5 = KviQString::empty) + : QListViewItem(pParent,pAfter,szLabel1,szLabel2,szLabel3,szLabel4,szLabel5) {}; + KviTalListViewItem(KviTalListViewItem * pParent,const QString &szLabel1,const QString &szLabel2 = KviQString::empty,const QString &szLabel3 = KviQString::empty,const QString &szLabel4 = KviQString::empty) + : QListViewItem(pParent,szLabel1,szLabel2,szLabel3,szLabel4) {}; + KviTalListViewItem(KviTalListViewItem * pParent,KviTalListViewItem * pAfter,const QString &szLabel1,const QString &szLabel2 = KviQString::empty,const QString &szLabel3 = KviQString::empty,const QString &szLabel4 = KviQString::empty) + : QListViewItem(pParent,pAfter,szLabel1,szLabel2,szLabel3,szLabel4) {}; + virtual ~KviTalListViewItem() {}; +public: + // Shadow the internal Qt methods + KviTalListViewItem * firstChild() const { return (KviTalListViewItem *)QListViewItem::firstChild(); }; + KviTalListViewItem * nextSibling() const { return (KviTalListViewItem *)QListViewItem::nextSibling(); }; + KviTalListViewItem * parent() const { return (KviTalListViewItem *)QListViewItem::parent(); }; + KviTalListView * listView() const { return (KviTalListView *)QListViewItem::listView(); }; + KviTalListViewItem * itemAbove() { return (KviTalListViewItem *)QListViewItem::itemAbove(); }; + KviTalListViewItem * itemBelow() { return (KviTalListViewItem *)QListViewItem::itemBelow(); }; +}; + +struct KviTalCheckListItemPrivate; + +class KVILIB_API KviTalCheckListItem : public KviTalListViewItem +{ +public: + enum Type { + RadioButton, + CheckBox, + Controller, + RadioButtonController=Controller, + CheckBoxController + }; + enum ToggleState { Off, NoChange, On }; + + KviTalCheckListItem(KviTalCheckListItem *parent, const QString &text,Type = RadioButtonController); + KviTalCheckListItem(KviTalCheckListItem *parent, KviTalListViewItem *after,const QString &text, Type = RadioButtonController); + KviTalCheckListItem( KviTalListViewItem *parent, const QString &text,Type = RadioButtonController ); + KviTalCheckListItem( KviTalListViewItem *parent, KviTalListViewItem *after,const QString &text, Type = RadioButtonController ); + KviTalCheckListItem( KviTalListView *parent, const QString &text,Type = RadioButtonController ); + KviTalCheckListItem( KviTalListView *parent, KviTalListViewItem *after,const QString &text, Type = RadioButtonController ); + KviTalCheckListItem( KviTalListViewItem *parent, const QString &text,const QPixmap & ); + KviTalCheckListItem( KviTalListView *parent, const QString &text,const QPixmap & ); + ~KviTalCheckListItem(); + + void paintCell( QPainter *,const QColorGroup & cg,int column, int width, int alignment ); + virtual void paintFocus( QPainter *, const QColorGroup & cg, + const QRect & r ); + int width( const QFontMetrics&, const KviTalListView*, int column) const; + void setup(); + + virtual void setOn( bool ); // ### should be replaced by setChecked in ver4 + bool isOn() const { return on; } + Type type() const { return myType; } + QString text() const { return KviTalListViewItem::text( 0 ); } + QString text( int n ) const { return KviTalListViewItem::text( n ); } + + void setTristate( bool ); + bool isTristate() const; + ToggleState state() const; + void setState( ToggleState s); + + int rtti() const; + static int RTTI; + +protected: + void activate(); + void turnOffChild(); + virtual void stateChange( bool ); + +private: + void init(); + ToggleState internalState() const; + void setStoredState( ToggleState newState, void *key ); + ToggleState storedState( void *key ) const; + void stateChange( ToggleState s ); + void restoreState( void *key, int depth = 0 ); + void updateController( bool update = TRUE , bool store = FALSE ); + void updateStoredState( void *key ); + void setState( ToggleState s, bool update, bool store ); + void setCurrentState( ToggleState s ); + + Type myType; + bool on; // ### remove in ver4 + KviTalCheckListItemPrivate *d; +}; + + +#define KviTalListViewItemIterator QListViewItemIterator + +#endif // _KVI_TAL_LISTVIEW_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_listview_qt4.h b/src/kvilib/tal/kvi_tal_listview_qt4.h new file mode 100644 index 00000000..e6ccc829 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_listview_qt4.h @@ -0,0 +1,199 @@ +#ifndef _KVI_TAL_LISTVIEW_QT4_H_ +#define _KVI_TAL_LISTVIEW_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_listview_qt4.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include "kvi_qstring.h" + +#include <q3listview.h> + +class KviTalListViewItem; + + +class KVILIB_API KviTalListView : public Q3ListView +{ + friend class KviTalCheckListItem; + Q_OBJECT +public: + KviTalListView(QWidget * pParent); + virtual ~KviTalListView() {}; +public: + // Shadow the internal Qt methods + KviTalListViewItem * firstChild() const { return (KviTalListViewItem *)Q3ListView::firstChild(); }; + KviTalListViewItem * lastItem() const { return (KviTalListViewItem *)Q3ListView::lastItem(); }; + KviTalListViewItem * selectedItem() const { return (KviTalListViewItem *)Q3ListView::selectedItem(); }; + KviTalListViewItem * currentItem() const { return (KviTalListViewItem *)Q3ListView::currentItem(); }; + KviTalListViewItem * itemAt(const QPoint &pnt) const { return (KviTalListViewItem *)Q3ListView::itemAt(pnt); }; +signals: + void selectionChanged(KviTalListViewItem * pItem); + void currentChanged(KviTalListViewItem * pItem); + void clicked(KviTalListViewItem * pItem); + void clicked(KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void pressed(KviTalListViewItem * pItem); + void pressed(KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void doubleClicked(KviTalListViewItem * pItem); + void doubleClicked(KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void returnPressed(KviTalListViewItem * pItem); + void spacePressed(KviTalListViewItem * pItem); + void rightButtonClicked(KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void rightButtonPressed(KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void mouseButtonClicked(int iButton,KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void mouseButtonPressed(int iButton,KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void contextMenuRequested(KviTalListViewItem * pItem,const QPoint &pnt,int uColumn); + void onItem(KviTalListViewItem * pItem); + void expanded(KviTalListViewItem * pItem); + void collapsed(KviTalListViewItem * pItem); +protected slots: + void redirect_selectionChanged(Q3ListViewItem * pItem); + void redirect_currentChanged(Q3ListViewItem * pItem); + void redirect_clicked(Q3ListViewItem * pItem); + void redirect_clicked(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_pressed(Q3ListViewItem * pItem); + void redirect_pressed(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_doubleClicked(Q3ListViewItem * pItem); + void redirect_doubleClicked(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_returnPressed(Q3ListViewItem * pItem); + void redirect_spacePressed(Q3ListViewItem * pItem); + void redirect_rightButtonClicked(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_rightButtonPressed(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_mouseButtonClicked(int iButton,Q3ListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_mouseButtonPressed(int iButton,Q3ListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_contextMenuRequested(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn); + void redirect_onItem(Q3ListViewItem * pItem); + void redirect_expanded(Q3ListViewItem * pItem); + void redirect_collapsed(Q3ListViewItem * pItem); + +}; + + +class KVILIB_API KviTalListViewItem : public Q3ListViewItem +{ +public: + KviTalListViewItem(KviTalListView * pParent) + : Q3ListViewItem(pParent) {}; + KviTalListViewItem(KviTalListViewItem * pParent) + : Q3ListViewItem(pParent) {}; + KviTalListViewItem(KviTalListView * pParent,KviTalListViewItem * pAfter) + : Q3ListViewItem(pParent,pAfter) {}; + KviTalListViewItem(KviTalListViewItem * pParent,KviTalListViewItem * pAfter) + : Q3ListViewItem(pParent,pAfter) {}; + KviTalListViewItem(KviTalListView * pParent,const QString &szLabel1,const QString &szLabel2 = KviQString::empty,const QString &szLabel3 = KviQString::empty,const QString &szLabel4 = KviQString::empty,const QString &szLabel5 = KviQString::empty) + : Q3ListViewItem(pParent,szLabel1,szLabel2,szLabel3,szLabel4,szLabel5) {}; + KviTalListViewItem(KviTalListView * pParent,KviTalListViewItem * pAfter,const QString &szLabel1,const QString &szLabel2 = KviQString::empty,const QString &szLabel3 = KviQString::empty,const QString &szLabel4 = KviQString::empty,const QString &szLabel5 = KviQString::empty) + : Q3ListViewItem(pParent,pAfter,szLabel1,szLabel2,szLabel3,szLabel4,szLabel5) {}; + KviTalListViewItem(KviTalListViewItem * pParent,const QString &szLabel1,const QString &szLabel2 = KviQString::empty,const QString &szLabel3 = KviQString::empty,const QString &szLabel4 = KviQString::empty) + : Q3ListViewItem(pParent,szLabel1,szLabel2,szLabel3,szLabel4) {}; + KviTalListViewItem(KviTalListViewItem * pParent,KviTalListViewItem * pAfter,const QString &szLabel1,const QString &szLabel2 = KviQString::empty,const QString &szLabel3 = KviQString::empty,const QString &szLabel4 = KviQString::empty) + : Q3ListViewItem(pParent,pAfter,szLabel1,szLabel2,szLabel3,szLabel4) {}; +public: + // Shadow the internal Qt methods + KviTalListViewItem * firstChild() const { return (KviTalListViewItem *)Q3ListViewItem::firstChild(); }; + KviTalListViewItem * nextSibling() const { return (KviTalListViewItem *)Q3ListViewItem::nextSibling(); }; + KviTalListViewItem * parent() const { return (KviTalListViewItem *)Q3ListViewItem::parent(); }; + KviTalListView * listView() const { return (KviTalListView *)Q3ListViewItem::listView(); }; + KviTalListViewItem * itemAbove() { return (KviTalListViewItem *)Q3ListViewItem::itemAbove(); }; + KviTalListViewItem * itemBelow() { return (KviTalListViewItem *)Q3ListViewItem::itemBelow(); }; +}; + +struct KviTalCheckListItemPrivate; + +class KVILIB_API KviTalCheckListItem : public KviTalListViewItem +{ +public: + enum Type { RadioButton, + CheckBox, + Controller, + RadioButtonController=Controller, + CheckBoxController }; + + enum ToggleState { Off, NoChange, On }; + + KviTalCheckListItem(KviTalCheckListItem *parent, const QString &text, + Type = RadioButtonController); + KviTalCheckListItem(KviTalCheckListItem *parent, KviTalListViewItem *after, + const QString &text, Type = RadioButtonController); + KviTalCheckListItem(KviTalListViewItem *parent, const QString &text, + Type = RadioButtonController); + KviTalCheckListItem(KviTalListViewItem *parent, KviTalListViewItem *after, + const QString &text, Type = RadioButtonController); + KviTalCheckListItem(KviTalListView *parent, const QString &text, + Type = RadioButtonController); + KviTalCheckListItem(KviTalListView *parent, KviTalListViewItem *after, + const QString &text, Type = RadioButtonController); + KviTalCheckListItem(KviTalListViewItem *parent, const QString &text, + const QPixmap &); + KviTalCheckListItem(KviTalListView *parent, const QString &text, + const QPixmap &); + ~KviTalCheckListItem(); + + void paintCell(QPainter *, const QColorGroup & cg, + int column, int width, int alignment); + virtual void paintFocus(QPainter *, const QColorGroup &cg, + const QRect & r); + int width(const QFontMetrics&, const KviTalListView*, int column) const; + void setup(); + + virtual void setOn(bool); + bool isOn() const { return on; } + Type type() const { return myType; } + QString text() const { return KviTalListViewItem::text(0); } + QString text(int n) const { return KviTalListViewItem::text(n); } + + void setTristate(bool); + bool isTristate() const; + ToggleState state() const; + void setState(ToggleState s); + + int rtti() const; + enum { RTTI = 1 }; + +protected: + void activate(); + void turnOffChild(); + virtual void stateChange(bool); + +private: + void init(); + ToggleState internalState() const; + void setStoredState(ToggleState newState, KviTalCheckListItem *key); + ToggleState storedState(KviTalCheckListItem *key) const; + void stateChange(ToggleState s); + void restoreState(KviTalCheckListItem *key, int depth = 0); + void updateController(bool update = true , bool store = false); + void updateStoredState(KviTalCheckListItem *key); + void setState(ToggleState s, bool update, bool store); + void setCurrentState(ToggleState s); + + Type myType; + bool on; + KviTalCheckListItemPrivate *d; +}; + +#define KviTalListViewItemIterator Q3ListViewItemIterator + + +#endif // _KVI_TAL_LISTVIEW_QT4_H_ diff --git a/src/kvilib/tal/kvi_tal_mainwindow.cpp b/src/kvilib/tal/kvi_tal_mainwindow.cpp new file mode 100644 index 00000000..c2e52b2d --- /dev/null +++ b/src/kvilib/tal/kvi_tal_mainwindow.cpp @@ -0,0 +1,69 @@ +// +// File : kvi_tal_mainwindow.coo +// Creation date : Sun Aug 12 2001 04:40:24 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#define __KVILIB__ + + +#include "kvi_tal_mainwindow.h" + +#ifdef COMPILE_KDE_SUPPORT + + KviTalMainWindow::KviTalMainWindow(QWidget * par,const char * nam) + : KMainWindow(par,nam) + { + } + + #include "kvi_tal_mainwindow_kde.moc" + +#else + + #ifdef COMPILE_USE_QT4 + KviTalMainWindow::KviTalMainWindow(QWidget * par,const char * nam) + : QMainWindow(par,nam) + { + } + + bool KviTalMainWindow::usesBigPixmaps() + { + return (iconSize().width() > 40); + } + + void KviTalMainWindow::setUsesBigPixmaps(bool b) + { + if(b)setIconSize(QSize(48,48)); + else setIconSize(QSize(24,24)); + } + #include "kvi_tal_mainwindow_qt4.moc" + #else + KviTalMainWindow::KviTalMainWindow(QWidget * par,const char * nam) + : QMainWindow(par,nam) + { + } + #include "kvi_tal_mainwindow_qt3.moc" + #endif + +#endif + +KviTalMainWindow::~KviTalMainWindow() +{ +} + diff --git a/src/kvilib/tal/kvi_tal_mainwindow.h b/src/kvilib/tal/kvi_tal_mainwindow.h new file mode 100644 index 00000000..76a1a79c --- /dev/null +++ b/src/kvilib/tal/kvi_tal_mainwindow.h @@ -0,0 +1,38 @@ +#ifndef _KVI_TAL_MAINWINDOW_H_ +#define _KVI_TAL_MAINWINDOW_H_ + +// +// File : kvi_tal_mainwindow.h +// Creation date : Sun Aug 12 2001 04:41:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include "kvi_settings.h" + +#ifdef COMPILE_KDE_SUPPORT + #include "kvi_tal_mainwindow_kde.h" +#else + #ifdef COMPILE_USE_QT4 + #include "kvi_tal_mainwindow_qt4.h" + #else + #include "kvi_tal_mainwindow_qt3.h" + #endif +#endif + +#endif // _KVI_TAL_MAINWINDOW_H_ diff --git a/src/kvilib/tal/kvi_tal_mainwindow_kde.h b/src/kvilib/tal/kvi_tal_mainwindow_kde.h new file mode 100644 index 00000000..9f38aede --- /dev/null +++ b/src/kvilib/tal/kvi_tal_mainwindow_kde.h @@ -0,0 +1,36 @@ +#ifndef _KVI_TAL_MAINWINDOW_KDE_H_ +#define _KVI_TAL_MAINWINDOW_KDE_H_ + +// +// File : kvi_tal_mainwindow_kde.h +// Creation date : Sun Aug 12 2001 04:41:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include <kmainwindow.h> + +class KVILIB_API KviTalMainWindow : public KMainWindow +{ + Q_OBJECT +public: + KviTalMainWindow(QWidget * par,const char * nam); + ~KviTalMainWindow(); +}; + +#endif // _KVI_TAL_MAINWINDOW_KDE_H_ diff --git a/src/kvilib/tal/kvi_tal_mainwindow_qt3.h b/src/kvilib/tal/kvi_tal_mainwindow_qt3.h new file mode 100644 index 00000000..d328774f --- /dev/null +++ b/src/kvilib/tal/kvi_tal_mainwindow_qt3.h @@ -0,0 +1,36 @@ +#ifndef _KVI_TAL_MAINWINDOW_QT_H_ +#define _KVI_TAL_MAINWINDOW_QT_H_ + +// +// File : kvi_tal_mainwindow_qt.h +// Creation date : Sun Aug 12 2001 04:43:58 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include <qmainwindow.h> + +class KVILIB_API KviTalMainWindow : public QMainWindow +{ + Q_OBJECT +public: + KviTalMainWindow(QWidget * par,const char * nam); + ~KviTalMainWindow(); +}; + +#endif // _KVI_TAL_MAINWINDOW_QT_H_ diff --git a/src/kvilib/tal/kvi_tal_mainwindow_qt4.h b/src/kvilib/tal/kvi_tal_mainwindow_qt4.h new file mode 100644 index 00000000..b6c2c1be --- /dev/null +++ b/src/kvilib/tal/kvi_tal_mainwindow_qt4.h @@ -0,0 +1,39 @@ +#ifndef _KVI_TAL_MAINWINDOW_QT_H_ +#define _KVI_TAL_MAINWINDOW_QT_H_ + +// +// File : kvi_tal_mainwindow_qt.h +// Creation date : Sun Aug 12 2001 04:43:58 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include <qmainwindow.h> + +class KVILIB_API KviTalMainWindow : public QMainWindow +{ + Q_OBJECT +public: + KviTalMainWindow(QWidget * par,const char * nam); + ~KviTalMainWindow(); +public: + bool usesBigPixmaps(); + void setUsesBigPixmaps(bool b); +}; + +#endif // _KVI_TAL_MAINWINDOW_QT_H_ diff --git a/src/kvilib/tal/kvi_tal_menubar.cpp b/src/kvilib/tal/kvi_tal_menubar.cpp new file mode 100644 index 00000000..0fbb28be --- /dev/null +++ b/src/kvilib/tal/kvi_tal_menubar.cpp @@ -0,0 +1,58 @@ +// +// File : kvi_tal_menubar.cpp +// Creation date : Sun Aug 12 06:35:18 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#define __KVILIB__ + + +#include "kvi_tal_menubar.h" + +#ifdef COMPILE_KDE_SUPPORT + + KviTalMenuBar::KviTalMenuBar(QWidget * par,const char * nam) + : KMenuBar(par,nam) + { + } + + KviTalMenuBar::~KviTalMenuBar() + { + } + + #include "kvi_tal_menubar_kde.moc" + +#else + + KviTalMenuBar::KviTalMenuBar(QWidget * par,const char * nam) +#ifdef COMPILE_USE_QT4 + : QMenuBar(par) +#else + : QMenuBar(par,nam) +#endif + { + } + + KviTalMenuBar::~KviTalMenuBar() + { + } + + #include "kvi_tal_menubar_qt.moc" + +#endif diff --git a/src/kvilib/tal/kvi_tal_menubar.h b/src/kvilib/tal/kvi_tal_menubar.h new file mode 100644 index 00000000..08016bb7 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_menubar.h @@ -0,0 +1,33 @@ +#ifndef _KVI_TAL_MENUBAR_H_ +#define _KVI_TAL_MENUBAR_H_ +// +// File : kvi_tal_menubar.h +// Creation date : Sun Aug 12 06:35:15 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include "kvi_settings.h" + +#ifdef COMPILE_KDE_SUPPORT + #include "kvi_tal_menubar_kde.h" +#else + #include "kvi_tal_menubar_qt.h" +#endif + +#endif //_KVI_TAL_MENUBAR_H_ diff --git a/src/kvilib/tal/kvi_tal_menubar_kde.h b/src/kvilib/tal/kvi_tal_menubar_kde.h new file mode 100644 index 00000000..e345d221 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_menubar_kde.h @@ -0,0 +1,35 @@ +#ifndef _KVI_TAL_MENUBAR_KDE_H_ +#define _KVI_TAL_MENUBAR_KDE_H_ +// +// File : kvi_tal_menubar_kde.h +// Creation date : Sun Aug 12 06:35:22 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include <kmenubar.h> + +class KVILIB_API KviTalMenuBar : public KMenuBar +{ + Q_OBJECT +public: + KviTalMenuBar(QWidget * par,const char * nam); + ~KviTalMenuBar(); +}; + +#endif //_KVI_TAL_MENUBAR_KDE_H_ diff --git a/src/kvilib/tal/kvi_tal_menubar_qt.h b/src/kvilib/tal/kvi_tal_menubar_qt.h new file mode 100644 index 00000000..c42dab7f --- /dev/null +++ b/src/kvilib/tal/kvi_tal_menubar_qt.h @@ -0,0 +1,35 @@ +#ifndef _KVI_TAL_MENUBAR_QT_H_ +#define _KVI_TAL_MENUBAR_QT_H_ +// +// File : kvi_tal_menubar_qt.h +// Creation date : Sun Aug 12 06:35:24 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include <qmenubar.h> + +class KVILIB_API KviTalMenuBar : public QMenuBar +{ + Q_OBJECT +public: + KviTalMenuBar(QWidget * par,const char * nam); + ~KviTalMenuBar(); +}; + +#endif //_KVI_TAL_MENUBAR_QT_H_ diff --git a/src/kvilib/tal/kvi_tal_popupmenu.cpp b/src/kvilib/tal/kvi_tal_popupmenu.cpp new file mode 100644 index 00000000..ad3c8463 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_popupmenu.cpp @@ -0,0 +1,33 @@ +//============================================================================= +// +// File : kvi_tal_popupmenu.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_popupmenu.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_popupmenu_qt4.moc" +#else + #include "kvi_tal_popupmenu_qt3.moc" +#endif + diff --git a/src/kvilib/tal/kvi_tal_popupmenu.h b/src/kvilib/tal/kvi_tal_popupmenu.h new file mode 100644 index 00000000..5035f031 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_popupmenu.h @@ -0,0 +1,36 @@ +#ifndef _KVI_TAL_POPUPMENU_H_ +#define _KVI_TAL_POPUPMENU_H_ + +//============================================================================= +// +// File : kvi_tal_popupmenu.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_popupmenu_qt4.h" +#else + #include "kvi_tal_popupmenu_qt3.h" +#endif + +#endif // _KVI_TAL_POPUPMENU_H_ diff --git a/src/kvilib/tal/kvi_tal_popupmenu_qt3.h b/src/kvilib/tal/kvi_tal_popupmenu_qt3.h new file mode 100644 index 00000000..3340945b --- /dev/null +++ b/src/kvilib/tal/kvi_tal_popupmenu_qt3.h @@ -0,0 +1,42 @@ +#ifndef _KVI_TAL_POPUPMENU_QT3_H_ +#define _KVI_TAL_POPUPMENU_QT3_H_ + +//============================================================================= +// +// File : kvi_tal_popupmenu.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" +#include "kvi_qstring.h" + +#include <qpopupmenu.h> + +class KVILIB_API KviTalPopupMenu : public QPopupMenu +{ + Q_OBJECT +public: + KviTalPopupMenu(QWidget * pParent=0,const QString &szName = KviQString::empty) + : QPopupMenu(pParent,KviQString::toUtf8(szName).data()) {}; + virtual ~KviTalPopupMenu() {}; +}; + +#endif // _KVI_TAL_POPUPMENU_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_popupmenu_qt4.h b/src/kvilib/tal/kvi_tal_popupmenu_qt4.h new file mode 100644 index 00000000..58da15ef --- /dev/null +++ b/src/kvilib/tal/kvi_tal_popupmenu_qt4.h @@ -0,0 +1,89 @@ +#ifndef _KVI_TAL_POPUPMENU_QT4_H_ +#define _KVI_TAL_POPUPMENU_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_popupmenu_qt3.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" +#include "kvi_qstring.h" + +#include <q3popupmenu.h> +#include <qwidgetaction.h> + +class KVILIB_API KviTalPopupMenu : public Q3PopupMenu +{ + Q_OBJECT +public: + KviTalPopupMenu(QWidget * pParent=0,const QString &szName = KviQString::empty) + : Q3PopupMenu(pParent) + { + setName(szName); + }; + virtual ~KviTalPopupMenu() {}; + + int insertItem(const QString &szText) + { + return Q3PopupMenu::insertItem(szText); + } + int insertItem(const QPixmap &pix,const QString &szText) + { + return Q3PopupMenu::insertItem(QIcon(pix),szText,-1,-1); + } + int insertItem(const QString &szText,int id) + { + return Q3PopupMenu::insertItem(szText,id); + } + int insertItem(const QPixmap &pix,const QString &szText,int id) + { + return Q3PopupMenu::insertItem(QIcon(pix),szText,id,-1); + } + int insertItem(const QString &szText,const QObject * pReceiver,const char * szSlot) + { + return Q3PopupMenu::insertItem(szText,pReceiver,szSlot); + } + int insertItem(const QPixmap &pix,const QString &szText,const QObject * pReceiver,const char * szSlot) + { + return Q3PopupMenu::insertItem(QIcon(pix),szText,pReceiver,szSlot); + } + int insertItem(const QPixmap &pix,const QString &szText,QMenu *pMenu) + { + return Q3PopupMenu::insertItem(QIcon(pix),szText,pMenu,-1,-1); + } + int insertItem(const QString &szText,QMenu *pMenu) + { + return Q3PopupMenu::insertItem(szText,pMenu,-1,-1); + } + int insertItem(QWidget * pWidget) + { + // needs Qt 4.2 + QWidgetAction * pAct = new QWidgetAction(this); + pAct->setDefaultWidget(pWidget); + addAction(pAct); + return 0; + } + + +}; + +#endif // _KVI_TAL_POPUPMENU_QT4_H_ diff --git a/src/kvilib/tal/kvi_tal_scrollview.cpp b/src/kvilib/tal/kvi_tal_scrollview.cpp new file mode 100644 index 00000000..7e3e5eba --- /dev/null +++ b/src/kvilib/tal/kvi_tal_scrollview.cpp @@ -0,0 +1,33 @@ +//============================================================================= +// +// File : kvi_tal_scrollview.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_scrollview.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_scrollview_qt4.moc" +#else + #include "kvi_tal_scrollview_qt3.moc" +#endif + diff --git a/src/kvilib/tal/kvi_tal_scrollview.h b/src/kvilib/tal/kvi_tal_scrollview.h new file mode 100644 index 00000000..ff27acf4 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_scrollview.h @@ -0,0 +1,36 @@ +#ifndef _KVI_TAL_SCROLLVIEW_H_ +#define _KVI_TAL_SCROLLVIEW_H_ + +//============================================================================= +// +// File : kvi_tal_scrollview.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_scrollview_qt4.h" +#else + #include "kvi_tal_scrollview_qt3.h" +#endif + +#endif // _KVI_TAL_SCROLLVIEW_H_ diff --git a/src/kvilib/tal/kvi_tal_scrollview_qt3.h b/src/kvilib/tal/kvi_tal_scrollview_qt3.h new file mode 100644 index 00000000..da6141e1 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_scrollview_qt3.h @@ -0,0 +1,41 @@ +#ifndef _KVI_TAL_SCROLLVIEW_QT3_H_ +#define _KVI_TAL_SCROLLVIEW_QT3_H_ + +//============================================================================= +// +// File : kvi_tal_scrollview_qt3.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include <qscrollview.h> + +class KVILIB_API KviTalScrollView : public QScrollView +{ + Q_OBJECT +public: + KviTalScrollView(QWidget * pParent) + : QScrollView(pParent) {}; + virtual ~KviTalScrollView() {}; +}; + +#endif // _KVI_TAL_SCROLLVIEW_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_scrollview_qt4.h b/src/kvilib/tal/kvi_tal_scrollview_qt4.h new file mode 100644 index 00000000..c82f5723 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_scrollview_qt4.h @@ -0,0 +1,41 @@ +#ifndef _KVI_TAL_SCROLLVIEW_QT4_H_ +#define _KVI_TAL_SCROLLVIEW_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_scrollview_qt4.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include <q3scrollview.h> + +class KVILIB_API KviTalScrollView : public Q3ScrollView +{ + Q_OBJECT +public: + KviTalScrollView(QWidget * pParent) + : Q3ScrollView(pParent) {}; + virtual ~KviTalScrollView() {}; +}; + +#endif // _KVI_TAL_SCROLLVIEW_QT4_H_ diff --git a/src/kvilib/tal/kvi_tal_tabdialog.cpp b/src/kvilib/tal/kvi_tal_tabdialog.cpp new file mode 100644 index 00000000..81bd5b39 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_tabdialog.cpp @@ -0,0 +1,34 @@ +//============================================================================= +// +// File : kvi_tal_tabdialog.cpp +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_tabdialog.h" + + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_tabdialog_qt4.moc" +#else + #include "kvi_tal_tabdialog_qt3.moc" +#endif + diff --git a/src/kvilib/tal/kvi_tal_tabdialog.h b/src/kvilib/tal/kvi_tal_tabdialog.h new file mode 100644 index 00000000..46e09843 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_tabdialog.h @@ -0,0 +1,36 @@ +#ifndef _KVI_TAL_TABDIALOG_H_ +#define _KVI_TAL_TABDIALOG_H_ + +//============================================================================= +// +// File : kvi_tal_tabdialog.h +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_tabdialog_qt4.h" +#else + #include "kvi_tal_tabdialog_qt3.h" +#endif + +#endif // _KVI_TAL_TABDIALOG_H_ diff --git a/src/kvilib/tal/kvi_tal_tabdialog_qt3.h b/src/kvilib/tal/kvi_tal_tabdialog_qt3.h new file mode 100644 index 00000000..061053a3 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_tabdialog_qt3.h @@ -0,0 +1,39 @@ +#ifndef _KVI_TAL_TABDIALOG_QT3_H_ +#define _KVI_TAL_TABDIALOG_QT3_H_ + +//============================================================================= +// +// File : kvi_tal_tabdialog_qt3.h +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include <qtabdialog.h> + +class KVILIB_API KviTalTabDialog : public QTabDialog +{ + Q_OBJECT +public: + KviTalTabDialog(QWidget * pParent = 0,const char * name = 0,bool bModal = false) + : QTabDialog(pParent,name,bModal) {}; + ~KviTalTabDialog() {}; +}; + +#endif // _KVI_TAL_TABDIALOG_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_tabdialog_qt4.h b/src/kvilib/tal/kvi_tal_tabdialog_qt4.h new file mode 100644 index 00000000..c9e3eb0b --- /dev/null +++ b/src/kvilib/tal/kvi_tal_tabdialog_qt4.h @@ -0,0 +1,39 @@ +#ifndef _KVI_TAL_TABDIALOG_QT4_H_ +#define _KVI_TAL_TABDIALOG_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_tabdialog_qt4.h +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include <q3tabdialog.h> + +class KVILIB_API KviTalTabDialog : public Q3TabDialog +{ + Q_OBJECT +public: + KviTalTabDialog(QWidget * pParent = 0,const char * name = 0,bool bModal = false) + : Q3TabDialog(pParent,name,bModal) {}; + ~KviTalTabDialog() {}; +}; + +#endif // _KVI_TAL_TABDIALOG_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_textedit.cpp b/src/kvilib/tal/kvi_tal_textedit.cpp new file mode 100644 index 00000000..686c8cba --- /dev/null +++ b/src/kvilib/tal/kvi_tal_textedit.cpp @@ -0,0 +1,34 @@ +//============================================================================= +// +// File : kvi_tal_textedit.cpp +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_textedit.h" + + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_textedit_qt4.moc" +#else + #include "kvi_tal_textedit_qt3.moc" +#endif + diff --git a/src/kvilib/tal/kvi_tal_textedit.h b/src/kvilib/tal/kvi_tal_textedit.h new file mode 100644 index 00000000..fb7381ae --- /dev/null +++ b/src/kvilib/tal/kvi_tal_textedit.h @@ -0,0 +1,36 @@ +#ifndef _KVI_TAL_TEXTEDIT_H_ +#define _KVI_TAL_TEXTEDIT_H_ + +//============================================================================= +// +// File : kvi_tal_textedit.h +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_textedit_qt4.h" +#else + #include "kvi_tal_textedit_qt3.h" +#endif + +#endif // _KVI_TAL_TEXTEDIT_H_ diff --git a/src/kvilib/tal/kvi_tal_textedit_qt3.h b/src/kvilib/tal/kvi_tal_textedit_qt3.h new file mode 100644 index 00000000..b698f483 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_textedit_qt3.h @@ -0,0 +1,39 @@ +#ifndef _KVI_TAL_TEXTEDIT_QT3_H_ +#define _KVI_TAL_TEXTEDIT_QT3_H_ + +//============================================================================= +// +// File : kvi_tal_textedit_qt3.h +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include <qtextedit.h> + +class KVILIB_API KviTalTextEdit : public QTextEdit +{ + Q_OBJECT +public: + KviTalTextEdit(QWidget * pParent = 0,const char * name = 0) + : QTextEdit(pParent,name) {}; + ~KviTalTextEdit() {}; +}; + +#endif // _KVI_TAL_TEXTEDIT_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_textedit_qt4.h b/src/kvilib/tal/kvi_tal_textedit_qt4.h new file mode 100644 index 00000000..a3403d7c --- /dev/null +++ b/src/kvilib/tal/kvi_tal_textedit_qt4.h @@ -0,0 +1,39 @@ +#ifndef _KVI_TAL_TEXTEDIT_QT4_H_ +#define _KVI_TAL_TEXTEDIT_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_textedit_qt4.h +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include <q3textedit.h> + +class KVILIB_API KviTalTextEdit : public Q3TextEdit +{ + Q_OBJECT +public: + KviTalTextEdit(QWidget * pParent = 0,const char * name = 0) + : Q3TextEdit(pParent,name) {}; + ~KviTalTextEdit() {}; +}; + +#endif // _KVI_TAL_TEXTEDIT_QT4_H_ diff --git a/src/kvilib/tal/kvi_tal_toolbar.cpp b/src/kvilib/tal/kvi_tal_toolbar.cpp new file mode 100644 index 00000000..f54dc973 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_toolbar.cpp @@ -0,0 +1,107 @@ +// +// File : kvi_tal_toolbar.cpp +// Creation date : Mon Aug 13 05:05:45 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#define __KVILIB__ + + +#include "kvi_tal_toolbar.h" + +#ifdef COMPILE_KDE_SUPPORT + + KviTalToolBar::KviTalToolBar(const QString &label,QMainWindow *w,QT_TOOLBARDOCK_TYPE dock,bool bNewLine,const char * nam) + : KToolBar(w,dock,bNewLine,nam) + { + setLabel(label); + } + + KviTalToolBar::~KviTalToolBar() + { + } + + #include "kvi_tal_toolbar_kde.moc" + +#else + + #ifdef COMPILE_USE_QT4 + + KviTalToolBar::KviTalToolBar(const QString &label,QMainWindow *w,QT_TOOLBARDOCK_TYPE dock,bool bNewLine,const char * nam) + //: Q3ToolBar(label,w,dock,bNewLine,nam) + : QToolBar(label,w) + { + //setFrameStyle(QFrame::NoFrame); + setObjectName(nam); + if(!layout()) + this->setLayout(new QBoxLayout(QBoxLayout::LeftToRight)); + w->addToolBar(dock,this); + } + KviTalToolBar::KviTalToolBar(QMainWindow *w,const char * name) + : QToolBar(w) + { + //setFrameStyle(QFrame::NoFrame); + setObjectName(name); + if(!layout()) + this->setLayout(new QBoxLayout(QBoxLayout::LeftToRight)); + w->addToolBar(this); + } + + QBoxLayout * KviTalToolBar::boxLayout() + { + return (QBoxLayout*)this->layout(); + } + + void KviTalToolBar::setBoxLayout(QBoxLayout * l) + { + this->setLayout(l); + } + + bool KviTalToolBar::usesBigPixmaps() + { + return (iconSize().width() > 40); + } + + void KviTalToolBar::setUsesBigPixmaps(bool b) + { + if(b)setIconSize(QSize(48,48)); + else setIconSize(QSize(22,22)); + } + + #include "kvi_tal_toolbar_qt4.moc" + + #else + KviTalToolBar::KviTalToolBar(const QString &label,QMainWindow *w,QT_TOOLBARDOCK_TYPE dock,bool bNewLine,const char * nam) + : QToolBar(label,w,dock,bNewLine,nam) + { + } + KviTalToolBar::KviTalToolBar(QMainWindow *w,const char * name) + : QToolBar(w,name) + { + } + + #include "kvi_tal_toolbar_qt3.moc" + #endif + + KviTalToolBar::~KviTalToolBar() + { + } + + +#endif diff --git a/src/kvilib/tal/kvi_tal_toolbar.h b/src/kvilib/tal/kvi_tal_toolbar.h new file mode 100644 index 00000000..c5c9d5cc --- /dev/null +++ b/src/kvilib/tal/kvi_tal_toolbar.h @@ -0,0 +1,37 @@ +#ifndef _KVI_TAL_TOOLBAR_H_ +#define _KVI_TAL_TOOLBAR_H_ +// +// File : kvi_tal_toolbar.h +// Creation date : Mon Aug 13 05:05:44 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include "kvi_settings.h" + +#ifdef COMPILE_KDE_SUPPORT + #include "kvi_tal_toolbar_kde.h" +#else + #ifdef COMPILE_USE_QT4 + #include "kvi_tal_toolbar_qt4.h" + #else + #include "kvi_tal_toolbar_qt3.h" + #endif +#endif + +#endif //_KVI_TAL_TOOLBAR_H_ diff --git a/src/kvilib/tal/kvi_tal_toolbar_kde.h b/src/kvilib/tal/kvi_tal_toolbar_kde.h new file mode 100644 index 00000000..f6415f26 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_toolbar_kde.h @@ -0,0 +1,37 @@ +#ifndef _KVI_TAL_TOOLBAR_KDE_H_ +#define _KVI_TAL_TOOLBAR_KDE_H_ +// +// File : kvi_tal_toolbar_kde.h +// Creation date : Mon Aug 13 05:05:52 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include <ktoolbar.h> + +#include "kvi_tal_toolbardocktype.h" + +class KVILIB_API KviTalToolBar : public KToolBar +{ + Q_OBJECT +public: + KviTalToolBar(const QString &label,QMainWindow *w,QT_TOOLBARDOCK_TYPE dock = QT_DOCK_TOP,bool bNewLine = false,const char * nam = 0); + ~KviTalToolBar(); +}; + +#endif //_KVI_TAL_TOOLBAR_KDE_H_ diff --git a/src/kvilib/tal/kvi_tal_toolbar_qt3.h b/src/kvilib/tal/kvi_tal_toolbar_qt3.h new file mode 100644 index 00000000..a9b15b52 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_toolbar_qt3.h @@ -0,0 +1,39 @@ +#ifndef _KVI_TAL_TOOLBAR_QT_H_ +#define _KVI_TAL_TOOLBAR_QT_H_ +// +// File : kvi_tal_toolbar_qt.h +// Creation date : Mon Aug 13 05:05:50 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include <qtoolbar.h> +#include <qmainwindow.h> + +#include "kvi_tal_toolbardocktype.h" + +class KVILIB_API KviTalToolBar : public QToolBar +{ + Q_OBJECT +public: + KviTalToolBar(const QString &label,QMainWindow *w,QT_TOOLBARDOCK_TYPE dock = QT_DOCK_TOP,bool bNewLine = false,const char * nam = 0); + KviTalToolBar(QMainWindow *w,const char * name=0); + ~KviTalToolBar(); +}; + +#endif //_KVI_TAL_TOOLBAR_QT_H_ diff --git a/src/kvilib/tal/kvi_tal_toolbar_qt4.h b/src/kvilib/tal/kvi_tal_toolbar_qt4.h new file mode 100644 index 00000000..753d5a5c --- /dev/null +++ b/src/kvilib/tal/kvi_tal_toolbar_qt4.h @@ -0,0 +1,47 @@ +#ifndef _KVI_TAL_TOOLBAR_QT4_H_ +#define _KVI_TAL_TOOLBAR_QT4_H_ +// +// File : kvi_tal_toolbar_qt4.h +// Creation date : Wed Feb 1 2007 04:11:11 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include "kvi_settings.h" +#include "kvi_tal_toolbardocktype.h" + +#include <QToolBar> +#include <QMainWindow> +#include <QBoxLayout> + + +class KVILIB_API KviTalToolBar : public QToolBar +{ + Q_OBJECT +public: + KviTalToolBar(const QString &label,QMainWindow *w,QT_TOOLBARDOCK_TYPE dock = QT_DOCK_TOP,bool bNewLine = false,const char * nam = 0); + KviTalToolBar(QMainWindow *w,const char * name=0); + ~KviTalToolBar(); +public: + QBoxLayout * boxLayout(); + void setBoxLayout(QBoxLayout *l); + bool usesBigPixmaps(); + void setUsesBigPixmaps(bool b); +}; + +#endif //_KVI_TAL_TOOLBAR_QT_H_ diff --git a/src/kvilib/tal/kvi_tal_toolbardocktype.h b/src/kvilib/tal/kvi_tal_toolbardocktype.h new file mode 100644 index 00000000..a7c9697a --- /dev/null +++ b/src/kvilib/tal/kvi_tal_toolbardocktype.h @@ -0,0 +1,71 @@ +#ifndef _KVI_TAL_TOOLBARDOCKTYPE_H_ +#define _KVI_TAL_TOOLBARDOCKTYPE_H_ +// +// File : kvi_tal_toolbardocktype.h +// Creation date : Tue Sep 17 02:11:28 2002 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include "kvi_settings.h" +//#define COMPILE_USE_QT4 +#ifdef COMPILE_USE_QT4 +/* + #define QT_TOOLBARDOCK_TYPE Qt::Dock + #define QT_DOCK_TOP Qt::DockTop + #define QT_DOCK_LEFT Qt::DockLeft + #define QT_DOCK_RIGHT Qt::DockRight + #define QT_DOCK_BOTTOM Qt::DockBottom + #define QT_DOCK_MINIMIZED Qt::DockMinimized + #define QT_DOCK_TORNOFF Qt::DockTornOff + #define QT_DOCK_UNMANAGED Qt::DockUnmanaged +*/ + // We will need these when we'll use the real QToolBar in Qt 4.x + #define QT_TOOLBARDOCK_TYPE Qt::ToolBarArea + #define QT_DOCK_TOP Qt::TopToolBarArea + #define QT_DOCK_LEFT Qt::LeftToolBarArea + #define QT_DOCK_RIGHT Qt::RightToolBarArea + #define QT_DOCK_BOTTOM Qt::BottomToolBarArea + // THESE ARE UNSUPPORTED UNDER QT4! + #define QT_DOCK_MINIMIZED Qt::TopToolBarArea + #define QT_DOCK_TORNOFF Qt::TopToolBarArea + #define QT_DOCK_UNMANAGED Qt::TopToolBarArea + +#else + #if QT_VERSION >= 300 + #define QT_TOOLBARDOCK_TYPE Qt::Dock + #define QT_DOCK_TOP Qt::DockTop + #define QT_DOCK_LEFT Qt::DockLeft + #define QT_DOCK_RIGHT Qt::DockRight + #define QT_DOCK_BOTTOM Qt::DockBottom + #define QT_DOCK_MINIMIZED Qt::DockMinimized + #define QT_DOCK_TORNOFF Qt::DockTornOff + #define QT_DOCK_UNMANAGED Qt::DockUnmanaged + #else + #define QT_TOOLBARDOCK_TYPE QMainWindow::ToolBarDock + #define QT_DOCK_TOP QMainWindow::Top + #define QT_DOCK_LEFT QMainWindow::Left + #define QT_DOCK_RIGHT QMainWindow::Right + #define QT_DOCK_BOTTOM QMainWindow::Bottom + #define QT_DOCK_MINIMIZED QMainWindow::Minimized + #define QT_DOCK_TORNOFF QMainWindow::TornOff + #define QT_DOCK_UNMANAGED QMainWindow::Unmanaged + #endif +#endif + +#endif //_KVI_TAL_TOOLBARDOCKTYPE_H_ diff --git a/src/kvilib/tal/kvi_tal_tooltip.cpp b/src/kvilib/tal/kvi_tal_tooltip.cpp new file mode 100644 index 00000000..3bd384d2 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_tooltip.cpp @@ -0,0 +1,125 @@ +//============================================================================= +// +// File : kvi_tal_tooltip.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_tooltip.h" + +#include <qevent.h> + +KviTalToolTipHelper::KviTalToolTipHelper(KviTalToolTip * pToolTip,QWidget * pWidget) +: QObject(pWidget) +{ +#ifdef COMPILE_USE_QT4 + m_pToolTip = pToolTip; + pWidget->installEventFilter(this); +#endif +} + +KviTalToolTipHelper::~KviTalToolTipHelper() +{ +#ifdef COMPILE_USE_QT4 + if(m_pToolTip) + { + m_pToolTip->helperDying(); + delete m_pToolTip; + } +#endif +} + +void KviTalToolTipHelper::toolTipDying() +{ +#ifdef COMPILE_USE_QT4 + m_pToolTip = 0; +#endif +} + +bool KviTalToolTipHelper::eventFilter(QObject * pObject,QEvent * pEvent) +{ +#ifdef COMPILE_USE_QT4 + if((pEvent->type() == QEvent::ToolTip) && m_pToolTip) + { + debug("TOOL TIP EVENT WITH POSITION %d,%d",((QHelpEvent *)pEvent)->pos().x(),((QHelpEvent *)pEvent)->pos().y()); + m_pToolTip->maybeTip(((QHelpEvent *)pEvent)->pos()); + return true; + } +#endif + return false; +} + + +KviTalToolTip::KviTalToolTip(QWidget * pParent) +#ifndef COMPILE_USE_QT4 +: QToolTip(pParent) +#endif +{ +#ifdef COMPILE_USE_QT4 + m_pHelper = new KviTalToolTipHelper(this,pParent); + m_pParent = pParent; +#endif +} + +KviTalToolTip::~KviTalToolTip() +{ +#ifdef COMPILE_USE_QT4 + if(m_pHelper) + { + m_pHelper->toolTipDying(); + delete m_pHelper; + } +#endif +} + +#ifdef COMPILE_USE_QT4 +void KviTalToolTip::helperDying() +{ + m_pHelper = 0; +} +#endif + +#ifdef COMPILE_USE_QT4 +void KviTalToolTip::add(QWidget * widget,const QString & text) +{ + QToolTip::add(widget,text); +} + +void KviTalToolTip::remove(QWidget * widget) +{ + QToolTip::remove(widget); +} + +void KviTalToolTip::tip(const QRect & rect,const QString & text) +{ + debug("TOOL TIP AT %d,%d",rect.topLeft().x(),rect.topLeft().y()); + QToolTip::showText(m_pParent->mapToGlobal(rect.topLeft()),text); +} +#endif + +void KviTalToolTip::maybeTip(const QPoint & p) +{ + // does nothing here.. and in Qt 4.x will even fail to work +} + +#ifndef COMPILE_ON_WINDOWS + #include "kvi_tal_tooltip.moc" +#endif diff --git a/src/kvilib/tal/kvi_tal_tooltip.h b/src/kvilib/tal/kvi_tal_tooltip.h new file mode 100644 index 00000000..91811c3c --- /dev/null +++ b/src/kvilib/tal/kvi_tal_tooltip.h @@ -0,0 +1,79 @@ +#ifndef _KVI_TAL_TOOLTIP_H_ +#define _KVI_TAL_TOOLTIP_H_ + +//============================================================================= +// +// File : kvi_tal_tooltip.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include <qtooltip.h> +#include <qobject.h> + +class KviTalToolTip; + +// This is useful only with Qt4, but we put it here anyway +// to have both a consistent API and make moc happy +class KviTalToolTipHelper : public QObject +{ + friend class KviTalToolTip; + Q_OBJECT +public: + KviTalToolTipHelper(KviTalToolTip * pToolTip,QWidget * pWidget); + ~KviTalToolTipHelper(); +protected: + KviTalToolTip * m_pToolTip; +protected: + virtual bool eventFilter(QObject * pObject,QEvent * pEvent); + void toolTipDying(); +}; + + +class KVILIB_API KviTalToolTip +#ifndef COMPILE_USE_QT4 + : public QToolTip +#endif +{ + friend class KviTalToolTipHelper; +public: + KviTalToolTip(QWidget * pParent); + virtual ~KviTalToolTip(); +protected: +#ifdef COMPILE_USE_QT4 + KviTalToolTipHelper * m_pHelper; + QWidget * m_pParent; +#endif +public: +#ifdef COMPILE_USE_QT4 + static void add(QWidget * widget,const QString & text); + static void remove(QWidget * widget); + virtual void tip(const QRect & rect,const QString & text); +#endif +protected: + virtual void maybeTip(const QPoint & p); +#ifdef COMPILE_USE_QT4 + void helperDying(); +#endif +}; + +#endif // _KVI_TAL_TOOLTIP_H_ diff --git a/src/kvilib/tal/kvi_tal_vbox.cpp b/src/kvilib/tal/kvi_tal_vbox.cpp new file mode 100644 index 00000000..5ef67152 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_vbox.cpp @@ -0,0 +1,33 @@ +//============================================================================= +// +// File : kvi_tal_vbox.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_vbox.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_vbox_qt4.moc" +#else + #include "kvi_tal_vbox_qt3.moc" +#endif + diff --git a/src/kvilib/tal/kvi_tal_vbox.h b/src/kvilib/tal/kvi_tal_vbox.h new file mode 100644 index 00000000..a27df527 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_vbox.h @@ -0,0 +1,36 @@ +#ifndef _KVI_TAL_VBOX_H_ +#define _KVI_TAL_VBOX_H_ + +//============================================================================= +// +// File : kvi_tal_vbox.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_vbox_qt4.h" +#else + #include "kvi_tal_vbox_qt3.h" +#endif + +#endif // _KVI_TAL_VBOX_H_ diff --git a/src/kvilib/tal/kvi_tal_vbox_qt3.h b/src/kvilib/tal/kvi_tal_vbox_qt3.h new file mode 100644 index 00000000..440a2436 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_vbox_qt3.h @@ -0,0 +1,42 @@ +#ifndef _KVI_TAL_VBOX_QT3_H_ +#define _KVI_TAL_VBOX_QT3_H_ + +//============================================================================= +// +// File : kvi_tal_vbox_qt3.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include <qvbox.h> + +class KVILIB_API KviTalVBox : public QVBox +{ + Q_OBJECT +public: + KviTalVBox(QWidget * pParent) + : QVBox(pParent) {}; + virtual ~KviTalVBox() {}; +}; + + +#endif // _KVI_TAL_VBOX_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_vbox_qt4.h b/src/kvilib/tal/kvi_tal_vbox_qt4.h new file mode 100644 index 00000000..86de700d --- /dev/null +++ b/src/kvilib/tal/kvi_tal_vbox_qt4.h @@ -0,0 +1,42 @@ +#ifndef _KVI_TAL_VBOX_QT4_H_ +#define _KVI_TAL_VBOX_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_vbox_qt4.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include <q3vbox.h> + +class KVILIB_API KviTalVBox : public Q3VBox +{ + Q_OBJECT +public: + KviTalVBox(QWidget * pParent) + : Q3VBox(pParent) {}; + virtual ~KviTalVBox() {}; +}; + + +#endif // _KVI_TAL_VBOX_QT4_H_ diff --git a/src/kvilib/tal/kvi_tal_widgetstack.cpp b/src/kvilib/tal/kvi_tal_widgetstack.cpp new file mode 100644 index 00000000..1a99e3f9 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_widgetstack.cpp @@ -0,0 +1,33 @@ +//============================================================================= +// +// File : kvi_tal_widgetstack.cpp +// Creation date : Mon Jan 22 2007 11:17:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_widgetstack.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_widgetstack_qt4.moc" +#else + #include "kvi_tal_widgetstack_qt3.moc" +#endif + diff --git a/src/kvilib/tal/kvi_tal_widgetstack.h b/src/kvilib/tal/kvi_tal_widgetstack.h new file mode 100644 index 00000000..7c9133c8 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_widgetstack.h @@ -0,0 +1,36 @@ +#ifndef _KVI_TAL_WIDGETSTACK_H_ +#define _KVI_TAL_WIDGETSTACK_H_ + +//============================================================================= +// +// File : kvi_tal_widgetstack.h +// Creation date : Mon Jan 22 2007 11:17:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include "kvi_tal_widgetstack_qt4.h" +#else + #include "kvi_tal_widgetstack_qt3.h" +#endif + +#endif // _KVI_TAL_WIDGETSTACK_H_ diff --git a/src/kvilib/tal/kvi_tal_widgetstack_qt3.h b/src/kvilib/tal/kvi_tal_widgetstack_qt3.h new file mode 100644 index 00000000..cc0eb969 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_widgetstack_qt3.h @@ -0,0 +1,42 @@ +#ifndef _KVI_TAL_WIDGETSTACK_QT3_H_ +#define _KVI_TAL_WIDGETSTACK_QT3_H_ + +//============================================================================= +// +// File : kvi_tal_widgetstack_qt3.h +// Creation date : Mon Jan 22 2007 11:17:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include <qwidgetstack.h> + + +class KVILIB_API KviTalWidgetStack : public QWidgetStack +{ + Q_OBJECT +public: + KviTalWidgetStack(QWidget * pParent) + : QWidgetStack(pParent) {}; + virtual ~KviTalWidgetStack() {}; +}; + +#endif // _KVI_TAL_WIDGETSTACK_QT3_H_ diff --git a/src/kvilib/tal/kvi_tal_widgetstack_qt4.h b/src/kvilib/tal/kvi_tal_widgetstack_qt4.h new file mode 100644 index 00000000..6d0cc53f --- /dev/null +++ b/src/kvilib/tal/kvi_tal_widgetstack_qt4.h @@ -0,0 +1,42 @@ +#ifndef _KVI_TAL_WIDGETSTACK_QT4_H_ +#define _KVI_TAL_WIDGETSTACK_QT4_H_ + +//============================================================================= +// +// File : kvi_tal_widgetstack_qt4.h +// Creation date : Mon Jan 22 2007 11:17:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +//#include <qstackedwidget.h> +#include <q3widgetstack.h> + +class KVILIB_API KviTalWidgetStack : public Q3WidgetStack +{ + Q_OBJECT +public: + KviTalWidgetStack(QWidget * pParent) + : Q3WidgetStack(pParent) {}; + virtual ~KviTalWidgetStack() {}; +}; + +#endif // _KVI_TAL_WIDGETSTACK_QT4_H_ diff --git a/src/kvilib/tal/kvi_tal_windowstate.h b/src/kvilib/tal/kvi_tal_windowstate.h new file mode 100644 index 00000000..9510ba4a --- /dev/null +++ b/src/kvilib/tal/kvi_tal_windowstate.h @@ -0,0 +1,42 @@ +#ifndef _KVI_TAL_WINDOWSTATE_H_ +#define _KVI_TAL_WINDOWSTATE_H_ + +//============================================================================= +// +// File : kvi_tal_windowstate.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #define QT_WINDOWSTATE_FLAGS Qt::WindowState + + #define QT_WINDOWSTATE_MAXIMIZED Qt::WindowMaximized + #define QT_WINDOWSTATE_MINIMIZED Qt::WindowMinimized +#else + #define QT_WINDOWSTATE_FLAGS Qt::WidgetState + + #define QT_WINDOWSTATE_MAXIMIZED Qt::WState_Maximized + #define QT_WINDOWSTATE_MINIMIZED Qt::WState_Minimized +#endif + +#endif // _KVI_TAL_WINDOWSTATE_H_ diff --git a/src/kvilib/tal/kvi_tal_wizard.cpp b/src/kvilib/tal/kvi_tal_wizard.cpp new file mode 100644 index 00000000..6f5f39da --- /dev/null +++ b/src/kvilib/tal/kvi_tal_wizard.cpp @@ -0,0 +1,584 @@ +//============================================================================= +// +// File : kvi_tal_wizard.cpp +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define __KVILIB__ +#include "kvi_tal_wizard.h" +#include "kvi_tal_hbox.h" +#include "kvi_pointerlist.h" +#include "kvi_locale.h" + +#ifdef COMPILE_USE_QT4 + #include <QShowEvent> + #include <QLabel> + #include <QPushButton> + #include <QGridLayout> + #include <QFrame> + #include <QStackedWidget> + #include <QPalette> +#else + #include <qlabel.h> + #include <qpushbutton.h> + #include <qlayout.h> + #include <qevent.h> + #include <qframe.h> + #include <qwidgetstack.h> + #include <qpalette.h> +#endif + + +class KviTalWizardPageData +{ +public: + enum EnableFlags + { + EnableNext = 1, + EnableBack = 2, + EnableHelp = 4, + EnableCancel = 8, + EnableFinish = 16 + }; +public: + QWidget * pWidget; + QString szTitle; + bool bEnabled; + int iEnableFlags; + int iVisibleIndex; +}; + +class KviTalWizardPrivate +{ +public: + KviPointerList<KviTalWizardPageData> * pPageList; + int iEnabledPageCount; + KviTalWizardPageData * pCurrentPage; + QGridLayout * pLayout; + QLabel * pTitleLabel; + QLabel * pStepsLabel; + QPushButton * pBackButton; + QPushButton * pCancelButton; + QPushButton * pHelpButton; + QPushButton * pNextButton; + QWidget * pNextSpacer; + QPushButton * pFinishButton; + QWidget * pFinishSpacer; +#ifdef COMPILE_USE_QT4 + QStackedWidget * pWidgetStack; +#else + QWidgetStack * pWidgetStack; +#endif +public: + KviTalWizardPageData * findPage(QWidget * pWidget) + { + for(KviTalWizardPageData * pData = pPageList->first();pData;pData = pPageList->next()) + { + if(pData->pWidget == pWidget) + return pData; + } + return NULL; + } + + KviTalWizardPageData * findFirstEnabledPage() + { + KviTalWizardPageData * pData; + for(pData = pPageList->first();pData;pData = pPageList->next()) + { + if(pData->bEnabled) + return pData; + } + return NULL; + } + + KviTalWizardPageData * findLastEnabledPage() + { + KviTalWizardPageData * pData; + for(pData = pPageList->last();pData;pData = pPageList->prev()) + { + if(pData->bEnabled) + return pData; + } + return NULL; + } + + KviTalWizardPageData * findNextEnabledPage(QWidget * pReference) + { + if(!pReference) + return findFirstEnabledPage(); + KviTalWizardPageData * pData = findPage(pReference); + if(!pData) + return NULL; + for(pData = pPageList->next();pData;pData = pPageList->next()) + { + if(pData->bEnabled) + return pData; + } + return NULL; + } + + KviTalWizardPageData * findPrevEnabledPage(QWidget * pReference) + { + if(!pReference) + return findLastEnabledPage(); + KviTalWizardPageData * pData = findPage(pReference); + if(!pData) + return NULL; + for(pData = pPageList->prev();pData;pData = pPageList->prev()) + { + if(pData->bEnabled) + return pData; + } + return NULL; + } + + int reindexPages() + { + int iEnabledCount = 0; + for(KviTalWizardPageData * pData = pPageList->next();pData;pData = pPageList->next()) + { + if(pData->bEnabled) + { + iEnabledCount++; + pData->iVisibleIndex = iEnabledCount; + } + } + return iEnabledCount; + } +}; + + +KviTalWizard::KviTalWizard(QWidget * pParent) +: QDialog(pParent) +{ + m_p = new KviTalWizardPrivate; + m_p->pPageList = new KviPointerList<KviTalWizardPageData>; + m_p->pPageList->setAutoDelete(true); + m_p->pCurrentPage = NULL; + m_p->iEnabledPageCount = 0; + m_p->pLayout = new QGridLayout(this); + + m_p->pTitleLabel = new QLabel(this); +#ifdef COMPILE_USE_QT4 + m_p->pLayout->addWidget(m_p->pTitleLabel,0,0,1,3); +#else + m_p->pLayout->addMultiCellWidget(m_p->pTitleLabel,0,0,0,3); +#endif + m_p->pStepsLabel = new QLabel(this); + m_p->pStepsLabel->setMinimumWidth(80); + m_p->pStepsLabel->setAlignment(Qt::AlignRight); +#ifdef COMPILE_USE_QT4 + m_p->pLayout->addWidget(m_p->pStepsLabel,0,4,1,3); +#else + m_p->pLayout->addMultiCellWidget(m_p->pStepsLabel,0,0,4,6); +#endif + + QFrame * f1 = new QFrame(this); + f1->setFrameStyle(QFrame::Sunken | QFrame::HLine); +#ifdef COMPILE_USE_QT4 + m_p->pLayout->addWidget(f1,1,0,1,7); +#else + m_p->pLayout->addMultiCellWidget(f1,1,1,0,6); +#endif + +#ifdef COMPILE_USE_QT4 + m_p->pWidgetStack = new QStackedWidget(this); + m_p->pLayout->addWidget(m_p->pWidgetStack,2,0,1,7); +#else + m_p->pWidgetStack = new QWidgetStack(this); + m_p->pLayout->addMultiCellWidget(m_p->pWidgetStack,2,2,0,6); +#endif + + QFrame * f2 = new QFrame(this); + f2->setFrameStyle(QFrame::Sunken | QFrame::HLine); +#ifdef COMPILE_USE_QT4 + m_p->pLayout->addWidget(f2,3,0,1,7); +#else + m_p->pLayout->addMultiCellWidget(f2,3,3,0,6); +#endif + + KviTalHBox * pButtonBox = new KviTalHBox(this); +#ifdef COMPILE_USE_QT4 + m_p->pLayout->addWidget(pButtonBox,4,0,1,7); +#else + m_p->pLayout->addMultiCellWidget(pButtonBox,4,4,0,6); +#endif + + pButtonBox->setMargin(0); + pButtonBox->setSpacing(0); + + + m_p->pCancelButton = new QPushButton(__tr("Cancel"),pButtonBox); + m_p->pCancelButton->setMinimumWidth(80); + QObject::connect( + m_p->pCancelButton, + SIGNAL(clicked()), + this, + SLOT(cancelButtonClicked()) + ); + + QWidget * pSpacer = new QWidget(pButtonBox); + pSpacer->setFixedWidth(4); + + m_p->pHelpButton = new QPushButton(__tr("Help"),pButtonBox); + m_p->pHelpButton->setMinimumWidth(80); + QObject::connect( + m_p->pHelpButton, + SIGNAL(clicked()), + this, + SLOT(helpButtonClicked()) + ); + + QWidget * pLargeSpacer = new QWidget(pButtonBox); + pLargeSpacer->setMinimumWidth(50); + pButtonBox->setStretchFactor(pLargeSpacer,100); + + QString szText = "< "; + szText += __tr("Back"); + m_p->pBackButton = new QPushButton(szText,pButtonBox); + m_p->pBackButton->setMinimumWidth(80); + QObject::connect( + m_p->pBackButton, + SIGNAL(clicked()), + this, + SLOT(backButtonClicked()) + ); + + m_p->pNextSpacer = new QWidget(pButtonBox); + m_p->pNextSpacer->setFixedWidth(4); + + szText = __tr("Next"); + szText += " >"; + m_p->pNextButton = new QPushButton(szText,pButtonBox); + m_p->pNextButton->setMinimumWidth(80); + QObject::connect( + m_p->pNextButton, + SIGNAL(clicked()), + this, + SLOT(nextButtonClicked()) + ); + + m_p->pFinishSpacer = new QWidget(pButtonBox); + m_p->pFinishSpacer->setFixedWidth(4); + + m_p->pFinishButton = new QPushButton(__tr("Finish"),pButtonBox); + m_p->pFinishButton->setMinimumWidth(80); + QObject::connect( + m_p->pFinishButton, + SIGNAL(clicked()), + this, + SLOT(finishButtonClicked()) + ); + + m_p->pLayout->setMargin(8); + m_p->pLayout->setSpacing(4); + m_p->pLayout->setRowStretch(2,1); + m_p->pLayout->setColStretch(0,1); +} + +KviTalWizard::~KviTalWizard() +{ + delete m_p->pPageList; + delete m_p; +} + +void KviTalWizard::insertPage(QWidget * pWidget,const QString &szTitle,int iIndex) +{ + KviTalWizardPageData * pPageData = m_p->findPage(pWidget); + if(!pPageData) + { + pPageData = new KviTalWizardPageData; + pPageData->pWidget = pWidget; + pPageData->iEnableFlags = \ + KviTalWizardPageData::EnableNext | \ + KviTalWizardPageData::EnableCancel | \ + KviTalWizardPageData::EnableBack; + if(iIndex < 0) + { + m_p->pPageList->append(pPageData); + m_p->iEnabledPageCount++; + pPageData->iVisibleIndex = m_p->iEnabledPageCount; + } else { + m_p->pPageList->insert(iIndex,pPageData); + m_p->iEnabledPageCount = m_p->reindexPages(); + } + m_p->pWidgetStack->addWidget(pWidget); + } + pPageData->szTitle = szTitle; + pPageData->bEnabled = true; + +} + +void KviTalWizard::addPage(QWidget * pWidget,const QString &szTitle) +{ + insertPage(pWidget,szTitle,-1); +} + +bool KviTalWizard::setPageEnabled(QWidget * pWidget,bool bEnabled) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return false; + pData->bEnabled = bEnabled; + m_p->iEnabledPageCount = m_p->reindexPages(); + setCurrentPage(m_p->pCurrentPage); + return true; +} + +bool KviTalWizard::setPageTitle(QWidget * pWidget,const QString &szTitle) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return false; + pData->szTitle = szTitle; + return true; +} + +bool KviTalWizard::setCurrentPage(QWidget * pWidget) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return false; + setCurrentPage(pData); + return true; +} + +QWidget * KviTalWizard::currentPage() +{ + if(!m_p->pCurrentPage) + return NULL; + return m_p->pCurrentPage->pWidget; +} + +void KviTalWizard::setCurrentPage(KviTalWizardPageData * pData) +{ + m_p->pCurrentPage = pData; + + bool bCancelEnabled = true; + bool bNextEnabled = false; + bool bBackEnabled = false; + bool bHelpEnabled = false; + bool bFinishEnabled = false; + + QString szTitle; + QString szSteps; + + if(pData) + { + bNextEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableNext) && m_p->findNextEnabledPage(pData->pWidget); + bBackEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableBack) && m_p->findPrevEnabledPage(pData->pWidget); + bCancelEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableCancel); + bFinishEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableFinish); + bHelpEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableHelp); +#ifdef COMPILE_USE_QT4 + m_p->pWidgetStack->setCurrentWidget(pData->pWidget); +#else + m_p->pWidgetStack->raiseWidget(pData->pWidget); +#endif + szTitle = "<b>"; + szTitle += pData->szTitle; + szTitle += "</b>"; + QPalette pal = m_p->pStepsLabel->palette(); +#ifdef COMPILE_USE_QT4 + QColor clrWin = pal.color(QPalette::Normal,QPalette::Window); + QColor clrTxt = pal.color(QPalette::Normal,QPalette::WindowText); +#else + QColor clrWin = pal.color(QPalette::Normal,QColorGroup::Foreground); + QColor clrTxt = pal.color(QPalette::Normal,QColorGroup::Background); +#endif + QColor clrMid = qRgb( + (clrWin.red() + clrTxt.red()) / 2, + (clrWin.green() + clrTxt.green()) / 2, + (clrWin.blue() + clrTxt.blue()) / 2 + ); + + szSteps = "<nobr><font color=\""; + szSteps += clrMid.name(); + szSteps += "\"><b>["; + szSteps += QString("Step %1 of %2").arg(pData->iVisibleIndex).arg(m_p->iEnabledPageCount); + szSteps += "]</b></font></nobr>"; + } + + m_p->pTitleLabel->setText(szTitle); + m_p->pStepsLabel->setText(szSteps); + + m_p->pNextButton->setEnabled(bNextEnabled); + if(bNextEnabled) + { + m_p->pNextButton->show(); + m_p->pNextSpacer->show(); + } else { + m_p->pNextButton->hide(); + m_p->pNextSpacer->hide(); + } + m_p->pBackButton->setEnabled(bBackEnabled); + m_p->pHelpButton->setEnabled(bHelpEnabled); + if(bHelpEnabled) + m_p->pHelpButton->show(); + else + m_p->pHelpButton->hide(); + m_p->pCancelButton->setEnabled(bCancelEnabled); + m_p->pFinishButton->setEnabled(bFinishEnabled); + if(bFinishEnabled) + { + m_p->pFinishButton->show(); + m_p->pFinishSpacer->show(); + } else { + m_p->pFinishButton->hide(); + m_p->pFinishSpacer->hide(); + } +} + +void KviTalWizard::showEvent(QShowEvent * e) +{ + if(!(m_p->pCurrentPage)) + { + // display the first page + KviTalWizardPageData * pData = m_p->findFirstEnabledPage(); + if(pData) + setCurrentPage(pData->pWidget); + } + QDialog::showEvent(e); +} + +void KviTalWizard::closeEvent(QCloseEvent * e) +{ + e->ignore(); + cancelButtonClicked(); +} + +void KviTalWizard::backButtonClicked() +{ + if(!m_p->pCurrentPage) + return; + setCurrentPage(m_p->findPrevEnabledPage(m_p->pCurrentPage->pWidget)); +} + +void KviTalWizard::nextButtonClicked() +{ + setCurrentPage(m_p->findNextEnabledPage(m_p->pCurrentPage->pWidget)); +} + +void KviTalWizard::helpButtonClicked() +{ + emit helpClicked(); +} + +void KviTalWizard::cancelButtonClicked() +{ + reject(); +} + +void KviTalWizard::finishButtonClicked() +{ + accept(); +} + +void KviTalWizard::setHelpEnabled(QWidget * pWidget,bool bEnabled) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return; + if(bEnabled) + pData->iEnableFlags |= KviTalWizardPageData::EnableHelp; + else + pData->iEnableFlags &= ~KviTalWizardPageData::EnableHelp; + if(pData == m_p->pCurrentPage) + setCurrentPage(pData); +} + +void KviTalWizard::setCancelEnabled(QWidget * pWidget,bool bEnabled) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return; + if(bEnabled) + pData->iEnableFlags |= KviTalWizardPageData::EnableCancel; + else + pData->iEnableFlags &= ~KviTalWizardPageData::EnableCancel; + if(pData == m_p->pCurrentPage) + setCurrentPage(pData); +} + +void KviTalWizard::setFinishEnabled(QWidget * pWidget,bool bEnabled) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return; + if(bEnabled) + pData->iEnableFlags |= KviTalWizardPageData::EnableFinish; + else + pData->iEnableFlags &= ~KviTalWizardPageData::EnableFinish; + if(pData == m_p->pCurrentPage) + setCurrentPage(pData); +} + +void KviTalWizard::setNextEnabled(QWidget * pWidget,bool bEnabled) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return; + if(bEnabled) + pData->iEnableFlags |= KviTalWizardPageData::EnableNext; + else + pData->iEnableFlags &= ~KviTalWizardPageData::EnableNext; + if(pData == m_p->pCurrentPage) + setCurrentPage(pData); +} + +void KviTalWizard::setBackEnabled(QWidget * pWidget,bool bEnabled) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return; + if(bEnabled) + pData->iEnableFlags |= KviTalWizardPageData::EnableBack; + else + pData->iEnableFlags &= ~KviTalWizardPageData::EnableBack; + if(pData == m_p->pCurrentPage) + setCurrentPage(pData); +} + +QPushButton * KviTalWizard::cancelButton() +{ + return m_p->pCancelButton; +} + +QPushButton * KviTalWizard::helpButton() +{ + return m_p->pHelpButton; +} + +QPushButton * KviTalWizard::finishButton() +{ + return m_p->pFinishButton; +} + +QPushButton * KviTalWizard::nextButton() +{ + return m_p->pNextButton; +} + +QPushButton * KviTalWizard::backButton() +{ + return m_p->pBackButton; +} + diff --git a/src/kvilib/tal/kvi_tal_wizard.h b/src/kvilib/tal/kvi_tal_wizard.h new file mode 100644 index 00000000..f84e3555 --- /dev/null +++ b/src/kvilib/tal/kvi_tal_wizard.h @@ -0,0 +1,169 @@ +#ifndef _KVI_TAL_WIZARD_H_ +#define _KVI_TAL_WIZARD_H_ + +//============================================================================= +// +// File : kvi_tal_wizard.h +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_USE_QT4 + #include <QDialog> +#else + #include <qdialog.h> +#endif + +class QShowEvent; +class QPushButton; +class KviTalWizardPrivate; +class KviTalWizardPageData; + +/// +/// \class KviTalWizard +/// +/// \brief Provides a wizard-style dialog with steps +/// +class KVILIB_API KviTalWizard : public QDialog +{ + Q_OBJECT +public: + KviTalWizard(QWidget * pParent); + ~KviTalWizard(); +protected: + KviTalWizardPrivate * m_p; +public: + /// + /// Adds a page to the wizard with the specified title. + /// The pages are displayed in order they're added. + /// Adding a page a second time is equivalent to calling + /// setPageTitle() and enabling the page. + /// + void addPage(QWidget * pWidget,const QString &szTitle); + /// + /// Adds a page to the wizard with the specified title + /// and in the specified position. + /// Adding a page a second time is equivalent to calling + /// setPageTitle() and enabling the page. + /// + void insertPage(QWidget * pWidget,const QString &szTitle,int iIndex); + /// + /// Enables or disables a page. A disabled page + /// is skipped when the user presses "Next" in the + /// previous page or "Back" in the page after. + /// Disabling the current page has no effect. + /// + /// Returns true on success or false if the pWidget + /// does not identify a page that has been added to this wizard. + /// + bool setPageEnabled(QWidget * pWidget,bool bEnabled); + /// + /// Changes a page title. + /// + /// Returns true on success or false if the pWidget + /// does not identify a page that has been added to this wizard. + /// + bool setPageTitle(QWidget * pWidget,const QString &szTitle); + /// + /// Switches the wizard to the specified page. + /// Please note that this class handles page switching + /// automatically so you usually don't need to call this function. + /// + /// Returns true on success or false if the pWidget + /// does not identify a page that has been added to this wizard. + /// + bool setCurrentPage(QWidget * pWidget); + /// + /// Returns a pointer to the current page + /// + QWidget * currentPage(); + /// + /// Enables or disables the help button for the specified page. + /// By default the help button is always disabled. + /// + void setHelpEnabled(QWidget * pWidget,bool bEnabled); + /// + /// Enables or disables the cancel button for the specified page. + /// By default the cancel button is always enabled. + /// + void setCancelEnabled(QWidget * pWidget,bool bEnabled); + /// + /// Enables or disables the finish button for the specified page. + /// By default the finish button is always disabled. + /// + void setFinishEnabled(QWidget * pWidget,bool bEnabled); + /// + /// Enables or disables the next button for the specified page. + /// By default the next button is always enabled. + /// + void setNextEnabled(QWidget * pWidget,bool bEnabled); + /// + /// Enables or disables the prev button for the specified page. + /// By default the prev button is always enabled. + /// + void setBackEnabled(QWidget * pWidget,bool bEnabled); + /// + /// Returns a pointer to the cancel button displayed in the dialog. + /// + QPushButton * cancelButton(); + /// + /// Returns a pointer to the help button displayed in the dialog. + /// + QPushButton * helpButton(); + /// + /// Returns a pointer to the finish button displayed in the dialog. + /// + QPushButton * finishButton(); + /// + /// Returns a pointer to the next button displayed in the dialog. + /// + QPushButton * nextButton(); + /// + /// Returns a pointer to the back button displayed in the dialog. + /// + QPushButton * backButton(); +signals: + /// + /// Emitted when the help button is clicked. + /// + void helpClicked(); +protected: + /// + /// Displays the first page if no other page is shown yet. + /// + virtual void showEvent(QShowEvent * e); + /// + /// Handles redirects the close button to the "cancel" operation. + /// + virtual void closeEvent(QCloseEvent * e); +protected: + void setCurrentPage(KviTalWizardPageData * pData); +protected slots: + void backButtonClicked(); + void nextButtonClicked(); + void helpButtonClicked(); + void cancelButtonClicked(); + void finishButtonClicked(); +}; + + +#endif // _KVI_TAL_WIZARD_H_ diff --git a/src/kvilib/tal/moc_kvi_tal_wizard.cpp b/src/kvilib/tal/moc_kvi_tal_wizard.cpp new file mode 100644 index 00000000..0ad29754 --- /dev/null +++ b/src/kvilib/tal/moc_kvi_tal_wizard.cpp @@ -0,0 +1,128 @@ +/**************************************************************************** +** KviTalWizard meta object code from reading C++ file 'kvi_tal_wizard.h' +** +** Created: Sun Mar 23 20:56:27 2008 +** by: The Qt MOC ($Id: qt/moc_yacc.cpp 3.3.8 edited Feb 2 14:59 $) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#undef QT_NO_COMPAT +#include "kvi_tal_wizard.h" +#include <qmetaobject.h> +#include <qapplication.h> + +#include <private/qucomextra_p.h> +#if !defined(Q_MOC_OUTPUT_REVISION) || (Q_MOC_OUTPUT_REVISION != 26) +#error "This file was generated using the moc from 3.3.8. It" +#error "cannot be used with the include files from this version of Qt." +#error "(The moc has changed too much.)" +#endif + +const char *KviTalWizard::className() const +{ + return "KviTalWizard"; +} + +QMetaObject *KviTalWizard::metaObj = 0; +static QMetaObjectCleanUp cleanUp_KviTalWizard( "KviTalWizard", &KviTalWizard::staticMetaObject ); + +#ifndef QT_NO_TRANSLATION +QString KviTalWizard::tr( const char *s, const char *c ) +{ + if ( qApp ) + return qApp->translate( "KviTalWizard", s, c, QApplication::DefaultCodec ); + else + return QString::fromLatin1( s ); +} +#ifndef QT_NO_TRANSLATION_UTF8 +QString KviTalWizard::trUtf8( const char *s, const char *c ) +{ + if ( qApp ) + return qApp->translate( "KviTalWizard", s, c, QApplication::UnicodeUTF8 ); + else + return QString::fromUtf8( s ); +} +#endif // QT_NO_TRANSLATION_UTF8 + +#endif // QT_NO_TRANSLATION + +QMetaObject* KviTalWizard::staticMetaObject() +{ + if ( metaObj ) + return metaObj; + QMetaObject* parentObject = QDialog::staticMetaObject(); + static const QUMethod slot_0 = {"backButtonClicked", 0, 0 }; + static const QUMethod slot_1 = {"nextButtonClicked", 0, 0 }; + static const QUMethod slot_2 = {"helpButtonClicked", 0, 0 }; + static const QUMethod slot_3 = {"cancelButtonClicked", 0, 0 }; + static const QUMethod slot_4 = {"finishButtonClicked", 0, 0 }; + static const QMetaData slot_tbl[] = { + { "backButtonClicked()", &slot_0, QMetaData::Protected }, + { "nextButtonClicked()", &slot_1, QMetaData::Protected }, + { "helpButtonClicked()", &slot_2, QMetaData::Protected }, + { "cancelButtonClicked()", &slot_3, QMetaData::Protected }, + { "finishButtonClicked()", &slot_4, QMetaData::Protected } + }; + static const QUMethod signal_0 = {"helpClicked", 0, 0 }; + static const QMetaData signal_tbl[] = { + { "helpClicked()", &signal_0, QMetaData::Public } + }; + metaObj = QMetaObject::new_metaobject( + "KviTalWizard", parentObject, + slot_tbl, 5, + signal_tbl, 1, +#ifndef QT_NO_PROPERTIES + 0, 0, + 0, 0, +#endif // QT_NO_PROPERTIES + 0, 0 ); + cleanUp_KviTalWizard.setMetaObject( metaObj ); + return metaObj; +} + +void* KviTalWizard::qt_cast( const char* clname ) +{ + if ( !qstrcmp( clname, "KviTalWizard" ) ) + return this; + return QDialog::qt_cast( clname ); +} + +// SIGNAL helpClicked +void KviTalWizard::helpClicked() +{ + activate_signal( staticMetaObject()->signalOffset() + 0 ); +} + +bool KviTalWizard::qt_invoke( int _id, QUObject* _o ) +{ + switch ( _id - staticMetaObject()->slotOffset() ) { + case 0: backButtonClicked(); break; + case 1: nextButtonClicked(); break; + case 2: helpButtonClicked(); break; + case 3: cancelButtonClicked(); break; + case 4: finishButtonClicked(); break; + default: + return QDialog::qt_invoke( _id, _o ); + } + return TRUE; +} + +bool KviTalWizard::qt_emit( int _id, QUObject* _o ) +{ + switch ( _id - staticMetaObject()->signalOffset() ) { + case 0: helpClicked(); break; + default: + return QDialog::qt_emit(_id,_o); + } + return TRUE; +} +#ifndef QT_NO_PROPERTIES + +bool KviTalWizard::qt_property( int id, int f, QVariant* v) +{ + return QDialog::qt_property( id, f, v); +} + +bool KviTalWizard::qt_static_property( QObject* , int , int , QVariant* ){ return FALSE; } +#endif // QT_NO_PROPERTIES |