Diffstat (limited to 'kaddressbook/views/contactlistview.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/contactlistview.h | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h new file mode 100644 index 0000000..ae9c994 --- a/dev/null +++ b/kaddressbook/views/contactlistview.h | |||
@@ -0,0 +1,128 @@ | |||
1 | #ifndef CONTACTLISTVIEW_H | ||
2 | #define CONTACTLISTVIEW_H | ||
3 | |||
4 | #include <qcolor.h> | ||
5 | #include <qpixmap.h> | ||
6 | #include <qtooltip.h> | ||
7 | #include <qstring.h> | ||
8 | |||
9 | #include <klistview.h> | ||
10 | |||
11 | #include <kabc/field.h> | ||
12 | #include <kabc/addressee.h> | ||
13 | #include <kabc/addressbook.h> | ||
14 | |||
15 | |||
16 | class QDropEvent; | ||
17 | class KAddressBookTableView; | ||
18 | class ContactListView; | ||
19 | |||
20 | /** The whole tooltip design needs a lot of work. Currently it is | ||
21 | * hacked together to function. | ||
22 | */ | ||
23 | class DynamicTip : public QToolTip | ||
24 | { | ||
25 | public: | ||
26 | DynamicTip( ContactListView * parent ); | ||
27 | |||
28 | protected: | ||
29 | void maybeTip( const QPoint & ); | ||
30 | |||
31 | private: | ||
32 | }; | ||
33 | |||
34 | class ContactListViewItem : public KListViewItem | ||
35 | { | ||
36 | |||
37 | public: | ||
38 | ContactListViewItem(const KABC::Addressee &a, ContactListView* parent, | ||
39 | KABC::AddressBook *doc, const KABC::Field::List &fields ); | ||
40 | const KABC::Addressee &addressee() const { return mAddressee; } | ||
41 | virtual void refresh(); | ||
42 | virtual ContactListView* parent(); | ||
43 | virtual QString key ( int, bool ) const; | ||
44 | |||
45 | /** Adds the border around the cell if the user wants it. | ||
46 | * This is how the single line config option is implemented. | ||
47 | */ | ||
48 | virtual void paintCell(QPainter * p, const QColorGroup & cg, | ||
49 | int column, int width, int align ); | ||
50 | |||
51 | private: | ||
52 | KABC::Addressee mAddressee; | ||
53 | KABC::Field::List mFields; | ||
54 | ContactListView *parentListView; | ||
55 | KABC::AddressBook *mDocument; | ||
56 | }; | ||
57 | |||
58 | |||
59 | ///////////////////////////////////////////// | ||
60 | // ContactListView | ||
61 | |||
62 | class ContactListView : public KListView | ||
63 | { | ||
64 | Q_OBJECT | ||
65 | |||
66 | public: | ||
67 | ContactListView(KAddressBookTableView *view, | ||
68 | KABC::AddressBook *doc, | ||
69 | QWidget *parent, | ||
70 | const char *name = 0L ); | ||
71 | virtual ~ContactListView() {} | ||
72 | //void resort(); | ||
73 | |||
74 | /** Returns true if tooltips should be displayed, false otherwise | ||
75 | */ | ||
76 | bool tooltips() const { return mToolTips; } | ||
77 | void setToolTipsEnabled(bool enabled) { mToolTips = enabled; } | ||
78 | |||
79 | bool alternateBackground() const { return mABackground; } | ||
80 | void setAlternateBackgroundEnabled(bool enabled); | ||
81 | |||
82 | bool singleLine() const { return mSingleLine; } | ||
83 | void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; } | ||
84 | |||
85 | const QColor &alternateColor() const { return mAlternateColor; } | ||
86 | |||
87 | /** Sets the background pixmap to <i>filename</i>. If the | ||
88 | * QString is empty (QString::isEmpty()), then the background | ||
89 | * pixmap will be disabled. | ||
90 | */ | ||
91 | void setBackgroundPixmap(const QString &filename); | ||
92 | |||
93 | protected: | ||
94 | /** Paints the background pixmap in the empty area. This method is needed | ||
95 | * since Qt::FixedPixmap will not scroll with the list view. | ||
96 | */ | ||
97 | virtual void paintEmptyArea( QPainter * p, const QRect & rect ); | ||
98 | virtual void contentsMousePressEvent(QMouseEvent*); | ||
99 | void contentsMouseMoveEvent( QMouseEvent *e ); | ||
100 | void contentsDropEvent( QDropEvent *e ); | ||
101 | virtual bool acceptDrag(QDropEvent *e) const; | ||
102 | |||
103 | protected slots: | ||
104 | void itemDropped(QDropEvent *e); | ||
105 | |||
106 | public slots: | ||
107 | |||
108 | signals: | ||
109 | void startAddresseeDrag(); | ||
110 | void addresseeDropped(QDropEvent *); | ||
111 | |||
112 | private: | ||
113 | KAddressBookTableView *pabWidget; | ||
114 | int oldColumn; | ||
115 | int column; | ||
116 | bool ascending; | ||
117 | |||
118 | bool mABackground; | ||
119 | bool mSingleLine; | ||
120 | bool mToolTips; | ||
121 | |||
122 | QColor mAlternateColor; | ||
123 | |||
124 | QPoint presspos; | ||
125 | }; | ||
126 | |||
127 | |||
128 | #endif | ||