summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp78
-rw-r--r--noncore/applets/notesapplet/notes.h6
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
@@ -27,14 +27,17 @@
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>
@@ -90,7 +93,9 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
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 );
@@ -109,6 +114,10 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
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);
@@ -117,11 +126,15 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
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();
@@ -130,8 +143,16 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
130 // parent->setFocus(); 143 // parent->setFocus();
131} 144}
132 145
146void NotesControl::slotSaveButton() {
147 if(edited) {
148 save();
149 populateBox();
150 }
151}
152
133void NotesControl::slotDeleteButtonClicked() { 153void 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();
@@ -180,7 +201,27 @@ void NotesControl::slotNewButton() {
180 view->setFocus(); 201 view->setFocus();
181} 202}
182 203
183void NotesControl::boxPressed(int mouse, QListBoxItem *item, const QPoint&) { 204void 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
220void NotesControl::slotBeamFinished(Ir *) {
221 this->show();
222}
223
224void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) {
184 switch (mouse) { 225 switch (mouse) {
185 case 1:{ 226 case 1:{
186 } 227 }
@@ -204,8 +245,9 @@ void NotesControl::slotBoxSelected(const QString &itemString) {
204void NotesControl::showMenu() { 245void 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
@@ -256,6 +298,8 @@ void NotesControl::save() {
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");
@@ -293,6 +337,7 @@ void NotesControl::populateBox() {
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
298void NotesControl::load() { 343void NotesControl::load() {
@@ -346,6 +391,31 @@ void NotesControl::slotViewEdited() {
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
351NotesApplet::NotesApplet( QWidget *parent, const char *name ) 421NotesApplet::NotesApplet( QWidget *parent, const char *name )
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
@@ -21,6 +21,7 @@
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
26class QComboBox; 27class QComboBox;
@@ -53,7 +54,10 @@ private:
53 void focusOutEvent( QFocusEvent * ); 54 void focusOutEvent( QFocusEvent * );
54 void load(const QString&); 55 void load(const QString&);
55private slots: 56private 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&);
@@ -61,6 +65,8 @@ private slots:
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
66class NotesApplet : public QWidget { 72class NotesApplet : public QWidget {