summaryrefslogtreecommitdiff
path: root/noncore/applets/notesapplet/notes.cpp
Unidiff
Diffstat (limited to 'noncore/applets/notesapplet/notes.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp54
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
@@ -15,10 +15,8 @@
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>
@@ -26,14 +24,15 @@
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>
27using namespace Opie::Core;
28using 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>
@@ -43,10 +42,13 @@
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 */
49using namespace Opie::Ui;
50static char * notes_xpm[] = { 52static char * notes_xpm[] = {
51"16 16 11 1", 53"16 16 11 1",
52" c None", 54" c None",
@@ -84,9 +86,9 @@ NotesControl::NotesControl( QWidget *, const char * )
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");
@@ -165,7 +167,7 @@ void NotesControl::slotDeleteButtonClicked() {
165void NotesControl::slotDeleteButton() { 167void 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
@@ -176,12 +178,12 @@ void NotesControl::slotDeleteButton() {
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 }
@@ -192,10 +194,10 @@ void NotesControl::slotDeleteButton() {
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 }
@@ -283,7 +285,7 @@ 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();
@@ -301,7 +303,7 @@ void NotesControl::save() {
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 );
@@ -312,11 +314,11 @@ void NotesControl::save() {
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(" "), "_" );
@@ -327,7 +329,7 @@ void NotesControl::save() {
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 }
@@ -339,7 +341,7 @@ void NotesControl::save() {
339 341
340void NotesControl::populateBox() { 342void 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 );
@@ -374,7 +376,7 @@ void NotesControl::load() {
374} 376}
375 377
376void NotesControl::load(const QString & file) { 378void 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() )
@@ -401,7 +403,7 @@ 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);
@@ -435,7 +437,7 @@ void NotesControl::slotSearch() {
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
@@ -482,10 +484,10 @@ void NotesApplet::mousePressEvent( QMouseEvent *) {
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);