-rw-r--r-- | noncore/applets/notesapplet/notes.cpp | 78 | ||||
-rw-r--r-- | noncore/applets/notesapplet/notes.h | 6 |
2 files changed, 80 insertions, 4 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp index 81864c6..2d38e97 100644 --- a/noncore/applets/notesapplet/notes.cpp +++ b/noncore/applets/notesapplet/notes.cpp | |||
@@ -14,40 +14,43 @@ | |||
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #include "notes.h" | 16 | #include "notes.h" |
17 | 17 | ||
18 | #include <qapplication.h> | 18 | #include <qapplication.h> |
19 | #include <stdlib.h> | 19 | #include <stdlib.h> |
20 | #include <qstringlist.h> | 20 | #include <qstringlist.h> |
21 | 21 | ||
22 | #include <qpe/filemanager.h> | 22 | #include <qpe/filemanager.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/timestring.h> | 25 | #include <qpe/timestring.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/applnk.h> | 28 | #include <qpe/applnk.h> |
29 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
30 | #include <qsocket.h> | 30 | #include <qpe/ir.h> |
31 | 31 | ||
32 | // #include <qsocket.h> | ||
33 | // #include <qclipboard.h> | ||
32 | #include <qmultilineedit.h> | 34 | #include <qmultilineedit.h> |
33 | #include <qlistbox.h> | 35 | #include <qlistbox.h> |
34 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
35 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
36 | 38 | ||
37 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #include <qfile.h> | ||
38 | #include <qpoint.h> | 41 | #include <qpoint.h> |
39 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
40 | #include <qpainter.h> | 43 | #include <qpainter.h> |
41 | #include <qlayout.h> | 44 | #include <qlayout.h> |
42 | #include <qframe.h> | 45 | #include <qframe.h> |
43 | #include <qpixmap.h> | 46 | #include <qpixmap.h> |
44 | #include <qstring.h> | 47 | #include <qstring.h> |
45 | #include <qtimer.h> | 48 | #include <qtimer.h> |
46 | 49 | ||
47 | /* XPM */ | 50 | /* XPM */ |
48 | static char * notes_xpm[] = { | 51 | static char * notes_xpm[] = { |
49 | "16 16 11 1", | 52 | "16 16 11 1", |
50 | " c None", | 53 | " c None", |
51 | ". c #000000", | 54 | ". c #000000", |
52 | "+ c #7F7F7F", | 55 | "+ c #7F7F7F", |
53 | "@ c #BFBFBF", | 56 | "@ c #BFBFBF", |
@@ -77,74 +80,92 @@ static char * notes_xpm[] = { | |||
77 | 80 | ||
78 | 81 | ||
79 | NotesControl::NotesControl( QWidget *parent, const char *name ) | 82 | NotesControl::NotesControl( QWidget *parent, const char *name ) |
80 | : QFrame( parent, name,/* WDestructiveClose | */WStyle_StaysOnTop ) | 83 | : QFrame( parent, name,/* WDestructiveClose | */WStyle_StaysOnTop ) |
81 | // : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 84 | // : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
82 | { | 85 | { |
83 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 86 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
84 | loaded=false; | 87 | loaded=false; |
85 | edited=false; | 88 | edited=false; |
86 | doPopulate=true; | 89 | doPopulate=true; |
87 | QVBoxLayout *vbox = new QVBoxLayout( this,0, -1, "Vlayout" ); | 90 | QVBoxLayout *vbox = new QVBoxLayout( this,0, -1, "Vlayout" ); |
88 | QHBoxLayout *hbox = new QHBoxLayout( this, 0, -1, "HLayout" ); | 91 | QHBoxLayout *hbox = new QHBoxLayout( this, 0, -1, "HLayout" ); |
89 | 92 | ||
90 | view = new QMultiLineEdit(this, "OpieNotesView"); | 93 | view = new QMultiLineEdit(this, "OpieNotesView"); |
91 | 94 | ||
92 | box = new QListBox(this, "OpieNotesBox"); | 95 | box = new QListBox(this, "OpieNotesBox"); |
96 | |||
93 | QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold); | 97 | QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold); |
98 | |||
94 | box->setFixedHeight(50); | 99 | box->setFixedHeight(50); |
95 | 100 | ||
96 | vbox->setMargin( 6 ); | 101 | vbox->setMargin( 6 ); |
97 | vbox->setSpacing( 3 ); | 102 | vbox->setSpacing( 3 ); |
98 | 103 | ||
99 | vbox->addWidget( view); | 104 | vbox->addWidget( view); |
100 | vbox->addWidget( box); | 105 | vbox->addWidget( box); |
101 | 106 | ||
102 | setFixedHeight(180); | 107 | setFixedHeight(180); |
103 | QWidget *wid = QPEApplication::desktop(); | 108 | QWidget *wid = QPEApplication::desktop(); |
104 | setFixedWidth( wid->width()-10 /*200*/); | 109 | setFixedWidth( wid->width()-10 /*200*/); |
105 | 110 | ||
106 | setFocusPolicy(QWidget::StrongFocus); | 111 | setFocusPolicy(QWidget::StrongFocus); |
107 | 112 | ||
108 | newButton= new QPushButton( this, "newButton" ); | 113 | newButton= new QPushButton( this, "newButton" ); |
109 | newButton->setText(tr("New")); | 114 | newButton->setText(tr("New")); |
110 | hbox->addWidget( newButton); | 115 | hbox->addWidget( newButton); |
111 | 116 | ||
117 | saveButton= new QPushButton( this, "saveButton" ); | ||
118 | saveButton->setText(tr("Save")); | ||
119 | hbox->addWidget( saveButton); | ||
120 | |||
112 | deleteButton= new QPushButton( this, "deleteButton" ); | 121 | deleteButton= new QPushButton( this, "deleteButton" ); |
113 | deleteButton->setText(tr("Delete")); | 122 | deleteButton->setText(tr("Delete")); |
114 | hbox->addWidget( deleteButton); | 123 | hbox->addWidget( deleteButton); |
115 | 124 | ||
116 | vbox->addItem(hbox); | 125 | vbox->addItem(hbox); |
117 | 126 | ||
118 | connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)), | 127 | connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)), |
119 | this,SLOT( boxPressed(int, QListBoxItem *, const QPoint&)) ); | 128 | this,SLOT( boxPressed(int, QListBoxItem *, const QPoint&)) ); |
129 | |||
120 | connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString &))); | 130 | connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString &))); |
131 | |||
121 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) ); | 132 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) ); |
122 | 133 | ||
123 | connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) ); | 134 | connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) ); |
135 | |||
124 | connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); | 136 | connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); |
137 | connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton())); | ||
125 | connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked())); | 138 | connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked())); |
126 | 139 | ||
127 | populateBox(); | 140 | populateBox(); |
128 | load(); | 141 | load(); |
129 | setCaption("Notes"); | 142 | setCaption("Notes"); |
130 | // parent->setFocus(); | 143 | // parent->setFocus(); |
131 | } | 144 | } |
132 | 145 | ||
146 | void NotesControl::slotSaveButton() { | ||
147 | if(edited) { | ||
148 | save(); | ||
149 | populateBox(); | ||
150 | } | ||
151 | } | ||
152 | |||
133 | void NotesControl::slotDeleteButtonClicked() { | 153 | void NotesControl::slotDeleteButtonClicked() { |
134 | switch ( QMessageBox::warning(this,tr("Delete?"),tr("Do you really want to<BR><B> delete</B> this note ?") | 154 | switch ( QMessageBox::warning(this,tr("Delete?") |
155 | ,tr("Do you really want to<BR><B> delete</B> this note ?") | ||
135 | ,tr("Yes"),tr("No"),0,1,1) ) { | 156 | ,tr("Yes"),tr("No"),0,1,1) ) { |
136 | case 0: | 157 | case 0: |
137 | slotDeleteButton(); | 158 | slotDeleteButton(); |
138 | break; | 159 | break; |
139 | }; | 160 | }; |
140 | } | 161 | } |
141 | 162 | ||
142 | void NotesControl::slotDeleteButton() { | 163 | void NotesControl::slotDeleteButton() { |
143 | 164 | ||
144 | QString selectedText = box->currentText(); | 165 | QString selectedText = box->currentText(); |
145 | qDebug("deleting "+selectedText); | 166 | qDebug("deleting "+selectedText); |
146 | 167 | ||
147 | if( !selectedText.isEmpty()) { | 168 | if( !selectedText.isEmpty()) { |
148 | 169 | ||
149 | Config cfg("Notes"); | 170 | Config cfg("Notes"); |
150 | cfg.setGroup("Docs"); | 171 | cfg.setGroup("Docs"); |
@@ -167,58 +188,79 @@ void NotesControl::slotDeleteButton() { | |||
167 | cfg.removeEntry(entryName); | 188 | cfg.removeEntry(entryName); |
168 | cfg.write(); | 189 | cfg.write(); |
169 | DocLnk nf(selectedText); | 190 | DocLnk nf(selectedText); |
170 | nf.removeFiles(); | 191 | nf.removeFiles(); |
171 | } | 192 | } |
172 | } | 193 | } |
173 | populateBox(); | 194 | populateBox(); |
174 | } | 195 | } |
175 | } | 196 | } |
176 | 197 | ||
177 | void NotesControl::slotNewButton() { | 198 | void NotesControl::slotNewButton() { |
178 | if(edited) save(); | 199 | if(edited) save(); |
179 | view->clear(); | 200 | view->clear(); |
180 | view->setFocus(); | 201 | view->setFocus(); |
181 | } | 202 | } |
182 | 203 | ||
183 | void NotesControl::boxPressed(int mouse, QListBoxItem *item, const QPoint&) { | 204 | void NotesControl::slotBeamButton() { |
205 | Ir ir; | ||
206 | if(!ir.supported()){ | ||
207 | } else { | ||
208 | this->hide(); | ||
209 | QString selectedText = box->currentText(); | ||
210 | if( !selectedText.isEmpty()) { | ||
211 | QString file = QDir::homeDirPath()+"/"+selectedText; | ||
212 | QFile f(file); | ||
213 | Ir *irFile = new Ir(this, "IR"); | ||
214 | connect( irFile, SIGNAL(done(Ir*)), this, SLOT( slotBeamFinished( Ir * ))); | ||
215 | irFile->send( file, "Note", "text/plain" ); | ||
216 | } | ||
217 | } | ||
218 | } | ||
219 | |||
220 | void NotesControl::slotBeamFinished(Ir *) { | ||
221 | this->show(); | ||
222 | } | ||
223 | |||
224 | void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) { | ||
184 | switch (mouse) { | 225 | switch (mouse) { |
185 | case 1:{ | 226 | case 1:{ |
186 | } | 227 | } |
187 | break; | 228 | break; |
188 | case 2: | 229 | case 2: |
189 | menuTimer.start( 500, TRUE ); | 230 | menuTimer.start( 500, TRUE ); |
190 | break; | 231 | break; |
191 | }; | 232 | }; |
192 | } | 233 | } |
193 | 234 | ||
194 | void NotesControl::slotBoxSelected(const QString &itemString) { | 235 | void NotesControl::slotBoxSelected(const QString &itemString) { |
195 | if(edited) { | 236 | if(edited) { |
196 | save(); | 237 | save(); |
197 | } | 238 | } |
198 | loaded=false; | 239 | loaded=false; |
199 | edited=false; | 240 | edited=false; |
200 | load(itemString); | 241 | load(itemString); |
201 | } | 242 | } |
202 | 243 | ||
203 | 244 | ||
204 | void NotesControl::showMenu() { | 245 | void NotesControl::showMenu() { |
205 | QPopupMenu *m = new QPopupMenu(0); | 246 | QPopupMenu *m = new QPopupMenu(0); |
206 | 247 | ||
248 | m->insertItem( tr( "Beam Out" ), this, SLOT( slotBeamButton() )); | ||
249 | m->insertSeparator(); | ||
207 | m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() )); | 250 | m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() )); |
208 | |||
209 | m->setFocus(); | 251 | m->setFocus(); |
210 | m->exec( QCursor::pos() ); | 252 | m->exec( QCursor::pos() ); |
211 | 253 | ||
212 | if(m) delete m; | 254 | if(m) delete m; |
213 | 255 | ||
214 | } | 256 | } |
215 | 257 | ||
216 | void NotesControl::focusOutEvent ( QFocusEvent * e) { | 258 | void NotesControl::focusOutEvent ( QFocusEvent * e) { |
217 | if( e->reason() == QFocusEvent::Popup) | 259 | if( e->reason() == QFocusEvent::Popup) |
218 | save(); | 260 | save(); |
219 | else { | 261 | else { |
220 | if(!loaded) { | 262 | if(!loaded) { |
221 | populateBox(); | 263 | populateBox(); |
222 | load(); | 264 | load(); |
223 | } | 265 | } |
224 | } | 266 | } |
@@ -243,32 +285,34 @@ void NotesControl::save() { | |||
243 | // cut the length. filenames longer than that don't make sense | 285 | // cut the length. filenames longer than that don't make sense |
244 | // and something goes wrong when they get too long. | 286 | // and something goes wrong when they get too long. |
245 | if ( docname.length() > 40 ) | 287 | if ( docname.length() > 40 ) |
246 | docname = docname.left(40); | 288 | docname = docname.left(40); |
247 | if ( docname.isEmpty() ) | 289 | if ( docname.isEmpty() ) |
248 | docname = "Empty Text"; | 290 | docname = "Empty Text"; |
249 | qDebug(docname); | 291 | qDebug(docname); |
250 | 292 | ||
251 | if( oldDocName != docname) { | 293 | if( oldDocName != docname) { |
252 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 294 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
253 | QString entryName; | 295 | QString entryName; |
254 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 296 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
255 | cfg.writeEntry( entryName,docname ); | 297 | cfg.writeEntry( entryName,docname ); |
256 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); | 298 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); |
257 | cfg.write(); | 299 | cfg.write(); |
258 | } | 300 | } |
301 | else | ||
302 | qDebug("oldname equals docname"); | ||
259 | doc = new DocLnk(docname); | 303 | doc = new DocLnk(docname); |
260 | 304 | ||
261 | doc->setType("text/plain"); | 305 | doc->setType("text/plain"); |
262 | doc->setFile(docname); | 306 | doc->setFile(docname); |
263 | doc->setName(docname); | 307 | doc->setName(docname); |
264 | 308 | ||
265 | FileManager fm; | 309 | FileManager fm; |
266 | if ( !fm.saveFile( *doc, rt ) ) { | 310 | if ( !fm.saveFile( *doc, rt ) ) { |
267 | } | 311 | } |
268 | 312 | ||
269 | oldDocName=docname; | 313 | oldDocName=docname; |
270 | edited=false; | 314 | edited=false; |
271 | qDebug("save"); | 315 | qDebug("save"); |
272 | if (doPopulate) | 316 | if (doPopulate) |
273 | populateBox(); | 317 | populateBox(); |
274 | } | 318 | } |
@@ -280,32 +324,33 @@ void NotesControl::save() { | |||
280 | 324 | ||
281 | void NotesControl::populateBox() { | 325 | void NotesControl::populateBox() { |
282 | box->clear(); | 326 | box->clear(); |
283 | qDebug("populate"); | 327 | qDebug("populate"); |
284 | Config cfg("Notes"); | 328 | Config cfg("Notes"); |
285 | cfg.setGroup("Docs"); | 329 | cfg.setGroup("Docs"); |
286 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 330 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
287 | QStringList list; | 331 | QStringList list; |
288 | QString entryName; | 332 | QString entryName; |
289 | for ( int i = 0; i < noOfFiles; i++ ) { | 333 | for ( int i = 0; i < noOfFiles; i++ ) { |
290 | entryName.sprintf( "File%i", i + 1 ); | 334 | entryName.sprintf( "File%i", i + 1 ); |
291 | list.append(cfg.readEntry( entryName )); | 335 | list.append(cfg.readEntry( entryName )); |
292 | } | 336 | } |
293 | list.sort(); | 337 | list.sort(); |
294 | box->insertStringList(list,-1); | 338 | box->insertStringList(list,-1); |
295 | doPopulate=false; | 339 | doPopulate=false; |
340 | update(); | ||
296 | } | 341 | } |
297 | 342 | ||
298 | void NotesControl::load() { | 343 | void NotesControl::load() { |
299 | 344 | ||
300 | if(!loaded) { | 345 | if(!loaded) { |
301 | Config cfg("Notes"); | 346 | Config cfg("Notes"); |
302 | cfg.setGroup("Docs"); | 347 | cfg.setGroup("Docs"); |
303 | QString lastDoc=cfg.readEntry( "LastDoc",""); | 348 | QString lastDoc=cfg.readEntry( "LastDoc",""); |
304 | DocLnk nf; | 349 | DocLnk nf; |
305 | nf.setType("text/plain"); | 350 | nf.setType("text/plain"); |
306 | nf.setFile(lastDoc); | 351 | nf.setFile(lastDoc); |
307 | 352 | ||
308 | loadDoc(nf); | 353 | loadDoc(nf); |
309 | loaded=true; | 354 | loaded=true; |
310 | oldDocName=lastDoc; | 355 | oldDocName=lastDoc; |
311 | cfg.writeEntry( "LastDoc",oldDocName ); | 356 | cfg.writeEntry( "LastDoc",oldDocName ); |
@@ -333,32 +378,57 @@ void NotesControl::load(const QString & file) { | |||
333 | 378 | ||
334 | void NotesControl::loadDoc( const DocLnk &f) { | 379 | void NotesControl::loadDoc( const DocLnk &f) { |
335 | FileManager fm; | 380 | FileManager fm; |
336 | QString txt; | 381 | QString txt; |
337 | if ( !fm.loadFile( f, txt ) ) { | 382 | if ( !fm.loadFile( f, txt ) ) { |
338 | return; | 383 | return; |
339 | } | 384 | } |
340 | view->setText(txt); | 385 | view->setText(txt); |
341 | } | 386 | } |
342 | 387 | ||
343 | void NotesControl::slotViewEdited() { | 388 | void NotesControl::slotViewEdited() { |
344 | if(loaded) { | 389 | if(loaded) { |
345 | edited=true; | 390 | edited=true; |
346 | } | 391 | } |
347 | } | 392 | } |
348 | 393 | ||
394 | // void NotesControl::keyReleaseEvent( QKeyEvent *e) { | ||
395 | |||
396 | // switch ( e->state() ) { | ||
397 | // case ControlButton: | ||
398 | // if(e->key() == Key_C) { //copy | ||
399 | // qDebug("copy"); | ||
400 | // QClipboard *cb = QApplication::clipboard(); | ||
401 | // QString text; | ||
402 | |||
403 | // // Copy text from the clipboard (paste) | ||
404 | // text = cb->text(); | ||
405 | // } | ||
406 | // if(e->key() == Key_X) { //cut | ||
407 | // } | ||
408 | // if(e->key() == Key_V) { //paste | ||
409 | // QClipboard *cb = QApplication::clipboard(); | ||
410 | // QString text; | ||
411 | // view | ||
412 | // cb->setText(); | ||
413 | // } | ||
414 | // break; | ||
415 | // }; | ||
416 | // QWidget::keyReleaseEvent(e); | ||
417 | // } | ||
418 | |||
349 | //=========================================================================== | 419 | //=========================================================================== |
350 | 420 | ||
351 | NotesApplet::NotesApplet( QWidget *parent, const char *name ) | 421 | NotesApplet::NotesApplet( QWidget *parent, const char *name ) |
352 | : QWidget( parent, name ) { | 422 | : QWidget( parent, name ) { |
353 | setFixedHeight( 18 ); | 423 | setFixedHeight( 18 ); |
354 | setFixedWidth( 14 ); | 424 | setFixedWidth( 14 ); |
355 | vc = new NotesControl; | 425 | vc = new NotesControl; |
356 | } | 426 | } |
357 | 427 | ||
358 | NotesApplet::~NotesApplet() { | 428 | NotesApplet::~NotesApplet() { |
359 | } | 429 | } |
360 | 430 | ||
361 | void NotesApplet::mousePressEvent( QMouseEvent *) { | 431 | void NotesApplet::mousePressEvent( QMouseEvent *) { |
362 | if( !vc->isHidden()) { | 432 | if( !vc->isHidden()) { |
363 | vc->doPopulate=false; | 433 | vc->doPopulate=false; |
364 | vc->save(); | 434 | vc->save(); |
diff --git a/noncore/applets/notesapplet/notes.h b/noncore/applets/notesapplet/notes.h index 473a89a..a593881 100644 --- a/noncore/applets/notesapplet/notes.h +++ b/noncore/applets/notesapplet/notes.h | |||
@@ -8,72 +8,78 @@ | |||
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 <qframe.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 <qstring.h> | 25 | #include <qstring.h> |
25 | 26 | ||
26 | class QComboBox; | 27 | class QComboBox; |
27 | class QCheckBox; | 28 | class QCheckBox; |
28 | class QSpinBox; | 29 | class QSpinBox; |
29 | class QPushButton; | 30 | class QPushButton; |
30 | class QMultiLineEdit; | 31 | class QMultiLineEdit; |
31 | class QListBox; | 32 | class QListBox; |
32 | class QListBoxItem; | 33 | class QListBoxItem; |
33 | class NotesControl : public QFrame { | 34 | class NotesControl : public QFrame { |
34 | Q_OBJECT | 35 | Q_OBJECT |
35 | public: | 36 | public: |
36 | NotesControl( QWidget *parent=0, const char *name=0 ); | 37 | NotesControl( QWidget *parent=0, const char *name=0 ); |
37 | void performGrab(); | 38 | void performGrab(); |
38 | 39 | ||
39 | QPixmap notes; | 40 | QPixmap notes; |
40 | QMultiLineEdit *view; | 41 | QMultiLineEdit *view; |
41 | QListBox *box; | 42 | QListBox *box; |
42 | QPushButton *saveButton, *deleteButton, *newButton; | 43 | QPushButton *saveButton, *deleteButton, *newButton; |
43 | QString FileNamePath; | 44 | QString FileNamePath; |
44 | bool loaded, edited, doPopulate; | 45 | bool loaded, edited, doPopulate; |
45 | void save(); | 46 | void save(); |
46 | void populateBox(); | 47 | void populateBox(); |
47 | void load(); | 48 | void load(); |
48 | 49 | ||
49 | private: | 50 | private: |
50 | QTimer menuTimer; | 51 | QTimer menuTimer; |
51 | DocLnk *doc; | 52 | DocLnk *doc; |
52 | QString oldDocName; | 53 | QString oldDocName; |
53 | void focusOutEvent( QFocusEvent * ); | 54 | void focusOutEvent( QFocusEvent * ); |
54 | void load(const QString&); | 55 | void load(const QString&); |
55 | private slots: | 56 | private slots: |
57 | void slotBeamButton(); | ||
58 | void slotBeamFinished( Ir*); | ||
56 | void slotDeleteButton(); | 59 | void slotDeleteButton(); |
60 | void slotSaveButton(); | ||
57 | void slotDeleteButtonClicked(); | 61 | void slotDeleteButtonClicked(); |
58 | void slotNewButton(); | 62 | void slotNewButton(); |
59 | void boxPressed(int, QListBoxItem *, const QPoint&); | 63 | void boxPressed(int, QListBoxItem *, const QPoint&); |
60 | void showMenu(); | 64 | void showMenu(); |
61 | void loadDoc( const DocLnk &); | 65 | void loadDoc( const DocLnk &); |
62 | void slotViewEdited(); | 66 | void slotViewEdited(); |
63 | void slotBoxSelected(const QString &); | 67 | void slotBoxSelected(const QString &); |
68 | // void keyReleaseEvent( QKeyEvent *); | ||
69 | |||
64 | }; | 70 | }; |
65 | 71 | ||
66 | class NotesApplet : public QWidget { | 72 | class NotesApplet : public QWidget { |
67 | Q_OBJECT | 73 | Q_OBJECT |
68 | public: | 74 | public: |
69 | NotesApplet( QWidget *parent = 0, const char *name=0 ); | 75 | NotesApplet( QWidget *parent = 0, const char *name=0 ); |
70 | ~NotesApplet(); | 76 | ~NotesApplet(); |
71 | NotesControl *vc; | 77 | NotesControl *vc; |
72 | public slots: | 78 | public slots: |
73 | private: | 79 | private: |
74 | void mousePressEvent( QMouseEvent * ); | 80 | void mousePressEvent( QMouseEvent * ); |
75 | void paintEvent( QPaintEvent* ); | 81 | void paintEvent( QPaintEvent* ); |
76 | 82 | ||
77 | private: | 83 | private: |
78 | QPixmap notesPixmap; | 84 | QPixmap notesPixmap; |
79 | private slots: | 85 | private slots: |