summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-09-22 13:22:51 (UTC)
committer llornkcor <llornkcor>2002-09-22 13:22:51 (UTC)
commit0816ba0c42df8074d698b60041993dbda5591e27 (patch) (side-by-side diff)
treec8688bedc4bf5a87e967b0ede8218997dbdd4071
parent2778d4b110b6b9106da568eb10568af18e482900 (diff)
downloadopie-0816ba0c42df8074d698b60041993dbda5591e27.zip
opie-0816ba0c42df8074d698b60041993dbda5591e27.tar.gz
opie-0816ba0c42df8074d698b60041993dbda5591e27.tar.bz2
delete button so I dont have to explain so much about the hold-menu delete
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp
index a4aa093..cc5245c 100644
--- a/noncore/applets/notesapplet/notes.cpp
+++ b/noncore/applets/notesapplet/notes.cpp
@@ -84,9 +84,9 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
loaded=false;
edited=false;
doPopulate=true;
QVBoxLayout *vbox = new QVBoxLayout( this,0, -1, "Vlayout" );
- QHBoxLayout *hbox = new QHBoxLayout( this );
+ QHBoxLayout *hbox = new QHBoxLayout( this, 0, -1, "HLayout" );
view = new QMultiLineEdit(this, "OpieNotesView");
box = new QListBox(this, "OpieNotesBox");
@@ -107,8 +107,13 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
newButton= new QPushButton( this, "newButton" );
newButton->setText(tr("New"));
hbox->addWidget( newButton);
+
+ deleteButton= new QPushButton( this, "deleteButton" );
+ deleteButton->setText(tr("Delete"));
+ hbox->addWidget( deleteButton);
+
vbox->addItem(hbox);
connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)),
this,SLOT( boxPressed(int, QListBoxItem *, const QPoint&)) );
@@ -116,17 +121,21 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) );
connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) );
connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton()));
+ connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButton()));
populateBox();
load();
setCaption("Notes");
// parent->setFocus();
}
void NotesControl::slotDeleteButton() {
+
QString selectedText = box->currentText();
qDebug("deleting "+selectedText);
+
+ if( !selectedText.isEmpty()) {
Config cfg("Notes");
cfg.setGroup("Docs");
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
QString entryName, entryName2;;
@@ -150,8 +159,9 @@ void NotesControl::slotDeleteButton() {
nf.removeFiles();
}
}
populateBox();
+ }
}
void NotesControl::slotNewButton() {
if(edited) save();
@@ -246,15 +256,16 @@ void NotesControl::save() {
}
oldDocName=docname;
edited=false;
+ qDebug("save");
+ if (doPopulate)
+ populateBox();
}
- qDebug("save");
- if (doPopulate)
- populateBox();
- }
cfg.writeEntry( "LastDoc",oldDocName );
cfg.write();
+
+ }
}
void NotesControl::populateBox() {
box->clear();
@@ -274,22 +285,22 @@ void NotesControl::populateBox() {
}
void NotesControl::load() {
- Config cfg("Notes");
- cfg.setGroup("Docs");
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();
+ cfg.writeEntry( "LastDoc",oldDocName );
+ cfg.write();
+ }
}
void NotesControl::load(const QString & file) {
qDebug("loading "+file);
@@ -348,8 +359,9 @@ void NotesApplet::mousePressEvent( QMouseEvent *) {
vc->move( 5, 18);
vc->doPopulate=true;
vc->populateBox();
vc->doPopulate=false;
+ vc->loaded=false;
vc->load();
// this->setFocus();
vc->view->setFocus();