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