-rw-r--r-- | core/pim/todo/todotable.h | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h index 4f3a064..2746ce7 100644 --- a/core/pim/todo/todotable.h +++ b/core/pim/todo/todotable.h | |||
@@ -2,49 +2,50 @@ | |||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef TODOTABLE_H | 21 | #ifndef TODOTABLE_H |
22 | #define TODOTABLE_H | 22 | #define TODOTABLE_H |
23 | 23 | ||
24 | #include <qpe/categories.h> | 24 | #include <qpe/categories.h> |
25 | #include <qpe/stringutil.h> | 25 | #include <qpe/stringutil.h> |
26 | #include <qpe/task.h> | 26 | //#include <qpe/task.h> |
27 | #include <opie/todoevent.h> | ||
27 | 28 | ||
28 | #include <qtable.h> | 29 | #include <qtable.h> |
29 | #include <qmap.h> | 30 | #include <qmap.h> |
30 | #include <qguardedptr.h> | 31 | #include <qguardedptr.h> |
31 | 32 | ||
32 | class Node; | 33 | class Node; |
33 | class QComboBox; | 34 | class QComboBox; |
34 | class QTimer; | 35 | class QTimer; |
35 | 36 | ||
36 | class CheckItem : public QTableItem | 37 | class CheckItem : public QTableItem |
37 | { | 38 | { |
38 | public: | 39 | public: |
39 | CheckItem( QTable *t, const QString &sortkey ); | 40 | CheckItem( QTable *t, const QString &sortkey ); |
40 | 41 | ||
41 | void setChecked( bool b ); | 42 | void setChecked( bool b ); |
42 | void toggle(); | 43 | void toggle(); |
43 | bool isChecked() const; | 44 | bool isChecked() const; |
44 | void setKey( const QString &key ) { sortKey = key; } | 45 | void setKey( const QString &key ) { sortKey = key; } |
45 | QString key() const; | 46 | QString key() const; |
46 | 47 | ||
47 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); | 48 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); |
48 | 49 | ||
49 | private: | 50 | private: |
50 | bool checked; | 51 | bool checked; |
@@ -65,124 +66,124 @@ public: | |||
65 | private: | 66 | private: |
66 | QGuardedPtr<QComboBox> cb; | 67 | QGuardedPtr<QComboBox> cb; |
67 | 68 | ||
68 | }; | 69 | }; |
69 | 70 | ||
70 | class TodoTextItem : public QTableItem | 71 | class TodoTextItem : public QTableItem |
71 | { | 72 | { |
72 | public: | 73 | public: |
73 | TodoTextItem( QTable *t, const QString & str ) | 74 | TodoTextItem( QTable *t, const QString & str ) |
74 | :QTableItem( t, QTableItem::Never, str ) {} | 75 | :QTableItem( t, QTableItem::Never, str ) {} |
75 | 76 | ||
76 | QString key () const { return Qtopia::buildSortKey( text() ); } | 77 | QString key () const { return Qtopia::buildSortKey( text() ); } |
77 | }; | 78 | }; |
78 | 79 | ||
79 | 80 | ||
80 | 81 | ||
81 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; | 82 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; |
82 | 83 | ||
83 | class TodoTable : public QTable | 84 | class TodoTable : public QTable |
84 | { | 85 | { |
85 | Q_OBJECT | 86 | Q_OBJECT |
86 | 87 | ||
87 | public: | 88 | public: |
88 | TodoTable( QWidget *parent = 0, const char * name = 0 ); | 89 | TodoTable( QWidget *parent = 0, const char * name = 0 ); |
89 | void addEntry( const Task &todo ); | 90 | void addEntry( const ToDoEvent &todo ); |
90 | void clearFindRow() { currFindRow = -2; } | 91 | void clearFindRow() { currFindRow = -2; } |
91 | 92 | ||
92 | Task currentEntry() const; | 93 | ToDoEvent currentEntry() const; |
93 | void replaceCurrentEntry( const Task &todo, bool fromTableItem = false ); | 94 | void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false ); |
94 | 95 | ||
95 | QStringList categories(); | 96 | QStringList categories(); |
96 | 97 | ||
97 | void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } | 98 | void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } |
98 | bool showCompleted() const { return showComp; } | 99 | bool showCompleted() const { return showComp; } |
99 | 100 | ||
100 | void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } | 101 | void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } |
101 | const QString &showCategory() const { return showCat; } | 102 | const QString &showCategory() const { return showCat; } |
102 | int showCategoryId() const; | 103 | int showCategoryId() const; |
103 | 104 | ||
104 | bool save( const QString &fn ); | 105 | bool save( const QString &fn ); |
105 | void load( const QString &fn ); | 106 | void load( const QString &fn ); |
106 | void clear(); | 107 | void clear(); |
107 | void removeCurrentEntry(); | 108 | void removeCurrentEntry(); |
108 | 109 | ||
109 | void setPaintingEnabled( bool e ); | 110 | void setPaintingEnabled( bool e ); |
110 | 111 | ||
111 | virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ ); | 112 | virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ ); |
112 | 113 | ||
113 | // int rowHeight( int ) const; | 114 | // int rowHeight( int ) const; |
114 | // int rowPos( int row ) const; | 115 | // int rowPos( int row ) const; |
115 | // virtual int rowAt( int pos ) const; | 116 | // virtual int rowAt( int pos ) const; |
116 | 117 | ||
117 | signals: | 118 | signals: |
118 | void signalEdit(); | 119 | void signalEdit(); |
119 | void signalDoneChanged( bool b ); | 120 | void signalDoneChanged( bool b ); |
120 | void signalPriorityChanged( int i ); | 121 | void signalPriorityChanged( int i ); |
121 | void signalShowMenu( const QPoint & ); | 122 | void signalShowMenu( const QPoint & ); |
122 | void signalNotFound(); | 123 | void signalNotFound(); |
123 | void signalWrapAround(); | 124 | void signalWrapAround(); |
124 | 125 | ||
125 | protected: | 126 | protected: |
126 | void keyPressEvent( QKeyEvent *e ); | 127 | void keyPressEvent( QKeyEvent *e ); |
127 | 128 | ||
128 | private: | 129 | private: |
129 | void updateVisible(); | 130 | void updateVisible(); |
130 | void viewportPaintEvent( QPaintEvent * ); | 131 | void viewportPaintEvent( QPaintEvent * ); |
131 | void internalAddEntries( QList<Task> &list); | 132 | void internalAddEntries( QList<ToDoEvent> &list); |
132 | inline void insertIntoTable( Task *todo, int row ); | 133 | inline void insertIntoTable( ToDoEvent *todo, int row ); |
133 | void updateJournal( const Task &todo, journal_action action, int row = -1); | 134 | void updateJournal( const ToDoEvent &todo, journal_action action, int row = -1); |
134 | void mergeJournal(); | 135 | void mergeJournal(); |
135 | void journalFreeReplaceEntry( const Task &todo, int row ); | 136 | void journalFreeReplaceEntry( const ToDoEvent &todo, int row ); |
136 | void journalFreeRemoveEntry( int row ); | 137 | void journalFreeRemoveEntry( int row ); |
137 | inline void realignTable( int row ); | 138 | inline void realignTable( int row ); |
138 | void loadFile( const QString &strFile, bool fromJournal = false ); | 139 | void loadFile( const QString &strFile, bool fromJournal = false ); |
139 | 140 | ||
140 | private slots: | 141 | private slots: |
141 | void slotClicked( int row, int col, int button, const QPoint &pos ); | 142 | void slotClicked( int row, int col, int button, const QPoint &pos ); |
142 | void slotPressed( int row, int col, int button, const QPoint &pos ); | 143 | void slotPressed( int row, int col, int button, const QPoint &pos ); |
143 | void slotCheckPriority(int row, int col ); | 144 | void slotCheckPriority(int row, int col ); |
144 | void slotCurrentChanged(int row, int col ); | 145 | void slotCurrentChanged(int row, int col ); |
145 | void slotDoFind( const QString &findString, bool caseSensetive, | 146 | void slotDoFind( const QString &findString, bool caseSensetive, |
146 | bool backwards, int category ); | 147 | bool backwards, int category ); |
147 | void slotShowMenu(); | 148 | void slotShowMenu(); |
148 | void rowHeightChanged( int row ); | 149 | void rowHeightChanged( int row ); |
149 | 150 | ||
150 | private: | 151 | private: |
151 | friend class TodoWindow; | 152 | friend class TodoWindow; |
152 | 153 | ||
153 | QMap<CheckItem*, Task *> todoList; | 154 | QMap<CheckItem*, ToDoEvent *> todoList; |
154 | QStringList categoryList; | 155 | QStringList categoryList; |
155 | bool showComp; | 156 | bool showComp; |
156 | QString showCat; | 157 | QString showCat; |
157 | QTimer *menuTimer; | 158 | QTimer *menuTimer; |
158 | bool enablePainting; | 159 | bool enablePainting; |
159 | Categories mCat; | 160 | Categories mCat; |
160 | int currFindRow; | 161 | int currFindRow; |
161 | }; | 162 | }; |
162 | 163 | ||
163 | 164 | ||
164 | inline void TodoTable::insertIntoTable( Task *todo, int row ) | 165 | inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) |
165 | { | 166 | { |
166 | QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') | 167 | QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') |
167 | + todo->priority() ) | 168 | + todo->priority() ) |
168 | + Qtopia::buildSortKey( todo->description() ); | 169 | + Qtopia::buildSortKey( todo->description() ); |
169 | CheckItem *chk = new CheckItem( this, sortKey ); | 170 | CheckItem *chk = new CheckItem( this, sortKey ); |
170 | chk->setChecked( todo->isCompleted() ); | 171 | chk->setChecked( todo->isCompleted() ); |
171 | ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); | 172 | ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); |
172 | cmb->setText( QString::number( todo->priority() ) ); | 173 | cmb->setText( QString::number( todo->priority() ) ); |
173 | QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() ); | 174 | QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() ); |
174 | ti->setReplaceable( false ); | 175 | ti->setReplaceable( false ); |
175 | 176 | ||
176 | setItem( row, 0, chk ); | 177 | setItem( row, 0, chk ); |
177 | setItem( row, 1, cmb ); | 178 | setItem( row, 1, cmb ); |
178 | setItem( row, 2, ti ); | 179 | setItem( row, 2, ti ); |
179 | 180 | ||
180 | todoList.insert( chk, todo ); | 181 | todoList.insert( chk, todo ); |
181 | } | 182 | } |
182 | 183 | ||
183 | inline void TodoTable::realignTable( int row ) | 184 | inline void TodoTable::realignTable( int row ) |
184 | { | 185 | { |
185 | QTableItem *ti1, | 186 | QTableItem *ti1, |
186 | *ti2, | 187 | *ti2, |
187 | *ti3; | 188 | *ti3; |
188 | int totalRows = numRows(); | 189 | int totalRows = numRows(); |