summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-09-24 01:53:27 (UTC)
committer llornkcor <llornkcor>2002-09-24 01:53:27 (UTC)
commitef40f0d781c904723d7842fc8be8f7dbad0614da (patch) (side-by-side diff)
tree3c90068d73e19cf1fea43de570d7cd08c7ef6c33
parenta2c7b045c9a3ff9e275858b66e7fe29bdf4d8e31 (diff)
downloadopie-ef40f0d781c904723d7842fc8be8f7dbad0614da.zip
opie-ef40f0d781c904723d7842fc8be8f7dbad0614da.tar.gz
opie-ef40f0d781c904723d7842fc8be8f7dbad0614da.tar.bz2
added delete confirm to button
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp61
-rw-r--r--noncore/applets/notesapplet/notes.h1
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
@@ -109,60 +109,71 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
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&)) );
connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString &)));
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()));
+ connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked()));
+
populateBox();
load();
setCaption("Notes");
// parent->setFocus();
}
+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() {
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;;
- 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();
}
}
void NotesControl::slotNewButton() {
if(edited) save();
view->clear();
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
@@ -51,12 +51,13 @@ private:
DocLnk *doc;
QString oldDocName;
void focusOutEvent( QFocusEvent * );
void load(const QString&);
private slots:
void slotDeleteButton();
+ void slotDeleteButtonClicked();
void slotNewButton();
void boxPressed(int, QListBoxItem *, const QPoint&);
void showMenu();
void loadDoc( const DocLnk &);
void slotViewEdited();
void slotBoxSelected(const QString &);