-rw-r--r-- | core/pim/todo/todoview.h | 82 |
1 files changed, 9 insertions, 73 deletions
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h index e5c77f9..e73e808 100644 --- a/core/pim/todo/todoview.h +++ b/core/pim/todo/todoview.h | |||
@@ -1,188 +1,124 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef TODO_VIEW_H | 29 | #ifndef TODO_VIEW_H |
30 | #define TODO_VIEW_H | 30 | #define TODO_VIEW_H |
31 | 31 | ||
32 | #include <qarray.h> | 32 | #include <qarray.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qvaluelist.h> | 34 | #include <qvaluelist.h> |
35 | #include <qwidget.h> | 35 | #include <qwidget.h> |
36 | 36 | ||
37 | #include <opie/otodoaccess.h> | 37 | #include <opie/otodoaccess.h> |
38 | 38 | ||
39 | #include "smalltodo.h" | 39 | #include "smalltodo.h" |
40 | 40 | ||
41 | 41 | ||
42 | namespace Todo { | 42 | namespace Todo { |
43 | |||
44 | /** | ||
45 | * According to tronical it's not possible | ||
46 | * to have Q_OBJECT in a template at all | ||
47 | * so this is a hack widget not meant | ||
48 | * to be public | ||
49 | */ | ||
50 | class InternQtHack : public QObject { | ||
51 | Q_OBJECT | ||
52 | public: | ||
53 | InternQtHack() : QObject() {}; | ||
54 | void emitShow(int uid) { emit showTodo(uid); } | ||
55 | void emitEdit(int uid) { emit edit(uid ); } | ||
56 | void emitUpdate( int uid, | ||
57 | const SmallTodo& to) { | ||
58 | emit update(uid, to ); | ||
59 | } | ||
60 | void emitUpdate( int uid, | ||
61 | const OTodo& ev ){ | ||
62 | emit update(uid, ev ); | ||
63 | } | ||
64 | void emitRemove( int uid ) { | ||
65 | emit remove( uid ); | ||
66 | } | ||
67 | void emitUpdate( QWidget* wid ) { | ||
68 | emit update( wid ); | ||
69 | } | ||
70 | signals: | ||
71 | void showTodo(int uid ); | ||
72 | void edit(int uid ); | ||
73 | void update( int uid, const Todo::SmallTodo& ); | ||
74 | void update( int uid, const OTodo& ); | ||
75 | /* sorry you need to cast */; | ||
76 | void update( QWidget* wid ); | ||
77 | void remove( int uid ); | ||
78 | |||
79 | }; | ||
80 | class MainWindow; | 43 | class MainWindow; |
81 | 44 | ||
82 | /** | 45 | /** |
83 | * due to inheretince problems we need this base class | 46 | * due to inheretince problems we need this base class |
84 | */ | 47 | */ |
85 | class ViewBase { | 48 | struct ViewBase { |
86 | public: | 49 | public: |
87 | virtual QWidget* widget() = 0; | 50 | virtual QWidget* widget() = 0; |
88 | virtual QString type()const = 0; | 51 | virtual QString type()const = 0; |
89 | virtual int current() = 0; | 52 | virtual int current() = 0; |
90 | virtual QString currentRepresentation() = 0; | 53 | virtual QString currentRepresentation() = 0; |
91 | virtual void showOverDue( bool ) = 0; | 54 | virtual void showOverDue( bool ) = 0; |
92 | 55 | ||
93 | /* | 56 | /* |
94 | * update the view | 57 | * update the view |
95 | */ | 58 | */ |
96 | virtual void updateView() = 0; | 59 | virtual void updateView() = 0; |
97 | 60 | ||
98 | virtual void addEvent( const OTodo& ) = 0; | 61 | virtual void addEvent( const OTodo& ) = 0; |
99 | virtual void replaceEvent( const OTodo& ) = 0; | 62 | virtual void replaceEvent( const OTodo& ) = 0; |
100 | virtual void removeEvent( int uid ) = 0; | 63 | virtual void removeEvent( int uid ) = 0; |
101 | virtual void setShowCompleted( bool ) = 0; | 64 | virtual void setShowCompleted( bool ) = 0; |
102 | virtual void setShowDeadline( bool ) = 0; | 65 | virtual void setShowDeadline( bool ) = 0; |
103 | virtual void setShowCategory( const QString& = QString::null ) = 0; | 66 | virtual void setShowCategory( const QString& = QString::null ) = 0; |
104 | virtual void clear() = 0; | 67 | virtual void clear() = 0; |
105 | /* virtual QArray<int> completed() = 0; */ | ||
106 | virtual void newDay() = 0; | 68 | virtual void newDay() = 0; |
107 | |||
108 | virtual void connectShow( QObject*, const char* ) = 0; | ||
109 | virtual void connectEdit( QObject*, const char* ) = 0; | ||
110 | virtual void connectUpdateSmall( QObject*, const char* ) = 0; | ||
111 | virtual void connectUpdateBig( QObject*, const char* ) = 0; | ||
112 | virtual void connectUpdateView( QObject*, const char*) = 0; | ||
113 | virtual void connectRemove( QObject*, const char* ) = 0; | ||
114 | |||
115 | }; | 69 | }; |
116 | 70 | ||
117 | /** | 71 | /** |
118 | * A base class for all TodoView which are showing | 72 | * A base class for all TodoView which are showing |
119 | * a list of todos. | 73 | * a list of todos. |
120 | * Either in a QTable, QListView or any other QWidget | 74 | * Either in a QTable, QListView or any other QWidget |
121 | * derived class | 75 | * derived class |
122 | * Through the MainWindow( dispatcher ) one can access | 76 | * Through the MainWindow( dispatcher ) one can access |
123 | * the relevant informations | 77 | * the relevant informations |
124 | * | 78 | * |
125 | * It's not possible to have signal and slots from within | 79 | * It's not possible to have signal and slots from within |
126 | * templates this way you've to register for a signal | 80 | * templates this way you've to register for a signal |
127 | */ | 81 | */ |
128 | class TodoView : public ViewBase{ | 82 | class TodoView : public ViewBase{ |
129 | 83 | ||
130 | public: | 84 | public: |
131 | /** | 85 | /** |
132 | * c'tor | 86 | * c'tor |
133 | */ | 87 | */ |
134 | TodoView( MainWindow* win ); | 88 | TodoView( MainWindow* win ); |
135 | 89 | ||
136 | /** | 90 | /** |
137 | *d'tor | 91 | *d'tor |
138 | */ | 92 | */ |
139 | virtual ~TodoView(); | 93 | virtual ~TodoView(); |
140 | 94 | ||
141 | /* connect to the show signal */ | ||
142 | void connectShow(QObject* obj, | ||
143 | const char* slot ); | ||
144 | |||
145 | /* connect to edit */ | ||
146 | void connectEdit( QObject* obj, | ||
147 | const char* slot ); | ||
148 | void connectUpdateSmall( QObject* obj, | ||
149 | const char* slot ); | ||
150 | void connectUpdateBig( QObject* obj, | ||
151 | const char* slot ) ; | ||
152 | void connectUpdateView( QObject* obj, | ||
153 | const char* slot ); | ||
154 | void connectRemove( QObject* obj, | ||
155 | const char* slot ); | ||
156 | protected: | 95 | protected: |
157 | MainWindow* todoWindow(); | 96 | MainWindow* todoWindow(); |
158 | OTodo event(int uid ); | 97 | OTodo event(int uid ); |
159 | OTodoAccess::List list(); | 98 | OTodoAccess::List list(); |
160 | OTodoAccess::List sorted()const; | 99 | OTodoAccess::List sorted()const; |
161 | void sort(); | 100 | void sort(); |
162 | void sort(int sort ); | 101 | void sort(int sort ); |
163 | void setSortOrder( int order ); | 102 | void setSortOrder( int order ); |
164 | void setAscending( bool ); | 103 | void setAscending( bool ); |
165 | 104 | ||
166 | /* | 105 | /* |
167 | These things needs to be implemented | 106 | * These things needs to be implemented |
168 | in a implementation | 107 | * in a implementation |
169 | signals: | 108 | */ |
170 | */ | 109 | void showTodo( int uid ); |
171 | protected: | 110 | void edit( int uid ); |
172 | void showTodo( int uid ) { hack->emitShow(uid); } | ||
173 | void edit( int uid ) { hack->emitEdit(uid); } | ||
174 | void update(int uid, const SmallTodo& to ); | 111 | void update(int uid, const SmallTodo& to ); |
175 | void update(int uid, const OTodo& ev); | 112 | void update(int uid, const OTodo& ev); |
176 | void remove( int uid ) { | 113 | void remove( int uid ); |
177 | hack->emitRemove( uid ); | 114 | void complete( int uid ); |
178 | } | 115 | void complete( const OTodo& ev ); |
179 | private: | 116 | private: |
180 | InternQtHack* hack; | ||
181 | MainWindow *m_main; | 117 | MainWindow *m_main; |
182 | OTodoAccess::List m_sort; | 118 | OTodoAccess::List m_sort; |
183 | bool m_asc : 1; | 119 | bool m_asc : 1; |
184 | int m_sortOrder; | 120 | int m_sortOrder; |
185 | }; | 121 | }; |
186 | }; | 122 | }; |
187 | 123 | ||
188 | #endif | 124 | #endif |