summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -80,17 +80,17 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
: QFrame( parent, name,/* WDestructiveClose | */WStyle_StaysOnTop )
// : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
{
setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
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");
QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold);
box->setFixedHeight(50);
vbox->setMargin( 6 );
@@ -103,34 +103,43 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
QWidget *wid = QPEApplication::desktop();
setFixedWidth( wid->width()-10 /*200*/);
setFocusPolicy(QWidget::StrongFocus);
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&)) );
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()));
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;;
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);
@@ -146,16 +155,17 @@ void NotesControl::slotDeleteButton() {
entryName.sprintf( "File%i", noOfFiles );
cfg.removeEntry(entryName);
cfg.write();
DocLnk nf(selectedText);
nf.removeFiles();
}
}
populateBox();
+ }
}
void NotesControl::slotNewButton() {
if(edited) save();
view->clear();
view->setFocus();
}
@@ -242,23 +252,24 @@ void NotesControl::save() {
doc->setName(docname);
FileManager fm;
if ( !fm.saveFile( *doc, rt ) ) {
}
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();
qDebug("populate");
Config cfg("Notes");
cfg.setGroup("Docs");
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
@@ -270,30 +281,30 @@ void NotesControl::populateBox() {
}
list.sort();
box->insertStringList(list,-1);
doPopulate=false;
}
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);
if(!loaded) {
DocLnk nf;
nf.setType("text/plain");
nf.setFile( file);
@@ -344,16 +355,17 @@ void NotesApplet::mousePressEvent( QMouseEvent *) {
} else {
// vc = new NotesControl;
// QPoint curPos = mapToGlobal( rect().topLeft() );
vc->show();
vc->move( 5, 18);
vc->doPopulate=true;
vc->populateBox();
vc->doPopulate=false;
+ vc->loaded=false;
vc->load();
// this->setFocus();
vc->view->setFocus();
}
}
void NotesApplet::paintEvent( QPaintEvent* ) {