diff options
| author | 2008-03-29 03:44:53 +0000 | |
|---|---|---|
| committer | 2008-03-29 03:44:53 +0000 | |
| commit | d5c884c1ecf85d616aab52f9bfd11eb8bfcc46ea (patch) | |
| tree | 4e270e6a5f780167381e5d3080e18a99b22ce6f8 | |
| parent | more on porting (diff) | |
| download | KVIrc-d5c884c1ecf85d616aab52f9bfd11eb8bfcc46ea.tar.gz KVIrc-d5c884c1ecf85d616aab52f9bfd11eb8bfcc46ea.tar.bz2 KVIrc-d5c884c1ecf85d616aab52f9bfd11eb8bfcc46ea.zip | |
cleaned up tal classes
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@1320 17fca916-40b9-46aa-a4ea-0a15b648b75c
30 files changed, 1086 insertions, 2977 deletions
@@ -132,54 +132,27 @@ src/kvilib/system kvi_time.cpp kvi_time.h src/kvilib/tal - kvi_tal_application.cpp - kvi_tal_application.h - kvi_tal_application_kde.h - kvi_tal_application_qt.h - kvi_tal_filedialog.cpp - kvi_tal_filedialog.h - kvi_tal_filedialog_kde.h - kvi_tal_filedialog_qt.h kvi_tal_grid.cpp kvi_tal_grid.h - kvi_tal_groupbox.cpp kvi_tal_groupbox.h - kvi_tal_groupbox_qt3.h - kvi_tal_groupbox_qt4.h kvi_tal_iconview.cpp kvi_tal_iconview.h - kvi_tal_iconview_qt3.h - kvi_tal_iconview_qt4.h kvi_tal_listbox.cpp kvi_tal_listbox.h - kvi_tal_listbox_qt3.h - kvi_tal_listbox_qt4.h kvi_tal_listview.cpp kvi_tal_listview.h - kvi_tal_listview_qt3.h - kvi_tal_listview_qt4.h - kvi_tal_mainwindow.cpp - kvi_tal_mainwindow.h - kvi_tal_mainwindow_kde.h - kvi_tal_mainwindow_qt.h kvi_tal_menubar.cpp kvi_tal_menubar.h kvi_tal_menubar_kde.h kvi_tal_menubar_qt.h kvi_tal_popupmenu.cpp kvi_tal_popupmenu.h - kvi_tal_popupmenu_qt3.h - kvi_tal_popupmenu_qt4.h kvi_tal_scrollview.cpp kvi_tal_scrollview.h kvi_tal_tabdialog.cpp kvi_tal_tabdialog.h - kvi_tal_tabdialog_qt3.h - kvi_tal_tabdialog_qt4.h kvi_tal_textedit.cpp kvi_tal_textedit.h - kvi_tal_textedit_qt3.h - kvi_tal_textedit_qt4.h kvi_tal_toolbar.cpp kvi_tal_toolbar.h kvi_tal_toolbar_kde.h diff --git a/src/kvilib/build/Makefile.am b/src/kvilib/build/Makefile.am index ab35ab03b..cf580b820 100644 --- a/src/kvilib/build/Makefile.am +++ b/src/kvilib/build/Makefile.am @@ -185,16 +185,10 @@ headers_HEADERS = \ ../tal/kvi_tal_filedialog_qt.h \ ../tal/kvi_tal_grid.h \ ../tal/kvi_tal_groupbox.h \ - ../tal/kvi_tal_groupbox_qt3.h \ - ../tal/kvi_tal_groupbox_qt4.h \ ../tal/kvi_tal_hbox.h \ ../tal/kvi_tal_iconview.h \ - ../tal/kvi_tal_iconview_qt3.h \ - ../tal/kvi_tal_iconview_qt4.h \ ../tal/kvi_tal_listbox.h \ ../tal/kvi_tal_listview.h \ - ../tal/kvi_tal_listview_qt3.h \ - ../tal/kvi_tal_listview_qt4.h \ ../tal/kvi_tal_mainwindow.h \ ../tal/kvi_tal_mainwindow_kde.h \ ../tal/kvi_tal_mainwindow_qt.h \ @@ -202,15 +196,9 @@ headers_HEADERS = \ ../tal/kvi_tal_menubar_kde.h \ ../tal/kvi_tal_menubar_qt.h \ ../tal/kvi_tal_popupmenu.h \ - ../tal/kvi_tal_popupmenu_qt3.h \ - ../tal/kvi_tal_popupmenu_qt4.h \ ../tal/kvi_tal_scrollview.h \ ../tal/kvi_tal_tabdialog.h \ - ../tal/kvi_tal_tabdialog_qt3.h \ - ../tal/kvi_tal_tabdialog_qt4.h \ ../tal/kvi_tal_textedit.h \ - ../tal/kvi_tal_textedit_qt3.h \ - ../tal/kvi_tal_textedit_qt4.h \ ../tal/kvi_tal_toolbar.h \ ../tal/kvi_tal_toolbar_kde.h \ ../tal/kvi_tal_toolbar_qt.h \ @@ -266,22 +254,16 @@ headers_HEADERS = \ ../tal/kvi_tal_filedialog.cpp: ../tal/kvi_tal_filedialog_kde.moc ../tal/kvi_tal_filedialog.cpp: ../tal/kvi_tal_filedialog_qt.moc ../tal/kvi_tal_grid.cpp: ../tal/kvi_tal_grid.moc -../tal/kvi_tal_groupbox.cpp: ../tal/kvi_tal_groupbox_qt3.moc -../tal/kvi_tal_groupbox.cpp: ../tal/kvi_tal_groupbox_qt4.moc +../tal/kvi_tal_groupbox.cpp: ../tal/kvi_tal_groupbox.moc ../tal/kvi_tal_hbox.cpp: ../tal/kvi_tal_hbox.moc ../tal/kvi_tal_vbox.cpp: ../tal/kvi_tal_vbox.moc -../tal/kvi_tal_popupmenu.cpp: ../tal/kvi_tal_popupmenu_qt3.moc -../tal/kvi_tal_popupmenu.cpp: ../tal/kvi_tal_popupmenu_qt4.moc -../tal/kvi_tal_listview.cpp: ../tal/kvi_tal_listview_qt3.moc -../tal/kvi_tal_listview.cpp: ../tal/kvi_tal_listview_qt4.moc +../tal/kvi_tal_popupmenu.cpp: ../tal/kvi_tal_popupmenu.moc +../tal/kvi_tal_listview.cpp: ../tal/kvi_tal_listview.moc ../tal/kvi_tal_listbox.cpp: ../tal/kvi_tal_listbox.moc -../tal/kvi_tal_iconview.cpp: ../tal/kvi_tal_iconview_qt3.moc -../tal/kvi_tal_iconview.cpp: ../tal/kvi_tal_iconview_qt4.moc +../tal/kvi_tal_iconview.cpp: ../tal/kvi_tal_iconview.moc ../tal/kvi_tal_scrollview.cpp: ../tal/kvi_tal_scrollview.moc -../tal/kvi_tal_tabdialog.cpp: ../tal/kvi_tal_tabdialog_qt3.moc -../tal/kvi_tal_tabdialog.cpp: ../tal/kvi_tal_tabdialog_qt4.moc -../tal/kvi_tal_textedit.cpp: ../tal/kvi_tal_textedit_qt3.moc -../tal/kvi_tal_textedit.cpp: ../tal/kvi_tal_textedit_qt4.moc +../tal/kvi_tal_tabdialog.cpp: ../tal/kvi_tal_tabdialog.moc +../tal/kvi_tal_textedit.cpp: ../tal/kvi_tal_textedit.moc ../tal/kvi_tal_toolbar.cpp: ../tal/kvi_tal_toolbar_qt.moc ../tal/kvi_tal_toolbar.cpp: ../tal/kvi_tal_toolbar_kde.moc ../tal/kvi_tal_tooltip.cpp: ../tal/kvi_tal_tooltip.moc diff --git a/src/kvilib/tal/kvi_tal_filedialog_kde.h b/src/kvilib/tal/kvi_tal_filedialog_kde.h index 08df95bc9..8d1797ae9 100644 --- a/src/kvilib/tal/kvi_tal_filedialog_kde.h +++ b/src/kvilib/tal/kvi_tal_filedialog_kde.h @@ -24,7 +24,6 @@ // #include <kfiledialog.h> -//#include <QFileDialog> class KVILIB_API KviTalFileDialog : public KFileDialog { diff --git a/src/kvilib/tal/kvi_tal_groupbox.cpp b/src/kvilib/tal/kvi_tal_groupbox.cpp index 830df938e..983261a2c 100644 --- a/src/kvilib/tal/kvi_tal_groupbox.cpp +++ b/src/kvilib/tal/kvi_tal_groupbox.cpp @@ -25,10 +25,4 @@ #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 - +#include "kvi_tal_groupbox.moc" diff --git a/src/kvilib/tal/kvi_tal_groupbox.h b/src/kvilib/tal/kvi_tal_groupbox.h index c13660e1e..c3d803765 100644 --- a/src/kvilib/tal/kvi_tal_groupbox.h +++ b/src/kvilib/tal/kvi_tal_groupbox.h @@ -27,10 +27,21 @@ #include "kvi_settings.h" -#ifdef COMPILE_USE_QT4 - #include "kvi_tal_groupbox_qt4.h" -#else - #include "kvi_tal_groupbox_qt3.h" -#endif +#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_H_ diff --git a/src/kvilib/tal/kvi_tal_groupbox_qt3.h b/src/kvilib/tal/kvi_tal_groupbox_qt3.h deleted file mode 100644 index d11ffe842..000000000 --- a/src/kvilib/tal/kvi_tal_groupbox_qt3.h +++ /dev/null @@ -1,47 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 deleted file mode 100644 index f795ee3d3..000000000 --- a/src/kvilib/tal/kvi_tal_groupbox_qt4.h +++ /dev/null @@ -1,47 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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_iconview.cpp b/src/kvilib/tal/kvi_tal_iconview.cpp index b045fe44b..9865d1fed 100644 --- a/src/kvilib/tal/kvi_tal_iconview.cpp +++ b/src/kvilib/tal/kvi_tal_iconview.cpp @@ -25,191 +25,94 @@ #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 *))); +} - 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_selectionChanged(Q3IconViewItem * pItem) - { - emit selectionChanged((KviTalIconViewItem *)pItem); - } +void KviTalIconView::redirect_currentChanged(Q3IconViewItem * pItem) +{ + emit currentChanged((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) - { - emit clicked((KviTalIconViewItem *)pItem); - } +void KviTalIconView::redirect_clicked(Q3IconViewItem * pItem,const QPoint &pnt) +{ + emit clicked((KviTalIconViewItem *)pItem,pnt); +} - 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) - { - emit pressed((KviTalIconViewItem *)pItem); - } +void KviTalIconView::redirect_pressed(Q3IconViewItem * pItem,const QPoint &pnt) +{ + emit pressed((KviTalIconViewItem *)pItem,pnt); +} - 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_doubleClicked(Q3IconViewItem * pItem) - { - emit doubleClicked((KviTalIconViewItem *)pItem); - } +void KviTalIconView::redirect_returnPressed(Q3IconViewItem * pItem) +{ + emit returnPressed((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_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_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_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_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_contextMenuRequested(Q3IconViewItem * pItem,const QPoint &pnt) - { - emit contextMenuRequested((KviTalIconViewItem *)pItem,pnt); - } +void KviTalIconView::redirect_onItem(Q3IconViewItem * pItem) +{ + emit onItem((KviTalIconViewItem *)pItem); +} - 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 +#include "kvi_tal_iconview.moc" diff --git a/src/kvilib/tal/kvi_tal_iconview.h b/src/kvilib/tal/kvi_tal_iconview.h index 1ef7ee8d1..ec0a5e714 100644 --- a/src/kvilib/tal/kvi_tal_iconview.h +++ b/src/kvilib/tal/kvi_tal_iconview.h @@ -26,11 +26,73 @@ //============================================================================= #include "kvi_settings.h" +#include "kvi_qstring.h" -#ifdef COMPILE_USE_QT4 - #include "kvi_tal_iconview_qt4.h" -#else - #include "kvi_tal_iconview_qt3.h" -#endif +#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_H_ diff --git a/src/kvilib/tal/kvi_tal_iconview_qt3.h b/src/kvilib/tal/kvi_tal_iconview_qt3.h deleted file mode 100644 index 371a296d6..000000000 --- a/src/kvilib/tal/kvi_tal_iconview_qt3.h +++ /dev/null @@ -1,100 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 deleted file mode 100644 index 899acaac2..000000000 --- a/src/kvilib/tal/kvi_tal_iconview_qt4.h +++ /dev/null @@ -1,99 +0,0 @@ -#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.h b/src/kvilib/tal/kvi_tal_listbox.h index 912784c81..2914ba96f 100644 --- a/src/kvilib/tal/kvi_tal_listbox.h +++ b/src/kvilib/tal/kvi_tal_listbox.h @@ -41,6 +41,8 @@ // present in qt 3.3.6 AND in qt 4.1.2. // +#include "kvi_settings.h" + #include <q3listbox.h> class KviTalListBoxItem; @@ -121,13 +123,15 @@ public: KviTalListBoxText(KviTalListBox* listbox, const QString & text, KviTalListBoxItem *after); ~KviTalListBoxText(); - int height(const KviTalListBox *) const; - int width(const KviTalListBox *) const; + 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) }; @@ -146,16 +150,17 @@ public: const QPixmap *pixmap() const { return ± } - int height(const KviTalListBox *) const; - int width(const KviTalListBox *) const; + 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; }; diff --git a/src/kvilib/tal/kvi_tal_listbox_qt3.h b/src/kvilib/tal/kvi_tal_listbox_qt3.h deleted file mode 100644 index 91a284966..000000000 --- a/src/kvilib/tal/kvi_tal_listbox_qt3.h +++ /dev/null @@ -1,157 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 deleted file mode 100644 index d77dc9e76..000000000 --- a/src/kvilib/tal/kvi_tal_listbox_qt4.h +++ /dev/null @@ -1,152 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 index 1fd3b3157..b731c7360 100644 --- a/src/kvilib/tal/kvi_tal_listview.cpp +++ b/src/kvilib/tal/kvi_tal_listview.cpp @@ -23,1520 +23,770 @@ //============================================================================= #define __KVILIB__ -#include "kvi_tal_listview.h" +#include "kvi_tal_listview.h" #include "kvi_pointerhashtable.h" +#include <qpainter.h> +#include <qstyle.h> +#include <q3header.h> +#include <qapplication.h> +#include <qhash.h> +#include <qstyleoption.h> +#include <qaccessible.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); +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; +} - void KviTalListView::redirect_pressed(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit pressed((KviTalListViewItem *)pItem,pnt,uColumn); - } +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_doubleClicked(Q3ListViewItem * pItem) - { - emit doubleClicked((KviTalListViewItem *)pItem); - } +void KviTalListView::redirect_selectionChanged(Q3ListViewItem * pItem) +{ + emit selectionChanged((KviTalListViewItem *)pItem); +} - void KviTalListView::redirect_doubleClicked(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit doubleClicked((KviTalListViewItem *)pItem,pnt,uColumn); - } +void KviTalListView::redirect_currentChanged(Q3ListViewItem * pItem) +{ + emit currentChanged((KviTalListViewItem *)pItem); +} - void KviTalListView::redirect_returnPressed(Q3ListViewItem * pItem) - { - emit returnPressed((KviTalListViewItem *)pItem); - } +void KviTalListView::redirect_clicked(Q3ListViewItem * pItem) +{ + emit clicked((KviTalListViewItem *)pItem); +} - void KviTalListView::redirect_spacePressed(Q3ListViewItem * pItem) - { - emit spacePressed((KviTalListViewItem *)pItem); - } +void KviTalListView::redirect_clicked(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) +{ + emit clicked((KviTalListViewItem *)pItem,pnt,uColumn); +} - void KviTalListView::redirect_rightButtonClicked(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit rightButtonClicked((KviTalListViewItem *)pItem,pnt,uColumn); - } +void KviTalListView::redirect_pressed(Q3ListViewItem * pItem) +{ + emit pressed((KviTalListViewItem *)pItem); +} - void KviTalListView::redirect_rightButtonPressed(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit rightButtonPressed((KviTalListViewItem *)pItem,pnt,uColumn); - } +void KviTalListView::redirect_pressed(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) +{ + emit pressed((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_doubleClicked(Q3ListViewItem * pItem) +{ + emit doubleClicked((KviTalListViewItem *)pItem); +} - void KviTalListView::redirect_mouseButtonPressed(int iButton,Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit mouseButtonPressed(iButton,(KviTalListViewItem *)pItem,pnt,uColumn); - } +void KviTalListView::redirect_doubleClicked(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) +{ + emit doubleClicked((KviTalListViewItem *)pItem,pnt,uColumn); +} - void KviTalListView::redirect_contextMenuRequested(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit contextMenuRequested((KviTalListViewItem *)pItem,pnt,uColumn); - } +void KviTalListView::redirect_returnPressed(Q3ListViewItem * pItem) +{ + emit returnPressed((KviTalListViewItem *)pItem); +} - void KviTalListView::redirect_onItem(Q3ListViewItem * pItem) - { - emit onItem((KviTalListViewItem *)pItem); - } +void KviTalListView::redirect_spacePressed(Q3ListViewItem * pItem) +{ + emit spacePressed((KviTalListViewItem *)pItem); +} - void KviTalListView::redirect_expanded(Q3ListViewItem * pItem) - { - emit expanded((KviTalListViewItem *)pItem); - } +void KviTalListView::redirect_rightButtonClicked(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) +{ + emit rightButtonClicked((KviTalListViewItem *)pItem,pnt,uColumn); +} - void KviTalListView::redirect_collapsed(Q3ListViewItem * pItem) - { - emit collapsed((KviTalListViewItem *)pItem); - } +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); +} - struct KviTalCheckListItemPrivate - { - KviTalCheckListItemPrivate(): - exclusive(0), - currentState(KviTalCheckListItem::Off), - tristate(false) {} - - KviTalCheckListItem *exclusive; - KviTalCheckListItem::ToggleState currentState; - QHash<KviTalCheckListItem *, KviTalCheckListItem::ToggleState> statesDict; - bool tristate; - }; +void KviTalListView::redirect_mouseButtonPressed(int iButton,Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) +{ + emit mouseButtonPressed(iButton,(KviTalListViewItem *)pItem,pnt,uColumn); +} - 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; - } - } +void KviTalListView::redirect_contextMenuRequested(Q3ListViewItem * pItem,const QPoint &pnt,int uColumn) +{ + emit contextMenuRequested((KviTalListViewItem *)pItem,pnt,uColumn); +} - 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; - } +void KviTalListView::redirect_onItem(Q3ListViewItem * pItem) +{ + emit onItem((KviTalListViewItem *)pItem); +} - 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 KviTalListView::redirect_expanded(Q3ListViewItem * pItem) +{ + emit expanded((KviTalListViewItem *)pItem); +} - 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 KviTalListView::redirect_collapsed(Q3ListViewItem * pItem) +{ + emit collapsed((KviTalListViewItem *)pItem); +} - 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> +struct KviTalCheckListItemPrivate +{ + KviTalCheckListItemPrivate(): + exclusive(0), + currentState(KviTalCheckListItem::Off), + tristate(false) {} - 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 *))); - } + KviTalCheckListItem *exclusive; + KviTalCheckListItem::ToggleState currentState; + QHash<KviTalCheckListItem *, KviTalCheckListItem::ToggleState> statesDict; + bool tristate; +}; - void KviTalListView::redirect_selectionChanged(QListViewItem * pItem) - { - emit selectionChanged((KviTalListViewItem *)pItem); +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; } +} - void KviTalListView::redirect_currentChanged(QListViewItem * pItem) - { - emit currentChanged((KviTalListViewItem *)pItem); +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; } +} - void KviTalListView::redirect_clicked(QListViewItem * pItem) - { - emit clicked((KviTalListViewItem *)pItem); +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(); +} - void KviTalListView::redirect_clicked(QListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit clicked((KviTalListViewItem *)pItem,pnt,uColumn); +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(); +} - void KviTalListView::redirect_pressed(QListViewItem * pItem) - { - emit pressed((KviTalListViewItem *)pItem); +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(); +} - void KviTalListView::redirect_pressed(QListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit pressed((KviTalListViewItem *)pItem,pnt,uColumn); +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(); +} - void KviTalListView::redirect_doubleClicked(QListViewItem * pItem) - { - emit doubleClicked((KviTalListViewItem *)pItem); - } +int KviTalCheckListItem::rtti() const +{ + return RTTI; +} - void KviTalListView::redirect_doubleClicked(QListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit doubleClicked((KviTalListViewItem *)pItem,pnt,uColumn); - } +KviTalCheckListItem::KviTalCheckListItem(KviTalListView *parent, const QString &text,const QPixmap & p) +: KviTalListViewItem(parent, text) +{ + myType = RadioButtonController; + setPixmap(0, p); + init(); +} - void KviTalListView::redirect_returnPressed(QListViewItem * pItem) - { - emit returnPressed((KviTalListViewItem *)pItem); - } +KviTalCheckListItem::KviTalCheckListItem(KviTalListViewItem *parent, const QString &text,const QPixmap & p) +: KviTalListViewItem(parent, text) +{ + myType = RadioButtonController; + setPixmap(0, p); + init(); +} - void KviTalListView::redirect_spacePressed(QListViewItem * pItem) - { - emit spacePressed((KviTalListViewItem *)pItem); - } +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); +} - void KviTalListView::redirect_rightButtonClicked(QListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit rightButtonClicked((KviTalListViewItem *)pItem,pnt,uColumn); - } +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 KviTalListView::redirect_rightButtonPressed(QListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit rightButtonPressed((KviTalListViewItem *)pItem,pnt,uColumn); +void KviTalCheckListItem::setTristate(bool b) +{ + if ((myType != CheckBoxController) && (myType != CheckBox)) { + qWarning("KviTalCheckListItem::setTristate(), has no effect on RadioButton " + "or RadioButtonController."); + return; } + d->tristate = b; +} - void KviTalListView::redirect_mouseButtonClicked(int iButton,QListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit mouseButtonClicked(iButton,(KviTalListViewItem *)pItem,pnt,uColumn); - } +bool KviTalCheckListItem::isTristate() const +{ + return d->tristate; +} - void KviTalListView::redirect_mouseButtonPressed(int iButton,QListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit mouseButtonPressed(iButton,(KviTalListViewItem *)pItem,pnt,uColumn); - } +KviTalCheckListItem::ToggleState KviTalCheckListItem::state() const +{ + if (!isTristate() && internalState() == NoChange) + return Off; + else + return d->currentState; +} - void KviTalListView::redirect_contextMenuRequested(QListViewItem * pItem,const QPoint &pnt,int uColumn) - { - emit contextMenuRequested((KviTalListViewItem *)pItem,pnt,uColumn); - } +KviTalCheckListItem::ToggleState KviTalCheckListItem::internalState() const +{ + return d->currentState; +} - void KviTalListView::redirect_onItem(QListViewItem * pItem) - { - emit onItem((KviTalListViewItem *)pItem); - } +void KviTalCheckListItem::setState(ToggleState s) +{ + if (myType == CheckBoxController && state() == NoChange) + updateStoredState(this); + setState(s, true, true); +} - void KviTalListView::redirect_expanded(QListViewItem * pItem) - { - emit expanded((KviTalListViewItem *)pItem); - } +void KviTalCheckListItem::setState(ToggleState s, bool update, bool store) +{ - void KviTalListView::redirect_collapsed(QListViewItem * pItem) - { - emit collapsed((KviTalListViewItem *)pItem); - } + if (s == internalState()) + return; - 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 ); + 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++; + 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(); } - 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 ); + 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 { - // 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 ); + setCurrentState(s); + stateChange(state()); } - } else { - setCurrentState( s ); - stateChange( state() ); - } - } - } else if ( myType == RadioButton ) { - if ( s == On ) { - if ( d->exclusive && d->exclusive->d->exclusive != this ) + } else if (myType == RadioButton) { + if (s == On) { + if (d->exclusive && d->exclusive->d->exclusive != this) d->exclusive->turnOffChild(); - setCurrentState( s ); - if ( d->exclusive ) + setCurrentState(s); + if (d->exclusive) d->exclusive->d->exclusive = this; } else { - if ( d->exclusive && d->exclusive->d->exclusive == this ) + if (d->exclusive && d->exclusive->d->exclusive == this) d->exclusive->d->exclusive = 0; - setCurrentState( Off ); + setCurrentState(Off); } - stateChange( state() ); - } - repaint(); + stateChange(state()); } - - 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() ) + 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; - - 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; + } + 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 ); + } 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 ); +} + +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; - } + 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(); - } +} + +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 ); + } + 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( 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 ); +} + +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, 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 ) { + // 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; + if (myType == RadioButtonController && pixmap(0)) { + // r += 0; } else { - r += lv->style().pixelMetric(QStyle::PM_CheckListButtonSize, lv) + 4; + 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 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 ) { + 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 ); + 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; + } + + 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::Style_NoChange; - } else { - styleflags |= QStyle::Style_Off; - } - if ( isSelected() ) - styleflags |= QStyle::Style_Selected; - if ( isEnabled() && lv->isEnabled() ) - styleflags |= QStyle::Style_Enabled; - - if ( myType == RadioButtonController ) { + 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 ) ) { - lv->style().drawPrimitive(QStyle::PE_CheckListController, p, - QRect(x, 0, boxsize, - fm.height() + 2 + marg), - cg, styleflags, QStyleOption(this)); - r += boxsize + 4; + 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 ); //### + } else { + Q_ASSERT(lv); //### int x = 0; int y = 0; - if ( !parentControl ) - x += 3; - if ( align & AlignVCenter ) - y = ( ( height() - boxsize ) / 2 ) + marg; + if (!parentControl) + x += 3; + if (align & Qt::AlignVCenter) + y = ((height() - boxsize) / 2) + marg; else - y = (fm.height() + 2 + marg - boxsize) / 2; + 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)); - } + 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 ) ); + + // 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) ) ) { + 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() ); + 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() ); + rect.setRect(r.x() + boxsize + 5, r.y(), r.width() - boxsize - 5, + r.height()); KviTalListViewItem::paintFocus(p, cg, rect); - } else { + } else { KviTalListViewItem::paintFocus(p, cg, r); - } } - - #include "kvi_tal_listview_qt3.moc" -#endif - +} +#include "kvi_tal_listview.moc" diff --git a/src/kvilib/tal/kvi_tal_listview.h b/src/kvilib/tal/kvi_tal_listview.h index 5fe825495..c06369543 100644 --- a/src/kvilib/tal/kvi_tal_listview.h +++ b/src/kvilib/tal/kvi_tal_listview.h @@ -41,11 +41,174 @@ // #include "kvi_settings.h" +#include "kvi_qstring.h" -#ifdef COMPILE_USE_QT4 - #include "kvi_tal_listview_qt4.h" -#else - #include "kvi_tal_listview_qt3.h" -#endif +#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_H_ diff --git a/src/kvilib/tal/kvi_tal_listview_qt3.h b/src/kvilib/tal/kvi_tal_listview_qt3.h deleted file mode 100644 index 955b1c326..000000000 --- a/src/kvilib/tal/kvi_tal_listview_qt3.h +++ /dev/null @@ -1,190 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 deleted file mode 100644 index bef1ef976..000000000 --- a/src/kvilib/tal/kvi_tal_listview_qt4.h +++ /dev/null @@ -1,199 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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_popupmenu.cpp b/src/kvilib/tal/kvi_tal_popupmenu.cpp index fcc57edcc..3d7df2bc8 100644 --- a/src/kvilib/tal/kvi_tal_popupmenu.cpp +++ b/src/kvilib/tal/kvi_tal_popupmenu.cpp @@ -25,9 +25,4 @@ #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 - +#include "kvi_tal_popupmenu.moc" diff --git a/src/kvilib/tal/kvi_tal_popupmenu.h b/src/kvilib/tal/kvi_tal_popupmenu.h index 6aa1c1a58..478acd345 100644 --- a/src/kvilib/tal/kvi_tal_popupmenu.h +++ b/src/kvilib/tal/kvi_tal_popupmenu.h @@ -26,11 +26,62 @@ //============================================================================= #include "kvi_settings.h" +#include "kvi_qstring.h" -#ifdef COMPILE_USE_QT4 - #include "kvi_tal_popupmenu_qt4.h" -#else - #include "kvi_tal_popupmenu_qt3.h" -#endif +#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_H_ diff --git a/src/kvilib/tal/kvi_tal_popupmenu_qt3.h b/src/kvilib/tal/kvi_tal_popupmenu_qt3.h deleted file mode 100644 index f29e601d5..000000000 --- a/src/kvilib/tal/kvi_tal_popupmenu_qt3.h +++ /dev/null @@ -1,42 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 deleted file mode 100644 index cb7a864b5..000000000 --- a/src/kvilib/tal/kvi_tal_popupmenu_qt4.h +++ /dev/null @@ -1,89 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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_tabdialog.cpp b/src/kvilib/tal/kvi_tal_tabdialog.cpp index ea5f09b6a..d68e4fc90 100644 --- a/src/kvilib/tal/kvi_tal_tabdialog.cpp +++ b/src/kvilib/tal/kvi_tal_tabdialog.cpp @@ -25,10 +25,4 @@ #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 - +#include "kvi_tal_tabdialog.moc" diff --git a/src/kvilib/tal/kvi_tal_tabdialog.h b/src/kvilib/tal/kvi_tal_tabdialog.h index 2372bf63c..951f9636f 100644 --- a/src/kvilib/tal/kvi_tal_tabdialog.h +++ b/src/kvilib/tal/kvi_tal_tabdialog.h @@ -27,10 +27,15 @@ #include "kvi_settings.h" -#ifdef COMPILE_USE_QT4 - #include "kvi_tal_tabdialog_qt4.h" -#else - #include "kvi_tal_tabdialog_qt3.h" -#endif +#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_H_ diff --git a/src/kvilib/tal/kvi_tal_tabdialog_qt3.h b/src/kvilib/tal/kvi_tal_tabdialog_qt3.h deleted file mode 100644 index 3941c99ff..000000000 --- a/src/kvilib/tal/kvi_tal_tabdialog_qt3.h +++ /dev/null @@ -1,39 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 deleted file mode 100644 index 4862596a3..000000000 --- a/src/kvilib/tal/kvi_tal_tabdialog_qt4.h +++ /dev/null @@ -1,39 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 index 4ee16dcb2..d0002b6ff 100644 --- a/src/kvilib/tal/kvi_tal_textedit.cpp +++ b/src/kvilib/tal/kvi_tal_textedit.cpp @@ -26,9 +26,4 @@ #include "kvi_tal_textedit.h" -#ifdef COMPILE_USE_QT4 - #include "kvi_tal_textedit_qt4.moc" -#else - #include "kvi_tal_textedit_qt3.moc" -#endif - +#include "kvi_tal_textedit.moc" diff --git a/src/kvilib/tal/kvi_tal_textedit.h b/src/kvilib/tal/kvi_tal_textedit.h index c3c904516..348816015 100644 --- a/src/kvilib/tal/kvi_tal_textedit.h +++ b/src/kvilib/tal/kvi_tal_textedit.h @@ -27,10 +27,15 @@ #include "kvi_settings.h" -#ifdef COMPILE_USE_QT4 - #include "kvi_tal_textedit_qt4.h" -#else - #include "kvi_tal_textedit_qt3.h" -#endif +#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_H_ diff --git a/src/kvilib/tal/kvi_tal_textedit_qt3.h b/src/kvilib/tal/kvi_tal_textedit_qt3.h deleted file mode 100644 index ca5d2dfb0..000000000 --- a/src/kvilib/tal/kvi_tal_textedit_qt3.h +++ /dev/null @@ -1,39 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 deleted file mode 100644 index 22c3a76d2..000000000 --- a/src/kvilib/tal/kvi_tal_textedit_qt4.h +++ /dev/null @@ -1,39 +0,0 @@ -#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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, 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_ |
