summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 1e8ce7f..f571511 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -960,66 +960,66 @@ bool TextEdit::saveAs() {
960 docname.replace( QRegExp("/"), "_" ); 960 docname.replace( QRegExp("/"), "_" );
961 // cut the length. filenames longer than that 961 // cut the length. filenames longer than that
962 //don't make sense and something goes wrong when they get too long. 962 //don't make sense and something goes wrong when they get too long.
963 if ( docname.length() > 40 ) 963 if ( docname.length() > 40 )
964 docname = docname.left(40); 964 docname = docname.left(40);
965 if ( docname.isEmpty() ) 965 if ( docname.isEmpty() )
966 docname = tr("Unnamed"); 966 docname = tr("Unnamed");
967 if(doc) doc->setName(docname); 967 if(doc) doc->setName(docname);
968 currentFileName=docname; 968 currentFileName=docname;
969// } 969// }
970// else 970// else
971// qDebug("hmmmmmm"); 971// qDebug("hmmmmmm");
972 } 972 }
973 973
974 974
975 QMap<QString, QStringList> map; 975 QMap<QString, QStringList> map;
976 map.insert(tr("All"), QStringList() ); 976 map.insert(tr("All"), QStringList() );
977 QStringList text; 977 QStringList text;
978 text << "text/*"; 978 text << "text/*";
979 map.insert(tr("Text"), text ); 979 map.insert(tr("Text"), text );
980 text << "*"; 980 text << "*";
981 map.insert(tr("All"), text ); 981 map.insert(tr("All"), text );
982 982
983 QFileInfo cuFi( currentFileName); 983 QFileInfo cuFi( currentFileName);
984 QString filee = cuFi.fileName(); 984 QString filee = cuFi.fileName();
985 QString dire = cuFi.dirPath(); 985 QString dire = cuFi.dirPath();
986 if(dire==".") 986 if(dire==".")
987 dire = QPEApplication::documentDir(); 987 dire = QPEApplication::documentDir();
988 QString str; 988 QString str;
989 if( !featureAutoSave) 989 if( !featureAutoSave)
990 { 990 {
991 str = OFileDialog::getSaveFileName( 2, 991 str = OFileDialog::getSaveFileName( 2,
992 dire, 992 dire,
993 filee, map); 993 filee, map);
994 } 994 }
995 else 995 else
996 str=currentFileName; 996 str=currentFileName;
997 if(!str.isEmpty()) { 997 if(!str.isEmpty()) {
998 QString fileNm=str; 998 QString fileNm=str;
999 999
1000 qDebug("saving filename "+fileNm); 1000 qDebug("saving filename "+fileNm);
1001 QFileInfo fi(fileNm); 1001 QFileInfo fi(fileNm);
1002 currentFileName=fi.fileName(); 1002 currentFileName=fi.fileName();
1003 if(doc) 1003 if(doc)
1004// QString file = doc->file(); 1004// QString file = doc->file();
1005// doc->removeFiles(); 1005// doc->removeFiles();
1006 delete doc; 1006 delete doc;
1007 DocLnk nf; 1007 DocLnk nf;
1008 nf.setType("text/plain"); 1008 nf.setType("text/plain");
1009 nf.setFile( fileNm); 1009 nf.setFile( fileNm);
1010 doc = new DocLnk(nf); 1010 doc = new DocLnk(nf);
1011// editor->setText(rt); 1011// editor->setText(rt);
1012 qDebug("Saving file as "+currentFileName); 1012 qDebug("Saving file as "+currentFileName);
1013 doc->setName( currentFileName); 1013 doc->setName( currentFileName);
1014 updateCaption( currentFileName); 1014 updateCaption( currentFileName);
1015 1015
1016 FileManager fm; 1016 FileManager fm;
1017 if ( !fm.saveFile( *doc, rt ) ) { 1017 if ( !fm.saveFile( *doc, rt ) ) {
1018 return false; 1018 return false;
1019 } 1019 }
1020 1020
1021 if( filePerms ) { 1021 if( filePerms ) {
1022 filePermissions *filePerm; 1022 filePermissions *filePerm;
1023 filePerm = new filePermissions(this, 1023 filePerm = new filePermissions(this,
1024 tr("Permissions"),true, 1024 tr("Permissions"),true,
1025 0,(const QString &)fileNm); 1025 0,(const QString &)fileNm);
@@ -1189,77 +1189,74 @@ void TextEdit::editPasteTimeDate() {
1189int TextEdit::savePrompt() 1189int TextEdit::savePrompt()
1190{ 1190{
1191 switch( QMessageBox::information( 0, (tr("Textedit")), 1191 switch( QMessageBox::information( 0, (tr("Textedit")),
1192 (tr("Textedit detected\n" 1192 (tr("Textedit detected\n"
1193 "you have unsaved changes\n" 1193 "you have unsaved changes\n"
1194 "Go ahead and save?\n")), 1194 "Go ahead and save?\n")),
1195 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) 1195 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) )
1196 { 1196 {
1197 case 0: 1197 case 0:
1198 { 1198 {
1199 return 1; 1199 return 1;
1200 } 1200 }
1201 break; 1201 break;
1202 1202
1203 case 1: 1203 case 1:
1204 { 1204 {
1205 return 2; 1205 return 2;
1206 } 1206 }
1207 break; 1207 break;
1208 1208
1209 case 2: 1209 case 2:
1210 { 1210 {
1211 return -1; 1211 return -1;
1212 } 1212 }
1213 break; 1213 break;
1214 }; 1214 };
1215 1215
1216 return 0; 1216 return 0;
1217} 1217}
1218 1218
1219void TextEdit::timerCrank() 1219void TextEdit::timerCrank()
1220{ 1220{
1221 if(featureAutoSave) 1221 if(featureAutoSave && edited1)
1222 { 1222 {
1223 if( edited1 ) 1223 if(currentFileName.isEmpty())
1224 { 1224 {
1225 if(currentFileName.isEmpty()) 1225 currentFileName = QDir::homeDirPath()+"/textedit.tmp";
1226 { 1226 saveAs();
1227 currentFileName = QDir::homeDirPath()+"/textedit.tmp";
1228 saveAs();
1229 }
1230 else
1231 {
1232 qDebug("autosave");
1233 save();
1234 }
1235 setTimer();
1236 } 1227 }
1228 else
1229 {
1230// qDebug("autosave");
1231 save();
1232 }
1233 setTimer();
1237 } 1234 }
1238} 1235}
1239 1236
1240void TextEdit::doTimer(bool b) 1237void TextEdit::doTimer(bool b)
1241{ 1238{
1242 Config cfg("TextEdit"); 1239 Config cfg("TextEdit");
1243 cfg.setGroup ( "View" ); 1240 cfg.setGroup ( "View" );
1244 cfg.writeEntry ( "autosave", b); 1241 cfg.writeEntry ( "autosave", b);
1245 featureAutoSave = b; 1242 featureAutoSave = b;
1246 nAutoSave->setOn(b); 1243 nAutoSave->setOn(b);
1247 if(b) 1244 if(b)
1248 { 1245 {
1249 qDebug("doTimer true"); 1246// qDebug("doTimer true");
1250 setTimer(); 1247 setTimer();
1251 } 1248 }
1252 else 1249// else
1253 qDebug("doTimer false"); 1250// qDebug("doTimer false");
1254} 1251}
1255 1252
1256void TextEdit::setTimer() 1253void TextEdit::setTimer()
1257{ 1254{
1258if(featureAutoSave) 1255if(featureAutoSave)
1259 { 1256 {
1260 qDebug("setting autosave"); 1257// qDebug("setting autosave");
1261 QTimer *timer = new QTimer(this ); 1258 QTimer *timer = new QTimer(this );
1262 connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); 1259 connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) );
1263 timer->start( 30000/*0*/, true); //5 minutes 1260 timer->start( 300000, true); //5 minutes
1264 } 1261 }
1265} 1262}