summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp
index 76cb6c1..f2dbabf 100644
--- a/noncore/applets/notesapplet/notes.cpp
+++ b/noncore/applets/notesapplet/notes.cpp
@@ -51,196 +51,194 @@
static char * notes_xpm[] = {
"16 16 11 1",
" c None",
". c #000000",
"+ c #7F7F7F",
"@ c #BFBFBF",
"# c #BFC1FF",
"$ c #FF0000",
"% c #FFFFFF",
"& c #00037F",
"* c #0006FF",
"= c #0005BF",
"- c #7F0000",
" .. ",
" .. ",
" ... ",
" .+ ",
" .@. ",
" . .+ ",
" ..#.@. ",
" ..###.+.. ",
" ..###$...##.. ",
"..###$$$%+$$##&.",
".*=####$-###&=&.",
".=**=###==&=&=..",
" ..=**=#&=&=.. ",
" ..=*=&=.. ",
" ..=.. ",
" . "};
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, 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 );
vbox->setSpacing( 3 );
vbox->addWidget( view);
vbox->addWidget( box);
setFixedHeight(180);
QWidget *wid = QPEApplication::desktop();
setFixedWidth( wid->width()-10 /*200*/);
setFocusPolicy(QWidget::StrongFocus);
newButton= new QPushButton( this, "newButton" );
newButton->setText(tr("New"));
hbox->addWidget( newButton);
saveButton= new QPushButton( this, "saveButton" );
saveButton->setText(tr("Save"));
hbox->addWidget( saveButton);
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(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton()));
connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked()));
populateBox();
load();
setCaption("Notes");
// parent->setFocus();
}
void NotesControl::slotSaveButton() {
- if(edited) {
- save();
- populateBox();
- }
+ 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:
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++;
}
cfg.writeEntry("NumberOfFiles", noOfFiles-1 );
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();
}
void NotesControl::slotBeamButton() {
Ir ir;
if(!ir.supported()){
} else {
this->hide();
QString selectedText = box->currentText();
if( !selectedText.isEmpty()) {
QString file = QDir::homeDirPath()+"/"+selectedText;
QFile f(file);
Ir *irFile = new Ir(this, "IR");
connect( irFile, SIGNAL(done(Ir*)), this, SLOT( slotBeamFinished( Ir * )));
irFile->send( file, "Note", "text/plain" );
}
}
}
void NotesControl::slotBeamFinished(Ir *) {
this->show();
}
void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) {
switch (mouse) {
case 1:{
}
break;
case 2:
menuTimer.start( 500, TRUE );
break;
};
}
void NotesControl::slotBoxSelected(const QString &itemString) {
if(edited) {
save();
}
loaded=false;
edited=false;
load(itemString);
}
void NotesControl::showMenu() {
QPopupMenu *m = new QPopupMenu(0);