-rw-r--r-- | noncore/applets/notesapplet/notes.cpp | 61 | ||||
-rw-r--r-- | noncore/applets/notesapplet/notes.h | 1 |
2 files changed, 37 insertions, 25 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp index cc5245c..81864c6 100644 --- a/noncore/applets/notesapplet/notes.cpp +++ b/noncore/applets/notesapplet/notes.cpp @@ -114,3 +114,3 @@ NotesControl::NotesControl( QWidget *parent, const char *name ) hbox->addWidget( deleteButton); - + vbox->addItem(hbox); @@ -124,3 +124,4 @@ NotesControl::NotesControl( QWidget *parent, const char *name ) connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); - connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButton())); + connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked())); + populateBox(); @@ -131,2 +132,11 @@ NotesControl::NotesControl( QWidget *parent, const char *name ) +void NotesControl::slotDeleteButtonClicked() { + switch ( QMessageBox::warning(this,tr("Delete?"),tr("Do you really want to<BR><B> delete</B> this note ?") + ,tr("Yes"),tr("No"),0,1,1) ) { + case 0: + slotDeleteButton(); + break; + }; +} + void NotesControl::slotDeleteButton() { @@ -137,27 +147,28 @@ void NotesControl::slotDeleteButton() { if( !selectedText.isEmpty()) { - Config cfg("Notes"); - cfg.setGroup("Docs"); - int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); - QString entryName, entryName2;; - for ( int i = 0; i < noOfFiles; i++ ) { - entryName.sprintf( "File%i", i + 1 ); - if(selectedText == cfg.readEntry( entryName )) { - qDebug("removing %s, %d", selectedText.latin1(), i); - for ( int j = i; j < noOfFiles; j++ ) { - entryName.sprintf( "File%i", i + 1 ); - entryName2.sprintf( "File%i", i + 2 ); - QString temp = cfg.readEntry(entryName2); - qDebug("move "+temp); - cfg.writeEntry(entryName, temp); - i++; + + Config cfg("Notes"); + cfg.setGroup("Docs"); + int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); + QString entryName, entryName2;; + for ( int i = 0; i < noOfFiles; i++ ) { + entryName.sprintf( "File%i", i + 1 ); + if(selectedText == cfg.readEntry( entryName )) { + qDebug("removing %s, %d", selectedText.latin1(), i); + for ( int j = i; j < noOfFiles; j++ ) { + entryName.sprintf( "File%i", i + 1 ); + entryName2.sprintf( "File%i", i + 2 ); + QString temp = cfg.readEntry(entryName2); + qDebug("move "+temp); + cfg.writeEntry(entryName, temp); + i++; + } + cfg.writeEntry("NumberOfFiles", noOfFiles-1 ); + entryName.sprintf( "File%i", noOfFiles ); + cfg.removeEntry(entryName); + cfg.write(); + DocLnk nf(selectedText); + nf.removeFiles(); } - cfg.writeEntry("NumberOfFiles", noOfFiles-1 ); - entryName.sprintf( "File%i", noOfFiles ); - cfg.removeEntry(entryName); - cfg.write(); - DocLnk nf(selectedText); - nf.removeFiles(); } - } - populateBox(); + populateBox(); } diff --git a/noncore/applets/notesapplet/notes.h b/noncore/applets/notesapplet/notes.h index c589f81..473a89a 100644 --- a/noncore/applets/notesapplet/notes.h +++ b/noncore/applets/notesapplet/notes.h @@ -56,2 +56,3 @@ private slots: void slotDeleteButton(); + void slotDeleteButtonClicked(); void slotNewButton(); |