-rw-r--r-- | libopie/libopie.pro | 33 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.cpp | 345 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.h | 125 | ||||
-rw-r--r-- | libopie/ofileselector/olister.h | 1 | ||||
-rw-r--r-- | libopie/pim/opimrecord.cpp | 26 | ||||
-rw-r--r-- | libopie/pim/opimrecord.h | 4 | ||||
-rw-r--r-- | libopie/pim/otodo.cpp | 265 | ||||
-rw-r--r-- | libopie/pim/otodo.h | 26 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.cpp | 26 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.h | 4 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.cpp | 265 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.h | 26 |
12 files changed, 443 insertions, 703 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro index 6c47e86..70be6ac 100644 --- a/libopie/libopie.pro +++ b/libopie/libopie.pro | |||
@@ -1,40 +1,61 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on release | 2 | CONFIG += qte warn_on release |
3 | HEADERS = ofontmenu.h ofileselector.h \ | 3 | HEADERS = ofontmenu.h \ |
4 | ofiledialog.h tododb.h \ | 4 | tododb.h \ |
5 | todoevent.h todoresource.h \ | 5 | todoevent.h todoresource.h \ |
6 | todovcalresource.h xmltree.h \ | 6 | todovcalresource.h xmltree.h \ |
7 | colordialog.h colorpopupmenu.h \ | 7 | colordialog.h colorpopupmenu.h \ |
8 | oclickablelabel.h oprocctrl.h \ | 8 | oclickablelabel.h oprocctrl.h \ |
9 | oprocess.h odevice.h \ | 9 | oprocess.h odevice.h \ |
10 | otimepicker.h otabwidget.h \ | 10 | otimepicker.h otabwidget.h \ |
11 | otabbar.h otabinfo.h | 11 | otabbar.h otabinfo.h \ |
12 | SOURCES = ofontmenu.cc ofileselector.cc \ | 12 | ofileselector/ofiledialog.h \ |
13 | ofiledialog.cc xmltree.cc \ | 13 | ofileselector/ofilelistview.h \ |
14 | ofileselector/ofileselector.h \ | ||
15 | ofileselector/ofileselectoritem.h \ | ||
16 | ofileselector/ofileview.h \ | ||
17 | ofileselector/olister.h \ | ||
18 | ofileselector/olocallister.h \ | ||
19 | ofileselector/ofileselectormain.h \ | ||
20 | pim/opimrecord.h \ | ||
21 | pim/otodo.h | ||
22 | |||
23 | SOURCES = ofontmenu.cc \ | ||
24 | xmltree.cc \ | ||
14 | tododb.cpp todoevent.cpp \ | 25 | tododb.cpp todoevent.cpp \ |
15 | todovcalresource.cpp colordialog.cpp \ | 26 | todovcalresource.cpp colordialog.cpp \ |
16 | colorpopupmenu.cpp oclickablelabel.cpp \ | 27 | colorpopupmenu.cpp oclickablelabel.cpp \ |
17 | oprocctrl.cpp oprocess.cpp \ | 28 | oprocctrl.cpp oprocess.cpp \ |
18 | odevice.cpp otimepicker.cpp \ | 29 | odevice.cpp otimepicker.cpp \ |
19 | otabwidget.cpp otabbar.cpp | 30 | otabwidget.cpp otabbar.cpp \ |
31 | ofileselector/ofiledialog.cpp \ | ||
32 | ofileselector/ofilelistview.cpp \ | ||
33 | ofileselector/ofileselector.cpp \ | ||
34 | ofileselector/ofileselectoritem.cpp \ | ||
35 | ofileselector/ofileview.cpp \ | ||
36 | ofileselector/olister.cpp \ | ||
37 | ofileselector/olocallister.cpp \ | ||
38 | ofileselector/ofileselectormain.cpp \ | ||
39 | pim/opimrecord.cpp \ | ||
40 | pim/otodo.cpp | ||
20 | TARGET = opie | 41 | TARGET = opie |
21 | INCLUDEPATH += $(OPIEDIR)/include | 42 | INCLUDEPATH += $(OPIEDIR)/include |
22 | DESTDIR = $(QTDIR)/lib$(PROJMAK) | 43 | DESTDIR = $(QTDIR)/lib$(PROJMAK) |
23 | #VERSION = 1.0.0 | 44 | #VERSION = 1.0.0 |
24 | 45 | ||
25 | INTERFACES = otimepickerbase.ui | 46 | INTERFACES = otimepickerbase.ui |
26 | 47 | ||
27 | TRANSLATIONS = ../i18n/de/libopie.ts \ | 48 | TRANSLATIONS = ../i18n/de/libopie.ts \ |
28 | ../i18n/en/libopie.ts \ | 49 | ../i18n/en/libopie.ts \ |
29 | ../i18n/es/libopie.ts \ | 50 | ../i18n/es/libopie.ts \ |
30 | ../i18n/fr/libopie.ts \ | 51 | ../i18n/fr/libopie.ts \ |
31 | ../i18n/hu/libopie.ts \ | 52 | ../i18n/hu/libopie.ts \ |
32 | ../i18n/ja/libopie.ts \ | 53 | ../i18n/ja/libopie.ts \ |
33 | ../i18n/ko/libopie.ts \ | 54 | ../i18n/ko/libopie.ts \ |
34 | ../i18n/no/libopie.ts \ | 55 | ../i18n/no/libopie.ts \ |
35 | ../i18n/pl/libopie.ts \ | 56 | ../i18n/pl/libopie.ts \ |
36 | ../i18n/pt/libopie.ts \ | 57 | ../i18n/pt/libopie.ts \ |
37 | ../i18n/pt_BR/libopie.ts \ | 58 | ../i18n/pt_BR/libopie.ts \ |
38 | ../i18n/sl/libopie.ts \ | 59 | ../i18n/sl/libopie.ts \ |
39 | ../i18n/zh_CN/libopie.ts \ | 60 | ../i18n/zh_CN/libopie.ts \ |
40 | ../i18n/zh_TW/libopie.ts | 61 | ../i18n/zh_TW/libopie.ts |
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp index 98b61f7..c52aa62 100644 --- a/libopie/ofileselector/ofileselector.cpp +++ b/libopie/ofileselector/ofileselector.cpp | |||
@@ -1,65 +1,67 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qcombobox.h> | 4 | #include <qcombobox.h> |
5 | #include <qheader.h> | 5 | #include <qheader.h> |
6 | #include <qlabel.h> | 6 | #include <qlabel.h> |
7 | #include <qabstractlayout.h> | 7 | #include <qabstractlayout.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qlistview.h> | 10 | #include <qlistview.h> |
11 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
12 | #include <qpainter.h> | 12 | #include <qpainter.h> |
13 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
14 | #include <qwidgetstack.h> | 14 | #include <qwidgetstack.h> |
15 | #include <qpopupmenu.h> | 15 | #include <qpopupmenu.h> |
16 | #include <qdir.h> | 16 | #include <qdir.h> |
17 | #include <qfile.h> | 17 | #include <qfile.h> |
18 | #include <qfileinfo.h> | 18 | #include <qfileinfo.h> |
19 | #include <qtimer.h> | 19 | #include <qtimer.h> |
20 | 20 | ||
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/applnk.h> | 22 | #include <qpe/applnk.h> |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/mimetype.h> | 24 | #include <qpe/mimetype.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/storage.h> | 26 | #include <qpe/storage.h> |
27 | 27 | ||
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | #include <sys/stat.h> | 30 | #include <sys/stat.h> |
31 | 31 | ||
32 | #include "ofileview.h" | 32 | #include "ofileview.h" |
33 | #include "ofileselectormain.h" | ||
33 | #include "ofileselector.h" | 34 | #include "ofileselector.h" |
35 | #include "olocallister.h" | ||
34 | #include "olister.h" | 36 | #include "olister.h" |
35 | 37 | ||
36 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 38 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
37 | 39 | ||
38 | namespace { | 40 | namespace { |
39 | /* let's find the index for a specified string */ | 41 | /* let's find the index for a specified string */ |
40 | int indexByString( const QComboBox *box, const QString &str ){ | 42 | int indexByString( const QComboBox *box, const QString &str ){ |
41 | int index= 0; | 43 | int index= 0; |
42 | for(int i= 0; i < box->count(); i++ ){ | 44 | for(int i= 0; i < box->count(); i++ ){ |
43 | /* found */ | 45 | /* found */ |
44 | if( str == box->text(i ) ){ | 46 | if( str == box->text(i ) ){ |
45 | index= i; | 47 | index= i; |
46 | break; | 48 | break; |
47 | } | 49 | } |
48 | } | 50 | } |
49 | return index; | 51 | return index; |
50 | } | 52 | } |
51 | } | 53 | } |
52 | 54 | ||
53 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | 55 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, |
54 | const QString &dirName, | 56 | const QString &dirName, |
55 | const QString &fileName, | 57 | const QString &fileName, |
56 | const QMap<QString,QStringList>& mimeTypes) | 58 | const QMap<QString,QStringList>& mimeTypes) |
57 | : QWidget( wid, "OFileSelector") | 59 | : QWidget( wid, "OFileSelector") |
58 | { | 60 | { |
59 | m_mimetypes = mimeTypes; | 61 | m_mimetypes = mimeTypes; |
60 | if (mode == Save ) | 62 | if (mode == Save ) |
61 | m_name = fileName; | 63 | m_name = fileName; |
62 | 64 | ||
63 | initVars(); | 65 | initVars(); |
64 | 66 | ||
65 | m_mode = mode; | 67 | m_mode = mode; |
@@ -72,198 +74,185 @@ OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | |||
72 | const char *name, bool newVisible, | 74 | const char *name, bool newVisible, |
73 | bool closeVisible ) | 75 | bool closeVisible ) |
74 | : QWidget( parent, name ) | 76 | : QWidget( parent, name ) |
75 | { | 77 | { |
76 | /* update the mimefilter */ | 78 | /* update the mimefilter */ |
77 | if (!mimeFilter.isEmpty() ) { | 79 | if (!mimeFilter.isEmpty() ) { |
78 | QStringList list = QStringList::split(";", mimeFilter ); | 80 | QStringList list = QStringList::split(";", mimeFilter ); |
79 | m_mimetypes.insert(mimeFilter, list ); | 81 | m_mimetypes.insert(mimeFilter, list ); |
80 | } | 82 | } |
81 | initVars(); | 83 | initVars(); |
82 | m_currentDir = QPEApplication::documentDir(); | 84 | m_currentDir = QPEApplication::documentDir(); |
83 | m_mode = Fileselector; | 85 | m_mode = Fileselector; |
84 | m_selector = Normal; | 86 | m_selector = Normal; |
85 | m_shClose = closeVisible; | 87 | m_shClose = closeVisible; |
86 | m_shNew = newVisible; | 88 | m_shNew = newVisible; |
87 | m_shLne = false; | 89 | m_shLne = false; |
88 | m_shPerm = false; | 90 | m_shPerm = false; |
89 | m_shYesNo = false; | 91 | m_shYesNo = false; |
90 | init(); | 92 | init(); |
91 | 93 | ||
92 | 94 | ||
93 | } | 95 | } |
94 | 96 | ||
95 | OFileSelector::~OFileSelector() | 97 | OFileSelector::~OFileSelector() |
96 | { | 98 | { |
97 | 99 | ||
98 | 100 | ||
99 | } | 101 | } |
100 | 102 | ||
101 | void OFileSelector::setNewVisible( bool visible ) | 103 | void OFileSelector::setNewVisible( bool visible ) |
102 | { | 104 | { |
103 | m_shNew = visible; | 105 | m_shNew = visible; |
104 | if( m_selector == Normal ){ | 106 | if (m_new ) |
105 | delete m_select; | 107 | m_new->show(); |
106 | // we need to initialize but keep the selected mimetype | ||
107 | QString mime = currentMimeType(); | ||
108 | m_select = new FileSelector( mime , | ||
109 | m_stack, "fileselector", | ||
110 | m_shNew, m_shClose); | ||
111 | |||
112 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
113 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
114 | connect(m_select, SIGNAL(closeMe() ), | ||
115 | this, SIGNAL(closeMe() ) ); | ||
116 | //connect to close me and other signals as well | ||
117 | m_stack->addWidget( m_select, Normal ); | ||
118 | }else{ | ||
119 | m_new->show(); | ||
120 | } | ||
121 | } | 108 | } |
122 | void OFileSelector::setCloseVisible( bool visible ) | 109 | void OFileSelector::setCloseVisible( bool visible ) |
123 | { | 110 | { |
124 | m_shClose = visible; | 111 | m_shClose = visible; |
125 | if( m_selector == Normal ){ | 112 | |
126 | setNewVisible( m_shNew ); // yeah baby | 113 | if( m_close ) |
127 | }else{ | ||
128 | m_close->show(); | 114 | m_close->show(); |
129 | } | ||
130 | } | 115 | } |
131 | void OFileSelector::reread() | 116 | void OFileSelector::reread() |
132 | { | 117 | { |
133 | if( m_selector == Normal ){ | 118 | if( m_selector == Normal ) |
134 | setNewVisible( m_shNew ); // make it a initializeSelector | 119 | initializeOldSelector(); |
135 | }else { | 120 | else |
136 | reparse(); | 121 | reparse(); |
137 | } | ||
138 | } | 122 | } |
139 | 123 | ||
140 | const DocLnk *OFileSelector::selected() | 124 | const DocLnk *OFileSelector::selected() |
141 | { | 125 | { |
142 | DocLnk *lnk = new DocLnk(selectedDocument() ); | 126 | DocLnk *lnk = new DocLnk(selectedDocument() ); |
143 | return lnk; | 127 | return lnk; |
144 | } | 128 | } |
145 | 129 | ||
146 | void OFileSelector::setYesCancelVisible( bool show ) | 130 | void OFileSelector::setYesCancelVisible( bool show ) |
147 | { | 131 | { |
148 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( | 132 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( |
149 | m_shYesNo = show; | 133 | m_shYesNo = show; |
134 | |||
150 | if( m_shYesNo ) | 135 | if( m_shYesNo ) |
151 | m_boxOk->show(); | 136 | m_boxOk->show(); |
152 | else | 137 | else |
153 | m_boxOk->hide(); | 138 | m_boxOk->hide(); |
154 | 139 | ||
155 | } | 140 | } |
156 | void OFileSelector::setToolbarVisible( bool show ) | 141 | void OFileSelector::setToolbarVisible( bool show ) |
157 | { | 142 | { |
158 | m_shTool = show; | 143 | m_shTool = show; |
159 | initializeListView(); // FIXME see above waste of memory | ||
160 | 144 | ||
161 | if(!m_shTool ){ | 145 | if(!m_shTool ){ |
162 | m_location->hide(); | 146 | m_location->hide(); |
163 | m_up->hide(); | 147 | m_up->hide(); |
164 | m_homeButton->hide(); | 148 | m_homeButton->hide(); |
165 | m_docButton->hide(); | 149 | m_docButton->hide(); |
166 | }else{ | 150 | }else{ |
167 | m_location->show(); | 151 | m_location->show(); |
168 | m_up->show(); | 152 | m_up->show(); |
169 | m_homeButton->show(); | 153 | m_homeButton->show(); |
170 | m_docButton->show(); | 154 | m_docButton->show(); |
171 | } | 155 | } |
172 | } | 156 | } |
173 | void OFileSelector::setPermissionBarVisible( bool show ) | 157 | void OFileSelector::setPermissionBarVisible( bool show ) |
174 | { | 158 | { |
175 | m_shPerm = show; | 159 | m_shPerm = show; |
176 | initializePerm(); | 160 | initializePerm(); |
161 | |||
177 | if( m_shPerm ) | 162 | if( m_shPerm ) |
178 | m_checkPerm->show(); | 163 | m_checkPerm->show(); |
179 | else | 164 | else |
180 | m_checkPerm->hide(); | 165 | m_checkPerm->hide(); |
181 | } | 166 | } |
182 | void OFileSelector::setLineEditVisible( bool show ) | 167 | void OFileSelector::setLineEditVisible( bool show ) |
183 | { | 168 | { |
184 | if( show ){ | 169 | if( show ){ |
185 | initializeName(); | 170 | initializeName(); |
186 | m_boxName->show(); | 171 | m_boxName->show(); |
187 | }else{ | 172 | }else{ |
188 | if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go | 173 | // check if we showed before this is the way to go |
189 | m_boxName->hide(); | 174 | if( m_shLne && m_boxName != 0 ) |
190 | } | 175 | m_boxName->hide(); |
191 | } | 176 | } |
192 | m_shLne = show; | 177 | m_shLne = show; |
193 | } | 178 | } |
194 | 179 | ||
195 | void OFileSelector::setChooserVisible( bool show ) | 180 | void OFileSelector::setChooserVisible( bool show ) |
196 | { | 181 | { |
197 | m_shChooser = show; | 182 | m_shChooser = show; |
198 | initializeChooser(); | 183 | initializeChooser(); |
199 | if( m_shChooser ){ | 184 | |
200 | m_boxView->hide(); | 185 | if( m_shChooser ) |
201 | }else{ | 186 | m_boxView->hide(); |
202 | m_boxView->show(); | 187 | else |
203 | } | 188 | m_boxView->show(); |
189 | |||
204 | } | 190 | } |
205 | 191 | ||
206 | QCheckBox* OFileSelector::permissionCheckbox() | 192 | QCheckBox* OFileSelector::permissionCheckbox() |
207 | { | 193 | { |
208 | if( m_selector == Normal ) | 194 | if( m_selector == Normal ) |
209 | return 0l; | 195 | return 0l; |
210 | else | 196 | else |
211 | return m_checkPerm; | 197 | return m_checkPerm; |
212 | } | 198 | } |
213 | bool OFileSelector::setPermission()const | 199 | bool OFileSelector::setPermission()const |
214 | { | 200 | { |
215 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); | 201 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); |
216 | } | 202 | } |
217 | void OFileSelector::setPermissionChecked( bool check ) | 203 | void OFileSelector::setPermissionChecked( bool check ) |
218 | { | 204 | { |
219 | if( m_checkPerm ) | 205 | if( m_checkPerm ) |
220 | m_checkPerm->setChecked( check ); | 206 | m_checkPerm->setChecked( check ); |
221 | } | 207 | } |
222 | 208 | ||
223 | void OFileSelector::setMode(int mode) // FIXME do direct raising | 209 | void OFileSelector::setMode(int mode) // FIXME do direct raising |
224 | { | 210 | { |
225 | m_mode = mode; | 211 | m_mode = mode; |
226 | if( m_selector == Normal ) | 212 | if( m_selector == Normal ) |
227 | return; | 213 | return; |
228 | } | 214 | } |
229 | void OFileSelector::setShowDirs(bool ) | 215 | void OFileSelector::setShowDirs(bool dir) |
230 | { | 216 | { |
231 | m_dir = true; | 217 | m_dir = dir; |
232 | reparse(); | 218 | if ( m_selector != Fileselector ) |
219 | reparse(); | ||
233 | } | 220 | } |
234 | void OFileSelector::setCaseSensetive(bool caSe ) | 221 | void OFileSelector::setCaseSensetive(bool caSe ) |
235 | { | 222 | { |
236 | m_case = caSe; | 223 | m_case = caSe; |
237 | reparse(); | 224 | |
225 | if ( m_selector != Fileselector ) | ||
226 | reparse(); | ||
238 | } | 227 | } |
239 | void OFileSelector::setShowFiles(bool show ) | 228 | void OFileSelector::setShowFiles(bool show ) |
240 | { | 229 | { |
241 | m_files = show; | 230 | m_files = show; |
242 | reparse(); | 231 | reparse(); |
243 | } | 232 | } |
244 | /// | 233 | /// |
245 | bool OFileSelector::cd(const QString &path ) | 234 | bool OFileSelector::cd(const QString &path ) |
246 | { | 235 | { |
247 | m_currentDir = path; | 236 | m_currentDir = path; |
248 | reparse(); | 237 | reparse(); |
249 | return true; | 238 | return true; |
250 | } | 239 | } |
251 | void OFileSelector::setSelector(int mode ) | 240 | void OFileSelector::setSelector(int mode ) |
252 | { | 241 | { |
253 | QString text; | 242 | QString text; |
254 | switch( mode ){ | 243 | switch( mode ){ |
255 | case Normal: | 244 | case Normal: |
256 | text = tr("Documents"); | 245 | text = tr("Documents"); |
257 | break; | 246 | break; |
258 | case Extended: | 247 | case Extended: |
259 | text = tr("Files"); | 248 | text = tr("Files"); |
260 | break; | 249 | break; |
261 | case ExtendedAll: | 250 | case ExtendedAll: |
262 | text = tr("All Files"); | 251 | text = tr("All Files"); |
263 | break; | 252 | break; |
264 | } | 253 | } |
265 | slotViewCheck( text ); | 254 | slotViewCheck( text ); |
266 | } | 255 | } |
267 | 256 | ||
268 | void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) | 257 | void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) |
269 | { | 258 | { |
@@ -351,315 +340,269 @@ DocLnk OFileSelector::selectedDocument() const | |||
351 | break; | 340 | break; |
352 | } | 341 | } |
353 | case Extended: | 342 | case Extended: |
354 | case ExtendedAll: | 343 | case ExtendedAll: |
355 | default: | 344 | default: |
356 | lnk = DocLnk( selectedName() ); | 345 | lnk = DocLnk( selectedName() ); |
357 | break; | 346 | break; |
358 | } | 347 | } |
359 | return lnk; | 348 | return lnk; |
360 | } | 349 | } |
361 | QValueList<DocLnk> OFileSelector::selectedDocuments() const | 350 | QValueList<DocLnk> OFileSelector::selectedDocuments() const |
362 | { | 351 | { |
363 | QValueList<DocLnk> docs; | 352 | QValueList<DocLnk> docs; |
364 | docs.append( selectedDocument() ); | 353 | docs.append( selectedDocument() ); |
365 | return docs; | 354 | return docs; |
366 | } | 355 | } |
367 | 356 | ||
368 | 357 | ||
369 | // slots internal | 358 | // slots internal |
370 | 359 | ||
371 | void OFileSelector::slotOk() | 360 | void OFileSelector::slotOk() |
372 | { | 361 | { |
373 | emit ok(); | 362 | emit ok(); |
374 | } | 363 | } |
375 | void OFileSelector::slotCancel() | 364 | void OFileSelector::slotCancel() |
376 | { | 365 | { |
377 | emit cancel(); | 366 | emit cancel(); |
378 | } | 367 | } |
379 | /* switch the views */ | 368 | /* switch the views */ |
380 | void OFileSelector::slotViewCheck(const QString &sel) | 369 | void OFileSelector::slotViewCheck(const QString &sel) |
381 | { | 370 | { |
382 | if( sel == tr("Documents" ) ){ | 371 | if( sel == tr("Documents" ) ){ |
383 | if( m_select == 0 ){ | 372 | initializeOldSelector(); |
384 | // autMime? fix cause now we use All and not the current | 373 | m_selector = Normal; |
385 | // yes currentMime fixes that for us | 374 | |
386 | QString mime = currentMimeType(); | ||
387 | m_select = new FileSelector(mime, | ||
388 | m_stack, "fileselector", | ||
389 | m_shNew, m_shClose); | ||
390 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
391 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
392 | connect(m_select, SIGNAL(closeMe() ), | ||
393 | this, SIGNAL(closeMe() ) ); | ||
394 | //connect to close me and other signals as well | ||
395 | |||
396 | m_stack->addWidget( m_select, Normal ); | ||
397 | } | ||
398 | m_stack->raiseWidget( Normal ); | ||
399 | m_selector = Normal; | ||
400 | }else if( sel == tr("Files") ){ | 375 | }else if( sel == tr("Files") ){ |
401 | m_selector = Extended; | 376 | m_selector = Extended; |
402 | initializeListView(); | 377 | |
403 | reparse(); | 378 | // FIXME call the factory |
404 | m_stack->raiseWidget( Extended ); | 379 | //reparse(); |
405 | }else if( sel == tr("All Files") ){ | 380 | }else if( sel == tr("All Files") ){ |
406 | m_selector = ExtendedAll; | 381 | m_selector = ExtendedAll; |
407 | initializeListView(); | 382 | /* see above |
408 | reparse(); | 383 | reparse(); */ |
409 | m_stack->raiseWidget( Extended ); // same widget other QFileFilter | ||
410 | } | 384 | } |
411 | } | 385 | } |
412 | 386 | ||
413 | QString OFileSelector::currentMimeType() const{ | 387 | QString OFileSelector::currentMimeType() const{ |
414 | QString mime; | 388 | QString mime; |
415 | QString currentText; | 389 | QString currentText; |
416 | if (m_shChooser ) | 390 | if (m_shChooser && m_mimeCheck ) |
417 | currentText = m_mimeCheck->currentText(); | 391 | currentText = m_mimeCheck->currentText(); |
418 | 392 | ||
393 | qWarning("CurrentText" + currentText ); | ||
419 | if (tr("All") == currentText ) return QString::null; | 394 | if (tr("All") == currentText ) return QString::null; |
420 | else if (currentText.isEmpty() ) { | 395 | else if (currentText.isEmpty() ) { |
421 | ; | 396 | ; |
422 | }else { | 397 | }else { |
423 | QMap<QString, QStringList>::ConstIterator it; | 398 | QMap<QString, QStringList>::ConstIterator it; |
424 | it = m_mimetypes.find( currentText ); | 399 | it = m_mimetypes.find( currentText ); |
425 | if ( it == m_mimetypes.end() ) { | 400 | if ( it != m_mimetypes.end() ) { |
426 | mime = it.data().join(";"); | 401 | mime = it.data().join(";"); |
427 | }else{ | 402 | }else{ |
428 | mime = currentText; | 403 | mime = currentText; |
429 | } | 404 | } |
430 | } | 405 | } |
431 | return mime; | 406 | return mime; |
432 | } | 407 | } |
433 | void OFileSelector::slotMimeCheck(const QString &mime) | 408 | void OFileSelector::slotMimeCheck(const QString &mime) |
434 | { | 409 | { |
435 | if( m_selector == Normal ){ | 410 | if( m_selector == Normal ){ |
436 | //if( m_autoMime ){ | 411 | initializeOldSelector(); |
437 | QString newMimeType; | 412 | |
438 | if (mime != tr("All") ) { | ||
439 | QMap<QString, QStringList>::Iterator it; | ||
440 | it = m_mimetypes.find(mime); | ||
441 | if ( it != m_mimetypes.end() ) { | ||
442 | newMimeType = it.data().join(";"); | ||
443 | }else{ | ||
444 | newMimeType = mime; | ||
445 | } | ||
446 | } | ||
447 | delete m_select; | ||
448 | m_select = new FileSelector( newMimeType, | ||
449 | m_stack, "fileselector", | ||
450 | m_shNew, m_shClose); | ||
451 | |||
452 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
453 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
454 | connect(m_select, SIGNAL(closeMe() ), | ||
455 | this, SIGNAL(closeMe() ) ); | ||
456 | //connect to close me and other signals as well | ||
457 | m_stack->addWidget( m_select, Normal ); | ||
458 | m_stack->raiseWidget( Normal ); | ||
459 | updateMimes(); | 413 | updateMimes(); |
460 | updateMimeCheck(); | 414 | updateMimeCheck(); |
461 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 415 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
462 | //} | ||
463 | }else{ // others | 416 | }else{ // others |
464 | qWarning("Mime %s", mime.latin1() ); | 417 | qWarning("Mime %s", mime.latin1() ); |
465 | if(m_shChooser ){ | 418 | if(m_shChooser ){ |
466 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | 419 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); |
467 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 420 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
468 | } | 421 | } |
469 | reparse(); | 422 | reparse(); |
470 | } | 423 | } |
471 | 424 | ||
472 | } | 425 | } |
473 | /* | 426 | /* |
474 | * Ok if a non dir gets inserted into this combobox | 427 | * Ok if a non dir gets inserted into this combobox |
475 | * we need to change it | 428 | * we need to change it |
476 | * QFileInfo and dirPath will give us the right Dir | 429 | * QFileInfo and dirPath will give us the right Dir |
477 | */ | 430 | */ |
478 | void OFileSelector::slotLocationActivated(const QString &file) | 431 | void OFileSelector::slotLocationActivated(const QString &file) |
479 | { | 432 | { |
480 | qWarning("slotLocationActivated"); | 433 | qWarning("slotLocationActivated"); |
481 | QString name = file.left( file.find("<-", 0, TRUE ) ); | 434 | QString name = file.left( file.find("<-", 0, TRUE ) ); |
482 | QFileInfo info( name ); | 435 | QFileInfo info( name ); |
483 | if ( info.isFile() ) | 436 | if ( info.isFile() ) |
484 | cd(info.dirPath( TRUE ) ); //absolute | 437 | cd(info.dirPath( TRUE ) ); //absolute |
485 | else | 438 | else |
486 | cd(name ); | 439 | cd(name ); |
487 | reparse(); | 440 | reparse(); |
488 | } | 441 | } |
489 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | 442 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) |
490 | { | 443 | { |
491 | QStringList pathList; | 444 | QStringList pathList; |
492 | bool underDog = FALSE; | 445 | bool underDog = FALSE; |
493 | for(int i=0;i<count;i++) { | 446 | for(int i=0;i<count;i++) { |
494 | pathList << m_location->text(i); | 447 | pathList << m_location->text(i); |
495 | if( m_location->text(i) == currentPath) | 448 | if( m_location->text(i) == currentPath) |
496 | underDog = TRUE; | 449 | underDog = TRUE; |
497 | } | 450 | } |
498 | if( !underDog) { | 451 | if( !underDog) { |
499 | m_location->clear(); | 452 | m_location->clear(); |
500 | if( currentPath.left(2)=="//") | 453 | if( currentPath.left(2)=="//") |
501 | pathList.append( currentPath.right(currentPath.length()-1) ); | 454 | pathList.append( currentPath.right(currentPath.length()-1) ); |
502 | else | 455 | else |
503 | pathList.append( currentPath ); | 456 | pathList.append( currentPath ); |
504 | m_location->insertStringList( pathList,-1); | 457 | m_location->insertStringList( pathList,-1); |
505 | } | 458 | } |
506 | } | 459 | } |
507 | /* | 460 | /* |
508 | * Do not crash anymore | 461 | * Do not crash anymore |
509 | * don't try to change dir to a file | 462 | * don't try to change dir to a file |
510 | */ | 463 | */ |
511 | void OFileSelector::locationComboChanged() | 464 | void OFileSelector::locationComboChanged() |
512 | { | 465 | { |
513 | QFileInfo info( m_location->lineEdit()->text() ); | 466 | QFileInfo info( m_location->lineEdit()->text() ); |
514 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); | 467 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); |
515 | if (info.isFile() ) | 468 | if (info.isFile() ) |
516 | cd(info.dirPath(TRUE) ); //absolute path | 469 | cd(info.dirPath(TRUE) ); //absolute path |
517 | else | 470 | else |
518 | cd( m_location->lineEdit()->text() ); | 471 | cd( m_location->lineEdit()->text() ); |
519 | 472 | ||
520 | reparse(); | 473 | reparse(); |
521 | } | 474 | } |
522 | void OFileSelector::init() | 475 | void OFileSelector::init() |
523 | { | 476 | { |
524 | m_lay = new QVBoxLayout( this ); | 477 | m_lay = new QVBoxLayout( this ); |
525 | m_lay->setSpacing(0 ); | 478 | m_lay->setSpacing(0 ); |
526 | 479 | ||
527 | m_stack = new QWidgetStack( this ); | 480 | /* take care of the main view... */ |
481 | initToolbar(); | ||
482 | |||
483 | /* initialize the file lister */ | ||
484 | initLister(); | ||
528 | if( m_selector == Normal ){ | 485 | if( m_selector == Normal ){ |
529 | QString mime; | 486 | QString mime; |
530 | if (!m_autoMime) { | 487 | if (!m_autoMime) { |
531 | if (!m_mimetypes.isEmpty() ) { | 488 | if (!m_mimetypes.isEmpty() ) { |
532 | QMap<QString, QStringList>::Iterator it; | 489 | QMap<QString, QStringList>::Iterator it; |
533 | it = m_mimetypes.begin(); // cause we're in the init | 490 | it = m_mimetypes.begin(); // cause we're in the init |
534 | mime = it.data().join(";"); | 491 | mime = it.data().join(";"); |
535 | } | 492 | } |
536 | } | 493 | } |
537 | m_select = new FileSelector(mime, | 494 | initializeOldSelector(); |
538 | m_stack, "fileselector", | 495 | }else{ |
539 | m_shNew, m_shClose); | 496 | initializeView(); |
540 | |||
541 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
542 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
543 | connect(m_select, SIGNAL(closeMe() ), | ||
544 | this, SIGNAL( closeMe() ) ); | ||
545 | //connect to close me and other signals as well | ||
546 | |||
547 | m_stack->addWidget( m_select, Normal ); | ||
548 | m_stack->raiseWidget( Normal ); | ||
549 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL | ||
550 | // and initializeListview will take care of those | ||
551 | // toolbar get's generade in initializeListView | ||
552 | initializeListView( ); // will raise the widget as well | ||
553 | m_stack->raiseWidget( Extended ); | ||
554 | } | 497 | } |
555 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch | ||
556 | 498 | ||
557 | if( m_shLne ) // the LineEdit with the current FileName | 499 | if( m_shLne ) // the LineEdit with the current FileName |
558 | initializeName(); | 500 | initializeName(); |
559 | 501 | ||
560 | if( m_shPerm ) // the Permission QCheckBox | 502 | if( m_shPerm ) // the Permission QCheckBox |
561 | initializePerm(); | 503 | initializePerm(); |
562 | 504 | ||
563 | if( m_shChooser ) // the Chooser for the view and Mimetypes | 505 | if( m_shChooser ) // the Chooser for the view and Mimetypes |
564 | initializeChooser(); | 506 | initializeChooser(); |
565 | 507 | ||
566 | if( m_shYesNo ) // the Yes No button row | 508 | if( m_shYesNo ) // the Yes No button row |
567 | initializeYes( ); | 509 | initializeYes( ); |
568 | 510 | ||
569 | if (m_selector != Normal ) | 511 | if (m_selector != Normal ) |
570 | reparse(); | 512 | reparse(); |
571 | } | 513 | } |
572 | void OFileSelector::updateMimes() | 514 | void OFileSelector::updateMimes() |
573 | { | 515 | { |
574 | if( m_autoMime ){ | 516 | if( m_autoMime ){ |
575 | m_mimetypes.clear(); | 517 | m_mimetypes.clear(); |
576 | m_mimetypes.insert( tr("All"), QString::null ); | 518 | m_mimetypes.insert( tr("All"), QString::null ); |
577 | if( m_selector == Normal ){ | 519 | if( m_selector == Normal ){ |
578 | DocLnkSet set; | 520 | DocLnkSet set; |
579 | Global::findDocuments(&set, QString::null ); | 521 | Global::findDocuments(&set, QString::null ); |
580 | QListIterator<DocLnk> dit( set.children() ); | 522 | QListIterator<DocLnk> dit( set.children() ); |
581 | for( ; dit.current(); ++dit ){ | 523 | for( ; dit.current(); ++dit ){ |
582 | if( !m_mimetypes.contains( (*dit)->type() ) ) | 524 | if( !m_mimetypes.contains( (*dit)->type() ) ) |
583 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); | 525 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); |
584 | } | 526 | } |
585 | }// else done in reparse | 527 | }// else done in reparse |
586 | } | 528 | } |
587 | } | 529 | } |
588 | void OFileSelector::initVars() | 530 | void OFileSelector::initVars() |
589 | { | 531 | { |
590 | if( m_mimetypes.isEmpty() ) | 532 | if( m_mimetypes.isEmpty() ) |
591 | m_autoMime = true; | 533 | m_autoMime = true; |
592 | else | 534 | else |
593 | m_autoMime = false; | 535 | m_autoMime = false; |
594 | 536 | ||
595 | m_shClose = false; | 537 | m_shClose = false; |
596 | m_shNew = false; | 538 | m_shNew = false; |
597 | m_shTool = true; | 539 | m_shTool = true; |
598 | m_shPerm = false; | 540 | m_shPerm = false; |
599 | m_shLne = true; | 541 | m_shLne = true; |
600 | m_shChooser = true; | 542 | m_shChooser = true; |
601 | m_shYesNo = true; | 543 | m_shYesNo = true; |
602 | m_case = false; | 544 | m_case = false; |
603 | m_dir = true; | 545 | m_dir = true; |
604 | m_files = true; | 546 | m_files = true; |
605 | m_showPopup = false; | 547 | m_showPopup = false; |
548 | m_mainView = 0l; | ||
549 | m_fileView = 0l; | ||
550 | m_lister = 0l; | ||
606 | 551 | ||
607 | if(m_pixmaps == 0 ) // init the pixmaps | 552 | if(m_pixmaps == 0 ) // init the pixmaps |
608 | initPics(); | 553 | initPics(); |
609 | 554 | ||
610 | // pointers | 555 | // pointers |
611 | m_location = 0; | 556 | m_location = 0; |
612 | m_mimeCheck = 0; | 557 | m_mimeCheck = 0; |
613 | m_viewCheck = 0; | 558 | m_viewCheck = 0; |
614 | m_homeButton = 0; | 559 | m_homeButton = 0; |
615 | m_docButton = 0; | 560 | m_docButton = 0; |
616 | m_hideButton = 0; | 561 | m_hideButton = 0; |
617 | m_ok = 0; | 562 | m_ok = 0; |
618 | m_cancel = 0; | 563 | m_cancel = 0; |
619 | m_reread = 0; | 564 | m_reread = 0; |
620 | m_up = 0; | 565 | m_up = 0; |
621 | m_View = 0; | 566 | m_View = 0; |
622 | m_checkPerm = 0; | 567 | m_checkPerm = 0; |
623 | m_pseudo = 0; | 568 | m_pseudo = 0; |
624 | m_pseudoLayout = 0; | 569 | m_pseudoLayout = 0; |
625 | m_select = 0; | 570 | m_select = 0; |
626 | m_stack = 0; | ||
627 | m_lay = 0; | 571 | m_lay = 0; |
628 | m_Oselector = 0; | 572 | m_Oselector = 0; |
629 | m_boxToolbar = 0; | 573 | m_boxToolbar = 0; |
630 | m_boxOk = 0; | 574 | m_boxOk = 0; |
631 | m_boxName = 0; | 575 | m_boxName = 0; |
632 | m_boxView = 0; | 576 | m_boxView = 0; |
633 | m_custom = 0; | ||
634 | m_edit = 0; | 577 | m_edit = 0; |
635 | m_fnLabel = 0; | 578 | m_fnLabel = 0; |
636 | m_new = 0; | 579 | m_new = 0; |
637 | m_close = 0; | 580 | m_close = 0; |
638 | } | 581 | } |
639 | void OFileSelector::initializeName() | 582 | void OFileSelector::initializeName() |
640 | { | 583 | { |
641 | /** Name Layout Line | 584 | /** Name Layout Line |
642 | * This is the Layout line arranged in | 585 | * This is the Layout line arranged in |
643 | * horizontal way each components | 586 | * horizontal way each components |
644 | * are next to each other | 587 | * are next to each other |
645 | * but we will only do this if | 588 | * but we will only do this if |
646 | * we didn't initialize a while ago. | 589 | * we didn't initialize a while ago. |
647 | */ | 590 | */ |
648 | if( m_boxName == 0 ){ | 591 | if( m_boxName == 0 ){ |
649 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox | 592 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox |
650 | m_fnLabel = new QLabel( m_boxName ); | 593 | m_fnLabel = new QLabel( m_boxName ); |
651 | m_fnLabel->setText( tr("Name:") ); | 594 | m_fnLabel->setText( tr("Name:") ); |
652 | m_edit = new QLineEdit( m_boxName ); | 595 | m_edit = new QLineEdit( m_boxName ); |
653 | m_edit->setText( m_name ); | 596 | m_edit->setText( m_name ); |
654 | //m_boxName->addWidget( m_fnLabel ); | 597 | //m_boxName->addWidget( m_fnLabel ); |
655 | m_boxName->setMargin( 5 ); | 598 | m_boxName->setMargin( 5 ); |
656 | m_boxName->setSpacing( 8 ); | 599 | m_boxName->setSpacing( 8 ); |
657 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor | 600 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor |
658 | 601 | ||
659 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout | 602 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout |
660 | }// else we already initialized | 603 | }// else we already initialized |
661 | // maybe show the components? | 604 | // maybe show the components? |
662 | // | 605 | // |
663 | } | 606 | } |
664 | void OFileSelector::initializeYes() | 607 | void OFileSelector::initializeYes() |
665 | { | 608 | { |
@@ -685,153 +628,161 @@ void OFileSelector::initializeYes() | |||
685 | } | 628 | } |
686 | /* | 629 | /* |
687 | * OK m_mimeCheck is a QComboBox we now want to fill | 630 | * OK m_mimeCheck is a QComboBox we now want to fill |
688 | * out that combobox | 631 | * out that combobox |
689 | * if automime we need to update the mimetypes | 632 | * if automime we need to update the mimetypes |
690 | */ | 633 | */ |
691 | void OFileSelector::updateMimeCheck() { | 634 | void OFileSelector::updateMimeCheck() { |
692 | m_mimeCheck->clear(); | 635 | m_mimeCheck->clear(); |
693 | if (m_autoMime ) { | 636 | if (m_autoMime ) { |
694 | //m_mimeCheck->insertItem( tr("All") ); | 637 | //m_mimeCheck->insertItem( tr("All") ); |
695 | updateMimes(); | 638 | updateMimes(); |
696 | } | 639 | } |
697 | 640 | ||
698 | QMap<QString, QStringList>::Iterator it; | 641 | QMap<QString, QStringList>::Iterator it; |
699 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { | 642 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { |
700 | m_mimeCheck->insertItem( it.key() ); | 643 | m_mimeCheck->insertItem( it.key() ); |
701 | } | 644 | } |
702 | } | 645 | } |
703 | 646 | ||
704 | void OFileSelector::initializeChooser() | 647 | void OFileSelector::initializeChooser() |
705 | { | 648 | { |
706 | if( m_boxView == 0 ){ | 649 | if( m_boxView == 0 ){ |
707 | m_boxView = new QHBox( this ); | 650 | m_boxView = new QHBox( this ); |
708 | m_viewCheck = new QComboBox( m_boxView, "view check"); | 651 | m_viewCheck = new QComboBox( m_boxView, "view check"); |
709 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); | 652 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); |
710 | m_boxView->setSpacing( 8 ); | 653 | m_boxView->setSpacing( 8 ); |
711 | m_lay->addWidget(m_boxView, 0 ); | 654 | m_lay->addWidget(m_boxView, 0 ); |
712 | 655 | ||
713 | m_viewCheck->insertItem( tr("Documents") ); | 656 | m_viewCheck->insertItem( tr("Documents") ); |
714 | m_viewCheck->insertItem( tr("Files") ); | 657 | m_viewCheck->insertItem( tr("Files") ); |
715 | m_viewCheck->insertItem( tr("All Files") ); | 658 | m_viewCheck->insertItem( tr("All Files") ); |
716 | /* update to custom views */ | 659 | /* update to custom views */ |
660 | |||
717 | updateMimeCheck(); | 661 | updateMimeCheck(); |
718 | 662 | ||
719 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), | 663 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), |
720 | this, SLOT( slotViewCheck(const QString & ) ) ); | 664 | this, SLOT( slotViewCheck(const QString & ) ) ); |
721 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), | 665 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), |
722 | this, SLOT( slotMimeCheck( const QString & ) ) ); | 666 | this, SLOT( slotMimeCheck( const QString & ) ) ); |
723 | } | 667 | } |
724 | } | 668 | } |
725 | void OFileSelector::initializeListView() | 669 | /* generate the buttons for the toolbar */ |
726 | { | 670 | void OFileSelector::initToolbar() { |
727 | qWarning("initializeListView"); | 671 | m_mainView = new OFileSelectorMain( this ); |
728 | if( m_pseudo == 0 ){ | 672 | |
729 | qWarning("init"); | 673 | /* now generate the tool bar */ |
730 | m_pseudo = new QWidget( m_stack, "Pseudo Widget"); | 674 | qWarning( "toolbar" ); |
675 | m_pseudo = new QWidget( m_mainView, "Pseudo Widget" ); | ||
731 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); | 676 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); |
732 | // toolbar | 677 | |
733 | m_boxToolbar = new QHBox( m_pseudo ); | 678 | m_boxToolbar = new QHBox( m_pseudo ); |
734 | m_boxToolbar->setSpacing(0 ); // next to each other please | 679 | m_boxToolbar->setSpacing( 0 ); |
735 | 680 | ||
736 | // toolbar members | 681 | // tool bar members now |
737 | { | 682 | m_location = new QComboBox( m_boxToolbar ); |
738 | // location QComboBox | 683 | m_location->setEditable( TRUE ); |
739 | m_location = new QComboBox( m_boxToolbar ); | 684 | m_location->setDuplicatesEnabled( FALSE ); |
740 | m_location->setEditable( TRUE ); | 685 | connect( m_location, SIGNAL(activated(const QString& ) ), |
741 | m_location->setDuplicatesEnabled( FALSE ); | 686 | this, SLOT(slotLocationActivated(const QString& )) ); |
742 | connect( m_location, SIGNAL(activated(const QString &) ), | 687 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ) , |
743 | this, SLOT( slotLocationActivated(const QString &) ) ); | 688 | this, SLOT(locationComboChanged() ) ); |
744 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ), | 689 | |
745 | this, SLOT(locationComboChanged() ) ); | 690 | // UP Button |
746 | // UP Button | 691 | m_up = new QPushButton( Resource::loadIconSet("up"), QString::null, |
747 | m_up = new QPushButton(Resource::loadIconSet("up"),"", | 692 | m_boxToolbar, "cdUpButton" ); |
748 | m_boxToolbar,"cdUpButton"); | 693 | m_up->setFixedSize( QSize(20, 20 ) ); |
749 | m_up->setFixedSize( QSize( 20, 20 ) ); | 694 | connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) ); |
750 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); | 695 | m_up->setFlat( TRUE ); |
751 | m_up->setFlat(TRUE); | 696 | |
752 | 697 | // Home Button | |
753 | // Home Button | 698 | m_homeButton = new QPushButton(Resource::loadIconSet("home"), |
754 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , | 699 | QString::null, m_boxToolbar ); |
755 | "", m_boxToolbar); | 700 | m_homeButton->setFixedSize( QSize(20, 20 ) ); |
756 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); | 701 | connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) ); |
757 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); | 702 | m_homeButton->setFlat( TRUE ); |
758 | m_homeButton->setFlat(TRUE); | 703 | |
759 | // Documents Button | 704 | // Documents Button |
760 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", | 705 | m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"), |
761 | m_boxToolbar,"docsButton"); | 706 | QString::null, m_boxToolbar, |
762 | m_docButton->setFixedSize( QSize( 20, 20 ) ); | 707 | "docsButton" ); |
763 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); | 708 | m_docButton->setFixedSize( QSize(20, 20 ) ); |
764 | m_docButton->setFlat(TRUE); | 709 | m_docButton->setFlat( true ); |
765 | 710 | connect( m_docButton, SIGNAL(clicked() ), | |
766 | // Close button | 711 | this, SLOT(slotDoc() ) ); |
767 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", | 712 | |
768 | m_boxToolbar ); | 713 | // close button |
769 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); | 714 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", |
770 | m_close->setFixedSize( 20, 20 ); | 715 | m_boxToolbar ); |
771 | 716 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); | |
772 | m_boxToolbar->setFixedHeight( 20 ); | 717 | m_close->setFixedSize( 20, 20 ); |
773 | m_pseudoLayout->addWidget(m_boxToolbar ); | 718 | |
774 | 719 | m_boxToolbar->setFixedHeight( 20 ); | |
775 | // let;s fill the Location ComboBox | 720 | m_pseudoLayout->addWidget(m_boxToolbar ); |
776 | StorageInfo storage; | 721 | |
777 | const QList<FileSystem> &fs = storage.fileSystems(); | 722 | /* init the locations */ |
778 | QListIterator<FileSystem> it ( fs ); | 723 | initLocations(); |
779 | for( ; it.current(); ++it ){ | 724 | |
725 | if( !m_shTool ){ | ||
726 | m_location->hide( ); | ||
727 | m_up->hide( ); | ||
728 | m_homeButton->hide( ); | ||
729 | m_docButton->hide( ); | ||
730 | } | ||
731 | if(!m_shClose ) | ||
732 | m_close->hide(); | ||
733 | |||
734 | m_mainView->setToolbar( m_pseudo ); | ||
735 | m_lay->addWidget( m_mainView, 100 ); | ||
736 | } | ||
737 | /* initialize the OLocalLister */ | ||
738 | void OFileSelector::initLister() { | ||
739 | m_lister = new OLocalLister(this); | ||
740 | } | ||
741 | /* put default locations into the bar */ | ||
742 | void OFileSelector::initLocations () { | ||
743 | |||
744 | // let;s fill the Location ComboBox | ||
745 | StorageInfo storage; | ||
746 | const QList<FileSystem> &fs = storage.fileSystems(); | ||
747 | QListIterator<FileSystem> it ( fs ); | ||
748 | for( ; it.current(); ++it ){ | ||
780 | const QString disk = (*it)->name(); | 749 | const QString disk = (*it)->name(); |
781 | const QString path = (*it)->path(); | 750 | const QString path = (*it)->path(); |
782 | m_location->insertItem(path+ "<-"+disk ); | 751 | m_location->insertItem(path+ "<-"+disk ); |
783 | } | 752 | } |
784 | int count = m_location->count(); | 753 | int count = m_location->count(); |
785 | m_location->insertItem( m_currentDir ); | 754 | m_location->insertItem( m_currentDir ); |
786 | m_location->setCurrentItem( count ); | 755 | m_location->setCurrentItem( count ); |
787 | // due to the New and Close button we can not simply hide m_boxToolBar to not show it | ||
788 | if( !m_shTool ){ | ||
789 | m_location->hide( ); | ||
790 | m_up->hide( ); | ||
791 | m_homeButton->hide( ); | ||
792 | m_docButton->hide( ); | ||
793 | } | ||
794 | if(!m_shClose ) | ||
795 | m_close->hide(); | ||
796 | //if(!m_shNew) | ||
797 | //m_close->hide(); | ||
798 | |||
799 | } // off toolbar | ||
800 | // the Main ListView | ||
801 | // make a QWidgetStack first so Views can share the Toolbar | ||
802 | 756 | ||
803 | // m_pseudoLayout->addWidget( m_View, 288 ); | ||
804 | m_stack->addWidget( m_pseudo, Extended ); | ||
805 | } | ||
806 | } | 757 | } |
807 | void OFileSelector::initializePerm() | 758 | void OFileSelector::initializePerm() |
808 | { | 759 | { |
809 | if( m_checkPerm == 0 ){ | 760 | if( m_checkPerm == 0 ){ |
810 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); | 761 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); |
811 | m_checkPerm->setChecked( false ); | 762 | m_checkPerm->setChecked( false ); |
812 | m_lay->addWidget( m_checkPerm ); | 763 | m_lay->addWidget( m_checkPerm ); |
813 | } | 764 | } |
814 | } | 765 | } |
815 | void OFileSelector::initPics() | 766 | void OFileSelector::initPics() |
816 | { | 767 | { |
817 | m_pixmaps = new QMap<QString,QPixmap>; | 768 | m_pixmaps = new QMap<QString,QPixmap>; |
818 | QPixmap pm = Resource::loadPixmap( "folder" ); | 769 | QPixmap pm = Resource::loadPixmap( "folder" ); |
819 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 770 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
820 | 771 | ||
821 | QPainter painter( &pm ); | 772 | QPainter painter( &pm ); |
822 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 773 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
823 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 774 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
824 | m_pixmaps->insert("dirsymlink", pm ); | 775 | m_pixmaps->insert("dirsymlink", pm ); |
825 | 776 | ||
826 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 777 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
827 | QPainter pen(&pm2 ); | 778 | QPainter pen(&pm2 ); |
828 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 779 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
829 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 780 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
830 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 781 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
831 | } | 782 | } |
832 | // if a mime complies with the m_mimeCheck->currentItem | 783 | // if a mime complies with the m_mimeCheck->currentItem |
833 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) | 784 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) |
834 | { | 785 | { |
835 | if( mime == "All" ) | 786 | if( mime == "All" ) |
836 | return true; | 787 | return true; |
837 | MimeType type( path ); | 788 | MimeType type( path ); |
@@ -973,79 +924,99 @@ void OFileSelector::reparse() | |||
973 | 924 | ||
974 | // let's find possible mimetypes | 925 | // let's find possible mimetypes |
975 | m_mimetypes = currentLister()->mimeTypes( m_currentDir ); | 926 | m_mimetypes = currentLister()->mimeTypes( m_currentDir ); |
976 | 927 | ||
977 | // add them to the chooser | 928 | // add them to the chooser |
978 | updateMimeCheck(); | 929 | updateMimeCheck(); |
979 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); | 930 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); |
980 | currentMimeType = m_mimeCheck->currentText(); | 931 | currentMimeType = m_mimeCheck->currentText(); |
981 | } | 932 | } |
982 | }else { // no autoMime | 933 | }else { // no autoMime |
983 | // let the mimetype be set from out side the m_mimeCheck FEATURE | 934 | // let the mimetype be set from out side the m_mimeCheck FEATURE |
984 | 935 | ||
985 | if( m_shChooser ) | 936 | if( m_shChooser ) |
986 | currentMimeType = m_mimeCheck->currentText(); | 937 | currentMimeType = m_mimeCheck->currentText(); |
987 | 938 | ||
988 | } | 939 | } |
989 | // now we got our mimetypes we can add the files | 940 | // now we got our mimetypes we can add the files |
990 | 941 | ||
991 | currentLister()->reparse( m_currentDir ); | 942 | currentLister()->reparse( m_currentDir ); |
992 | /* we're done with adding let's sort */ | 943 | /* we're done with adding let's sort */ |
993 | currentView()->sort(); | 944 | currentView()->sort(); |
994 | 945 | ||
995 | 946 | ||
996 | if( m_shTool ){ | 947 | if( m_shTool ){ |
997 | m_location->insertItem( m_currentDir ); | 948 | m_location->insertItem( m_currentDir ); |
998 | 949 | ||
999 | } | 950 | } |
1000 | // reenable painting and updates | 951 | // reenable painting and updates |
1001 | } | 952 | } |
1002 | 953 | ||
1003 | 954 | ||
1004 | OFileView* OFileSelector::currentView() { | 955 | OFileView* OFileSelector::currentView() { |
1005 | return 0l; | 956 | return m_fileView; |
1006 | } | 957 | } |
1007 | OFileView* OFileSelector::currentView() const{ | 958 | OFileView* OFileSelector::currentView() const{ |
1008 | return 0l; | 959 | return m_fileView; |
1009 | } | 960 | } |
1010 | int OFileSelector::filter() { | 961 | int OFileSelector::filter() { |
1011 | int filter; | 962 | int filter; |
1012 | if ( m_selector == ExtendedAll ) | 963 | if ( m_selector == ExtendedAll ) |
1013 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 964 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
1014 | else | 965 | else |
1015 | filter = QDir::Files | QDir::Dirs | QDir::All ; | 966 | filter = QDir::Files | QDir::Dirs | QDir::All ; |
1016 | 967 | ||
1017 | return filter; | 968 | return filter; |
1018 | } | 969 | } |
1019 | int OFileSelector::sorting() { | 970 | int OFileSelector::sorting() { |
1020 | int sort; | 971 | int sort; |
1021 | 972 | ||
1022 | if (m_case ) | 973 | if (m_case ) |
1023 | sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 974 | sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
1024 | else | 975 | else |
1025 | sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 976 | sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
1026 | 977 | ||
1027 | return sort; | 978 | return sort; |
1028 | } | 979 | } |
1029 | void OFileSelector::internFileSelected( const QString& s) { | 980 | void OFileSelector::internFileSelected( const QString& s) { |
1030 | emit fileSelected( s ); | 981 | emit fileSelected( s ); |
1031 | } | 982 | } |
1032 | void OFileSelector::internFileSelected( const DocLnk& d ) { | 983 | void OFileSelector::internFileSelected( const DocLnk& d ) { |
1033 | emit fileSelected( d ); | 984 | emit fileSelected( d ); |
1034 | } | 985 | } |
1035 | void OFileSelector::internContextMenu() { | 986 | void OFileSelector::internContextMenu() { |
1036 | emit contextMenu(); | 987 | emit contextMenu(); |
1037 | } | 988 | } |
1038 | void OFileSelector::internChangedDir( const QString& s) { | 989 | void OFileSelector::internChangedDir( const QString& s) { |
1039 | emit dirSelected( s ); | 990 | emit dirSelected( s ); |
1040 | cd(s ); | 991 | cd(s ); |
1041 | } | 992 | } |
1042 | void OFileSelector::internChangedDir( const QDir& s) { | 993 | void OFileSelector::internChangedDir( const QDir& s) { |
1043 | emit dirSelected( s ); | 994 | emit dirSelected( s ); |
1044 | } | 995 | } |
1045 | QPixmap OFileSelector::pixmap( const QString& s ) { | 996 | QPixmap OFileSelector::pixmap( const QString& s ) { |
1046 | 997 | ||
1047 | return (*m_pixmaps)[s]; | 998 | return (*m_pixmaps)[s]; |
1048 | } | 999 | } |
1049 | OLister* OFileSelector::currentLister()const { | 1000 | OLister* OFileSelector::currentLister()const { |
1050 | return 0l; | 1001 | return m_lister; |
1002 | } | ||
1003 | void OFileSelector::initializeOldSelector() { | ||
1004 | qWarning("initializeOldSelector"); | ||
1005 | |||
1006 | delete m_select; | ||
1007 | |||
1008 | // we need to initialize but keep the selected mimetype | ||
1009 | /* we default not to show close and new buttons */ | ||
1010 | QString mime = currentMimeType(); | ||
1011 | qWarning("MimeType " + mime ); | ||
1012 | m_select = new FileSelector( mime , | ||
1013 | m_mainView, "fileselector", | ||
1014 | FALSE, FALSE); | ||
1015 | |||
1016 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | ||
1017 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | ||
1018 | connect(m_select, SIGNAL(closeMe() ), | ||
1019 | this, SIGNAL(closeMe() ) ); | ||
1020 | //connect to close me and other signals as well | ||
1021 | m_mainView->setWidget( m_select ); | ||
1051 | } | 1022 | } |
diff --git a/libopie/ofileselector/ofileselector.h b/libopie/ofileselector/ofileselector.h index a7b363f..bf9a26b 100644 --- a/libopie/ofileselector/ofileselector.h +++ b/libopie/ofileselector/ofileselector.h | |||
@@ -40,104 +40,105 @@ | |||
40 | #include <qwidget.h> | 40 | #include <qwidget.h> |
41 | #include <qstring.h> | 41 | #include <qstring.h> |
42 | #include <qpixmap.h> | 42 | #include <qpixmap.h> |
43 | #include <qstringlist.h> | 43 | #include <qstringlist.h> |
44 | #include <qmap.h> | 44 | #include <qmap.h> |
45 | #include <qvaluelist.h> | 45 | #include <qvaluelist.h> |
46 | 46 | ||
47 | #include <qpe/applnk.h> | 47 | #include <qpe/applnk.h> |
48 | #include <qlistview.h> | 48 | #include <qlistview.h> |
49 | 49 | ||
50 | /** This is OPIEs FileDialog Widget. You can use it | 50 | /** This is OPIEs FileDialog Widget. You can use it |
51 | * as a dropin replacement of the fileselector and | 51 | * as a dropin replacement of the fileselector and |
52 | * or use any of the new features. | 52 | * or use any of the new features. |
53 | * This is also a complete FileSave and FileLoad widget | 53 | * This is also a complete FileSave and FileLoad widget |
54 | * If you look for a Dialog check OFileDialog | 54 | * If you look for a Dialog check OFileDialog |
55 | * | 55 | * |
56 | */ | 56 | */ |
57 | class DocLnk; | 57 | class DocLnk; |
58 | class QCheckBox; | 58 | class QCheckBox; |
59 | class QComboBox; | 59 | class QComboBox; |
60 | class QPushButton; | 60 | class QPushButton; |
61 | class QGridLayout; | 61 | class QGridLayout; |
62 | class QLineEdit; | 62 | class QLineEdit; |
63 | class QLabel; | 63 | class QLabel; |
64 | class QWidgetStack; | 64 | class QWidgetStack; |
65 | class QHBoxLayout; | 65 | class QHBoxLayout; |
66 | class QVBoxLayout; | 66 | class QVBoxLayout; |
67 | class QPopupMenu; | 67 | class QPopupMenu; |
68 | class QFileInfo; | 68 | class QFileInfo; |
69 | class QHBox; | 69 | class QHBox; |
70 | class OFileView; | 70 | class OFileView; |
71 | class OLister; | 71 | class OLister; |
72 | class OFileSelectorMain; | ||
72 | // | 73 | // |
73 | 74 | ||
74 | /* the mimetypes one name and a list of mimetypes */ | 75 | /* the mimetypes one name and a list of mimetypes */ |
75 | typedef QMap< QString, QStringList> MimeTypes; | 76 | typedef QMap< QString, QStringList> MimeTypes; |
76 | 77 | ||
77 | /** | 78 | /** |
78 | * FIXME later | 79 | * FIXME later |
79 | */ | 80 | */ |
80 | struct OPopupMenuFactory { | 81 | struct OPopupMenuFactory { |
81 | OPopupMenuFactory() {} | 82 | OPopupMenuFactory() {} |
82 | 83 | ||
83 | }; | 84 | }; |
84 | 85 | ||
85 | 86 | ||
86 | /** | 87 | /** |
87 | * Opie the default OFileSelector | 88 | * Opie the default OFileSelector |
88 | * It features multiple views. | 89 | * It features multiple views. |
89 | */ | 90 | */ |
90 | class OFileSelector : public QWidget { | 91 | class OFileSelector : public QWidget { |
91 | Q_OBJECT | 92 | Q_OBJECT |
92 | 93 | ||
93 | /* friends are evil but I don't want to make the | 94 | /* friends are evil but I don't want to make the |
94 | * methods public | 95 | * methods public |
95 | */ | 96 | */ |
96 | friend class OLister; | 97 | friend class OLister; |
97 | friend class OFileView; | 98 | friend class OFileView; |
98 | public: | 99 | public: |
99 | /** | 100 | /** |
100 | * The mode of the file selector | 101 | * The mode of the file selector |
101 | * Either open, save, fileselector or dir browsing mode | 102 | * Either open, save, fileselector or dir browsing mode |
102 | * | 103 | * |
103 | */ | 104 | */ |
104 | enum Mode {Open = 1, Save = 2, Fileselector = 4, Dir = 8 }; | 105 | enum Mode {Open = 1, Save = 2, Fileselector = 4, Dir = 8 }; |
105 | 106 | ||
106 | /** | 107 | /** |
107 | * Selector. Either Normal for the one shipped with | 108 | * Selector. Either Normal for the one shipped with |
108 | * libqpe or Extended. for the Extended | 109 | * libqpe or Extended. for the Extended |
109 | * ExtendedAll also shows 'hidden' files | 110 | * ExtendedAll also shows 'hidden' files |
110 | */ | 111 | */ |
111 | enum Selector{Normal=0, Extended = 1, ExtendedAll =2 }; | 112 | enum Selector{Normal=0, Extended = 1, ExtendedAll = 2}; |
112 | 113 | ||
113 | /** | 114 | /** |
114 | * This is reserved for futrue views | 115 | * This is reserved for futrue views |
115 | */ | 116 | */ |
116 | enum View { Dirs = 1, Files = 2, Tree = 4, Icon = 8 }; | 117 | enum View { Dirs = 1, Files = 2, Tree = 4, Icon = 8 }; |
117 | 118 | ||
118 | /** | 119 | /** |
119 | * A c'tor which should be used for advanced mode | 120 | * A c'tor which should be used for advanced mode |
120 | * @param wid the parent | 121 | * @param wid the parent |
121 | * @param mode the Mode of the Selector | 122 | * @param mode the Mode of the Selector |
122 | * @param selector the current View of the Selector | 123 | * @param selector the current View of the Selector |
123 | * @param dirName in which dir to start | 124 | * @param dirName in which dir to start |
124 | * @param fileName a proposed filename | 125 | * @param fileName a proposed filename |
125 | * @param mimetypes A list of mimetypes \ | 126 | * @param mimetypes A list of mimetypes \ |
126 | * QString is for a identifier name like "Text files" | 127 | * QString is for a identifier name like "Text files" |
127 | * the coresponding QStringList is used for the mimetypes | 128 | * the coresponding QStringList is used for the mimetypes |
128 | * if empty it'll fill the list of mimetypes depending | 129 | * if empty it'll fill the list of mimetypes depending |
129 | * on the content of the current directory | 130 | * on the content of the current directory |
130 | */ | 131 | */ |
131 | 132 | ||
132 | OFileSelector(QWidget *wid, int mode, int selector, | 133 | OFileSelector(QWidget *wid, int mode, int selector, |
133 | const QString &dirName, | 134 | const QString &dirName, |
134 | const QString &fileName = QString::null, | 135 | const QString &fileName = QString::null, |
135 | const MimeTypes &mimetypes = MimeTypes() ); | 136 | const MimeTypes &mimetypes = MimeTypes() ); |
136 | 137 | ||
137 | 138 | ||
138 | /** | 139 | /** |
139 | * This is a QPE compatible c'tor | 140 | * This is a QPE compatible c'tor |
140 | */ | 141 | */ |
141 | OFileSelector(const QString &mimeFilter, QWidget *parent, | 142 | OFileSelector(const QString &mimeFilter, QWidget *parent, |
142 | const char *name, bool newVisible = TRUE, | 143 | const char *name, bool newVisible = TRUE, |
143 | bool closeVisible = FALSE ); | 144 | bool closeVisible = FALSE ); |
@@ -313,163 +314,171 @@ class OFileSelector : public QWidget { | |||
313 | QStringList selectedNames()const; | 314 | QStringList selectedNames()const; |
314 | 315 | ||
315 | /** | 316 | /** |
316 | * return the complete to the file | 317 | * return the complete to the file |
317 | */ | 318 | */ |
318 | QString selectedPath() const; | 319 | QString selectedPath() const; |
319 | 320 | ||
320 | /** | 321 | /** |
321 | * return the completed paths | 322 | * return the completed paths |
322 | */ | 323 | */ |
323 | QStringList selectedPaths() const; | 324 | QStringList selectedPaths() const; |
324 | 325 | ||
325 | /** | 326 | /** |
326 | * the current directory | 327 | * the current directory |
327 | */ | 328 | */ |
328 | QString directory()const; | 329 | QString directory()const; |
329 | 330 | ||
330 | /** | 331 | /** |
331 | * fileCount | 332 | * fileCount |
332 | */ | 333 | */ |
333 | int fileCount(); | 334 | int fileCount(); |
334 | 335 | ||
335 | DocLnk selectedDocument()const; | 336 | DocLnk selectedDocument()const; |
336 | 337 | ||
337 | QValueList<DocLnk> selectedDocuments()const; | 338 | QValueList<DocLnk> selectedDocuments()const; |
338 | 339 | ||
339 | OFileView* currentView(); | 340 | OFileView* currentView(); |
340 | OFileView* currentView()const; | 341 | OFileView* currentView()const; |
341 | OLister* currentLister()const; | 342 | OLister* currentLister()const; |
342 | int filter(); | 343 | int filter(); |
343 | int sorting(); | 344 | int sorting(); |
344 | QPixmap pixmap( const QString& ); | 345 | QPixmap pixmap( const QString& ); |
346 | /* our tool bar */ | ||
347 | QWidget* toolBar(); | ||
345 | 348 | ||
346 | signals: | 349 | signals: |
347 | void fileSelected( const DocLnk & ); | 350 | void fileSelected( const DocLnk & ); |
348 | void fileSelected( const QString & ); | 351 | void fileSelected( const QString & ); |
349 | void dirSelected(const QString &dir ); | 352 | void dirSelected(const QString &dir ); |
350 | void dirSelected( const QDir& ); | 353 | void dirSelected( const QDir& ); |
351 | void closeMe(); | 354 | void closeMe(); |
352 | void ok(); | 355 | void ok(); |
353 | void cancel(); | 356 | void cancel(); |
354 | void contextMenu(); | 357 | void contextMenu(); |
355 | 358 | ||
356 | private slots: | 359 | private slots: |
357 | void slotOk(); | 360 | void slotOk(); |
358 | void slotCancel(); | 361 | void slotCancel(); |
359 | void slotViewCheck(const QString & ); | 362 | void slotViewCheck(const QString & ); |
360 | void slotMimeCheck(const QString & ); | 363 | void slotMimeCheck(const QString & ); |
361 | void slotLocationActivated(const QString & ); | 364 | void slotLocationActivated(const QString & ); |
362 | void slotInsertLocationPath(const QString &, int); | 365 | void slotInsertLocationPath(const QString &, int); |
363 | void locationComboChanged(); | 366 | void locationComboChanged(); |
364 | 367 | ||
365 | private: | 368 | private: |
366 | void init(); | 369 | void init(); |
367 | void updateMimes(); | 370 | void updateMimes(); |
368 | 371 | ||
369 | 372 | ||
370 | private: | 373 | private: |
371 | 374 | ||
375 | OFileSelectorMain* m_mainView; | ||
376 | OLister* m_lister; | ||
377 | OFileView* m_fileView; | ||
372 | FileSelector* m_select; | 378 | FileSelector* m_select; |
373 | int m_mode, m_selector; | 379 | int m_mode, m_selector; |
374 | QComboBox *m_location, | 380 | QComboBox *m_location, |
375 | *m_mimeCheck, | 381 | *m_mimeCheck, |
376 | *m_viewCheck; | 382 | *m_viewCheck; |
377 | 383 | ||
378 | QPushButton *m_homeButton, | 384 | QPushButton *m_homeButton, |
379 | *m_docButton, | 385 | *m_docButton, |
380 | *m_hideButton, | 386 | *m_hideButton, |
381 | *m_ok, *m_cancel; | 387 | *m_ok, *m_cancel; |
382 | QPushButton *m_reread, | 388 | QPushButton *m_reread, |
383 | *m_up, | 389 | *m_up, |
384 | *m_new, | 390 | *m_new, |
385 | *m_close; | 391 | *m_close; |
386 | QListView *m_View; | 392 | QListView *m_View; |
387 | QCheckBox *m_checkPerm; | 393 | QCheckBox *m_checkPerm; |
388 | QWidget *m_pseudo; | 394 | QWidget *m_pseudo; |
389 | QVBoxLayout *m_pseudoLayout; | 395 | QVBoxLayout *m_pseudoLayout; |
390 | 396 | ||
391 | QString m_currentDir; | 397 | QString m_currentDir; |
392 | QString m_name; | 398 | QString m_name; |
393 | QMap<QString, QStringList> m_mimetypes; | 399 | |
394 | 400 | QMap<QString, QStringList> m_mimetypes; | |
395 | 401 | ||
396 | QWidgetStack *m_stack; | 402 | QVBoxLayout *m_lay; |
397 | QVBoxLayout *m_lay; | 403 | QGridLayout *m_Oselector; |
398 | QGridLayout *m_Oselector; | 404 | |
399 | 405 | QHBox *m_boxToolbar; | |
400 | QHBox *m_boxToolbar; | 406 | QHBox *m_boxOk; |
401 | QHBox *m_boxOk; | 407 | QHBox *m_boxName; |
402 | QHBox *m_boxName; | 408 | QHBox *m_boxView; |
403 | QHBox *m_boxView; | 409 | |
404 | 410 | ||
405 | QPopupMenu *m_custom; | 411 | QLineEdit *m_edit; |
406 | 412 | QLabel *m_fnLabel; | |
407 | QLineEdit *m_edit; | 413 | |
408 | QLabel *m_fnLabel; | 414 | bool m_shClose : 1; |
409 | 415 | bool m_shNew : 1; | |
410 | bool m_shClose : 1; | 416 | bool m_shTool : 1; |
411 | bool m_shNew : 1; | 417 | bool m_shPerm : 1; |
412 | bool m_shTool : 1; | 418 | bool m_shLne : 1; |
413 | bool m_shPerm : 1; | 419 | bool m_shChooser : 1; |
414 | bool m_shLne : 1; | 420 | bool m_shYesNo : 1; |
415 | bool m_shChooser : 1; | 421 | bool m_boCheckPerm : 1; |
416 | bool m_shYesNo : 1; | 422 | bool m_autoMime : 1; |
417 | bool m_boCheckPerm : 1; | 423 | bool m_case : 1; |
418 | bool m_autoMime : 1; | 424 | bool m_dir : 1; |
419 | bool m_case : 1; | 425 | bool m_files : 1; |
420 | bool m_dir : 1; | 426 | bool m_showPopup : 1; |
421 | bool m_files : 1; | 427 | bool m_showHidden : 1; |
422 | bool m_showPopup : 1; | 428 | |
423 | 429 | void initVars(); | |
424 | void initVars(); | 430 | |
425 | 431 | void delItems(); | |
426 | void delItems(); | 432 | void initializeName(); |
427 | void initializeName(); | 433 | void initializeYes(); |
428 | void initializeYes(); | 434 | void initializeChooser(); |
429 | void initializeChooser(); | 435 | void initializePerm(); |
430 | void initializeListView(); | 436 | void initPics(); |
431 | void initializePerm(); | 437 | bool compliesMime(const QString &path, |
432 | void initPics(); | 438 | const QString &mime); |
433 | bool compliesMime(const QString &path, | 439 | bool compliesMime(const QString& mime ); |
434 | const QString &mime); | ||
435 | bool compliesMime(const QString& mime ); | ||
436 | /** | 440 | /** |
437 | * Updates the QComboBox with the current mimetypes | 441 | * Updates the QComboBox with the current mimetypes |
438 | */ | 442 | */ |
439 | void updateMimeCheck(); | 443 | void updateMimeCheck(); |
440 | 444 | ||
445 | void initializeOldSelector(); | ||
446 | void initLister(); | ||
447 | void initToolbar(); | ||
448 | void initLocations(); | ||
449 | void initializeView() {}; // FIXME | ||
441 | /** | 450 | /** |
442 | * Returns the current mimetype | 451 | * Returns the current mimetype |
443 | */ | 452 | */ |
444 | QString currentMimeType()const; | 453 | QString currentMimeType()const; |
445 | class OFileSelectorPrivate; | 454 | class OFileSelectorPrivate; |
446 | OFileSelectorPrivate *d; | 455 | OFileSelectorPrivate *d; |
447 | static QMap<QString,QPixmap> *m_pixmaps; | 456 | static QMap<QString,QPixmap> *m_pixmaps; |
448 | 457 | ||
449 | private slots: | 458 | private slots: |
450 | void slotFileSelected(const QString & ); // not really meant to be a slot | 459 | void slotFileSelected(const QString & ); // not really meant to be a slot |
451 | void slotFileBridgeSelected( const DocLnk & ); | 460 | void slotFileBridgeSelected( const DocLnk & ); |
452 | // listview above | 461 | // listview above |
453 | // popup below | 462 | // popup below |
454 | virtual void slotDelete(); | 463 | virtual void slotDelete(); |
455 | virtual void cdUP(); | 464 | virtual void cdUP(); |
456 | virtual void slotHome(); | 465 | virtual void slotHome(); |
457 | virtual void slotDoc(); | 466 | virtual void slotDoc(); |
458 | virtual void slotNavigate( ); | 467 | virtual void slotNavigate( ); |
459 | 468 | ||
460 | /* for OLister */ | 469 | /* for OLister */ |
461 | private: | 470 | private: |
462 | 471 | ||
463 | /* for OFileView */ | 472 | /* for OFileView */ |
464 | private: | 473 | private: |
465 | void internFileSelected( const QString& ); | 474 | void internFileSelected( const QString& ); |
466 | void internFileSelected( const DocLnk& ); | 475 | void internFileSelected( const DocLnk& ); |
467 | void internContextMenu(); | 476 | void internContextMenu(); |
468 | void internChangedDir( const QString& ); | 477 | void internChangedDir( const QString& ); |
469 | void internChangedDir( const QDir& ) ; | 478 | void internChangedDir( const QDir& ) ; |
470 | 479 | ||
471 | }; | 480 | }; |
472 | 481 | ||
473 | 482 | ||
474 | #endif | 483 | #endif |
475 | 484 | ||
diff --git a/libopie/ofileselector/olister.h b/libopie/ofileselector/olister.h index 081b876..ef61cab 100644 --- a/libopie/ofileselector/olister.h +++ b/libopie/ofileselector/olister.h | |||
@@ -1,38 +1,39 @@ | |||
1 | #ifndef OPIE_FILE_LISTER_H | 1 | #ifndef OPIE_FILE_LISTER_H |
2 | #define OPIE_FILE_LISTER_H | 2 | #define OPIE_FILE_LISTER_H |
3 | 3 | ||
4 | #include <qfileinfo.h> | 4 | #include <qfileinfo.h> |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qstringlist.h> | ||
7 | 8 | ||
8 | class OFileSelector; | 9 | class OFileSelector; |
9 | /** | 10 | /** |
10 | * lister is something like KIO but very | 11 | * lister is something like KIO but very |
11 | * very basic and currently only for | 12 | * very basic and currently only for |
12 | * populating our views. | 13 | * populating our views. |
13 | * This is a base class which needs to be implemented. | 14 | * This is a base class which needs to be implemented. |
14 | * @see OLocalLister for a filesystem based implementation | 15 | * @see OLocalLister for a filesystem based implementation |
15 | */ | 16 | */ |
16 | class OLister { | 17 | class OLister { |
17 | public: | 18 | public: |
18 | OLister( OFileSelector* ); | 19 | OLister( OFileSelector* ); |
19 | virtual ~OLister(); | 20 | virtual ~OLister(); |
20 | virtual void reparse(const QString& path) = 0; | 21 | virtual void reparse(const QString& path) = 0; |
21 | 22 | ||
22 | /** | 23 | /** |
23 | * return a list of available mimetypes | 24 | * return a list of available mimetypes |
24 | */ | 25 | */ |
25 | virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0; | 26 | virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0; |
26 | 27 | ||
27 | protected: | 28 | protected: |
28 | bool showFiles()const; | 29 | bool showFiles()const; |
29 | bool showDirs()const; | 30 | bool showDirs()const; |
30 | bool compliesMime( const QString& mime ); | 31 | bool compliesMime( const QString& mime ); |
31 | void addFile( const QString& mine, | 32 | void addFile( const QString& mine, |
32 | QFileInfo*, | 33 | QFileInfo*, |
33 | bool isSymlink = FALSE ); | 34 | bool isSymlink = FALSE ); |
34 | void addFile( const QString& mine, | 35 | void addFile( const QString& mine, |
35 | const QString& path, | 36 | const QString& path, |
36 | const QString& file, | 37 | const QString& file, |
37 | bool isSymlink = FALSE ); | 38 | bool isSymlink = FALSE ); |
38 | void addDir( const QString& mine, | 39 | void addDir( const QString& mine, |
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp index 95de1df..d8f73c7 100644 --- a/libopie/pim/opimrecord.cpp +++ b/libopie/pim/opimrecord.cpp | |||
@@ -1,90 +1,106 @@ | |||
1 | #include "opimrecord.h" | 1 | #include "opimrecord.h" |
2 | 2 | ||
3 | OPimRecord::OPimRecord( int uid ) | 3 | OPimRecord::OPimRecord( int uid ) |
4 | : Qtopia::Record() { | 4 | : Qtopia::Record() { |
5 | |||
5 | setUid( uid ); | 6 | setUid( uid ); |
7 | /* assign a new UID */ | ||
6 | if ( uid == 1 ) | 8 | if ( uid == 1 ) |
7 | assignUid(); | 9 | assignUid(); |
8 | } | 10 | } |
9 | OPimRecord::~OPimRecord() { | 11 | OPimRecord::~OPimRecord() { |
10 | } | 12 | } |
11 | OPimRecord::OPimRecord( OPimRecord& rec ) | 13 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
12 | : Qtopia::Record( rec ) | 14 | : Qtopia::Record( rec ) |
13 | { | 15 | { |
14 | (*this) = rec; | 16 | (*this) = rec; |
15 | } | 17 | } |
16 | 18 | ||
17 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | 19 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { |
18 | /* how do I call the parent copy operator ? */ | 20 | Qtopia::Record::operator=( rec ); |
19 | setUid( rec.uid() ); | 21 | m_relations = rec.m_relations; |
20 | setCategories( rec.categories() ); | 22 | |
21 | return *this; | 23 | return *this; |
22 | } | 24 | } |
23 | QStringList OPimRecord::categoryNames()const { | 25 | QStringList OPimRecord::categoryNames()const { |
24 | QStringList list; | 26 | QStringList list; |
25 | 27 | ||
26 | return list; | 28 | return list; |
27 | } | 29 | } |
28 | void OPimRecord::setCategoryName( const QStringList& ) { | 30 | void OPimRecord::setCategoryNames( const QStringList& ) { |
29 | 31 | ||
30 | } | 32 | } |
31 | void OPimRecord::addCategoryName( const QString& ) { | 33 | void OPimRecord::addCategoryName( const QString& ) { |
32 | 34 | ||
33 | } | 35 | } |
34 | bool OPimRecord::isEmpty()const { | 36 | bool OPimRecord::isEmpty()const { |
35 | return ( uid() == 0 ); | 37 | return ( uid() == 0 ); |
36 | } | 38 | } |
37 | QStringList OPimRecord::relatedApps()const{ | 39 | QStringList OPimRecord::relatedApps()const{ |
38 | QStringList list; | 40 | QStringList list; |
39 | QMap<QString, QArray<int> >::ConstIterator it; | 41 | QMap<QString, QArray<int> >::ConstIterator it; |
40 | for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { | 42 | for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { |
41 | list << it.key(); | 43 | list << it.key(); |
42 | } | 44 | } |
43 | return list; | 45 | return list; |
44 | } | 46 | } |
45 | QArray<int> OPimRecord::relations(const QString& app )const { | 47 | QArray<int> OPimRecord::relations(const QString& app )const { |
46 | QArray<int> tmp; | 48 | QArray<int> tmp; |
47 | QMap<QString, QArray<int> >::ConstIterator it; | 49 | QMap<QString, QArray<int> >::ConstIterator it; |
48 | it = m_relations.find( app); | 50 | it = m_relations.find( app); |
49 | if ( it != m_relations.end() ) | 51 | if ( it != m_relations.end() ) |
50 | tmp = it.data(); | 52 | tmp = it.data(); |
51 | return tmp; | 53 | return tmp; |
52 | } | 54 | } |
53 | void OPimRecord::clearRelation( const QString& app ) { | 55 | void OPimRecord::clearRelation( const QString& app ) { |
54 | m_relations.remove( app ); | 56 | m_relations.remove( app ); |
55 | } | 57 | } |
56 | void OPimRecord::addRelation( const QString& app, int id ) { | 58 | void OPimRecord::addRelation( const QString& app, int id ) { |
57 | 59 | ||
58 | QMap<QString, QArray<int> >::Iterator it; | 60 | QMap<QString, QArray<int> >::Iterator it; |
59 | QArray<int> tmp; | 61 | QArray<int> tmp; |
60 | 62 | ||
61 | it = m_relations.find( app ); | 63 | it = m_relations.find( app ); |
62 | if ( it == m_relations.end() ) { | 64 | if ( it == m_relations.end() ) { |
63 | tmp.resize(1 ); | 65 | tmp.resize(1 ); |
64 | tmp[0] = id; | 66 | tmp[0] = id; |
65 | }else{ | 67 | }else{ |
66 | tmp = it.data(); | 68 | tmp = it.data(); |
67 | tmp.resize( tmp.size() + 1 ); | 69 | tmp.resize( tmp.size() + 1 ); |
68 | tmp[tmp.size() - 1] = id; | 70 | tmp[tmp.size() - 1] = id; |
69 | } | 71 | } |
70 | m_relations.replace( app, tmp ); | 72 | m_relations.replace( app, tmp ); |
71 | } | 73 | } |
72 | void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { | 74 | void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { |
73 | 75 | ||
74 | QMap<QString, QArray<int> >::Iterator it; | 76 | QMap<QString, QArray<int> >::Iterator it; |
75 | QArray<int> tmp; | 77 | QArray<int> tmp; |
76 | 78 | ||
77 | it = m_relations.find( app); | 79 | it = m_relations.find( app); |
78 | if ( it == m_relations.end() ) { | 80 | if ( it == m_relations.end() ) { |
79 | tmp = ids; | 81 | tmp = ids; |
80 | }else{ | 82 | }else{ |
81 | tmp = it.data(); | 83 | tmp = it.data(); |
82 | int offset = tmp.size()-1; | 84 | int offset = tmp.size()-1; |
83 | tmp.resize( tmp.size() + ids.size() ); | 85 | tmp.resize( tmp.size() + ids.size() ); |
84 | for (uint i = 0; i < ids.size(); i++ ) { | 86 | for (uint i = 0; i < ids.size(); i++ ) { |
85 | tmp[offset+i] = ids[i]; | 87 | tmp[offset+i] = ids[i]; |
86 | } | 88 | } |
87 | 89 | ||
88 | } | 90 | } |
89 | m_relations.replace( app, tmp ); | 91 | m_relations.replace( app, tmp ); |
90 | } | 92 | } |
93 | QString OPimRecord::crossToString()const { | ||
94 | QString str; | ||
95 | QMap<QString, QArray<int> >::ConstIterator it; | ||
96 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { | ||
97 | QArray<int> id = it.data(); | ||
98 | for ( uint i = 0; i < id.size(); ++i ) { | ||
99 | str += it.key() + "," + QString::number( i ) + ";"; | ||
100 | } | ||
101 | } | ||
102 | str = str.remove( str.length()-1, 1); // strip the ; | ||
103 | //qWarning("IDS " + str ); | ||
104 | |||
105 | return str; | ||
106 | } | ||
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h index a0e0413..18112d4 100644 --- a/libopie/pim/opimrecord.h +++ b/libopie/pim/opimrecord.h | |||
@@ -1,69 +1,69 @@ | |||
1 | #ifndef OPIE_PIM_RECORD_H | 1 | #ifndef OPIE_PIM_RECORD_H |
2 | #define OPIE_PIM_RECORD_H | 2 | #define OPIE_PIM_RECORD_H |
3 | 3 | ||
4 | #include <qmap.h> | 4 | #include <qmap.h> |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | #include <qstringlist.h> | 6 | #include <qstringlist.h> |
7 | 7 | ||
8 | #include <qpe/palmtoprecord.h> | 8 | #include <qpe/palmtoprecord.h> |
9 | 9 | ||
10 | class OPimRecord : public Qtopia::Record { | 10 | class OPimRecord : public Qtopia::Record { |
11 | public: | 11 | public: |
12 | /** | 12 | /** |
13 | * uid of 0 isEmpty | 13 | * uid of 0 isEmpty |
14 | * uid of 1 will be assigned a new one | 14 | * uid of 1 will be assigned a new one |
15 | */ | 15 | */ |
16 | OPimRecord(int uid = 0); | 16 | OPimRecord(int uid = 0); |
17 | ~OPimRecord(); | 17 | ~OPimRecord(); |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * copy c'tor | 20 | * copy c'tor |
21 | */ | 21 | */ |
22 | OPimRecord( OPimRecord& rec ); | 22 | OPimRecord( const OPimRecord& rec ); |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * copy operator | 25 | * copy operator |
26 | */ | 26 | */ |
27 | OPimRecord &operator=( const OPimRecord& ); | 27 | OPimRecord &operator=( const OPimRecord& ); |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * category names resolved | 30 | * category names resolved |
31 | */ | 31 | */ |
32 | QStringList categoryNames()const; | 32 | QStringList categoryNames()const; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * set category names they will be resolved | 35 | * set category names they will be resolved |
36 | */ | 36 | */ |
37 | void setCategoryName( const QStringList& ); | 37 | void setCategoryNames( const QStringList& ); |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * addCategoryName adds a name | 40 | * addCategoryName adds a name |
41 | * to the internal category list | 41 | * to the internal category list |
42 | */ | 42 | */ |
43 | void addCategoryName( const QString& ); | 43 | void addCategoryName( const QString& ); |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * if a Record isEmpty | 46 | * if a Record isEmpty |
47 | */ | 47 | */ |
48 | virtual bool isEmpty()const; | 48 | virtual bool isEmpty()const; |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * toRichText summary | 51 | * toRichText summary |
52 | */ | 52 | */ |
53 | virtual QString toRichText()const = 0; | 53 | virtual QString toRichText()const = 0; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * a small one line summary | 56 | * a small one line summary |
57 | */ | 57 | */ |
58 | virtual QString toShortText()const = 0; | 58 | virtual QString toShortText()const = 0; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * the name of the Record | 61 | * the name of the Record |
62 | */ | 62 | */ |
63 | virtual QString type()const = 0; | 63 | virtual QString type()const = 0; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * converts the internal structure to a map | 66 | * converts the internal structure to a map |
67 | */ | 67 | */ |
68 | virtual QMap<int, QString> toMap()const = 0; | 68 | virtual QMap<int, QString> toMap()const = 0; |
69 | 69 | ||
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp index d8e0447..3c93838 100644 --- a/libopie/pim/otodo.cpp +++ b/libopie/pim/otodo.cpp | |||
@@ -1,507 +1,354 @@ | |||
1 | 1 | ||
2 | #include <qobject.h> | 2 | #include <qobject.h> |
3 | #include <qshared.h> | 3 | #include <qshared.h> |
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
7 | #include <qpe/palmtopuidgen.h> | 7 | #include <qpe/palmtopuidgen.h> |
8 | #include <qpe/stringutil.h> | 8 | #include <qpe/stringutil.h> |
9 | #include <qpe/palmtoprecord.h> | 9 | #include <qpe/palmtoprecord.h> |
10 | #include <qpe/stringutil.h> | 10 | #include <qpe/stringutil.h> |
11 | #include <qpe/categories.h> | 11 | #include <qpe/categories.h> |
12 | #include <qpe/categoryselect.h> | 12 | #include <qpe/categoryselect.h> |
13 | 13 | ||
14 | #include "todoevent.h" | ||
15 | 14 | ||
16 | using namespace Opie; | ||
17 | 15 | ||
18 | Qtopia::UidGen ToDoEvent::m_gen; | 16 | #include "otodo.h" |
19 | 17 | ||
20 | struct ToDoEvent::ToDoEventData : public QShared { | 18 | |
21 | ToDoEventData() : QShared() { | 19 | struct OTodo::OTodoData : public QShared { |
20 | OTodoData() : QShared() { | ||
22 | }; | 21 | }; |
23 | 22 | ||
24 | QDate date; | 23 | QDate date; |
25 | bool isCompleted:1; | 24 | bool isCompleted:1; |
26 | bool hasDate:1; | 25 | bool hasDate:1; |
27 | int priority; | 26 | int priority; |
28 | QStringList category; | 27 | QStringList category; |
29 | QString desc; | 28 | QString desc; |
30 | QString sum; | 29 | QString sum; |
31 | QMap<QString, QString> extra; | 30 | QMap<QString, QString> extra; |
32 | QMap<QString, QArray<int> > relations; | ||
33 | int uid; | ||
34 | ushort prog; | 31 | ushort prog; |
35 | bool hasAlarmDateTime :1; | 32 | bool hasAlarmDateTime :1; |
36 | QDateTime alarmDateTime; | 33 | QDateTime alarmDateTime; |
37 | }; | 34 | }; |
38 | 35 | ||
39 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) | 36 | OTodo::OTodo(const OTodo &event ) |
40 | : data( event.data ) | 37 | : OPimRecord( event ), data( event.data ) |
41 | { | 38 | { |
42 | data->ref(); | 39 | data->ref(); |
43 | //qWarning("ref up"); | 40 | //qWarning("ref up"); |
44 | } | 41 | } |
45 | ToDoEvent::~ToDoEvent() { | 42 | OTodo::~OTodo() { |
46 | if ( data->deref() ) { | 43 | if ( data->deref() ) { |
47 | //qWarning("ToDoEvent::dereffing"); | 44 | //qWarning("OTodo::dereffing"); |
48 | delete data; | 45 | delete data; |
49 | data = 0l; | 46 | data = 0l; |
50 | } | 47 | } |
51 | } | 48 | } |
52 | 49 | ||
53 | ToDoEvent::ToDoEvent(bool completed, int priority, | 50 | OTodo::OTodo(bool completed, int priority, |
54 | const QStringList &category, | 51 | const QStringList &category, |
55 | const QString& summary, | 52 | const QString& summary, |
56 | const QString &description, | 53 | const QString &description, |
57 | ushort progress, | 54 | ushort progress, |
58 | bool hasDate, QDate date, int uid ) | 55 | bool hasDate, QDate date, int uid ) |
56 | : OPimRecord( uid ) | ||
59 | { | 57 | { |
60 | //qWarning("ToDoEventData"); | 58 | //qWarning("OTodoData"); |
61 | data = new ToDoEventData; | 59 | setCategories( idsFromString( category.join(";") ) ); |
60 | data = new OTodoData; | ||
62 | data->date = date; | 61 | data->date = date; |
63 | data->isCompleted = completed; | 62 | data->isCompleted = completed; |
64 | data->hasDate = hasDate; | 63 | data->hasDate = hasDate; |
65 | data->priority = priority; | 64 | data->priority = priority; |
66 | data->category = category; | ||
67 | data->sum = summary; | 65 | data->sum = summary; |
68 | data->prog = progress; | 66 | data->prog = progress; |
69 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 67 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
70 | if (uid == -1 ) { | ||
71 | uid = m_gen.generate(); | ||
72 | |||
73 | }// generated the ids | ||
74 | m_gen.store( uid ); | ||
75 | |||
76 | data->uid = uid; | ||
77 | data->hasAlarmDateTime = false; | 68 | data->hasAlarmDateTime = false; |
78 | 69 | ||
79 | } | 70 | } |
80 | QArray<int> ToDoEvent::categories()const | 71 | bool OTodo::match( const QRegExp ®Exp )const |
81 | { | ||
82 | qWarning( "ToDoEvent:cats" + data->category.join(";") ); | ||
83 | QArray<int> array(data->category.count() ); // currently the datebook can be only in one category | ||
84 | array = Qtopia::Record::idsFromString( data->category.join(";") ); | ||
85 | return array; | ||
86 | } | ||
87 | bool ToDoEvent::match( const QRegExp ®Exp )const | ||
88 | { | 72 | { |
89 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 73 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
90 | return true; | 74 | return true; |
91 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 75 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ |
92 | return true; | 76 | return true; |
93 | }else if(data->desc.find( regExp ) != -1 ){ | 77 | }else if(data->desc.find( regExp ) != -1 ){ |
94 | return true; | 78 | return true; |
79 | }else if(data->sum.find( regExp ) != -1 ) { | ||
80 | return true; | ||
95 | } | 81 | } |
96 | return false; | 82 | return false; |
97 | } | 83 | } |
98 | bool ToDoEvent::isCompleted() const | 84 | bool OTodo::isCompleted() const |
99 | { | 85 | { |
100 | return data->isCompleted; | 86 | return data->isCompleted; |
101 | } | 87 | } |
102 | bool ToDoEvent::hasDueDate() const | 88 | bool OTodo::hasDueDate() const |
103 | { | 89 | { |
104 | return data->hasDate; | 90 | return data->hasDate; |
105 | } | 91 | } |
106 | bool ToDoEvent::hasAlarmDateTime() const | 92 | bool OTodo::hasAlarmDateTime() const |
107 | { | 93 | { |
108 | return data->hasAlarmDateTime; | 94 | return data->hasAlarmDateTime; |
109 | } | 95 | } |
110 | int ToDoEvent::priority()const | 96 | int OTodo::priority()const |
111 | { | 97 | { |
112 | return data->priority; | 98 | return data->priority; |
113 | } | 99 | } |
114 | QStringList ToDoEvent::allCategories()const | 100 | QString OTodo::summary() const |
115 | { | ||
116 | return data->category; | ||
117 | } | ||
118 | QString ToDoEvent::extra(const QString& )const | ||
119 | { | ||
120 | return QString::null; | ||
121 | } | ||
122 | QString ToDoEvent::summary() const | ||
123 | { | 101 | { |
124 | return data->sum; | 102 | return data->sum; |
125 | } | 103 | } |
126 | ushort ToDoEvent::progress() const | 104 | ushort OTodo::progress() const |
127 | { | 105 | { |
128 | return data->prog; | 106 | return data->prog; |
129 | } | 107 | } |
130 | QStringList ToDoEvent::relatedApps() const | 108 | QDate OTodo::dueDate()const |
131 | { | ||
132 | QStringList list; | ||
133 | QMap<QString, QArray<int> >::ConstIterator it; | ||
134 | for ( it = data->relations.begin(); it != data->relations.end(); ++it ) { | ||
135 | list << it.key(); | ||
136 | } | ||
137 | return list; | ||
138 | } | ||
139 | QArray<int> ToDoEvent::relations( const QString& app)const | ||
140 | { | ||
141 | QArray<int> tmp; | ||
142 | QMap<QString, QArray<int> >::ConstIterator it; | ||
143 | it = data->relations.find( app); | ||
144 | if ( it != data->relations.end() ) | ||
145 | tmp = it.data(); | ||
146 | return tmp; | ||
147 | } | ||
148 | void ToDoEvent::insertCategory(const QString &str ) | ||
149 | { | ||
150 | changeOrModify(); | ||
151 | qWarning("insert category;" + str ); | ||
152 | data->category.append( str ); | ||
153 | } | ||
154 | void ToDoEvent::clearCategories() | ||
155 | { | ||
156 | changeOrModify(); | ||
157 | data->category.clear(); | ||
158 | } | ||
159 | void ToDoEvent::setCategories(const QStringList &list ) | ||
160 | { | ||
161 | changeOrModify(); | ||
162 | qWarning("set categories" + list.join(";") ); | ||
163 | data->category = list; | ||
164 | } | ||
165 | QDate ToDoEvent::dueDate()const | ||
166 | { | 109 | { |
167 | return data->date; | 110 | return data->date; |
168 | } | 111 | } |
169 | 112 | ||
170 | QDateTime ToDoEvent::alarmDateTime() const | 113 | QDateTime OTodo::alarmDateTime() const |
171 | { | 114 | { |
172 | return data->alarmDateTime; | 115 | return data->alarmDateTime; |
173 | } | 116 | } |
174 | 117 | ||
175 | QString ToDoEvent::description()const | 118 | QString OTodo::description()const |
176 | { | 119 | { |
177 | return data->desc; | 120 | return data->desc; |
178 | } | 121 | } |
179 | void ToDoEvent::setCompleted( bool completed ) | 122 | void OTodo::setCompleted( bool completed ) |
180 | { | 123 | { |
181 | changeOrModify(); | 124 | changeOrModify(); |
182 | data->isCompleted = completed; | 125 | data->isCompleted = completed; |
183 | } | 126 | } |
184 | void ToDoEvent::setHasDueDate( bool hasDate ) | 127 | void OTodo::setHasDueDate( bool hasDate ) |
185 | { | 128 | { |
186 | changeOrModify(); | 129 | changeOrModify(); |
187 | data->hasDate = hasDate; | 130 | data->hasDate = hasDate; |
188 | } | 131 | } |
189 | void ToDoEvent::setHasAlarmDateTime( bool hasAlarmDateTime ) | 132 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) |
190 | { | 133 | { |
191 | changeOrModify(); | 134 | changeOrModify(); |
192 | data->hasAlarmDateTime = hasAlarmDateTime; | 135 | data->hasAlarmDateTime = hasAlarmDateTime; |
193 | } | 136 | } |
194 | void ToDoEvent::setDescription(const QString &desc ) | 137 | void OTodo::setDescription(const QString &desc ) |
195 | { | 138 | { |
196 | changeOrModify(); | 139 | changeOrModify(); |
197 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 140 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); |
198 | } | 141 | } |
199 | void ToDoEvent::setExtra( const QString&, const QString& ) | 142 | void OTodo::setSummary( const QString& sum ) |
200 | { | ||
201 | |||
202 | } | ||
203 | void ToDoEvent::setSummary( const QString& sum ) | ||
204 | { | 143 | { |
205 | changeOrModify(); | 144 | changeOrModify(); |
206 | data->sum = sum; | 145 | data->sum = sum; |
207 | } | 146 | } |
208 | void ToDoEvent::setCategory( const QString &cat ) | 147 | void OTodo::setPriority(int prio ) |
209 | { | ||
210 | changeOrModify(); | ||
211 | //qWarning("setCategory %s", cat.latin1() ); | ||
212 | data->category.clear(); | ||
213 | data->category << cat; | ||
214 | } | ||
215 | void ToDoEvent::setPriority(int prio ) | ||
216 | { | 148 | { |
217 | changeOrModify(); | 149 | changeOrModify(); |
218 | data->priority = prio; | 150 | data->priority = prio; |
219 | } | 151 | } |
220 | void ToDoEvent::setDueDate( QDate date ) | 152 | void OTodo::setDueDate( QDate date ) |
221 | { | 153 | { |
222 | changeOrModify(); | 154 | changeOrModify(); |
223 | data->date = date; | 155 | data->date = date; |
224 | } | 156 | } |
225 | void ToDoEvent::setAlarmDateTime( const QDateTime& alarm ) | 157 | void OTodo::setAlarmDateTime( const QDateTime& alarm ) |
226 | { | 158 | { |
227 | changeOrModify(); | 159 | changeOrModify(); |
228 | data->alarmDateTime = alarm; | 160 | data->alarmDateTime = alarm; |
229 | } | 161 | } |
230 | void ToDoEvent::addRelated( const QString &app, int id ) | 162 | bool OTodo::isOverdue( ) |
231 | { | ||
232 | changeOrModify(); | ||
233 | |||
234 | QMap<QString, QArray<int> >::Iterator it; | ||
235 | QArray<int> tmp; | ||
236 | it = data->relations.find( app ); | ||
237 | if ( it == data->relations.end() ) { | ||
238 | tmp.resize(1 ); | ||
239 | tmp[0] = id; | ||
240 | }else{ | ||
241 | tmp = it.data(); | ||
242 | tmp.resize( tmp.size() + 1 ); | ||
243 | tmp[tmp.size() - 1] = id; | ||
244 | } | ||
245 | data->relations.replace( app, tmp ); | ||
246 | } | ||
247 | void ToDoEvent::addRelated(const QString& app, QArray<int> ids ) | ||
248 | { | ||
249 | changeOrModify(); | ||
250 | |||
251 | QMap<QString, QArray<int> >::Iterator it; | ||
252 | QArray<int> tmp; | ||
253 | it = data->relations.find( app); | ||
254 | if ( it == data->relations.end() ) { // not there | ||
255 | /** tmp.resize( ids.size() ); stupid?? | ||
256 | */ | ||
257 | tmp = ids; | ||
258 | }else{ | ||
259 | tmp = it.data(); | ||
260 | int offset = tmp.size()-1; | ||
261 | tmp.resize( tmp.size() + ids.size() ); | ||
262 | for (uint i = 0; i < ids.size(); i++ ) { | ||
263 | tmp[offset+i] = ids[i]; | ||
264 | } | ||
265 | |||
266 | } | ||
267 | data->relations.replace( app, tmp ); | ||
268 | } | ||
269 | void ToDoEvent::clearRelated( const QString& app ) | ||
270 | { | ||
271 | changeOrModify(); | ||
272 | data->relations.remove( app ); | ||
273 | } | ||
274 | bool ToDoEvent::isOverdue( ) | ||
275 | { | 163 | { |
276 | if( data->hasDate ) | 164 | if( data->hasDate ) |
277 | return QDate::currentDate() > data->date; | 165 | return QDate::currentDate() > data->date; |
278 | return false; | 166 | return false; |
279 | } | 167 | } |
280 | void ToDoEvent::setProgress(ushort progress ) | 168 | void OTodo::setProgress(ushort progress ) |
281 | { | 169 | { |
282 | changeOrModify(); | 170 | changeOrModify(); |
283 | data->prog = progress; | 171 | data->prog = progress; |
284 | } | 172 | } |
173 | QString OTodo::toShortText() const { | ||
174 | return summary(); | ||
175 | } | ||
285 | /*! | 176 | /*! |
286 | Returns a richt text string | 177 | Returns a richt text string |
287 | */ | 178 | */ |
288 | QString ToDoEvent::richText() const | 179 | QString OTodo::toRichText() const |
289 | { | 180 | { |
290 | QString text; | 181 | QString text; |
291 | QStringList catlist; | 182 | QStringList catlist; |
292 | 183 | ||
293 | // Description of the todo | 184 | // Description of the todo |
294 | if ( !summary().isEmpty() ) { | 185 | if ( !summary().isEmpty() ) { |
295 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; | 186 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; |
296 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 187 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
297 | } | 188 | } |
298 | if( !description().isEmpty() ){ | 189 | if( !description().isEmpty() ){ |
299 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 190 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
300 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; | 191 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; |
301 | } | 192 | } |
302 | text += "<br><br><br>"; | 193 | text += "<br><br><br>"; |
303 | 194 | ||
304 | text += "<b>" + QObject::tr( "Priority:") +" </b>" | 195 | text += "<b>" + QObject::tr( "Priority:") +" </b>" |
305 | + QString::number( priority() ) + " <br>"; | 196 | + QString::number( priority() ) + " <br>"; |
306 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 197 | text += "<b>" + QObject::tr( "Progress:") + " </b>" |
307 | + QString::number( progress() ) + " %<br>"; | 198 | + QString::number( progress() ) + " %<br>"; |
308 | if (hasDueDate() ){ | 199 | if (hasDueDate() ){ |
309 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; | 200 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; |
310 | text += dueDate().toString(); | 201 | text += dueDate().toString(); |
311 | text += "<br>"; | 202 | text += "<br>"; |
312 | } | 203 | } |
313 | if (hasAlarmDateTime() ){ | 204 | if (hasAlarmDateTime() ){ |
314 | text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; | 205 | text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; |
315 | text += alarmDateTime().toString(); | 206 | text += alarmDateTime().toString(); |
316 | text += "<br>"; | 207 | text += "<br>"; |
317 | } | 208 | } |
318 | 209 | ||
319 | // Open database of all categories and get the list of | ||
320 | // the categories this todoevent belongs to. | ||
321 | // Then print them... | ||
322 | // I am not sure whether there is no better way doing this !? | ||
323 | Categories catdb; | ||
324 | bool firstloop = true; | ||
325 | catdb.load( categoryFileName() ); | ||
326 | catlist = allCategories(); | ||
327 | |||
328 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 210 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
329 | for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { | 211 | text += categoryNames().join(", "); |
330 | if (!firstloop){ | ||
331 | text += ", "; | ||
332 | } | ||
333 | firstloop = false; | ||
334 | text += catdb.label ("todo", (*it).toInt()); | ||
335 | } | ||
336 | text += "<br>"; | 212 | text += "<br>"; |
213 | |||
337 | return text; | 214 | return text; |
338 | } | 215 | } |
339 | 216 | ||
340 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ | 217 | bool OTodo::operator<( const OTodo &toDoEvent )const{ |
341 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 218 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
342 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 219 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
343 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 220 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
344 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 221 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
345 | return priority() < toDoEvent.priority(); | 222 | return priority() < toDoEvent.priority(); |
346 | }else{ | 223 | }else{ |
347 | return dueDate() < toDoEvent.dueDate(); | 224 | return dueDate() < toDoEvent.dueDate(); |
348 | } | 225 | } |
349 | } | 226 | } |
350 | return false; | 227 | return false; |
351 | } | 228 | } |
352 | bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const | 229 | bool OTodo::operator<=(const OTodo &toDoEvent )const |
353 | { | 230 | { |
354 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 231 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
355 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 232 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
356 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 233 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
357 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 234 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
358 | return priority() <= toDoEvent.priority(); | 235 | return priority() <= toDoEvent.priority(); |
359 | }else{ | 236 | }else{ |
360 | return dueDate() <= toDoEvent.dueDate(); | 237 | return dueDate() <= toDoEvent.dueDate(); |
361 | } | 238 | } |
362 | } | 239 | } |
363 | return true; | 240 | return true; |
364 | } | 241 | } |
365 | bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const | 242 | bool OTodo::operator>(const OTodo &toDoEvent )const |
366 | { | 243 | { |
367 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | 244 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; |
368 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 245 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
369 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 246 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
370 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 247 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
371 | return priority() > toDoEvent.priority(); | 248 | return priority() > toDoEvent.priority(); |
372 | }else{ | 249 | }else{ |
373 | return dueDate() > toDoEvent.dueDate(); | 250 | return dueDate() > toDoEvent.dueDate(); |
374 | } | 251 | } |
375 | } | 252 | } |
376 | return false; | 253 | return false; |
377 | } | 254 | } |
378 | bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const | 255 | bool OTodo::operator>=(const OTodo &toDoEvent )const |
379 | { | 256 | { |
380 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 257 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
381 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 258 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
382 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 259 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
383 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 260 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
384 | return priority() > toDoEvent.priority(); | 261 | return priority() > toDoEvent.priority(); |
385 | }else{ | 262 | }else{ |
386 | return dueDate() > toDoEvent.dueDate(); | 263 | return dueDate() > toDoEvent.dueDate(); |
387 | } | 264 | } |
388 | } | 265 | } |
389 | return true; | 266 | return true; |
390 | } | 267 | } |
391 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const | 268 | bool OTodo::operator==(const OTodo &toDoEvent )const |
392 | { | 269 | { |
393 | if( data->priority == toDoEvent.data->priority && | 270 | if( data->priority == toDoEvent.data->priority && |
394 | data->priority == toDoEvent.data->prog && | 271 | data->priority == toDoEvent.data->prog && |
395 | data->isCompleted == toDoEvent.data->isCompleted && | 272 | data->isCompleted == toDoEvent.data->isCompleted && |
396 | data->hasDate == toDoEvent.data->hasDate && | 273 | data->hasDate == toDoEvent.data->hasDate && |
397 | data->date == toDoEvent.data->date && | 274 | data->date == toDoEvent.data->date && |
398 | data->category == toDoEvent.data->category && | 275 | data->category == toDoEvent.data->category && |
399 | data->sum == toDoEvent.data->sum && | 276 | data->sum == toDoEvent.data->sum && |
400 | data->desc == toDoEvent.data->desc && | 277 | data->desc == toDoEvent.data->desc && |
401 | data->hasAlarmDateTime == toDoEvent.data->hasAlarmDateTime && | 278 | data->hasAlarmDateTime == toDoEvent.data->hasAlarmDateTime && |
402 | data->alarmDateTime == toDoEvent.data->alarmDateTime ) | 279 | data->alarmDateTime == toDoEvent.data->alarmDateTime ) |
403 | return true; | 280 | return true; |
404 | 281 | ||
405 | return false; | 282 | return false; |
406 | } | 283 | } |
407 | void ToDoEvent::deref() { | 284 | void OTodo::deref() { |
408 | 285 | ||
409 | //qWarning("deref in ToDoEvent"); | 286 | //qWarning("deref in ToDoEvent"); |
410 | if ( data->deref() ) { | 287 | if ( data->deref() ) { |
411 | //qWarning("deleting"); | 288 | //qWarning("deleting"); |
412 | delete data; | 289 | delete data; |
413 | d= 0; | 290 | d= 0; |
414 | } | 291 | } |
415 | } | 292 | } |
416 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) | 293 | OTodo &OTodo::operator=(const OTodo &item ) |
417 | { | 294 | { |
295 | OPimRecord::operator=( item ); | ||
418 | //qWarning("operator= ref "); | 296 | //qWarning("operator= ref "); |
419 | item.data->ref(); | 297 | item.data->ref(); |
420 | deref(); | 298 | deref(); |
421 | 299 | ||
422 | data = item.data; | ||
423 | |||
424 | |||
425 | return *this; | 300 | return *this; |
426 | } | 301 | } |
427 | 302 | ||
428 | QMap<int, QString> ToDoEvent::toMap() const { | 303 | QMap<int, QString> OTodo::toMap() const { |
429 | QMap<int, QString> map; | 304 | QMap<int, QString> map; |
430 | 305 | ||
431 | map.insert( Uid, QString::number( data->uid ) ); | 306 | map.insert( Uid, QString::number( uid() ) ); |
432 | map.insert( Category, data->category.join(";") ); | 307 | map.insert( Category, idsToString( categories() ) ); |
433 | map.insert( HasDate, QString::number( data->hasDate ) ); | 308 | map.insert( HasDate, QString::number( data->hasDate ) ); |
434 | map.insert( Completed, QString::number( data->isCompleted ) ); | 309 | map.insert( Completed, QString::number( data->isCompleted ) ); |
435 | map.insert( Description, data->desc ); | 310 | map.insert( Description, data->desc ); |
436 | map.insert( Summary, data->sum ); | 311 | map.insert( Summary, data->sum ); |
437 | map.insert( Priority, QString::number( data->priority ) ); | 312 | map.insert( Priority, QString::number( data->priority ) ); |
438 | map.insert( DateDay, QString::number( data->date.day() ) ); | 313 | map.insert( DateDay, QString::number( data->date.day() ) ); |
439 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 314 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
440 | map.insert( DateYear, QString::number( data->date.year() ) ); | 315 | map.insert( DateYear, QString::number( data->date.year() ) ); |
441 | map.insert( Progress, QString::number( data->prog ) ); | 316 | map.insert( Progress, QString::number( data->prog ) ); |
442 | map.insert( CrossReference, crossToString() ); | 317 | map.insert( CrossReference, crossToString() ); |
443 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); | 318 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); |
444 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); | 319 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); |
445 | 320 | ||
446 | return map; | 321 | return map; |
447 | } | 322 | } |
448 | 323 | ||
449 | 324 | QMap<QString, QString> OTodo::toExtraMap()const { | |
450 | QString ToDoEvent::crossToString()const { | ||
451 | QString str; | ||
452 | QMap<QString, QArray<int> >::ConstIterator it; | ||
453 | for (it = data->relations.begin(); it != data->relations.end(); ++it ) { | ||
454 | QArray<int> id = it.data(); | ||
455 | for ( uint i = 0; i < id.size(); ++i ) { | ||
456 | str += it.key() + "," + QString::number( i ) + ";"; | ||
457 | } | ||
458 | } | ||
459 | str = str.remove( str.length()-1, 1); // strip the ; | ||
460 | //qWarning("IDS " + str ); | ||
461 | |||
462 | return str; | ||
463 | } | ||
464 | int ToDoEvent::uid()const { | ||
465 | return data->uid; | ||
466 | } | ||
467 | void ToDoEvent::setUid( int id ) { | ||
468 | if ( id == -1 ) | ||
469 | id = m_gen.generate(); | ||
470 | m_gen.store(id ); | ||
471 | changeOrModify(); | ||
472 | data->uid = id; | ||
473 | } | ||
474 | QMap<QString, QString> ToDoEvent::extras()const { | ||
475 | return data->extra; | 325 | return data->extra; |
476 | } | 326 | } |
477 | /** | 327 | /** |
478 | * change or modify looks at the ref count and either | 328 | * change or modify looks at the ref count and either |
479 | * creates a new QShared Object or it can modify it | 329 | * creates a new QShared Object or it can modify it |
480 | * right in place | 330 | * right in place |
481 | */ | 331 | */ |
482 | void ToDoEvent::changeOrModify() { | 332 | void OTodo::changeOrModify() { |
483 | if ( data->count != 1 ) { | 333 | if ( data->count != 1 ) { |
484 | //qWarning("changeOrModify"); | 334 | //qWarning("changeOrModify"); |
485 | data->deref(); | 335 | data->deref(); |
486 | ToDoEventData* d2 = new ToDoEventData(); | 336 | OTodoData* d2 = new OTodoData(); |
487 | copy(data, d2 ); | 337 | copy(data, d2 ); |
488 | data = d2; | 338 | data = d2; |
489 | } | 339 | } |
490 | } | 340 | } |
491 | void ToDoEvent::copy( ToDoEventData* src, ToDoEventData* dest ) { | 341 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
492 | dest->date = src->date; | 342 | dest->date = src->date; |
493 | dest->isCompleted = src->isCompleted; | 343 | dest->isCompleted = src->isCompleted; |
494 | dest->hasDate = src->hasDate; | 344 | dest->hasDate = src->hasDate; |
495 | dest->priority = src->priority; | 345 | dest->priority = src->priority; |
496 | dest->category = src->category; | ||
497 | dest->desc = src->desc; | 346 | dest->desc = src->desc; |
498 | dest->sum = src->sum; | 347 | dest->sum = src->sum; |
499 | dest->extra = src->extra; | 348 | dest->extra = src->extra; |
500 | dest->relations = src->relations; | ||
501 | dest->uid = src->uid; | ||
502 | dest->prog = src->prog; | 349 | dest->prog = src->prog; |
503 | dest->hasAlarmDateTime = src->hasAlarmDateTime; | 350 | dest->hasAlarmDateTime = src->hasAlarmDateTime; |
504 | dest->alarmDateTime = src->alarmDateTime; | 351 | dest->alarmDateTime = src->alarmDateTime; |
505 | } | 352 | } |
506 | 353 | ||
507 | 354 | ||
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h index 429108a..e1729db 100644 --- a/libopie/pim/otodo.h +++ b/libopie/pim/otodo.h | |||
@@ -1,53 +1,53 @@ | |||
1 | 1 | ||
2 | #ifndef OPIE_TODO_EVENT_H | 2 | #ifndef OPIE_TODO_EVENT_H |
3 | #define OPIE_TODO_EVENT_H | 3 | #define OPIE_TODO_EVENT_H |
4 | 4 | ||
5 | 5 | ||
6 | #include <qarray.h> | 6 | #include <qarray.h> |
7 | #include <qmap.h> | 7 | #include <qmap.h> |
8 | #include <qregexp.h> | 8 | #include <qregexp.h> |
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | #include <qdatetime.h> | 10 | #include <qdatetime.h> |
11 | #include <qvaluelist.h> | 11 | #include <qvaluelist.h> |
12 | 12 | ||
13 | #include <qpe/recordfields.h> | 13 | #include <qpe/recordfields.h> |
14 | #include <qpe/palmtopuidgen.h> | 14 | #include <qpe/palmtopuidgen.h> |
15 | 15 | ||
16 | #include <opie/opimrecord.h> | 16 | #include <opie/opimrecord.h> |
17 | 17 | ||
18 | 18 | ||
19 | class OTodo : public OPimRecord { | 19 | class OTodo : public OPimRecord { |
20 | public: | 20 | public: |
21 | typedef QValueList<ToDoEvent> ValueList; | 21 | typedef QValueList<OTodo> ValueList; |
22 | enum RecordFields { | 22 | enum RecordFields { |
23 | Uid = Qtopia::UID_ID, | 23 | Uid = Qtopia::UID_ID, |
24 | Category = Qtopia::CATEGORY_ID, | 24 | Category = Qtopia::CATEGORY_ID, |
25 | HasDate, | 25 | HasDate, |
26 | Completed, | 26 | Completed, |
27 | Description, | 27 | Description, |
28 | Summary, | 28 | Summary, |
29 | Priority, | 29 | Priority, |
30 | DateDay, | 30 | DateDay, |
31 | DateMonth, | 31 | DateMonth, |
32 | DateYear, | 32 | DateYear, |
33 | Progress, | 33 | Progress, |
34 | CrossReference, | 34 | CrossReference, |
35 | HasAlarmDateTime, | 35 | HasAlarmDateTime, |
36 | AlarmDateTime | 36 | AlarmDateTime |
37 | }; | 37 | }; |
38 | public: | 38 | public: |
39 | // priorities from Very low to very high | 39 | // priorities from Very low to very high |
40 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; | 40 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; |
41 | 41 | ||
42 | /* Constructs a new ToDoEvent | 42 | /* Constructs a new ToDoEvent |
43 | @param completed Is the TodoEvent completed | 43 | @param completed Is the TodoEvent completed |
44 | @param priority What is the priority of this ToDoEvent | 44 | @param priority What is the priority of this ToDoEvent |
45 | @param category Which category does it belong( uid ) | 45 | @param category Which category does it belong( uid ) |
46 | @param summary A small summary of the todo | 46 | @param summary A small summary of the todo |
47 | @param description What is this ToDoEvent about | 47 | @param description What is this ToDoEvent about |
48 | @param hasDate Does this Event got a deadline | 48 | @param hasDate Does this Event got a deadline |
49 | @param date what is the deadline? | 49 | @param date what is the deadline? |
50 | @param uid what is the UUID of this Event | 50 | @param uid what is the UUID of this Event |
51 | **/ | 51 | **/ |
52 | OTodo( bool completed = false, int priority = Normal, | 52 | OTodo( bool completed = false, int priority = Normal, |
53 | const QStringList &category = QStringList(), | 53 | const QStringList &category = QStringList(), |
@@ -89,64 +89,71 @@ public: | |||
89 | 89 | ||
90 | /** | 90 | /** |
91 | * progress as ushort 0, 20, 40, 60, 80 or 100% | 91 | * progress as ushort 0, 20, 40, 60, 80 or 100% |
92 | */ | 92 | */ |
93 | ushort progress() const; | 93 | ushort progress() const; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * The due Date | 96 | * The due Date |
97 | */ | 97 | */ |
98 | QDate dueDate()const; | 98 | QDate dueDate()const; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Alarm Date and Time | 101 | * Alarm Date and Time |
102 | */ | 102 | */ |
103 | QDateTime alarmDateTime()const; | 103 | QDateTime alarmDateTime()const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * The description of the todo | 106 | * The description of the todo |
107 | */ | 107 | */ |
108 | QString description()const; | 108 | QString description()const; |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * A small summary of the todo | 111 | * A small summary of the todo |
112 | */ | 112 | */ |
113 | QString summary() const; | 113 | QString summary() const; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * @reimplemented | 116 | * @reimplemented |
117 | * Return this todoevent in a RichText formatted QString | 117 | * Return this todoevent in a RichText formatted QString |
118 | */ | 118 | */ |
119 | QString toRichText() const; | 119 | QString toRichText() const; |
120 | 120 | ||
121 | /** | ||
122 | * reimplementation | ||
123 | */ | ||
124 | QString type()const; | ||
125 | QString toShortText()const; | ||
126 | QMap<QString, QString> toExtraMap()const; | ||
127 | QString recordField(int id )const; | ||
121 | 128 | ||
122 | /** | 129 | /** |
123 | * returns a list of apps which have related items | 130 | * returns a list of apps which have related items |
124 | */ | 131 | */ |
125 | QStringList relatedApps()const; | 132 | QStringList relatedApps()const; |
126 | 133 | ||
127 | /** | 134 | /** |
128 | * returns all relations for one app | 135 | * returns all relations for one app |
129 | */ | 136 | */ |
130 | QArray<int> relations( const QString& app )const; | 137 | QArray<int> relations( const QString& app )const; |
131 | 138 | ||
132 | /** | 139 | /** |
133 | * toMap puts all data into the map. int relates | 140 | * toMap puts all data into the map. int relates |
134 | * to ToDoEvent RecordFields enum | 141 | * to ToDoEvent RecordFields enum |
135 | */ | 142 | */ |
136 | QMap<int, QString> toMap()const; | 143 | QMap<int, QString> toMap()const; |
137 | 144 | ||
138 | /** | 145 | /** |
139 | * Set if this Todo is completed | 146 | * Set if this Todo is completed |
140 | */ | 147 | */ |
141 | void setCompleted(bool completed ); | 148 | void setCompleted(bool completed ); |
142 | 149 | ||
143 | /** | 150 | /** |
144 | * set if this todo got an end data | 151 | * set if this todo got an end data |
145 | */ | 152 | */ |
146 | void setHasDueDate( bool hasDate ); | 153 | void setHasDueDate( bool hasDate ); |
147 | 154 | ||
148 | /** | 155 | /** |
149 | * set if this todo has an alarm time and date | 156 | * set if this todo has an alarm time and date |
150 | */ | 157 | */ |
151 | void setHasAlarmDateTime ( bool hasAlarm ); | 158 | void setHasAlarmDateTime ( bool hasAlarm ); |
152 | 159 | ||
@@ -154,52 +161,51 @@ public: | |||
154 | * Set the priority of the Todo | 161 | * Set the priority of the Todo |
155 | */ | 162 | */ |
156 | void setPriority(int priority ); | 163 | void setPriority(int priority ); |
157 | 164 | ||
158 | /** | 165 | /** |
159 | * Set the progress. | 166 | * Set the progress. |
160 | */ | 167 | */ |
161 | void setProgress( ushort progress ); | 168 | void setProgress( ushort progress ); |
162 | 169 | ||
163 | /** | 170 | /** |
164 | * set the end date | 171 | * set the end date |
165 | */ | 172 | */ |
166 | void setDueDate( QDate date ); | 173 | void setDueDate( QDate date ); |
167 | 174 | ||
168 | /** | 175 | /** |
169 | * set the alarm time | 176 | * set the alarm time |
170 | */ | 177 | */ |
171 | void setAlarmDateTime ( const QDateTime& alarm ); | 178 | void setAlarmDateTime ( const QDateTime& alarm ); |
172 | 179 | ||
173 | void setDescription(const QString& ); | 180 | void setDescription(const QString& ); |
174 | void setSummary(const QString& ); | 181 | void setSummary(const QString& ); |
175 | bool isOverdue(); | 182 | bool isOverdue(); |
176 | 183 | ||
177 | 184 | ||
178 | bool match( const QRegExp &r )const; | 185 | bool match( const QRegExp &r )const; |
179 | 186 | ||
180 | bool operator<(const OTodo &toDoEvent )const; | 187 | bool operator<(const OTodo &toDoEvent )const; |
181 | bool operator<=(const OTodo &toDoEvent )const; | 188 | bool operator<=(const OTodo &toDoEvent )const; |
182 | bool operator!=(const OTodo &toDoEvent )const; | 189 | bool operator!=(const OTodo &toDoEvent )const; |
183 | bool operator>(const OTodo &toDoEvent )const; | 190 | bool operator>(const OTodo &toDoEvent )const; |
184 | bool operator>=(const OTodo &toDoEvent)const; | 191 | bool operator>=(const OTodo &toDoEvent)const; |
185 | bool operator==(const OTodo &toDoEvent )const; | 192 | bool operator==(const OTodo &toDoEvent )const; |
186 | ToDoEvent &operator=(const OTodo &toDoEvent ); | 193 | OTodo &operator=(const OTodo &toDoEvent ); |
187 | 194 | ||
188 | private: | 195 | private: |
189 | class OTodoPrivate; | 196 | class OTodoPrivate; |
190 | struct OTodoEventData; | 197 | struct OTodoData; |
191 | 198 | ||
192 | void deref(); | 199 | void deref(); |
193 | void changeOrModify(); | 200 | void changeOrModify(); |
194 | void copy( OTodoData* src, OTodoData* dest ); | 201 | void copy( OTodoData* src, OTodoData* dest ); |
195 | ToDoEventPrivate *d; | 202 | OTodoPrivate *d; |
196 | ToDoEventData *data; | 203 | OTodoData *data; |
197 | 204 | ||
198 | static Qtopia::UidGen m_gen; | ||
199 | }; | ||
200 | inline bool ToDoEvent::operator!=(const ToDoEvent &toDoEvent )const { | ||
201 | return !(*this == toDoEvent); | ||
202 | } | ||
203 | }; | 205 | }; |
206 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { | ||
207 | return !(*this == toDoEvent); | ||
208 | } | ||
209 | |||
204 | 210 | ||
205 | #endif | 211 | #endif |
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index 95de1df..d8f73c7 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp | |||
@@ -1,90 +1,106 @@ | |||
1 | #include "opimrecord.h" | 1 | #include "opimrecord.h" |
2 | 2 | ||
3 | OPimRecord::OPimRecord( int uid ) | 3 | OPimRecord::OPimRecord( int uid ) |
4 | : Qtopia::Record() { | 4 | : Qtopia::Record() { |
5 | |||
5 | setUid( uid ); | 6 | setUid( uid ); |
7 | /* assign a new UID */ | ||
6 | if ( uid == 1 ) | 8 | if ( uid == 1 ) |
7 | assignUid(); | 9 | assignUid(); |
8 | } | 10 | } |
9 | OPimRecord::~OPimRecord() { | 11 | OPimRecord::~OPimRecord() { |
10 | } | 12 | } |
11 | OPimRecord::OPimRecord( OPimRecord& rec ) | 13 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
12 | : Qtopia::Record( rec ) | 14 | : Qtopia::Record( rec ) |
13 | { | 15 | { |
14 | (*this) = rec; | 16 | (*this) = rec; |
15 | } | 17 | } |
16 | 18 | ||
17 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | 19 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { |
18 | /* how do I call the parent copy operator ? */ | 20 | Qtopia::Record::operator=( rec ); |
19 | setUid( rec.uid() ); | 21 | m_relations = rec.m_relations; |
20 | setCategories( rec.categories() ); | 22 | |
21 | return *this; | 23 | return *this; |
22 | } | 24 | } |
23 | QStringList OPimRecord::categoryNames()const { | 25 | QStringList OPimRecord::categoryNames()const { |
24 | QStringList list; | 26 | QStringList list; |
25 | 27 | ||
26 | return list; | 28 | return list; |
27 | } | 29 | } |
28 | void OPimRecord::setCategoryName( const QStringList& ) { | 30 | void OPimRecord::setCategoryNames( const QStringList& ) { |
29 | 31 | ||
30 | } | 32 | } |
31 | void OPimRecord::addCategoryName( const QString& ) { | 33 | void OPimRecord::addCategoryName( const QString& ) { |
32 | 34 | ||
33 | } | 35 | } |
34 | bool OPimRecord::isEmpty()const { | 36 | bool OPimRecord::isEmpty()const { |
35 | return ( uid() == 0 ); | 37 | return ( uid() == 0 ); |
36 | } | 38 | } |
37 | QStringList OPimRecord::relatedApps()const{ | 39 | QStringList OPimRecord::relatedApps()const{ |
38 | QStringList list; | 40 | QStringList list; |
39 | QMap<QString, QArray<int> >::ConstIterator it; | 41 | QMap<QString, QArray<int> >::ConstIterator it; |
40 | for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { | 42 | for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { |
41 | list << it.key(); | 43 | list << it.key(); |
42 | } | 44 | } |
43 | return list; | 45 | return list; |
44 | } | 46 | } |
45 | QArray<int> OPimRecord::relations(const QString& app )const { | 47 | QArray<int> OPimRecord::relations(const QString& app )const { |
46 | QArray<int> tmp; | 48 | QArray<int> tmp; |
47 | QMap<QString, QArray<int> >::ConstIterator it; | 49 | QMap<QString, QArray<int> >::ConstIterator it; |
48 | it = m_relations.find( app); | 50 | it = m_relations.find( app); |
49 | if ( it != m_relations.end() ) | 51 | if ( it != m_relations.end() ) |
50 | tmp = it.data(); | 52 | tmp = it.data(); |
51 | return tmp; | 53 | return tmp; |
52 | } | 54 | } |
53 | void OPimRecord::clearRelation( const QString& app ) { | 55 | void OPimRecord::clearRelation( const QString& app ) { |
54 | m_relations.remove( app ); | 56 | m_relations.remove( app ); |
55 | } | 57 | } |
56 | void OPimRecord::addRelation( const QString& app, int id ) { | 58 | void OPimRecord::addRelation( const QString& app, int id ) { |
57 | 59 | ||
58 | QMap<QString, QArray<int> >::Iterator it; | 60 | QMap<QString, QArray<int> >::Iterator it; |
59 | QArray<int> tmp; | 61 | QArray<int> tmp; |
60 | 62 | ||
61 | it = m_relations.find( app ); | 63 | it = m_relations.find( app ); |
62 | if ( it == m_relations.end() ) { | 64 | if ( it == m_relations.end() ) { |
63 | tmp.resize(1 ); | 65 | tmp.resize(1 ); |
64 | tmp[0] = id; | 66 | tmp[0] = id; |
65 | }else{ | 67 | }else{ |
66 | tmp = it.data(); | 68 | tmp = it.data(); |
67 | tmp.resize( tmp.size() + 1 ); | 69 | tmp.resize( tmp.size() + 1 ); |
68 | tmp[tmp.size() - 1] = id; | 70 | tmp[tmp.size() - 1] = id; |
69 | } | 71 | } |
70 | m_relations.replace( app, tmp ); | 72 | m_relations.replace( app, tmp ); |
71 | } | 73 | } |
72 | void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { | 74 | void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { |
73 | 75 | ||
74 | QMap<QString, QArray<int> >::Iterator it; | 76 | QMap<QString, QArray<int> >::Iterator it; |
75 | QArray<int> tmp; | 77 | QArray<int> tmp; |
76 | 78 | ||
77 | it = m_relations.find( app); | 79 | it = m_relations.find( app); |
78 | if ( it == m_relations.end() ) { | 80 | if ( it == m_relations.end() ) { |
79 | tmp = ids; | 81 | tmp = ids; |
80 | }else{ | 82 | }else{ |
81 | tmp = it.data(); | 83 | tmp = it.data(); |
82 | int offset = tmp.size()-1; | 84 | int offset = tmp.size()-1; |
83 | tmp.resize( tmp.size() + ids.size() ); | 85 | tmp.resize( tmp.size() + ids.size() ); |
84 | for (uint i = 0; i < ids.size(); i++ ) { | 86 | for (uint i = 0; i < ids.size(); i++ ) { |
85 | tmp[offset+i] = ids[i]; | 87 | tmp[offset+i] = ids[i]; |
86 | } | 88 | } |
87 | 89 | ||
88 | } | 90 | } |
89 | m_relations.replace( app, tmp ); | 91 | m_relations.replace( app, tmp ); |
90 | } | 92 | } |
93 | QString OPimRecord::crossToString()const { | ||
94 | QString str; | ||
95 | QMap<QString, QArray<int> >::ConstIterator it; | ||
96 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { | ||
97 | QArray<int> id = it.data(); | ||
98 | for ( uint i = 0; i < id.size(); ++i ) { | ||
99 | str += it.key() + "," + QString::number( i ) + ";"; | ||
100 | } | ||
101 | } | ||
102 | str = str.remove( str.length()-1, 1); // strip the ; | ||
103 | //qWarning("IDS " + str ); | ||
104 | |||
105 | return str; | ||
106 | } | ||
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index a0e0413..18112d4 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h | |||
@@ -1,69 +1,69 @@ | |||
1 | #ifndef OPIE_PIM_RECORD_H | 1 | #ifndef OPIE_PIM_RECORD_H |
2 | #define OPIE_PIM_RECORD_H | 2 | #define OPIE_PIM_RECORD_H |
3 | 3 | ||
4 | #include <qmap.h> | 4 | #include <qmap.h> |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | #include <qstringlist.h> | 6 | #include <qstringlist.h> |
7 | 7 | ||
8 | #include <qpe/palmtoprecord.h> | 8 | #include <qpe/palmtoprecord.h> |
9 | 9 | ||
10 | class OPimRecord : public Qtopia::Record { | 10 | class OPimRecord : public Qtopia::Record { |
11 | public: | 11 | public: |
12 | /** | 12 | /** |
13 | * uid of 0 isEmpty | 13 | * uid of 0 isEmpty |
14 | * uid of 1 will be assigned a new one | 14 | * uid of 1 will be assigned a new one |
15 | */ | 15 | */ |
16 | OPimRecord(int uid = 0); | 16 | OPimRecord(int uid = 0); |
17 | ~OPimRecord(); | 17 | ~OPimRecord(); |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * copy c'tor | 20 | * copy c'tor |
21 | */ | 21 | */ |
22 | OPimRecord( OPimRecord& rec ); | 22 | OPimRecord( const OPimRecord& rec ); |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * copy operator | 25 | * copy operator |
26 | */ | 26 | */ |
27 | OPimRecord &operator=( const OPimRecord& ); | 27 | OPimRecord &operator=( const OPimRecord& ); |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * category names resolved | 30 | * category names resolved |
31 | */ | 31 | */ |
32 | QStringList categoryNames()const; | 32 | QStringList categoryNames()const; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * set category names they will be resolved | 35 | * set category names they will be resolved |
36 | */ | 36 | */ |
37 | void setCategoryName( const QStringList& ); | 37 | void setCategoryNames( const QStringList& ); |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * addCategoryName adds a name | 40 | * addCategoryName adds a name |
41 | * to the internal category list | 41 | * to the internal category list |
42 | */ | 42 | */ |
43 | void addCategoryName( const QString& ); | 43 | void addCategoryName( const QString& ); |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * if a Record isEmpty | 46 | * if a Record isEmpty |
47 | */ | 47 | */ |
48 | virtual bool isEmpty()const; | 48 | virtual bool isEmpty()const; |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * toRichText summary | 51 | * toRichText summary |
52 | */ | 52 | */ |
53 | virtual QString toRichText()const = 0; | 53 | virtual QString toRichText()const = 0; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * a small one line summary | 56 | * a small one line summary |
57 | */ | 57 | */ |
58 | virtual QString toShortText()const = 0; | 58 | virtual QString toShortText()const = 0; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * the name of the Record | 61 | * the name of the Record |
62 | */ | 62 | */ |
63 | virtual QString type()const = 0; | 63 | virtual QString type()const = 0; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * converts the internal structure to a map | 66 | * converts the internal structure to a map |
67 | */ | 67 | */ |
68 | virtual QMap<int, QString> toMap()const = 0; | 68 | virtual QMap<int, QString> toMap()const = 0; |
69 | 69 | ||
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index d8e0447..3c93838 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp | |||
@@ -1,507 +1,354 @@ | |||
1 | 1 | ||
2 | #include <qobject.h> | 2 | #include <qobject.h> |
3 | #include <qshared.h> | 3 | #include <qshared.h> |
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
7 | #include <qpe/palmtopuidgen.h> | 7 | #include <qpe/palmtopuidgen.h> |
8 | #include <qpe/stringutil.h> | 8 | #include <qpe/stringutil.h> |
9 | #include <qpe/palmtoprecord.h> | 9 | #include <qpe/palmtoprecord.h> |
10 | #include <qpe/stringutil.h> | 10 | #include <qpe/stringutil.h> |
11 | #include <qpe/categories.h> | 11 | #include <qpe/categories.h> |
12 | #include <qpe/categoryselect.h> | 12 | #include <qpe/categoryselect.h> |
13 | 13 | ||
14 | #include "todoevent.h" | ||
15 | 14 | ||
16 | using namespace Opie; | ||
17 | 15 | ||
18 | Qtopia::UidGen ToDoEvent::m_gen; | 16 | #include "otodo.h" |
19 | 17 | ||
20 | struct ToDoEvent::ToDoEventData : public QShared { | 18 | |
21 | ToDoEventData() : QShared() { | 19 | struct OTodo::OTodoData : public QShared { |
20 | OTodoData() : QShared() { | ||
22 | }; | 21 | }; |
23 | 22 | ||
24 | QDate date; | 23 | QDate date; |
25 | bool isCompleted:1; | 24 | bool isCompleted:1; |
26 | bool hasDate:1; | 25 | bool hasDate:1; |
27 | int priority; | 26 | int priority; |
28 | QStringList category; | 27 | QStringList category; |
29 | QString desc; | 28 | QString desc; |
30 | QString sum; | 29 | QString sum; |
31 | QMap<QString, QString> extra; | 30 | QMap<QString, QString> extra; |
32 | QMap<QString, QArray<int> > relations; | ||
33 | int uid; | ||
34 | ushort prog; | 31 | ushort prog; |
35 | bool hasAlarmDateTime :1; | 32 | bool hasAlarmDateTime :1; |
36 | QDateTime alarmDateTime; | 33 | QDateTime alarmDateTime; |
37 | }; | 34 | }; |
38 | 35 | ||
39 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) | 36 | OTodo::OTodo(const OTodo &event ) |
40 | : data( event.data ) | 37 | : OPimRecord( event ), data( event.data ) |
41 | { | 38 | { |
42 | data->ref(); | 39 | data->ref(); |
43 | //qWarning("ref up"); | 40 | //qWarning("ref up"); |
44 | } | 41 | } |
45 | ToDoEvent::~ToDoEvent() { | 42 | OTodo::~OTodo() { |
46 | if ( data->deref() ) { | 43 | if ( data->deref() ) { |
47 | //qWarning("ToDoEvent::dereffing"); | 44 | //qWarning("OTodo::dereffing"); |
48 | delete data; | 45 | delete data; |
49 | data = 0l; | 46 | data = 0l; |
50 | } | 47 | } |
51 | } | 48 | } |
52 | 49 | ||
53 | ToDoEvent::ToDoEvent(bool completed, int priority, | 50 | OTodo::OTodo(bool completed, int priority, |
54 | const QStringList &category, | 51 | const QStringList &category, |
55 | const QString& summary, | 52 | const QString& summary, |
56 | const QString &description, | 53 | const QString &description, |
57 | ushort progress, | 54 | ushort progress, |
58 | bool hasDate, QDate date, int uid ) | 55 | bool hasDate, QDate date, int uid ) |
56 | : OPimRecord( uid ) | ||
59 | { | 57 | { |
60 | //qWarning("ToDoEventData"); | 58 | //qWarning("OTodoData"); |
61 | data = new ToDoEventData; | 59 | setCategories( idsFromString( category.join(";") ) ); |
60 | data = new OTodoData; | ||
62 | data->date = date; | 61 | data->date = date; |
63 | data->isCompleted = completed; | 62 | data->isCompleted = completed; |
64 | data->hasDate = hasDate; | 63 | data->hasDate = hasDate; |
65 | data->priority = priority; | 64 | data->priority = priority; |
66 | data->category = category; | ||
67 | data->sum = summary; | 65 | data->sum = summary; |
68 | data->prog = progress; | 66 | data->prog = progress; |
69 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 67 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
70 | if (uid == -1 ) { | ||
71 | uid = m_gen.generate(); | ||
72 | |||
73 | }// generated the ids | ||
74 | m_gen.store( uid ); | ||
75 | |||
76 | data->uid = uid; | ||
77 | data->hasAlarmDateTime = false; | 68 | data->hasAlarmDateTime = false; |
78 | 69 | ||
79 | } | 70 | } |
80 | QArray<int> ToDoEvent::categories()const | 71 | bool OTodo::match( const QRegExp ®Exp )const |
81 | { | ||
82 | qWarning( "ToDoEvent:cats" + data->category.join(";") ); | ||
83 | QArray<int> array(data->category.count() ); // currently the datebook can be only in one category | ||
84 | array = Qtopia::Record::idsFromString( data->category.join(";") ); | ||
85 | return array; | ||
86 | } | ||
87 | bool ToDoEvent::match( const QRegExp ®Exp )const | ||
88 | { | 72 | { |
89 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 73 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
90 | return true; | 74 | return true; |
91 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 75 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ |
92 | return true; | 76 | return true; |
93 | }else if(data->desc.find( regExp ) != -1 ){ | 77 | }else if(data->desc.find( regExp ) != -1 ){ |
94 | return true; | 78 | return true; |
79 | }else if(data->sum.find( regExp ) != -1 ) { | ||
80 | return true; | ||
95 | } | 81 | } |
96 | return false; | 82 | return false; |
97 | } | 83 | } |
98 | bool ToDoEvent::isCompleted() const | 84 | bool OTodo::isCompleted() const |
99 | { | 85 | { |
100 | return data->isCompleted; | 86 | return data->isCompleted; |
101 | } | 87 | } |
102 | bool ToDoEvent::hasDueDate() const | 88 | bool OTodo::hasDueDate() const |
103 | { | 89 | { |
104 | return data->hasDate; | 90 | return data->hasDate; |
105 | } | 91 | } |
106 | bool ToDoEvent::hasAlarmDateTime() const | 92 | bool OTodo::hasAlarmDateTime() const |
107 | { | 93 | { |
108 | return data->hasAlarmDateTime; | 94 | return data->hasAlarmDateTime; |
109 | } | 95 | } |
110 | int ToDoEvent::priority()const | 96 | int OTodo::priority()const |
111 | { | 97 | { |
112 | return data->priority; | 98 | return data->priority; |
113 | } | 99 | } |
114 | QStringList ToDoEvent::allCategories()const | 100 | QString OTodo::summary() const |
115 | { | ||
116 | return data->category; | ||
117 | } | ||
118 | QString ToDoEvent::extra(const QString& )const | ||
119 | { | ||
120 | return QString::null; | ||
121 | } | ||
122 | QString ToDoEvent::summary() const | ||
123 | { | 101 | { |
124 | return data->sum; | 102 | return data->sum; |
125 | } | 103 | } |
126 | ushort ToDoEvent::progress() const | 104 | ushort OTodo::progress() const |
127 | { | 105 | { |
128 | return data->prog; | 106 | return data->prog; |
129 | } | 107 | } |
130 | QStringList ToDoEvent::relatedApps() const | 108 | QDate OTodo::dueDate()const |
131 | { | ||
132 | QStringList list; | ||
133 | QMap<QString, QArray<int> >::ConstIterator it; | ||
134 | for ( it = data->relations.begin(); it != data->relations.end(); ++it ) { | ||
135 | list << it.key(); | ||
136 | } | ||
137 | return list; | ||
138 | } | ||
139 | QArray<int> ToDoEvent::relations( const QString& app)const | ||
140 | { | ||
141 | QArray<int> tmp; | ||
142 | QMap<QString, QArray<int> >::ConstIterator it; | ||
143 | it = data->relations.find( app); | ||
144 | if ( it != data->relations.end() ) | ||
145 | tmp = it.data(); | ||
146 | return tmp; | ||
147 | } | ||
148 | void ToDoEvent::insertCategory(const QString &str ) | ||
149 | { | ||
150 | changeOrModify(); | ||
151 | qWarning("insert category;" + str ); | ||
152 | data->category.append( str ); | ||
153 | } | ||
154 | void ToDoEvent::clearCategories() | ||
155 | { | ||
156 | changeOrModify(); | ||
157 | data->category.clear(); | ||
158 | } | ||
159 | void ToDoEvent::setCategories(const QStringList &list ) | ||
160 | { | ||
161 | changeOrModify(); | ||
162 | qWarning("set categories" + list.join(";") ); | ||
163 | data->category = list; | ||
164 | } | ||
165 | QDate ToDoEvent::dueDate()const | ||
166 | { | 109 | { |
167 | return data->date; | 110 | return data->date; |
168 | } | 111 | } |
169 | 112 | ||
170 | QDateTime ToDoEvent::alarmDateTime() const | 113 | QDateTime OTodo::alarmDateTime() const |
171 | { | 114 | { |
172 | return data->alarmDateTime; | 115 | return data->alarmDateTime; |
173 | } | 116 | } |
174 | 117 | ||
175 | QString ToDoEvent::description()const | 118 | QString OTodo::description()const |
176 | { | 119 | { |
177 | return data->desc; | 120 | return data->desc; |
178 | } | 121 | } |
179 | void ToDoEvent::setCompleted( bool completed ) | 122 | void OTodo::setCompleted( bool completed ) |
180 | { | 123 | { |
181 | changeOrModify(); | 124 | changeOrModify(); |
182 | data->isCompleted = completed; | 125 | data->isCompleted = completed; |
183 | } | 126 | } |
184 | void ToDoEvent::setHasDueDate( bool hasDate ) | 127 | void OTodo::setHasDueDate( bool hasDate ) |
185 | { | 128 | { |
186 | changeOrModify(); | 129 | changeOrModify(); |
187 | data->hasDate = hasDate; | 130 | data->hasDate = hasDate; |
188 | } | 131 | } |
189 | void ToDoEvent::setHasAlarmDateTime( bool hasAlarmDateTime ) | 132 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) |
190 | { | 133 | { |
191 | changeOrModify(); | 134 | changeOrModify(); |
192 | data->hasAlarmDateTime = hasAlarmDateTime; | 135 | data->hasAlarmDateTime = hasAlarmDateTime; |
193 | } | 136 | } |
194 | void ToDoEvent::setDescription(const QString &desc ) | 137 | void OTodo::setDescription(const QString &desc ) |
195 | { | 138 | { |
196 | changeOrModify(); | 139 | changeOrModify(); |
197 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 140 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); |
198 | } | 141 | } |
199 | void ToDoEvent::setExtra( const QString&, const QString& ) | 142 | void OTodo::setSummary( const QString& sum ) |
200 | { | ||
201 | |||
202 | } | ||
203 | void ToDoEvent::setSummary( const QString& sum ) | ||
204 | { | 143 | { |
205 | changeOrModify(); | 144 | changeOrModify(); |
206 | data->sum = sum; | 145 | data->sum = sum; |
207 | } | 146 | } |
208 | void ToDoEvent::setCategory( const QString &cat ) | 147 | void OTodo::setPriority(int prio ) |
209 | { | ||
210 | changeOrModify(); | ||
211 | //qWarning("setCategory %s", cat.latin1() ); | ||
212 | data->category.clear(); | ||
213 | data->category << cat; | ||
214 | } | ||
215 | void ToDoEvent::setPriority(int prio ) | ||
216 | { | 148 | { |
217 | changeOrModify(); | 149 | changeOrModify(); |
218 | data->priority = prio; | 150 | data->priority = prio; |
219 | } | 151 | } |
220 | void ToDoEvent::setDueDate( QDate date ) | 152 | void OTodo::setDueDate( QDate date ) |
221 | { | 153 | { |
222 | changeOrModify(); | 154 | changeOrModify(); |
223 | data->date = date; | 155 | data->date = date; |
224 | } | 156 | } |
225 | void ToDoEvent::setAlarmDateTime( const QDateTime& alarm ) | 157 | void OTodo::setAlarmDateTime( const QDateTime& alarm ) |
226 | { | 158 | { |
227 | changeOrModify(); | 159 | changeOrModify(); |
228 | data->alarmDateTime = alarm; | 160 | data->alarmDateTime = alarm; |
229 | } | 161 | } |
230 | void ToDoEvent::addRelated( const QString &app, int id ) | 162 | bool OTodo::isOverdue( ) |
231 | { | ||
232 | changeOrModify(); | ||
233 | |||
234 | QMap<QString, QArray<int> >::Iterator it; | ||
235 | QArray<int> tmp; | ||
236 | it = data->relations.find( app ); | ||
237 | if ( it == data->relations.end() ) { | ||
238 | tmp.resize(1 ); | ||
239 | tmp[0] = id; | ||
240 | }else{ | ||
241 | tmp = it.data(); | ||
242 | tmp.resize( tmp.size() + 1 ); | ||
243 | tmp[tmp.size() - 1] = id; | ||
244 | } | ||
245 | data->relations.replace( app, tmp ); | ||
246 | } | ||
247 | void ToDoEvent::addRelated(const QString& app, QArray<int> ids ) | ||
248 | { | ||
249 | changeOrModify(); | ||
250 | |||
251 | QMap<QString, QArray<int> >::Iterator it; | ||
252 | QArray<int> tmp; | ||
253 | it = data->relations.find( app); | ||
254 | if ( it == data->relations.end() ) { // not there | ||
255 | /** tmp.resize( ids.size() ); stupid?? | ||
256 | */ | ||
257 | tmp = ids; | ||
258 | }else{ | ||
259 | tmp = it.data(); | ||
260 | int offset = tmp.size()-1; | ||
261 | tmp.resize( tmp.size() + ids.size() ); | ||
262 | for (uint i = 0; i < ids.size(); i++ ) { | ||
263 | tmp[offset+i] = ids[i]; | ||
264 | } | ||
265 | |||
266 | } | ||
267 | data->relations.replace( app, tmp ); | ||
268 | } | ||
269 | void ToDoEvent::clearRelated( const QString& app ) | ||
270 | { | ||
271 | changeOrModify(); | ||
272 | data->relations.remove( app ); | ||
273 | } | ||
274 | bool ToDoEvent::isOverdue( ) | ||
275 | { | 163 | { |
276 | if( data->hasDate ) | 164 | if( data->hasDate ) |
277 | return QDate::currentDate() > data->date; | 165 | return QDate::currentDate() > data->date; |
278 | return false; | 166 | return false; |
279 | } | 167 | } |
280 | void ToDoEvent::setProgress(ushort progress ) | 168 | void OTodo::setProgress(ushort progress ) |
281 | { | 169 | { |
282 | changeOrModify(); | 170 | changeOrModify(); |
283 | data->prog = progress; | 171 | data->prog = progress; |
284 | } | 172 | } |
173 | QString OTodo::toShortText() const { | ||
174 | return summary(); | ||
175 | } | ||
285 | /*! | 176 | /*! |
286 | Returns a richt text string | 177 | Returns a richt text string |
287 | */ | 178 | */ |
288 | QString ToDoEvent::richText() const | 179 | QString OTodo::toRichText() const |
289 | { | 180 | { |
290 | QString text; | 181 | QString text; |
291 | QStringList catlist; | 182 | QStringList catlist; |
292 | 183 | ||
293 | // Description of the todo | 184 | // Description of the todo |
294 | if ( !summary().isEmpty() ) { | 185 | if ( !summary().isEmpty() ) { |
295 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; | 186 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; |
296 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 187 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
297 | } | 188 | } |
298 | if( !description().isEmpty() ){ | 189 | if( !description().isEmpty() ){ |
299 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 190 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
300 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; | 191 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; |
301 | } | 192 | } |
302 | text += "<br><br><br>"; | 193 | text += "<br><br><br>"; |
303 | 194 | ||
304 | text += "<b>" + QObject::tr( "Priority:") +" </b>" | 195 | text += "<b>" + QObject::tr( "Priority:") +" </b>" |
305 | + QString::number( priority() ) + " <br>"; | 196 | + QString::number( priority() ) + " <br>"; |
306 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 197 | text += "<b>" + QObject::tr( "Progress:") + " </b>" |
307 | + QString::number( progress() ) + " %<br>"; | 198 | + QString::number( progress() ) + " %<br>"; |
308 | if (hasDueDate() ){ | 199 | if (hasDueDate() ){ |
309 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; | 200 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; |
310 | text += dueDate().toString(); | 201 | text += dueDate().toString(); |
311 | text += "<br>"; | 202 | text += "<br>"; |
312 | } | 203 | } |
313 | if (hasAlarmDateTime() ){ | 204 | if (hasAlarmDateTime() ){ |
314 | text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; | 205 | text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; |
315 | text += alarmDateTime().toString(); | 206 | text += alarmDateTime().toString(); |
316 | text += "<br>"; | 207 | text += "<br>"; |
317 | } | 208 | } |
318 | 209 | ||
319 | // Open database of all categories and get the list of | ||
320 | // the categories this todoevent belongs to. | ||
321 | // Then print them... | ||
322 | // I am not sure whether there is no better way doing this !? | ||
323 | Categories catdb; | ||
324 | bool firstloop = true; | ||
325 | catdb.load( categoryFileName() ); | ||
326 | catlist = allCategories(); | ||
327 | |||
328 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 210 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
329 | for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { | 211 | text += categoryNames().join(", "); |
330 | if (!firstloop){ | ||
331 | text += ", "; | ||
332 | } | ||
333 | firstloop = false; | ||
334 | text += catdb.label ("todo", (*it).toInt()); | ||
335 | } | ||
336 | text += "<br>"; | 212 | text += "<br>"; |
213 | |||
337 | return text; | 214 | return text; |
338 | } | 215 | } |
339 | 216 | ||
340 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ | 217 | bool OTodo::operator<( const OTodo &toDoEvent )const{ |
341 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 218 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
342 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 219 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
343 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 220 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
344 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 221 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
345 | return priority() < toDoEvent.priority(); | 222 | return priority() < toDoEvent.priority(); |
346 | }else{ | 223 | }else{ |
347 | return dueDate() < toDoEvent.dueDate(); | 224 | return dueDate() < toDoEvent.dueDate(); |
348 | } | 225 | } |
349 | } | 226 | } |
350 | return false; | 227 | return false; |
351 | } | 228 | } |
352 | bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const | 229 | bool OTodo::operator<=(const OTodo &toDoEvent )const |
353 | { | 230 | { |
354 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 231 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
355 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 232 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
356 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 233 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
357 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 234 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
358 | return priority() <= toDoEvent.priority(); | 235 | return priority() <= toDoEvent.priority(); |
359 | }else{ | 236 | }else{ |
360 | return dueDate() <= toDoEvent.dueDate(); | 237 | return dueDate() <= toDoEvent.dueDate(); |
361 | } | 238 | } |
362 | } | 239 | } |
363 | return true; | 240 | return true; |
364 | } | 241 | } |
365 | bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const | 242 | bool OTodo::operator>(const OTodo &toDoEvent )const |
366 | { | 243 | { |
367 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | 244 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; |
368 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 245 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
369 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 246 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
370 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 247 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
371 | return priority() > toDoEvent.priority(); | 248 | return priority() > toDoEvent.priority(); |
372 | }else{ | 249 | }else{ |
373 | return dueDate() > toDoEvent.dueDate(); | 250 | return dueDate() > toDoEvent.dueDate(); |
374 | } | 251 | } |
375 | } | 252 | } |
376 | return false; | 253 | return false; |
377 | } | 254 | } |
378 | bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const | 255 | bool OTodo::operator>=(const OTodo &toDoEvent )const |
379 | { | 256 | { |
380 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 257 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
381 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 258 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
382 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 259 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
383 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 260 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
384 | return priority() > toDoEvent.priority(); | 261 | return priority() > toDoEvent.priority(); |
385 | }else{ | 262 | }else{ |
386 | return dueDate() > toDoEvent.dueDate(); | 263 | return dueDate() > toDoEvent.dueDate(); |
387 | } | 264 | } |
388 | } | 265 | } |
389 | return true; | 266 | return true; |
390 | } | 267 | } |
391 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const | 268 | bool OTodo::operator==(const OTodo &toDoEvent )const |
392 | { | 269 | { |
393 | if( data->priority == toDoEvent.data->priority && | 270 | if( data->priority == toDoEvent.data->priority && |
394 | data->priority == toDoEvent.data->prog && | 271 | data->priority == toDoEvent.data->prog && |
395 | data->isCompleted == toDoEvent.data->isCompleted && | 272 | data->isCompleted == toDoEvent.data->isCompleted && |
396 | data->hasDate == toDoEvent.data->hasDate && | 273 | data->hasDate == toDoEvent.data->hasDate && |
397 | data->date == toDoEvent.data->date && | 274 | data->date == toDoEvent.data->date && |
398 | data->category == toDoEvent.data->category && | 275 | data->category == toDoEvent.data->category && |
399 | data->sum == toDoEvent.data->sum && | 276 | data->sum == toDoEvent.data->sum && |
400 | data->desc == toDoEvent.data->desc && | 277 | data->desc == toDoEvent.data->desc && |
401 | data->hasAlarmDateTime == toDoEvent.data->hasAlarmDateTime && | 278 | data->hasAlarmDateTime == toDoEvent.data->hasAlarmDateTime && |
402 | data->alarmDateTime == toDoEvent.data->alarmDateTime ) | 279 | data->alarmDateTime == toDoEvent.data->alarmDateTime ) |
403 | return true; | 280 | return true; |
404 | 281 | ||
405 | return false; | 282 | return false; |
406 | } | 283 | } |
407 | void ToDoEvent::deref() { | 284 | void OTodo::deref() { |
408 | 285 | ||
409 | //qWarning("deref in ToDoEvent"); | 286 | //qWarning("deref in ToDoEvent"); |
410 | if ( data->deref() ) { | 287 | if ( data->deref() ) { |
411 | //qWarning("deleting"); | 288 | //qWarning("deleting"); |
412 | delete data; | 289 | delete data; |
413 | d= 0; | 290 | d= 0; |
414 | } | 291 | } |
415 | } | 292 | } |
416 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) | 293 | OTodo &OTodo::operator=(const OTodo &item ) |
417 | { | 294 | { |
295 | OPimRecord::operator=( item ); | ||
418 | //qWarning("operator= ref "); | 296 | //qWarning("operator= ref "); |
419 | item.data->ref(); | 297 | item.data->ref(); |
420 | deref(); | 298 | deref(); |
421 | 299 | ||
422 | data = item.data; | ||
423 | |||
424 | |||
425 | return *this; | 300 | return *this; |
426 | } | 301 | } |
427 | 302 | ||
428 | QMap<int, QString> ToDoEvent::toMap() const { | 303 | QMap<int, QString> OTodo::toMap() const { |
429 | QMap<int, QString> map; | 304 | QMap<int, QString> map; |
430 | 305 | ||
431 | map.insert( Uid, QString::number( data->uid ) ); | 306 | map.insert( Uid, QString::number( uid() ) ); |
432 | map.insert( Category, data->category.join(";") ); | 307 | map.insert( Category, idsToString( categories() ) ); |
433 | map.insert( HasDate, QString::number( data->hasDate ) ); | 308 | map.insert( HasDate, QString::number( data->hasDate ) ); |
434 | map.insert( Completed, QString::number( data->isCompleted ) ); | 309 | map.insert( Completed, QString::number( data->isCompleted ) ); |
435 | map.insert( Description, data->desc ); | 310 | map.insert( Description, data->desc ); |
436 | map.insert( Summary, data->sum ); | 311 | map.insert( Summary, data->sum ); |
437 | map.insert( Priority, QString::number( data->priority ) ); | 312 | map.insert( Priority, QString::number( data->priority ) ); |
438 | map.insert( DateDay, QString::number( data->date.day() ) ); | 313 | map.insert( DateDay, QString::number( data->date.day() ) ); |
439 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 314 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
440 | map.insert( DateYear, QString::number( data->date.year() ) ); | 315 | map.insert( DateYear, QString::number( data->date.year() ) ); |
441 | map.insert( Progress, QString::number( data->prog ) ); | 316 | map.insert( Progress, QString::number( data->prog ) ); |
442 | map.insert( CrossReference, crossToString() ); | 317 | map.insert( CrossReference, crossToString() ); |
443 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); | 318 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); |
444 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); | 319 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); |
445 | 320 | ||
446 | return map; | 321 | return map; |
447 | } | 322 | } |
448 | 323 | ||
449 | 324 | QMap<QString, QString> OTodo::toExtraMap()const { | |
450 | QString ToDoEvent::crossToString()const { | ||
451 | QString str; | ||
452 | QMap<QString, QArray<int> >::ConstIterator it; | ||
453 | for (it = data->relations.begin(); it != data->relations.end(); ++it ) { | ||
454 | QArray<int> id = it.data(); | ||
455 | for ( uint i = 0; i < id.size(); ++i ) { | ||
456 | str += it.key() + "," + QString::number( i ) + ";"; | ||
457 | } | ||
458 | } | ||
459 | str = str.remove( str.length()-1, 1); // strip the ; | ||
460 | //qWarning("IDS " + str ); | ||
461 | |||
462 | return str; | ||
463 | } | ||
464 | int ToDoEvent::uid()const { | ||
465 | return data->uid; | ||
466 | } | ||
467 | void ToDoEvent::setUid( int id ) { | ||
468 | if ( id == -1 ) | ||
469 | id = m_gen.generate(); | ||
470 | m_gen.store(id ); | ||
471 | changeOrModify(); | ||
472 | data->uid = id; | ||
473 | } | ||
474 | QMap<QString, QString> ToDoEvent::extras()const { | ||
475 | return data->extra; | 325 | return data->extra; |
476 | } | 326 | } |
477 | /** | 327 | /** |
478 | * change or modify looks at the ref count and either | 328 | * change or modify looks at the ref count and either |
479 | * creates a new QShared Object or it can modify it | 329 | * creates a new QShared Object or it can modify it |
480 | * right in place | 330 | * right in place |
481 | */ | 331 | */ |
482 | void ToDoEvent::changeOrModify() { | 332 | void OTodo::changeOrModify() { |
483 | if ( data->count != 1 ) { | 333 | if ( data->count != 1 ) { |
484 | //qWarning("changeOrModify"); | 334 | //qWarning("changeOrModify"); |
485 | data->deref(); | 335 | data->deref(); |
486 | ToDoEventData* d2 = new ToDoEventData(); | 336 | OTodoData* d2 = new OTodoData(); |
487 | copy(data, d2 ); | 337 | copy(data, d2 ); |
488 | data = d2; | 338 | data = d2; |
489 | } | 339 | } |
490 | } | 340 | } |
491 | void ToDoEvent::copy( ToDoEventData* src, ToDoEventData* dest ) { | 341 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
492 | dest->date = src->date; | 342 | dest->date = src->date; |
493 | dest->isCompleted = src->isCompleted; | 343 | dest->isCompleted = src->isCompleted; |
494 | dest->hasDate = src->hasDate; | 344 | dest->hasDate = src->hasDate; |
495 | dest->priority = src->priority; | 345 | dest->priority = src->priority; |
496 | dest->category = src->category; | ||
497 | dest->desc = src->desc; | 346 | dest->desc = src->desc; |
498 | dest->sum = src->sum; | 347 | dest->sum = src->sum; |
499 | dest->extra = src->extra; | 348 | dest->extra = src->extra; |
500 | dest->relations = src->relations; | ||
501 | dest->uid = src->uid; | ||
502 | dest->prog = src->prog; | 349 | dest->prog = src->prog; |
503 | dest->hasAlarmDateTime = src->hasAlarmDateTime; | 350 | dest->hasAlarmDateTime = src->hasAlarmDateTime; |
504 | dest->alarmDateTime = src->alarmDateTime; | 351 | dest->alarmDateTime = src->alarmDateTime; |
505 | } | 352 | } |
506 | 353 | ||
507 | 354 | ||
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h index 429108a..e1729db 100644 --- a/libopie2/opiepim/otodo.h +++ b/libopie2/opiepim/otodo.h | |||
@@ -1,53 +1,53 @@ | |||
1 | 1 | ||
2 | #ifndef OPIE_TODO_EVENT_H | 2 | #ifndef OPIE_TODO_EVENT_H |
3 | #define OPIE_TODO_EVENT_H | 3 | #define OPIE_TODO_EVENT_H |
4 | 4 | ||
5 | 5 | ||
6 | #include <qarray.h> | 6 | #include <qarray.h> |
7 | #include <qmap.h> | 7 | #include <qmap.h> |
8 | #include <qregexp.h> | 8 | #include <qregexp.h> |
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | #include <qdatetime.h> | 10 | #include <qdatetime.h> |
11 | #include <qvaluelist.h> | 11 | #include <qvaluelist.h> |
12 | 12 | ||
13 | #include <qpe/recordfields.h> | 13 | #include <qpe/recordfields.h> |
14 | #include <qpe/palmtopuidgen.h> | 14 | #include <qpe/palmtopuidgen.h> |
15 | 15 | ||
16 | #include <opie/opimrecord.h> | 16 | #include <opie/opimrecord.h> |
17 | 17 | ||
18 | 18 | ||
19 | class OTodo : public OPimRecord { | 19 | class OTodo : public OPimRecord { |
20 | public: | 20 | public: |
21 | typedef QValueList<ToDoEvent> ValueList; | 21 | typedef QValueList<OTodo> ValueList; |
22 | enum RecordFields { | 22 | enum RecordFields { |
23 | Uid = Qtopia::UID_ID, | 23 | Uid = Qtopia::UID_ID, |
24 | Category = Qtopia::CATEGORY_ID, | 24 | Category = Qtopia::CATEGORY_ID, |
25 | HasDate, | 25 | HasDate, |
26 | Completed, | 26 | Completed, |
27 | Description, | 27 | Description, |
28 | Summary, | 28 | Summary, |
29 | Priority, | 29 | Priority, |
30 | DateDay, | 30 | DateDay, |
31 | DateMonth, | 31 | DateMonth, |
32 | DateYear, | 32 | DateYear, |
33 | Progress, | 33 | Progress, |
34 | CrossReference, | 34 | CrossReference, |
35 | HasAlarmDateTime, | 35 | HasAlarmDateTime, |
36 | AlarmDateTime | 36 | AlarmDateTime |
37 | }; | 37 | }; |
38 | public: | 38 | public: |
39 | // priorities from Very low to very high | 39 | // priorities from Very low to very high |
40 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; | 40 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; |
41 | 41 | ||
42 | /* Constructs a new ToDoEvent | 42 | /* Constructs a new ToDoEvent |
43 | @param completed Is the TodoEvent completed | 43 | @param completed Is the TodoEvent completed |
44 | @param priority What is the priority of this ToDoEvent | 44 | @param priority What is the priority of this ToDoEvent |
45 | @param category Which category does it belong( uid ) | 45 | @param category Which category does it belong( uid ) |
46 | @param summary A small summary of the todo | 46 | @param summary A small summary of the todo |
47 | @param description What is this ToDoEvent about | 47 | @param description What is this ToDoEvent about |
48 | @param hasDate Does this Event got a deadline | 48 | @param hasDate Does this Event got a deadline |
49 | @param date what is the deadline? | 49 | @param date what is the deadline? |
50 | @param uid what is the UUID of this Event | 50 | @param uid what is the UUID of this Event |
51 | **/ | 51 | **/ |
52 | OTodo( bool completed = false, int priority = Normal, | 52 | OTodo( bool completed = false, int priority = Normal, |
53 | const QStringList &category = QStringList(), | 53 | const QStringList &category = QStringList(), |
@@ -89,64 +89,71 @@ public: | |||
89 | 89 | ||
90 | /** | 90 | /** |
91 | * progress as ushort 0, 20, 40, 60, 80 or 100% | 91 | * progress as ushort 0, 20, 40, 60, 80 or 100% |
92 | */ | 92 | */ |
93 | ushort progress() const; | 93 | ushort progress() const; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * The due Date | 96 | * The due Date |
97 | */ | 97 | */ |
98 | QDate dueDate()const; | 98 | QDate dueDate()const; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Alarm Date and Time | 101 | * Alarm Date and Time |
102 | */ | 102 | */ |
103 | QDateTime alarmDateTime()const; | 103 | QDateTime alarmDateTime()const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * The description of the todo | 106 | * The description of the todo |
107 | */ | 107 | */ |
108 | QString description()const; | 108 | QString description()const; |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * A small summary of the todo | 111 | * A small summary of the todo |
112 | */ | 112 | */ |
113 | QString summary() const; | 113 | QString summary() const; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * @reimplemented | 116 | * @reimplemented |
117 | * Return this todoevent in a RichText formatted QString | 117 | * Return this todoevent in a RichText formatted QString |
118 | */ | 118 | */ |
119 | QString toRichText() const; | 119 | QString toRichText() const; |
120 | 120 | ||
121 | /** | ||
122 | * reimplementation | ||
123 | */ | ||
124 | QString type()const; | ||
125 | QString toShortText()const; | ||
126 | QMap<QString, QString> toExtraMap()const; | ||
127 | QString recordField(int id )const; | ||
121 | 128 | ||
122 | /** | 129 | /** |
123 | * returns a list of apps which have related items | 130 | * returns a list of apps which have related items |
124 | */ | 131 | */ |
125 | QStringList relatedApps()const; | 132 | QStringList relatedApps()const; |
126 | 133 | ||
127 | /** | 134 | /** |
128 | * returns all relations for one app | 135 | * returns all relations for one app |
129 | */ | 136 | */ |
130 | QArray<int> relations( const QString& app )const; | 137 | QArray<int> relations( const QString& app )const; |
131 | 138 | ||
132 | /** | 139 | /** |
133 | * toMap puts all data into the map. int relates | 140 | * toMap puts all data into the map. int relates |
134 | * to ToDoEvent RecordFields enum | 141 | * to ToDoEvent RecordFields enum |
135 | */ | 142 | */ |
136 | QMap<int, QString> toMap()const; | 143 | QMap<int, QString> toMap()const; |
137 | 144 | ||
138 | /** | 145 | /** |
139 | * Set if this Todo is completed | 146 | * Set if this Todo is completed |
140 | */ | 147 | */ |
141 | void setCompleted(bool completed ); | 148 | void setCompleted(bool completed ); |
142 | 149 | ||
143 | /** | 150 | /** |
144 | * set if this todo got an end data | 151 | * set if this todo got an end data |
145 | */ | 152 | */ |
146 | void setHasDueDate( bool hasDate ); | 153 | void setHasDueDate( bool hasDate ); |
147 | 154 | ||
148 | /** | 155 | /** |
149 | * set if this todo has an alarm time and date | 156 | * set if this todo has an alarm time and date |
150 | */ | 157 | */ |
151 | void setHasAlarmDateTime ( bool hasAlarm ); | 158 | void setHasAlarmDateTime ( bool hasAlarm ); |
152 | 159 | ||
@@ -154,52 +161,51 @@ public: | |||
154 | * Set the priority of the Todo | 161 | * Set the priority of the Todo |
155 | */ | 162 | */ |
156 | void setPriority(int priority ); | 163 | void setPriority(int priority ); |
157 | 164 | ||
158 | /** | 165 | /** |
159 | * Set the progress. | 166 | * Set the progress. |
160 | */ | 167 | */ |
161 | void setProgress( ushort progress ); | 168 | void setProgress( ushort progress ); |
162 | 169 | ||
163 | /** | 170 | /** |
164 | * set the end date | 171 | * set the end date |
165 | */ | 172 | */ |
166 | void setDueDate( QDate date ); | 173 | void setDueDate( QDate date ); |
167 | 174 | ||
168 | /** | 175 | /** |
169 | * set the alarm time | 176 | * set the alarm time |
170 | */ | 177 | */ |
171 | void setAlarmDateTime ( const QDateTime& alarm ); | 178 | void setAlarmDateTime ( const QDateTime& alarm ); |
172 | 179 | ||
173 | void setDescription(const QString& ); | 180 | void setDescription(const QString& ); |
174 | void setSummary(const QString& ); | 181 | void setSummary(const QString& ); |
175 | bool isOverdue(); | 182 | bool isOverdue(); |
176 | 183 | ||
177 | 184 | ||
178 | bool match( const QRegExp &r )const; | 185 | bool match( const QRegExp &r )const; |
179 | 186 | ||
180 | bool operator<(const OTodo &toDoEvent )const; | 187 | bool operator<(const OTodo &toDoEvent )const; |
181 | bool operator<=(const OTodo &toDoEvent )const; | 188 | bool operator<=(const OTodo &toDoEvent )const; |
182 | bool operator!=(const OTodo &toDoEvent )const; | 189 | bool operator!=(const OTodo &toDoEvent )const; |
183 | bool operator>(const OTodo &toDoEvent )const; | 190 | bool operator>(const OTodo &toDoEvent )const; |
184 | bool operator>=(const OTodo &toDoEvent)const; | 191 | bool operator>=(const OTodo &toDoEvent)const; |
185 | bool operator==(const OTodo &toDoEvent )const; | 192 | bool operator==(const OTodo &toDoEvent )const; |
186 | ToDoEvent &operator=(const OTodo &toDoEvent ); | 193 | OTodo &operator=(const OTodo &toDoEvent ); |
187 | 194 | ||
188 | private: | 195 | private: |
189 | class OTodoPrivate; | 196 | class OTodoPrivate; |
190 | struct OTodoEventData; | 197 | struct OTodoData; |
191 | 198 | ||
192 | void deref(); | 199 | void deref(); |
193 | void changeOrModify(); | 200 | void changeOrModify(); |
194 | void copy( OTodoData* src, OTodoData* dest ); | 201 | void copy( OTodoData* src, OTodoData* dest ); |
195 | ToDoEventPrivate *d; | 202 | OTodoPrivate *d; |
196 | ToDoEventData *data; | 203 | OTodoData *data; |
197 | 204 | ||
198 | static Qtopia::UidGen m_gen; | ||
199 | }; | ||
200 | inline bool ToDoEvent::operator!=(const ToDoEvent &toDoEvent )const { | ||
201 | return !(*this == toDoEvent); | ||
202 | } | ||
203 | }; | 205 | }; |
206 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { | ||
207 | return !(*this == toDoEvent); | ||
208 | } | ||
209 | |||
204 | 210 | ||
205 | #endif | 211 | #endif |