summaryrefslogtreecommitdiff
Unidiff
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
@@ -85,7 +85,7 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
85 edited=false; 85 edited=false;
86 doPopulate=true; 86 doPopulate=true;
87 QVBoxLayout *vbox = new QVBoxLayout( this,0, -1, "Vlayout" ); 87 QVBoxLayout *vbox = new QVBoxLayout( this,0, -1, "Vlayout" );
88 QHBoxLayout *hbox = new QHBoxLayout( this ); 88 QHBoxLayout *hbox = new QHBoxLayout( this, 0, -1, "HLayout" );
89 89
90 view = new QMultiLineEdit(this, "OpieNotesView"); 90 view = new QMultiLineEdit(this, "OpieNotesView");
91 91
@@ -108,6 +108,11 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
108 newButton= new QPushButton( this, "newButton" ); 108 newButton= new QPushButton( this, "newButton" );
109 newButton->setText(tr("New")); 109 newButton->setText(tr("New"));
110 hbox->addWidget( newButton); 110 hbox->addWidget( newButton);
111
112 deleteButton= new QPushButton( this, "deleteButton" );
113 deleteButton->setText(tr("Delete"));
114 hbox->addWidget( deleteButton);
115
111 vbox->addItem(hbox); 116 vbox->addItem(hbox);
112 117
113 connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)), 118 connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)),
@@ -117,6 +122,7 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
117 122
118 connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) ); 123 connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) );
119 connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); 124 connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton()));
125 connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButton()));
120 populateBox(); 126 populateBox();
121 load(); 127 load();
122 setCaption("Notes"); 128 setCaption("Notes");
@@ -124,8 +130,11 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
124} 130}
125 131
126void NotesControl::slotDeleteButton() { 132void NotesControl::slotDeleteButton() {
133
127 QString selectedText = box->currentText(); 134 QString selectedText = box->currentText();
128 qDebug("deleting "+selectedText); 135 qDebug("deleting "+selectedText);
136
137 if( !selectedText.isEmpty()) {
129 Config cfg("Notes"); 138 Config cfg("Notes");
130 cfg.setGroup("Docs"); 139 cfg.setGroup("Docs");
131 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 140 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
@@ -151,6 +160,7 @@ void NotesControl::slotDeleteButton() {
151 } 160 }
152 } 161 }
153 populateBox(); 162 populateBox();
163 }
154} 164}
155 165
156void NotesControl::slotNewButton() { 166void NotesControl::slotNewButton() {
@@ -247,13 +257,14 @@ void NotesControl::save() {
247 257
248 oldDocName=docname; 258 oldDocName=docname;
249 edited=false; 259 edited=false;
260 qDebug("save");
261 if (doPopulate)
262 populateBox();
250 } 263 }
251 qDebug("save");
252 if (doPopulate)
253 populateBox();
254 }
255 cfg.writeEntry( "LastDoc",oldDocName ); 264 cfg.writeEntry( "LastDoc",oldDocName );
256 cfg.write(); 265 cfg.write();
266
267 }
257} 268}
258 269
259void NotesControl::populateBox() { 270void NotesControl::populateBox() {
@@ -275,9 +286,9 @@ void NotesControl::populateBox() {
275 286
276void NotesControl::load() { 287void NotesControl::load() {
277 288
278 Config cfg("Notes");
279 cfg.setGroup("Docs");
280 if(!loaded) { 289 if(!loaded) {
290 Config cfg("Notes");
291 cfg.setGroup("Docs");
281 QString lastDoc=cfg.readEntry( "LastDoc",""); 292 QString lastDoc=cfg.readEntry( "LastDoc","");
282 DocLnk nf; 293 DocLnk nf;
283 nf.setType("text/plain"); 294 nf.setType("text/plain");
@@ -286,9 +297,9 @@ void NotesControl::load() {
286 loadDoc(nf); 297 loadDoc(nf);
287 loaded=true; 298 loaded=true;
288 oldDocName=lastDoc; 299 oldDocName=lastDoc;
289 } 300 cfg.writeEntry( "LastDoc",oldDocName );
290 cfg.writeEntry( "LastDoc",oldDocName ); 301 cfg.write();
291 cfg.write(); 302 }
292} 303}
293 304
294void NotesControl::load(const QString & file) { 305void NotesControl::load(const QString & file) {
@@ -349,6 +360,7 @@ void NotesApplet::mousePressEvent( QMouseEvent *) {
349 vc->doPopulate=true; 360 vc->doPopulate=true;
350 vc->populateBox(); 361 vc->populateBox();
351 vc->doPopulate=false; 362 vc->doPopulate=false;
363 vc->loaded=false;
352 364
353 vc->load(); 365 vc->load();
354// this->setFocus(); 366// this->setFocus();