KVIrc  4.9.2
DeveloperAPIs
KviTreeWindowList.h
Go to the documentation of this file.
1 #ifndef _KVI_WINDOWLIST_TREE_H_
2 #define _KVI_WINDOWLIST_TREE_H_
3 //=============================================================================
4 //
5 // File : KviTreeWindowList.h
6 // Creation date : Thu Jan 7 1999 03:56:50 by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 1999-2010 Szymon Stefanek (pragma at kvirc dot net)
10 //
11 // This program is FREE software. You can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the HOPE that it will be USEFUL,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 // See the GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 #include "KviWindowListBase.h"
28 #include <QTreeWidget>
29 #include <QStyledItemDelegate>
30 #include <QAbstractItemView>
31 
32 class KviTreeWindowList;
33 class KviTreeWindowListItemInternal;
34 
35 class KVIRC_API KviTreeWindowListItem : public QTreeWidgetItem, public KviWindowListItem
36 {
37  friend class KviTreeWindowList;
39  friend class KviTreeWindowListItemInternal;
40 
41 public:
42  KviTreeWindowListItem(QTreeWidget * par, KviWindow * wnd);
45 
46 public:
47  virtual QString key() const;
48  virtual void captionChanged();
49  virtual void highlight(int iLevel = 1);
50  virtual void unhighlight();
51  virtual void setProgress(int progress);
52  virtual void applyOptions();
53 
54 protected:
55  void setActive(bool bActive);
56  bool operator<(const QTreeWidgetItem & other) const
57  {
58  return key() < ((KviTreeWindowListItem *)&other)->key();
59  }
60 };
61 
62 class KVIRC_API KviTreeWindowListTreeWidget : public QTreeWidget
63 {
64  friend class KviTreeWindowListItem;
66  Q_OBJECT
67 public:
68  KviTreeWindowListTreeWidget(QWidget * par);
70  bool isReverseSort() { return bReverseSort; };
71 protected:
72  virtual void mousePressEvent(QMouseEvent * e);
73  virtual void mouseMoveEvent(QMouseEvent * e);
74  virtual void wheelEvent(QWheelEvent * e);
75  virtual void mouseDoubleClickEvent(QMouseEvent * e);
76  virtual void paintEvent(QPaintEvent * event);
77 
78 private:
79  KviWindowListItem * lastItem();
81 public slots:
82  void sort();
83  void reverseSort();
84 };
85 
87 {
88  Q_OBJECT
89 public:
92 
93 private:
97  QStyledItemDelegate * m_pItemDelegate;
98 
99 public:
100  virtual KviWindowListItem * addItem(KviWindow *);
101  virtual bool removeItem(KviWindowListItem *);
102  virtual void setActiveItem(KviWindowListItem *);
103  virtual KviWindowListItem * firstItem();
104  virtual KviWindowListItem * nextItem(void);
105  virtual KviWindowListItem * lastItem();
106  virtual KviWindowListItem * prevItem(void);
107  virtual bool setIterationPointer(KviWindowListItem * it);
108  virtual void updatePseudoTransparency();
109  virtual void updateActivityMeter();
110 
111 protected:
112  virtual void moveEvent(QMoveEvent *);
113 protected slots:
114  void tipRequest(KviDynamicToolTip * tip, const QPoint & pnt);
115 };
116 
117 #define KVI_TTBID_HIGHLIGHT Qt::UserRole
118 #define KVI_TTBID_PROGRESS Qt::UserRole + 1
119 
120 class KVIRC_API KviTreeWindowListItemDelegate : public QStyledItemDelegate
121 {
122  Q_OBJECT
123 public:
124  KviTreeWindowListItemDelegate(QAbstractItemView * pWidget = 0)
125  : QStyledItemDelegate(pWidget){};
127  QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
128  void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
129 };
130 
131 #endif //_KVI_WINDOWLIST_TREE_H_
KviTreeWindowListItemDelegate(QAbstractItemView *pWidget=0)
Definition: KviTreeWindowList.h:124
Definition: KviDynamicToolTip.h:49
#define KVIRC_API
Definition: kvi_settings.h:128
virtual void updateActivityMeter()
Definition: KviWindowListBase.cpp:93
bool isReverseSort()
Definition: KviTreeWindowList.h:70
virtual bool setIterationPointer(KviWindowListItem *)
Definition: KviWindowListBase.h:99
virtual void captionChanged()
Definition: KviWindowListBase.h:62
KviTreeWindowListItem * m_pCurrentItem
Definition: KviTreeWindowList.h:95
virtual void setProgress(int)
Definition: KviWindowListBase.h:64
virtual KviWindowListItem * addItem(KviWindow *)
Definition: KviWindowListBase.h:91
#define e
Definition: detector.cpp:69
virtual void updatePseudoTransparency()
Definition: KviWindowListBase.h:101
virtual KviWindowListItem * nextItem()
Definition: KviWindowListBase.h:96
virtual KviWindowListItem * lastItem(void)
Definition: KviWindowListBase.h:95
Definition: KviTreeWindowList.h:120
KviTreeWindowListTreeWidget * m_pTreeWidget
Definition: KviTreeWindowList.h:94
Definition: KviTreeWindowList.h:62
virtual void highlight(int)
Definition: KviWindowListBase.h:63
virtual void setActiveItem(KviWindowListItem *)
Definition: KviWindowListBase.h:93
Definition: KviTreeWindowList.h:86
QStyledItemDelegate * m_pItemDelegate
Definition: KviTreeWindowList.h:97
~KviTreeWindowListItemDelegate()
Definition: KviTreeWindowList.h:126
Base class for all windows in KVIrc.
Definition: KviWindow.h:74
virtual KviWindowListItem * firstItem()
Definition: KviWindowListBase.h:94
Definition: KviTreeWindowList.h:35
virtual bool removeItem(KviWindowListItem *)
Definition: KviWindowListBase.h:92
Definition: KviWindowListBase.h:77
bool operator<(const QTreeWidgetItem &other) const
Definition: KviTreeWindowList.h:56
virtual KviWindowListItem * prevItem(void)
Definition: KviWindowListBase.h:97
bool bReverseSort
Definition: KviTreeWindowList.h:80
KviDynamicToolTip * m_pToolTip
Definition: KviTreeWindowList.h:96
Definition: KviWindowListBase.h:49
virtual void unhighlight()
Definition: KviWindowListBase.h:66