-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 @@ -283,174 +283,174 @@ void NotesControl::save() { docname = docname.mid( 1 ); docname.replace( QRegExp("/"), "_" ); // cut the length. filenames longer than that don't make sense // and something goes wrong when they get too long. if ( docname.length() > 40 ) docname = docname.left(40); if ( docname.isEmpty() ) docname = "Empty Text"; qDebug(docname); if( oldDocName != docname) { int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); QString entryName; entryName.sprintf( "File%i", noOfFiles + 1 ); cfg.writeEntry( entryName,docname ); cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); cfg.write(); } else qDebug("oldname equals docname"); doc = new DocLnk(docname); doc->setType("text/plain"); doc->setFile(docname); doc->setName(docname); FileManager fm; if ( !fm.saveFile( *doc, rt ) ) { } oldDocName=docname; edited=false; qDebug("save"); if (doPopulate) populateBox(); } cfg.writeEntry( "LastDoc",oldDocName ); cfg.write(); } } void NotesControl::populateBox() { box->clear(); qDebug("populate"); Config cfg("Notes"); cfg.setGroup("Docs"); int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); QStringList list; QString entryName; for ( int i = 0; i < noOfFiles; i++ ) { entryName.sprintf( "File%i", i + 1 ); list.append(cfg.readEntry( entryName )); } list.sort(); box->insertStringList(list,-1); doPopulate=false; update(); } void NotesControl::load() { if(!loaded) { Config cfg("Notes"); cfg.setGroup("Docs"); QString lastDoc=cfg.readEntry( "LastDoc",""); DocLnk nf; nf.setType("text/plain"); nf.setFile(lastDoc); loadDoc(nf); loaded=true; oldDocName=lastDoc; cfg.writeEntry( "LastDoc",oldDocName ); cfg.write(); } } void NotesControl::load(const QString & file) { qDebug("loading "+file); if(!loaded) { DocLnk nf; nf.setType("text/plain"); nf.setFile( file); loadDoc(nf); loaded=true; } // view->setFocus(); oldDocName=file; Config cfg("Notes"); cfg.setGroup("Docs"); cfg.writeEntry( "LastDoc",oldDocName ); cfg.write(); } void NotesControl::loadDoc( const DocLnk &f) { FileManager fm; QString txt; if ( !fm.loadFile( f, txt ) ) { return; } view->setText(txt); } void NotesControl::slotViewEdited() { if(loaded) { edited=true; } } // void NotesControl::keyReleaseEvent( QKeyEvent *e) { // switch ( e->state() ) { // case ControlButton: // if(e->key() == Key_C) { //copy // qDebug("copy"); // QClipboard *cb = QApplication::clipboard(); // QString text; // // Copy text from the clipboard (paste) // text = cb->text(); // } // if(e->key() == Key_X) { //cut // } // if(e->key() == Key_V) { //paste // QClipboard *cb = QApplication::clipboard(); // QString text; -// view +// //view // cb->setText(); // } // break; // }; // QWidget::keyReleaseEvent(e); // } //=========================================================================== NotesApplet::NotesApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { setFixedHeight( 18 ); setFixedWidth( 14 ); vc = new NotesControl; } NotesApplet::~NotesApplet() { } void NotesApplet::mousePressEvent( QMouseEvent *) { if( !vc->isHidden()) { vc->doPopulate=false; vc->save(); vc->close(); } else { // vc = new NotesControl; // QPoint curPos = mapToGlobal( rect().topLeft() ); vc->show(); - vc->move( 5, 18); + vc->move( 2, 28); vc->doPopulate=true; vc->populateBox(); vc->doPopulate=false; vc->loaded=false; vc->load(); // this->setFocus(); vc->view->setFocus(); } } void NotesApplet::paintEvent( QPaintEvent* ) { QPainter p(this); p.drawPixmap( 0, 1, ( const char** ) notes_xpm ); } 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 @@ /********************************************************************** ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com ** All rights reserved. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #ifndef __NOTES_APPLET_H__ #define __NOTES_APPLET_H__ #include <qwidget.h> #include <qframe.h> #include <qpixmap.h> #include <qguardedptr.h> #include <qtimer.h> #include <qpe/filemanager.h> #include <qpe/ir.h> #include <qstring.h> class QComboBox; class QCheckBox; class QSpinBox; class QPushButton; class QMultiLineEdit; class QListBox; class QListBoxItem; class NotesControl : public QFrame { Q_OBJECT public: NotesControl( QWidget *parent=0, const char *name=0 ); - void performGrab(); QPixmap notes; QMultiLineEdit *view; QListBox *box; QPushButton *saveButton, *deleteButton, *newButton; QString FileNamePath; bool loaded, edited, doPopulate; void save(); void populateBox(); void load(); private: QTimer menuTimer; DocLnk *doc; QString oldDocName; void focusOutEvent( QFocusEvent * ); void load(const QString&); private slots: void slotBeamButton(); void slotBeamFinished( Ir*); void slotDeleteButton(); void slotSaveButton(); void slotDeleteButtonClicked(); void slotNewButton(); void boxPressed(int, QListBoxItem *, const QPoint&); void showMenu(); void loadDoc( const DocLnk &); void slotViewEdited(); void slotBoxSelected(const QString &); // void keyReleaseEvent( QKeyEvent *); }; class NotesApplet : public QWidget { Q_OBJECT public: NotesApplet( QWidget *parent = 0, const char *name=0 ); ~NotesApplet(); NotesControl *vc; public slots: private: void mousePressEvent( QMouseEvent * ); void paintEvent( QPaintEvent* ); private: QPixmap notesPixmap; private slots: }; #endif // __NOTES_APPLET_H__ |