summaryrefslogtreecommitdiff
path: root/noncore/applets
authorllornkcor <llornkcor>2002-10-17 03:47:16 (UTC)
committer llornkcor <llornkcor>2002-10-17 03:47:16 (UTC)
commit8f6dc7fd4aca312bc615bf4f85755b82d29b250d (patch) (side-by-side diff)
tree34e9be456b07b7678a3d4b812eec8471317fe641 /noncore/applets
parent11cde43ced1c85ad350cd32ca72b75dcfbce5fce (diff)
downloadopie-8f6dc7fd4aca312bc615bf4f85755b82d29b250d.zip
opie-8f6dc7fd4aca312bc615bf4f85755b82d29b250d.tar.gz
opie-8f6dc7fd4aca312bc615bf4f85755b82d29b250d.tar.bz2
force removal of desktop file when deleting note
Diffstat (limited to 'noncore/applets') (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp
index 92fdb0a..90c2550 100644
--- a/noncore/applets/notesapplet/notes.cpp
+++ b/noncore/applets/notesapplet/notes.cpp
@@ -66,48 +66,49 @@ static char * notes_xpm[] = {
" ... ",
" .+ ",
" .@. ",
" . .+ ",
" ..#.@. ",
" ..###.+.. ",
" ..###$...##.. ",
"..###$$$%+$$##&.",
".*=####$-###&=&.",
".=**=###==&=&=..",
" ..=**=#&=&=.. ",
" ..=*=&=.. ",
" ..=.. ",
" . "};
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;
+ isNew=false;
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" );
@@ -166,58 +167,68 @@ void NotesControl::slotDeleteButton() {
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();
+ 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;
}
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) {
@@ -248,81 +259,86 @@ void NotesControl::showMenu() {
m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() ));
m->setFocus();
m->exec( QCursor::pos() );
if(m) delete m;
}
void NotesControl::focusOutEvent ( QFocusEvent * e) {
if( e->reason() == QFocusEvent::Popup)
save();
else {
if(!loaded) {
populateBox();
load();
}
}
QWidget::focusOutEvent(e);
}
void NotesControl::save() {
Config cfg("Notes");
cfg.setGroup("Docs");
if( edited) {
+// qDebug("is edited");
QString rt = view->text();
- if(!rt.isEmpty()) {
+ if( rt.length()>1) {
QString pt = rt.simplifyWhiteSpace();
int i = pt.find( ' ' );
QString docname = pt;
if ( i > 0 )
docname = pt.left( i );
// remove "." at the beginning
while( docname.startsWith( "." ) )
docname = docname.mid( 1 );
docname.replace( QRegExp("/"), "_" );
// cut the length. filenames longer than that don't make sense
// and something goes wrong when they get too long.
if ( docname.length() > 40 )
docname = docname.left(40);
if ( docname.isEmpty() )
docname = "Empty Text";
- qDebug(docname);
+// qDebug(docname);
if( oldDocName != docname) {
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
QString entryName;
entryName.sprintf( "File%i", noOfFiles + 1 );
cfg.writeEntry( entryName,docname );
cfg.writeEntry("NumberOfFiles", noOfFiles+1 );
cfg.write();
}
- else
- qDebug("oldname equals docname");
+// else
+// qDebug("oldname equals docname");
+
+
doc = new DocLnk(docname);
+ if(QFile(doc->linkFile()).exists())
+ qDebug("puppie");
doc->setType("text/plain");
- doc->setFile(docname);
+ doc->setFile(QDir::homeDirPath()+"/"+docname);
doc->setName(docname);
FileManager fm;
if ( !fm.saveFile( *doc, rt ) ) {
}
oldDocName=docname;
edited=false;
// 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 );