summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-01-08 16:44:31 (UTC)
committer llornkcor <llornkcor>2003-01-08 16:44:31 (UTC)
commitade18a3bf5111a8ff7e43e94ca003c0dd64bc89d (patch) (side-by-side diff)
treef5ea5e991d7e60ba642612d7ce7b0c3f9108246f
parent6f03e28e8fd89c29de7b4cf97a2f6550a5ad8832 (diff)
downloadopie-ade18a3bf5111a8ff7e43e94ca003c0dd64bc89d.zip
opie-ade18a3bf5111a8ff7e43e94ca003c0dd64bc89d.tar.gz
opie-ade18a3bf5111a8ff7e43e94ca003c0dd64bc89d.tar.bz2
fix for empty _*.txt entries when there are no other notes
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp
index 2b25476..4e98b31 100644
--- a/noncore/applets/notesapplet/notes.cpp
+++ b/noncore/applets/notesapplet/notes.cpp
@@ -302,154 +302,154 @@ void NotesControl::save() {
// 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);
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");
doc = new DocLnk(docname);
if(QFile(doc->linkFile()).exists())
qDebug("puppie");
doc->setType("text/plain");
doc->setName(docname);
QString temp = docname.replace( QRegExp(" "), "_" );
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();
}
}
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++ ) {
entryName.sprintf( "File%i", i + 1 );
list.append(cfg.readEntry( entryName ));
}
list.sort();
box->insertStringList(list,-1);
doPopulate=false;
update();
}
void NotesControl::load() {
if(!loaded) {
Config cfg("Notes");
cfg.setGroup("Docs");
- QString lastDoc=cfg.readEntry( "LastDoc","");
+ QString lastDoc=cfg.readEntry( "LastDoc","notes");
DocLnk nf;
nf.setType("text/plain");
nf.setFile(lastDoc);
loadDoc(nf);
loaded=true;
oldDocName=lastDoc;
cfg.writeEntry( "LastDoc",oldDocName );
cfg.write();
}
}
void NotesControl::load(const QString & file) {
qDebug("loading "+file);
QString name = file;
QString temp;
if( !QFile( QDir::homeDirPath()+"/"+file).exists() )
temp = QDir::homeDirPath()+"/notes/"+ name.replace( QRegExp(" "), "_" );
else
temp = name;
if(!loaded) {
DocLnk nf;
nf.setType("text/plain");
nf.setFile( temp);
-
+ if(!temp.isEmpty())
loadDoc(nf);
loaded=true;
}
// view->setFocus();
oldDocName=file;
Config cfg("Notes");
cfg.setGroup("Docs");
cfg.writeEntry( "LastDoc",oldDocName );
cfg.write();
}
void NotesControl::loadDoc( const DocLnk &f) {
FileManager fm;
QString txt;
if ( !fm.loadFile( f, txt ) ) {
qDebug("could not load file "+f.file());
return;
}
view->setText(txt);
}
void NotesControl::slotViewEdited() {
if(loaded) {
edited=true;
}
}
void NotesControl::slotShowMax() {
Config cfg("Notes");
cfg.setGroup("Options");
showMax=!showMax;
cfg.writeEntry("ShowMax", showMax);
cfg.write();
hide();
}
void NotesControl::slotSearch() {
int boxCount = box->count();
for(int i=0;i< boxCount;i++) {
}
}
// void NotesControl::keyReleaseEvent( QKeyEvent *e) {
// switch ( e->state() ) {
// case ControlButton:
// if(e->key() == Key_C) { //copy
// qDebug("copy");
// QClipboard *cb = QApplication::clipboard();
// QString text;
// // Copy text from the clipboard (paste)
// text = cb->text();
// }
// if(e->key() == Key_X) { //cut
// }
// if(e->key() == Key_V) { //paste
// QClipboard *cb = QApplication::clipboard();
// QString text;
// //view
// cb->setText();
// }