summaryrefslogtreecommitdiff
Unidiff
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
@@ -112,7 +112,7 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
112 deleteButton= new QPushButton( this, "deleteButton" ); 112 deleteButton= new QPushButton( this, "deleteButton" );
113 deleteButton->setText(tr("Delete")); 113 deleteButton->setText(tr("Delete"));
114 hbox->addWidget( deleteButton); 114 hbox->addWidget( deleteButton);
115 115
116 vbox->addItem(hbox); 116 vbox->addItem(hbox);
117 117
118 connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)), 118 connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)),
@@ -122,44 +122,55 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
122 122
123 connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) ); 123 connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) );
124 connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); 124 connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton()));
125 connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButton())); 125 connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked()));
126
126 populateBox(); 127 populateBox();
127 load(); 128 load();
128 setCaption("Notes"); 129 setCaption("Notes");
129 // parent->setFocus(); 130 // parent->setFocus();
130} 131}
131 132
133void NotesControl::slotDeleteButtonClicked() {
134 switch ( QMessageBox::warning(this,tr("Delete?"),tr("Do you really want to<BR><B> delete</B> this note ?")
135 ,tr("Yes"),tr("No"),0,1,1) ) {
136 case 0:
137 slotDeleteButton();
138 break;
139 };
140}
141
132void NotesControl::slotDeleteButton() { 142void NotesControl::slotDeleteButton() {
133 143
134 QString selectedText = box->currentText(); 144 QString selectedText = box->currentText();
135 qDebug("deleting "+selectedText); 145 qDebug("deleting "+selectedText);
136 146
137 if( !selectedText.isEmpty()) { 147 if( !selectedText.isEmpty()) {
138 Config cfg("Notes"); 148
139 cfg.setGroup("Docs"); 149 Config cfg("Notes");
140 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 150 cfg.setGroup("Docs");
141 QString entryName, entryName2;; 151 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
142 for ( int i = 0; i < noOfFiles; i++ ) { 152 QString entryName, entryName2;;
143 entryName.sprintf( "File%i", i + 1 ); 153 for ( int i = 0; i < noOfFiles; i++ ) {
144 if(selectedText == cfg.readEntry( entryName )) { 154 entryName.sprintf( "File%i", i + 1 );
145 qDebug("removing %s, %d", selectedText.latin1(), i); 155 if(selectedText == cfg.readEntry( entryName )) {
146 for ( int j = i; j < noOfFiles; j++ ) { 156 qDebug("removing %s, %d", selectedText.latin1(), i);
147 entryName.sprintf( "File%i", i + 1 ); 157 for ( int j = i; j < noOfFiles; j++ ) {
148 entryName2.sprintf( "File%i", i + 2 ); 158 entryName.sprintf( "File%i", i + 1 );
149 QString temp = cfg.readEntry(entryName2); 159 entryName2.sprintf( "File%i", i + 2 );
150 qDebug("move "+temp); 160 QString temp = cfg.readEntry(entryName2);
151 cfg.writeEntry(entryName, temp); 161 qDebug("move "+temp);
152 i++; 162 cfg.writeEntry(entryName, temp);
163 i++;
164 }
165 cfg.writeEntry("NumberOfFiles", noOfFiles-1 );
166 entryName.sprintf( "File%i", noOfFiles );
167 cfg.removeEntry(entryName);
168 cfg.write();
169 DocLnk nf(selectedText);
170 nf.removeFiles();
153 } 171 }
154 cfg.writeEntry("NumberOfFiles", noOfFiles-1 );
155 entryName.sprintf( "File%i", noOfFiles );
156 cfg.removeEntry(entryName);
157 cfg.write();
158 DocLnk nf(selectedText);
159 nf.removeFiles();
160 } 172 }
161 } 173 populateBox();
162 populateBox();
163 } 174 }
164} 175}
165 176
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
@@ -54,6 +54,7 @@ private:
54 void load(const QString&); 54 void load(const QString&);
55private slots: 55private slots:
56 void slotDeleteButton(); 56 void slotDeleteButton();
57 void slotDeleteButtonClicked();
57 void slotNewButton(); 58 void slotNewButton();
58 void boxPressed(int, QListBoxItem *, const QPoint&); 59 void boxPressed(int, QListBoxItem *, const QPoint&);
59 void showMenu(); 60 void showMenu();