Diffstat (limited to 'noncore/applets/notesapplet/notes.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/applets/notesapplet/notes.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp index 13f7cf3..b3e72a7 100644 --- a/noncore/applets/notesapplet/notes.cpp +++ b/noncore/applets/notesapplet/notes.cpp | |||
@@ -14,27 +14,26 @@ | |||
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #include "notes.h" | 16 | #include "notes.h" |
17 | 17 | ||
18 | #include <qapplication.h> | 18 | /* OPIE */ |
19 | #include <stdlib.h> | 19 | #include <opie2/odebug.h> |
20 | #include <qstringlist.h> | ||
21 | |||
22 | #include <opie2/otaskbarapplet.h> | 20 | #include <opie2/otaskbarapplet.h> |
23 | #include <qpe/filemanager.h> | 21 | #include <qpe/filemanager.h> |
24 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/timestring.h> | 23 | #include <qpe/timestring.h> |
26 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
27 | #include <qpe/ir.h> | 25 | #include <qpe/ir.h> |
28 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | using namespace Opie::Core; | ||
28 | using namespace Opie::Ui; | ||
29 | 29 | ||
30 | // #include <qsocket.h> | 30 | /* QT */ |
31 | // #include <qclipboard.h> | ||
32 | #include <qmultilineedit.h> | 31 | #include <qmultilineedit.h> |
33 | #include <qlistbox.h> | 32 | #include <qlistbox.h> |
34 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
35 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
36 | 35 | #include <qapplication.h> | |
37 | #include <qdir.h> | 36 | #include <qdir.h> |
38 | #include <qfile.h> | 37 | #include <qfile.h> |
39 | #include <qpoint.h> | 38 | #include <qpoint.h> |
40 | #include <qpushbutton.h> | 39 | #include <qpushbutton.h> |
@@ -42,12 +41,15 @@ | |||
42 | #include <qlayout.h> | 41 | #include <qlayout.h> |
43 | #include <qframe.h> | 42 | #include <qframe.h> |
44 | #include <qpixmap.h> | 43 | #include <qpixmap.h> |
45 | #include <qstring.h> | 44 | #include <qstring.h> |
45 | #include <qstringlist.h> | ||
46 | #include <qtimer.h> | 46 | #include <qtimer.h> |
47 | 47 | ||
48 | /* STD */ | ||
49 | #include <stdlib.h> | ||
50 | |||
48 | /* XPM */ | 51 | /* XPM */ |
49 | using namespace Opie::Ui; | ||
50 | static char * notes_xpm[] = { | 52 | static char * notes_xpm[] = { |
51 | "16 16 11 1", | 53 | "16 16 11 1", |
52 | " c None", | 54 | " c None", |
53 | ". c #000000", | 55 | ". c #000000", |
@@ -83,11 +85,11 @@ NotesControl::NotesControl( QWidget *, const char * ) | |||
83 | // : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 85 | // : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
84 | { | 86 | { |
85 | QDir d( QDir::homeDirPath()+"/notes"); | 87 | QDir d( QDir::homeDirPath()+"/notes"); |
86 | if( !d.exists()) { | 88 | if( !d.exists()) { |
87 | qDebug("make dir"); | 89 | odebug << "make dir" << oendl; |
88 | if(!d.mkdir( QDir::homeDirPath()+"/notes", true)) | 90 | if(!d.mkdir( QDir::homeDirPath()+"/notes", true)) |
89 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed"); | 91 | odebug << "<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed" << oendl; |
90 | } | 92 | } |
91 | Config cfg("Notes"); | 93 | Config cfg("Notes"); |
92 | cfg.setGroup("Options"); | 94 | cfg.setGroup("Options"); |
93 | showMax = cfg.readBoolEntry("ShowMax", false); | 95 | showMax = cfg.readBoolEntry("ShowMax", false); |
@@ -164,9 +166,9 @@ void NotesControl::slotDeleteButtonClicked() { | |||
164 | 166 | ||
165 | void NotesControl::slotDeleteButton() { | 167 | void NotesControl::slotDeleteButton() { |
166 | 168 | ||
167 | QString selectedText = box->currentText(); | 169 | QString selectedText = box->currentText(); |
168 | qDebug("deleting "+selectedText); | 170 | odebug << "deleting "+selectedText << oendl; |
169 | 171 | ||
170 | if( !selectedText.isEmpty()) { | 172 | if( !selectedText.isEmpty()) { |
171 | 173 | ||
172 | Config cfg("Notes"); | 174 | Config cfg("Notes"); |
@@ -175,14 +177,14 @@ void NotesControl::slotDeleteButton() { | |||
175 | QString entryName, entryName2;; | 177 | QString entryName, entryName2;; |
176 | for ( int i = 0; i < noOfFiles; i++ ) { | 178 | for ( int i = 0; i < noOfFiles; i++ ) { |
177 | entryName.sprintf( "File%i", i + 1 ); | 179 | entryName.sprintf( "File%i", i + 1 ); |
178 | if(selectedText == cfg.readEntry( entryName )) { | 180 | if(selectedText == cfg.readEntry( entryName )) { |
179 | qDebug("removing %s, %d", selectedText.latin1(), i); | 181 | odebug << "removing " << selectedText.latin1() << ", " << i << "" << oendl; |
180 | for ( int j = i; j < noOfFiles; j++ ) { | 182 | for ( int j = i; j < noOfFiles; j++ ) { |
181 | entryName.sprintf( "File%i", i + 1 ); | 183 | entryName.sprintf( "File%i", i + 1 ); |
182 | entryName2.sprintf( "File%i", i + 2 ); | 184 | entryName2.sprintf( "File%i", i + 2 ); |
183 | QString temp = cfg.readEntry(entryName2); | 185 | QString temp = cfg.readEntry(entryName2); |
184 | qDebug("move "+temp); | 186 | odebug << "move "+temp << oendl; |
185 | cfg.writeEntry(entryName, temp); | 187 | cfg.writeEntry(entryName, temp); |
186 | i++; | 188 | i++; |
187 | } | 189 | } |
188 | cfg.writeEntry("NumberOfFiles", noOfFiles-1 ); | 190 | cfg.writeEntry("NumberOfFiles", noOfFiles-1 ); |
@@ -191,12 +193,12 @@ void NotesControl::slotDeleteButton() { | |||
191 | cfg.write(); | 193 | cfg.write(); |
192 | DocLnk nf(selectedText); | 194 | DocLnk nf(selectedText); |
193 | nf.removeFiles(); | 195 | nf.removeFiles(); |
194 | QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop"; | 196 | QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop"; |
195 | qDebug(fi); | 197 | odebug << fi << oendl; |
196 | 198 | ||
197 | QFile f( fi); | 199 | QFile f( fi); |
198 | if( !f.remove()) qDebug(".desktop file not removed"); | 200 | if( !f.remove()) odebug << ".desktop file not removed" << oendl; |
199 | 201 | ||
200 | } | 202 | } |
201 | } | 203 | } |
202 | view->clear(); | 204 | view->clear(); |
@@ -282,9 +284,9 @@ void NotesControl::focusOutEvent ( QFocusEvent * e) { | |||
282 | void NotesControl::save() { | 284 | void NotesControl::save() { |
283 | Config cfg("Notes"); | 285 | Config cfg("Notes"); |
284 | cfg.setGroup("Docs"); | 286 | cfg.setGroup("Docs"); |
285 | if( edited) { | 287 | if( edited) { |
286 | // qDebug("is edited"); | 288 | // odebug << "is edited" << oendl; |
287 | QString rt = view->text(); | 289 | QString rt = view->text(); |
288 | if( rt.length()>1) { | 290 | if( rt.length()>1) { |
289 | QString pt = rt.simplifyWhiteSpace(); | 291 | QString pt = rt.simplifyWhiteSpace(); |
290 | int i = pt.find( ' ', pt.find( ' ' )+2 ); | 292 | int i = pt.find( ' ', pt.find( ' ' )+2 ); |
@@ -300,9 +302,9 @@ void NotesControl::save() { | |||
300 | if ( docname.length() > 40 ) | 302 | if ( docname.length() > 40 ) |
301 | docname = docname.left(40); | 303 | docname = docname.left(40); |
302 | if ( docname.isEmpty() ) | 304 | if ( docname.isEmpty() ) |
303 | docname = "Empty Text"; | 305 | docname = "Empty Text"; |
304 | // qDebug(docname); | 306 | // odebug << docname << oendl; |
305 | 307 | ||
306 | if( oldDocName != docname) { | 308 | if( oldDocName != docname) { |
307 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 309 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
308 | QString entryName; | 310 | QString entryName; |
@@ -311,13 +313,13 @@ void NotesControl::save() { | |||
311 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); | 313 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); |
312 | cfg.write(); | 314 | cfg.write(); |
313 | } | 315 | } |
314 | // else | 316 | // else |
315 | // qDebug("oldname equals docname"); | 317 | // odebug << "oldname equals docname" << oendl; |
316 | 318 | ||
317 | doc = new DocLnk(docname); | 319 | doc = new DocLnk(docname); |
318 | if(QFile(doc->linkFile()).exists()) | 320 | if(QFile(doc->linkFile()).exists()) |
319 | qDebug("puppie"); | 321 | odebug << "puppie" << oendl; |
320 | doc->setType("text/plain"); | 322 | doc->setType("text/plain"); |
321 | doc->setName(docname); | 323 | doc->setName(docname); |
322 | QString temp = docname.replace( QRegExp(" "), "_" ); | 324 | QString temp = docname.replace( QRegExp(" "), "_" ); |
323 | doc->setFile( QDir::homeDirPath()+"/notes/"+temp); | 325 | doc->setFile( QDir::homeDirPath()+"/notes/"+temp); |
@@ -326,9 +328,9 @@ void NotesControl::save() { | |||
326 | } | 328 | } |
327 | 329 | ||
328 | oldDocName=docname; | 330 | oldDocName=docname; |
329 | edited=false; | 331 | edited=false; |
330 | // qDebug("save"); | 332 | // odebug << "save" << oendl; |
331 | if (doPopulate) | 333 | if (doPopulate) |
332 | populateBox(); | 334 | populateBox(); |
333 | } | 335 | } |
334 | cfg.writeEntry( "LastDoc",oldDocName ); | 336 | cfg.writeEntry( "LastDoc",oldDocName ); |
@@ -338,9 +340,9 @@ void NotesControl::save() { | |||
338 | } | 340 | } |
339 | 341 | ||
340 | void NotesControl::populateBox() { | 342 | void NotesControl::populateBox() { |
341 | box->clear(); | 343 | box->clear(); |
342 | // qDebug("populate"); | 344 | // odebug << "populate" << oendl; |
343 | Config cfg("Notes"); | 345 | Config cfg("Notes"); |
344 | cfg.setGroup("Docs"); | 346 | cfg.setGroup("Docs"); |
345 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 347 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
346 | QStringList list; | 348 | QStringList list; |
@@ -373,9 +375,9 @@ void NotesControl::load() { | |||
373 | } | 375 | } |
374 | } | 376 | } |
375 | 377 | ||
376 | void NotesControl::load(const QString & file) { | 378 | void NotesControl::load(const QString & file) { |
377 | qDebug("loading "+file); | 379 | odebug << "loading "+file << oendl; |
378 | QString name = file; | 380 | QString name = file; |
379 | QString temp; | 381 | QString temp; |
380 | if( !QFile( QDir::homeDirPath()+"/"+file).exists() ) | 382 | if( !QFile( QDir::homeDirPath()+"/"+file).exists() ) |
381 | temp = QDir::homeDirPath()+"/notes/"+ name.replace( QRegExp(" "), "_" ); | 383 | temp = QDir::homeDirPath()+"/notes/"+ name.replace( QRegExp(" "), "_" ); |
@@ -400,9 +402,9 @@ void NotesControl::load(const QString & file) { | |||
400 | void NotesControl::loadDoc( const DocLnk &f) { | 402 | void NotesControl::loadDoc( const DocLnk &f) { |
401 | FileManager fm; | 403 | FileManager fm; |
402 | QString txt; | 404 | QString txt; |
403 | if ( !fm.loadFile( f, txt ) ) { | 405 | if ( !fm.loadFile( f, txt ) ) { |
404 | qDebug("could not load file "+f.file()); | 406 | odebug << "could not load file "+f.file() << oendl; |
405 | return; | 407 | return; |
406 | } | 408 | } |
407 | view->setText(txt); | 409 | view->setText(txt); |
408 | } | 410 | } |
@@ -434,9 +436,9 @@ void NotesControl::slotSearch() { | |||
434 | 436 | ||
435 | // switch ( e->state() ) { | 437 | // switch ( e->state() ) { |
436 | // case ControlButton: | 438 | // case ControlButton: |
437 | // if(e->key() == Key_C) { //copy | 439 | // if(e->key() == Key_C) { //copy |
438 | // qDebug("copy"); | 440 | // odebug << "copy" << oendl; |
439 | // QClipboard *cb = QApplication::clipboard(); | 441 | // QClipboard *cb = QApplication::clipboard(); |
440 | // QString text; | 442 | // QString text; |
441 | 443 | ||
442 | // // Copy text from the clipboard (paste) | 444 | // // Copy text from the clipboard (paste) |
@@ -481,12 +483,12 @@ void NotesApplet::mousePressEvent( QMouseEvent *) { | |||
481 | } else { | 483 | } else { |
482 | // vc = new NotesControl; | 484 | // vc = new NotesControl; |
483 | // QPoint curPos = mapToGlobal( rect().topLeft() ); | 485 | // QPoint curPos = mapToGlobal( rect().topLeft() ); |
484 | if(vc->showMax) { | 486 | if(vc->showMax) { |
485 | qDebug("show max"); | 487 | odebug << "show max" << oendl; |
486 | vc->showMaximized(); | 488 | vc->showMaximized(); |
487 | } else { | 489 | } else { |
488 | qDebug("no show max"); | 490 | odebug << "no show max" << oendl; |
489 | QWidget *wid = QPEApplication::desktop(); | 491 | QWidget *wid = QPEApplication::desktop(); |
490 | QRect rect = QApplication::desktop()->geometry(); | 492 | QRect rect = QApplication::desktop()->geometry(); |
491 | vc->setGeometry( ( wid->width() / 2) - ( vc->width() / 2 ) , 28 , wid->width() -10 , 180); | 493 | vc->setGeometry( ( wid->width() / 2) - ( vc->width() / 2 ) , 28 , wid->width() -10 , 180); |
492 | vc->move ( (rect.center()/2) - (vc->rect().center()/2)); | 494 | vc->move ( (rect.center()/2) - (vc->rect().center()/2)); |