summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp45
-rw-r--r--noncore/applets/notesapplet/notes.h10
-rw-r--r--noncore/applets/notesapplet/notesappletimpl.cpp1
3 files changed, 28 insertions, 28 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp
index 4e98b31..e2b0c2a 100644
--- a/noncore/applets/notesapplet/notes.cpp
+++ b/noncore/applets/notesapplet/notes.cpp
@@ -70,105 +70,103 @@ static char * notes_xpm[] = {
70" ..#.@. ", 70" ..#.@. ",
71" ..###.+.. ", 71" ..###.+.. ",
72" ..###$...##.. ", 72" ..###$...##.. ",
73"..###$$$%+$$##&.", 73"..###$$$%+$$##&.",
74".*=####$-###&=&.", 74".*=####$-###&=&.",
75".=**=###==&=&=..", 75".=**=###==&=&=..",
76" ..=**=#&=&=.. ", 76" ..=**=#&=&=.. ",
77" ..=*=&=.. ", 77" ..=*=&=.. ",
78" ..=.. ", 78" ..=.. ",
79" . "}; 79" . "};
80 80
81 81
82NotesControl::NotesControl( QWidget *parent, const char *name ) 82NotesControl::NotesControl( QWidget *, const char * )
83 : QFrame( parent, name,/* WDestructiveClose | */WStyle_StaysOnTop ) 83 : QVBox( 0, "NotesControl",/* WDestructiveClose | */WStyle_StaysOnTop )
84// : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) 84// : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
85{ 85{
86 QDir d( QDir::homeDirPath()+"/notes"); 86 QDir d( QDir::homeDirPath()+"/notes");
87 if( !d.exists()) { 87 if( !d.exists()) {
88 qDebug("make dir"); 88 qDebug("make dir");
89 if(!d.mkdir( QDir::homeDirPath()+"/notes", true)) 89 if(!d.mkdir( QDir::homeDirPath()+"/notes", true))
90 qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed"); 90 qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed");
91 } 91 }
92 Config cfg("Notes"); 92 Config cfg("Notes");
93 cfg.setGroup("Options"); 93 cfg.setGroup("Options");
94 showMax = cfg.readBoolEntry("ShowMax", false); 94 showMax = cfg.readBoolEntry("ShowMax", false);
95 95
96 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 96 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
97 loaded=false; 97 loaded=false;
98 edited=false; 98 edited=false;
99 doPopulate=true; 99 doPopulate=true;
100 isNew=false; 100 isNew=false;
101 QVBoxLayout *vbox = new QVBoxLayout( this,0, -1, "Vlayout" ); 101 QVBox *vbox = new QVBox( this, "Vlayout" );
102 QHBoxLayout *hbox = new QHBoxLayout( this, 0, -1, "HLayout" ); 102 QHBox *hbox = new QHBox( this, "HLayout" );
103 103
104 view = new QMultiLineEdit(this, "OpieNotesView"); 104 view = new QMultiLineEdit(vbox, "OpieNotesView");
105 105
106 box = new QListBox(this, "OpieNotesBox"); 106 box = new QListBox(vbox, "OpieNotesBox");
107 107
108 QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold); 108 QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold);
109 109
110 box->setFixedHeight(50); 110 box->setFixedHeight(50);
111 111
112 vbox->setMargin( 6 ); 112 vbox->setMargin( 6 );
113 vbox->setSpacing( 3 ); 113 vbox->setSpacing( 3 );
114 114
115 vbox->addWidget( view); 115
116 vbox->addWidget( box);
117 116
118 setFocusPolicy(QWidget::StrongFocus); 117 setFocusPolicy(QWidget::StrongFocus);
119 118
120 newButton= new QPushButton( this, "newButton" ); 119 newButton= new QPushButton( hbox, "newButton" );
121 newButton->setText(tr("New")); 120 newButton->setText(tr("New"));
122 hbox->addWidget( newButton);
123 121
124 saveButton= new QPushButton( this, "saveButton" ); 122
123 saveButton= new QPushButton( hbox, "saveButton" );
125 saveButton->setText(tr("Save")); 124 saveButton->setText(tr("Save"));
126 hbox->addWidget( saveButton);
127 125
128 deleteButton= new QPushButton( this, "deleteButton" ); 126
127 deleteButton= new QPushButton( hbox, "deleteButton" );
129 deleteButton->setText(tr("Delete")); 128 deleteButton->setText(tr("Delete"));
130 hbox->addWidget( deleteButton); 129
131 130
132 vbox->addItem(hbox);
133 131
134 connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)), 132 connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)),
135 this,SLOT( boxPressed(int, QListBoxItem *, const QPoint&)) ); 133 this,SLOT( boxPressed(int, QListBoxItem *, const QPoint&)) );
136 134
137 connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString &))); 135 connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString &)));
138 136
139 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) ); 137 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) );
140 138
141 connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) ); 139 connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) );
142 140
143 connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); 141 connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton()));
144 connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton())); 142 connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton()));
145 connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked())); 143 connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked()));
146 144
147 populateBox(); 145 populateBox();
148 load(); 146 load();
149 setCaption("Notes"); 147 setCaption("Notes");
150 // parent->setFocus(); 148 // parent->setFocus();
151} 149}
152 150
153void NotesControl::slotSaveButton() { 151void NotesControl::slotSaveButton() {
154 slotNewButton(); 152 slotNewButton();
155 populateBox(); 153 populateBox();
156} 154}
157 155
158void NotesControl::slotDeleteButtonClicked() { 156void NotesControl::slotDeleteButtonClicked() {
159 switch ( QMessageBox::warning(this,tr("Delete?") 157 switch ( QMessageBox::warning(this,tr("Delete?")
160 ,tr("Do you really want to<BR><B> delete</B> this note ?") 158 ,tr("Do you really want to<BR><B> delete</B> this note ?")
161 ,tr("Yes"),tr("No"),0,1,1) ) { 159 ,tr("Yes"),tr("No"),0,1,1) ) {
162 case 0: 160 case 0:
163 slotDeleteButton(); 161 slotDeleteButton();
164 break; 162 break;
165 }; 163 };
166} 164}
167 165
168void NotesControl::slotDeleteButton() { 166void NotesControl::slotDeleteButton() {
169 167
170 QString selectedText = box->currentText(); 168 QString selectedText = box->currentText();
171 qDebug("deleting "+selectedText); 169 qDebug("deleting "+selectedText);
172 170
173 if( !selectedText.isEmpty()) { 171 if( !selectedText.isEmpty()) {
174 172
@@ -190,29 +188,29 @@ void NotesControl::slotDeleteButton() {
190 } 188 }
191 cfg.writeEntry("NumberOfFiles", noOfFiles-1 ); 189 cfg.writeEntry("NumberOfFiles", noOfFiles-1 );
192 entryName.sprintf( "File%i", noOfFiles ); 190 entryName.sprintf( "File%i", noOfFiles );
193 cfg.removeEntry(entryName); 191 cfg.removeEntry(entryName);
194 cfg.write(); 192 cfg.write();
195 DocLnk nf(selectedText); 193 DocLnk nf(selectedText);
196 nf.removeFiles(); 194 nf.removeFiles();
197 QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop"; 195 QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop";
198 qDebug(fi); 196 qDebug(fi);
199 197
200 QFile f( fi); 198 QFile f( fi);
201 if( !f.remove()) qDebug(".desktop file not removed"); 199 if( !f.remove()) qDebug(".desktop file not removed");
202 200
203 } 201 }
204 } 202 }
205 view->clear(); 203 view->clear();
206 204
207 populateBox(); 205 populateBox();
208 } 206 }
209} 207}
210 208
211void NotesControl::slotNewButton() { 209void NotesControl::slotNewButton() {
212 if(edited) save(); 210 if(edited) save();
213 view->clear(); 211 view->clear();
214 view->setFocus(); 212 view->setFocus();
215 edited=false; 213 edited=false;
216 isNew=false; 214 isNew=false;
217} 215}
218 216
@@ -326,26 +324,26 @@ void NotesControl::save() {
326 doc->setFile( QDir::homeDirPath()+"/notes/"+temp); 324 doc->setFile( QDir::homeDirPath()+"/notes/"+temp);
327 FileManager fm; 325 FileManager fm;
328 if ( !fm.saveFile( *doc, rt ) ) { 326 if ( !fm.saveFile( *doc, rt ) ) {
329 } 327 }
330 328
331 oldDocName=docname; 329 oldDocName=docname;
332 edited=false; 330 edited=false;
333// qDebug("save"); 331// qDebug("save");
334 if (doPopulate) 332 if (doPopulate)
335 populateBox(); 333 populateBox();
336 } 334 }
337 cfg.writeEntry( "LastDoc",oldDocName ); 335 cfg.writeEntry( "LastDoc",oldDocName );
338 cfg.write(); 336 cfg.write();
339 337
340 } 338 }
341} 339}
342 340
343void NotesControl::populateBox() { 341void NotesControl::populateBox() {
344 box->clear(); 342 box->clear();
345// qDebug("populate"); 343// qDebug("populate");
346 Config cfg("Notes"); 344 Config cfg("Notes");
347 cfg.setGroup("Docs"); 345 cfg.setGroup("Docs");
348 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 346 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
349 QStringList list; 347 QStringList list;
350 QString entryName; 348 QString entryName;
351 for ( int i = 0; i < noOfFiles; i++ ) { 349 for ( int i = 0; i < noOfFiles; i++ ) {
@@ -459,24 +457,25 @@ void NotesControl::slotSearch() {
459// } 457// }
460 458
461//=========================================================================== 459//===========================================================================
462 460
463NotesApplet::NotesApplet( QWidget *parent, const char *name ) 461NotesApplet::NotesApplet( QWidget *parent, const char *name )
464 : QWidget( parent, name ) { 462 : QWidget( parent, name ) {
465 setFixedHeight( 18 ); 463 setFixedHeight( 18 );
466 setFixedWidth( 14 ); 464 setFixedWidth( 14 );
467 vc = new NotesControl; 465 vc = new NotesControl;
468} 466}
469 467
470NotesApplet::~NotesApplet() { 468NotesApplet::~NotesApplet() {
469 delete vc;
471} 470}
472 471
473void NotesApplet::mousePressEvent( QMouseEvent *) { 472void NotesApplet::mousePressEvent( QMouseEvent *) {
474 if( !vc->isHidden()) { 473 if( !vc->isHidden()) {
475 vc->doPopulate=false; 474 vc->doPopulate=false;
476 vc->save(); 475 vc->save();
477 vc->close(); 476 vc->close();
478 } else { 477 } else {
479// vc = new NotesControl; 478// vc = new NotesControl;
480// QPoint curPos = mapToGlobal( rect().topLeft() ); 479// QPoint curPos = mapToGlobal( rect().topLeft() );
481 if(vc->showMax) { 480 if(vc->showMax) {
482 qDebug("show max"); 481 qDebug("show max");
diff --git a/noncore/applets/notesapplet/notes.h b/noncore/applets/notesapplet/notes.h
index c428efe..08253cb 100644
--- a/noncore/applets/notesapplet/notes.h
+++ b/noncore/applets/notesapplet/notes.h
@@ -7,55 +7,55 @@
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13**********************************************************************/ 13**********************************************************************/
14 14
15#ifndef __NOTES_APPLET_H__ 15#ifndef __NOTES_APPLET_H__
16#define __NOTES_APPLET_H__ 16#define __NOTES_APPLET_H__
17 17
18#include <qwidget.h> 18#include <qwidget.h>
19#include <qframe.h> 19#include <qvbox.h>
20#include <qpixmap.h> 20#include <qpixmap.h>
21#include <qguardedptr.h> 21#include <qguardedptr.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qpe/filemanager.h> 23#include <qpe/filemanager.h>
24#include <qpe/ir.h> 24#include <qpe/ir.h>
25#include <qstring.h> 25#include <qstring.h>
26 26
27class QComboBox; 27class QComboBox;
28class QCheckBox; 28class QCheckBox;
29class QSpinBox; 29class QSpinBox;
30class QPushButton; 30class QPushButton;
31class QMultiLineEdit; 31class QMultiLineEdit;
32class QListBox; 32class QListBox;
33class QListBoxItem; 33class QListBoxItem;
34class NotesControl : public QFrame { 34class NotesControl : public QVBox {
35 Q_OBJECT 35 Q_OBJECT
36public: 36public:
37 NotesControl( QWidget *parent=0, const char *name=0 ); 37 NotesControl( QWidget *parent=0, const char *name=0 );
38 38
39 QPixmap notes; 39 QPixmap notes;
40 QMultiLineEdit *view; 40 QMultiLineEdit *view;
41 QListBox *box; 41 QListBox *box;
42 QPushButton *saveButton, *deleteButton, *newButton; 42 QPushButton *saveButton, *deleteButton, *newButton;
43 QString FileNamePath; 43 QString FileNamePath;
44 bool loaded, edited, doPopulate, isNew; 44 bool loaded, edited, doPopulate, isNew;
45 bool showMax; 45 bool showMax;
46 void save(); 46 void save();
47 void populateBox(); 47 void populateBox();
48 void load(); 48 void load();
49 49
50private: 50private:
51 QTimer menuTimer; 51 QTimer menuTimer;
52 DocLnk *doc; 52 DocLnk *doc;
53 QString oldDocName; 53 QString oldDocName;
54 void focusOutEvent( QFocusEvent * ); 54 void focusOutEvent( QFocusEvent * );
55 void load(const QString&); 55 void load(const QString&);
56private slots: 56private slots:
57 void slotSearch(); 57 void slotSearch();
58 void slotShowMax(); 58 void slotShowMax();
59 void slotBeamButton(); 59 void slotBeamButton();
60 void slotBeamFinished( Ir*); 60 void slotBeamFinished( Ir*);
61 void slotDeleteButton(); 61 void slotDeleteButton();
@@ -67,27 +67,27 @@ private slots:
67 void loadDoc( const DocLnk &); 67 void loadDoc( const DocLnk &);
68 void slotViewEdited(); 68 void slotViewEdited();
69 void slotBoxSelected(const QString &); 69 void slotBoxSelected(const QString &);
70// void keyReleaseEvent( QKeyEvent *); 70// void keyReleaseEvent( QKeyEvent *);
71 71
72}; 72};
73 73
74class NotesApplet : public QWidget { 74class NotesApplet : public QWidget {
75 Q_OBJECT 75 Q_OBJECT
76public: 76public:
77 NotesApplet( QWidget *parent = 0, const char *name=0 ); 77 NotesApplet( QWidget *parent = 0, const char *name=0 );
78 ~NotesApplet(); 78 ~NotesApplet();
79 NotesControl *vc; 79 NotesControl *vc;
80public slots: 80public slots:
81private: 81private:
82 void mousePressEvent( QMouseEvent * ); 82 void mousePressEvent( QMouseEvent * );
83 void paintEvent( QPaintEvent* ); 83 void paintEvent( QPaintEvent* );
84 84
85private: 85private:
86 QPixmap notesPixmap; 86 QPixmap notesPixmap;
87private slots: 87private slots:
88 88
89 89
90}; 90};
91 91
92#endif // __NOTES_APPLET_H__ 92#endif // __NOTES_APPLET_H__
93 93
diff --git a/noncore/applets/notesapplet/notesappletimpl.cpp b/noncore/applets/notesapplet/notesappletimpl.cpp
index 93e1e97..0526bad 100644
--- a/noncore/applets/notesapplet/notesappletimpl.cpp
+++ b/noncore/applets/notesapplet/notesappletimpl.cpp
@@ -9,24 +9,25 @@
9** 9**
10** 10**
11**********************************************************************/ 11**********************************************************************/
12#include "notes.h" 12#include "notes.h"
13#include "notesappletimpl.h" 13#include "notesappletimpl.h"
14 14
15 15
16NotesAppletImpl::NotesAppletImpl() 16NotesAppletImpl::NotesAppletImpl()
17 : notes(0), ref(0) { 17 : notes(0), ref(0) {
18} 18}
19 19
20NotesAppletImpl::~NotesAppletImpl() { 20NotesAppletImpl::~NotesAppletImpl() {
21 // not needed though cause we should have a valid parent
21 delete notes; 22 delete notes;
22} 23}
23 24
24QWidget *NotesAppletImpl::applet( QWidget *parent ) { 25QWidget *NotesAppletImpl::applet( QWidget *parent ) {
25 if ( !notes ) 26 if ( !notes )
26 notes = new NotesApplet( parent ); 27 notes = new NotesApplet( parent );
27 return notes; 28 return notes;
28} 29}
29 30
30int NotesAppletImpl::position() const { 31int NotesAppletImpl::position() const {
31 return 6; 32 return 6;
32} 33}