summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp
index f2dbabf..92fdb0a 100644
--- a/noncore/applets/notesapplet/notes.cpp
+++ b/noncore/applets/notesapplet/notes.cpp
@@ -217,205 +217,205 @@ void NotesControl::slotBeamButton() {
void NotesControl::slotBeamFinished(Ir *) {
this->show();
}
void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) {
switch (mouse) {
case 1:{
}
break;
case 2:
menuTimer.start( 500, TRUE );
break;
};
}
void NotesControl::slotBoxSelected(const QString &itemString) {
if(edited) {
save();
}
loaded=false;
edited=false;
load(itemString);
}
void NotesControl::showMenu() {
QPopupMenu *m = new QPopupMenu(0);
m->insertItem( tr( "Beam Out" ), this, SLOT( slotBeamButton() ));
m->insertSeparator();
m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() ));
m->setFocus();
m->exec( QCursor::pos() );
if(m) delete m;
}
void NotesControl::focusOutEvent ( QFocusEvent * e) {
if( e->reason() == QFocusEvent::Popup)
save();
else {
if(!loaded) {
populateBox();
load();
}
}
QWidget::focusOutEvent(e);
}
void NotesControl::save() {
Config cfg("Notes");
cfg.setGroup("Docs");
if( edited) {
QString rt = view->text();
if(!rt.isEmpty()) {
QString pt = rt.simplifyWhiteSpace();
int i = pt.find( ' ' );
QString docname = pt;
if ( i > 0 )
docname = pt.left( i );
// remove "." at the beginning
while( docname.startsWith( "." ) )
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");
+// qDebug("save");
if (doPopulate)
populateBox();
}
cfg.writeEntry( "LastDoc",oldDocName );
cfg.write();
}
}
void NotesControl::populateBox() {
box->clear();
- qDebug("populate");
+// 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
// cb->setText();
// }
// break;
// };
// QWidget::keyReleaseEvent(e);
// }
//===========================================================================
NotesApplet::NotesApplet( QWidget *parent, const char *name )
: QWidget( parent, name ) {
setFixedHeight( 18 );