summaryrefslogtreecommitdiff
path: root/noncore/applets/notesapplet/notes.cpp
Side-by-side diff
Diffstat (limited to 'noncore/applets/notesapplet/notes.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp45
1 files changed, 22 insertions, 23 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp
index 4e98b31..e2b0c2a 100644
--- a/noncore/applets/notesapplet/notes.cpp
+++ b/noncore/applets/notesapplet/notes.cpp
@@ -70,105 +70,103 @@ static char * notes_xpm[] = {
" ..#.@. ",
" ..###.+.. ",
" ..###$...##.. ",
"..###$$$%+$$##&.",
".*=####$-###&=&.",
".=**=###==&=&=..",
" ..=**=#&=&=.. ",
" ..=*=&=.. ",
" ..=.. ",
" . "};
-NotesControl::NotesControl( QWidget *parent, const char *name )
- : QFrame( parent, name,/* WDestructiveClose | */WStyle_StaysOnTop )
+NotesControl::NotesControl( QWidget *, const char * )
+ : QVBox( 0, "NotesControl",/* WDestructiveClose | */WStyle_StaysOnTop )
// : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
{
QDir d( QDir::homeDirPath()+"/notes");
if( !d.exists()) {
qDebug("make dir");
if(!d.mkdir( QDir::homeDirPath()+"/notes", true))
qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed");
}
Config cfg("Notes");
cfg.setGroup("Options");
- showMax = cfg.readBoolEntry("ShowMax", false);
+ showMax = cfg.readBoolEntry("ShowMax", false);
setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
loaded=false;
edited=false;
doPopulate=true;
isNew=false;
- QVBoxLayout *vbox = new QVBoxLayout( this,0, -1, "Vlayout" );
- QHBoxLayout *hbox = new QHBoxLayout( this, 0, -1, "HLayout" );
+ QVBox *vbox = new QVBox( this, "Vlayout" );
+ QHBox *hbox = new QHBox( this, "HLayout" );
- view = new QMultiLineEdit(this, "OpieNotesView");
+ view = new QMultiLineEdit(vbox, "OpieNotesView");
- box = new QListBox(this, "OpieNotesBox");
+ box = new QListBox(vbox, "OpieNotesBox");
QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold);
box->setFixedHeight(50);
vbox->setMargin( 6 );
vbox->setSpacing( 3 );
- vbox->addWidget( view);
- vbox->addWidget( box);
+
setFocusPolicy(QWidget::StrongFocus);
- newButton= new QPushButton( this, "newButton" );
+ newButton= new QPushButton( hbox, "newButton" );
newButton->setText(tr("New"));
- hbox->addWidget( newButton);
- saveButton= new QPushButton( this, "saveButton" );
+
+ saveButton= new QPushButton( hbox, "saveButton" );
saveButton->setText(tr("Save"));
- hbox->addWidget( saveButton);
- deleteButton= new QPushButton( this, "deleteButton" );
+
+ deleteButton= new QPushButton( hbox, "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(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton()));
connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked()));
populateBox();
load();
setCaption("Notes");
- // parent->setFocus();
+ // parent->setFocus();
}
void NotesControl::slotSaveButton() {
slotNewButton();
populateBox();
}
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:
+ case 0:
slotDeleteButton();
break;
};
}
void NotesControl::slotDeleteButton() {
QString selectedText = box->currentText();
qDebug("deleting "+selectedText);
if( !selectedText.isEmpty()) {
@@ -190,29 +188,29 @@ void NotesControl::slotDeleteButton() {
}
cfg.writeEntry("NumberOfFiles", noOfFiles-1 );
entryName.sprintf( "File%i", noOfFiles );
cfg.removeEntry(entryName);
cfg.write();
DocLnk nf(selectedText);
nf.removeFiles();
QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop";
qDebug(fi);
QFile f( fi);
if( !f.remove()) qDebug(".desktop file not removed");
-
+
}
}
view->clear();
-
+
populateBox();
}
}
void NotesControl::slotNewButton() {
if(edited) save();
view->clear();
view->setFocus();
edited=false;
isNew=false;
}
@@ -326,26 +324,26 @@ void NotesControl::save() {
doc->setFile( QDir::homeDirPath()+"/notes/"+temp);
FileManager fm;
if ( !fm.saveFile( *doc, rt ) ) {
}
oldDocName=docname;
edited=false;
// qDebug("save");
if (doPopulate)
populateBox();
}
cfg.writeEntry( "LastDoc",oldDocName );
- cfg.write();
-
+ cfg.write();
+
}
}
void NotesControl::populateBox() {
box->clear();
// qDebug("populate");
Config cfg("Notes");
cfg.setGroup("Docs");
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
QStringList list;
QString entryName;
for ( int i = 0; i < noOfFiles; i++ ) {
@@ -459,24 +457,25 @@ void NotesControl::slotSearch() {
// }
//===========================================================================
NotesApplet::NotesApplet( QWidget *parent, const char *name )
: QWidget( parent, name ) {
setFixedHeight( 18 );
setFixedWidth( 14 );
vc = new NotesControl;
}
NotesApplet::~NotesApplet() {
+ delete vc;
}
void NotesApplet::mousePressEvent( QMouseEvent *) {
if( !vc->isHidden()) {
vc->doPopulate=false;
vc->save();
vc->close();
} else {
// vc = new NotesControl;
// QPoint curPos = mapToGlobal( rect().topLeft() );
if(vc->showMax) {
qDebug("show max");