summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/backup/backuprestore.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp
index cfba907..477e24d 100644
--- a/noncore/settings/backup/backuprestore.cpp
+++ b/noncore/settings/backup/backuprestore.cpp
@@ -54,58 +54,70 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags f
54 this, SLOT(sourceDirChanged(int))); 54 this, SLOT(sourceDirChanged(int)));
55 connect(updateList, SIGNAL(clicked()), 55 connect(updateList, SIGNAL(clicked()),
56 this, SLOT( fileListUpdate())); 56 this, SLOT( fileListUpdate()));
57 57
58 //add directorys for backing up 58 //add directorys for backing up
59 applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); 59 applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/");
60 selectItem(applicationSettings); 60 selectItem(applicationSettings);
61 applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); 61 applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/");
62 selectItem(applicationSettings); 62 selectItem(applicationSettings);
63 documents= new QListViewItem(backupList, "Documents", "", "Documents/"); 63 documents= new QListViewItem(backupList, "Documents", "", "Documents/");
64 selectItem(documents); 64 selectItem(documents);
65 65
66 scanForApplicationSettings(); 66 scanForApplicationSettings();
67 67
68 backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); 68 backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" );
69 if (StorageInfo::hasCf()) 69 if (StorageInfo::hasCf())
70 { 70 {
71 backupLocations.insert("CF", "/mnt/cf"); 71 backupLocations.insert("CF", "/mnt/cf");
72 } 72 }
73 if (StorageInfo::hasSd() || StorageInfo::hasMmc()) 73 if (StorageInfo::hasSd() || StorageInfo::hasMmc())
74 { 74 {
75 backupLocations.insert("SD", "/mnt/card"); 75 backupLocations.insert("SD", "/mnt/card");
76 } 76 }
77 77
78 Config config("BackupAndRestore");
79 //read last locations
80 config.setGroup("LastLocation");
81 QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" );
82 QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" );
83 int locationIndex = 0;
84
78 QMap<QString, QString>::Iterator it; 85 QMap<QString, QString>::Iterator it;
79 for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) 86 for( it = backupLocations.begin(); it != backupLocations.end(); ++it )
80 { 87 {
81 storeToLocation->insertItem(it.key()); 88 storeToLocation->insertItem(it.key());
82 restoreSource->insertItem(it.key()); 89 restoreSource->insertItem(it.key());
90
91 //check for last locations
92 if ( it.key() == lastStoreLocation )
93 storeToLocation->setCurrentItem( locationIndex );
94 if ( it.key() == lastRestoreLocation )
95 restoreSource->setCurrentItem( locationIndex );
96 locationIndex++;
83 } 97 }
84 98
85 // Read the list of items to ignore. 99 // Read the list of items to ignore.
86 Config config("BackupAndRestore");
87
88 QList<QString> dontBackupList; 100 QList<QString> dontBackupList;
89 dontBackupList.setAutoDelete(true); 101 dontBackupList.setAutoDelete(true);
90 config.setGroup("DontBackup"); 102 config.setGroup("DontBackup");
91 int total = config.readNumEntry("Total", 0); 103 int total = config.readNumEntry("Total", 0);
92 for(int i = 0; i < total; i++) 104 for(int i = 0; i < total; i++)
93 { 105 {
94 dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); 106 dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), "")));
95 } 107 }
96 108
97 QList<QListViewItem> list; 109 QList<QListViewItem> list;
98 getAllItems(backupList->firstChild(), list); 110 getAllItems(backupList->firstChild(), list);
99 111
100 for(uint i = 0; i < list.count(); i++) 112 for(uint i = 0; i < list.count(); i++)
101 { 113 {
102 QString text = list.at(i)->text(HEADER_NAME); 114 QString text = list.at(i)->text(HEADER_NAME);
103 for(uint i2 = 0; i2 < dontBackupList.count(); i2++) 115 for(uint i2 = 0; i2 < dontBackupList.count(); i2++)
104 { 116 {
105 if(*dontBackupList.at(i2) == text) 117 if(*dontBackupList.at(i2) == text)
106 { 118 {
107 selectItem(list.at(i)); 119 selectItem(list.at(i));
108 break; 120 break;
109 } 121 }
110 } 122 }
111 } 123 }
@@ -258,48 +270,54 @@ void BackupAndRestore::backup()
258 { // until end of file... 270 { // until end of file...
259 s += t.readLine(); // line of text excluding '\n' 271 s += t.readLine(); // line of text excluding '\n'
260 } 272 }
261 errorFile.close(); 273 errorFile.close();
262 274
263 pErrDialog->m_textarea->setText( s ); 275 pErrDialog->m_textarea->setText( s );
264 } 276 }
265 else 277 else
266 { 278 {
267 pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" ); 279 pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" );
268 } 280 }
269 pErrDialog->showMaximized(); 281 pErrDialog->showMaximized();
270 pErrDialog->exec(); 282 pErrDialog->exec();
271 delete pErrDialog; 283 delete pErrDialog;
272 break; 284 break;
273 } 285 }
274 setCaption(tr("Backup and Restore.. Failed !!")); 286 setCaption(tr("Backup and Restore.. Failed !!"));
275 return; 287 return;
276 } 288 }
277 else 289 else
278 { 290 {
279 QMessageBox::information(this, tr( "Message" ), tr( "Backup Successfull." ), QString(tr( "Ok" ) ) ); 291 QMessageBox::information(this, tr( "Message" ), tr( "Backup Successfull." ), QString(tr( "Ok" ) ) );
280 292
281 } 293 }
294
295 //write store-location
296 Config config( "BackupAndRestore" );
297 config.setGroup( "LastLocation" );
298 config.writeEntry( "LastStoreLocation", storeToLocation->currentText() );
299
282 setCaption(tr("Backup and Restore")); 300 setCaption(tr("Backup and Restore"));
283} 301}
284 302
285/*** 303/***
286 * Get a list of all of the files to backup. 304 * Get a list of all of the files to backup.
287 */ 305 */
288int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent) 306int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent)
289{ 307{
290 QListViewItem * currentItem; 308 QListViewItem * currentItem;
291 QString currentHome; 309 QString currentHome;
292 if(!parent) 310 if(!parent)
293 currentItem = backupList->firstChild(); 311 currentItem = backupList->firstChild();
294 else 312 else
295 { 313 {
296 currentItem = parent->firstChild(); 314 currentItem = parent->firstChild();
297 currentHome = parent->text(BACKUP_LOCATION); 315 currentHome = parent->text(BACKUP_LOCATION);
298 } 316 }
299 317
300 uint count = 0; 318 uint count = 0;
301 while( currentItem != 0 ) 319 while( currentItem != 0 )
302 { 320 {
303 if(currentItem->text(HEADER_BACKUP) == "B" ) 321 if(currentItem->text(HEADER_BACKUP) == "B" )
304 { 322 {
305 if(currentItem->childCount() == 0 ) 323 if(currentItem->childCount() == 0 )
@@ -417,32 +435,37 @@ void BackupAndRestore::restore()
417 { // until end of file... 435 { // until end of file...
418 s += t.readLine(); // line of text excluding '\n' 436 s += t.readLine(); // line of text excluding '\n'
419 } 437 }
420 errorFile.close(); 438 errorFile.close();
421 439
422 pErrDialog->m_textarea->setText( s ); 440 pErrDialog->m_textarea->setText( s );
423 } 441 }
424 else 442 else
425 { 443 {
426 pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) ); 444 pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) );
427 } 445 }
428 pErrDialog->showMaximized(); 446 pErrDialog->showMaximized();
429 pErrDialog->exec(); 447 pErrDialog->exec();
430 delete pErrDialog; 448 delete pErrDialog;
431 449
432 setCaption(tr("Backup and Restore.. Failed !!")); 450 setCaption(tr("Backup and Restore.. Failed !!"));
433 return; 451 return;
434 452
435 break; 453 break;
436 454
437 } 455 }
438 } 456 }
439 else 457 else
440 { 458 {
441 QMessageBox::critical(this, tr( "Message" ), 459 QMessageBox::information(this, tr( "Message" ), tr( "Restore Successfull." ), QString( tr( "Ok") ) );
442 tr( "Restore Successfull." ), QString( tr( "Ok") ) );
443 } 460 }
461
462 //write restore-location
463 Config config( "BackupAndRestore" );
464 config.setGroup( "LastLocation" );
465 config.writeEntry( "LastRestoreLocation", restoreSource->currentText() );
466
444 setCaption(tr("Backup and Restore")); 467 setCaption(tr("Backup and Restore"));
445} 468}
446 469
447// backuprestore.cpp 470// backuprestore.cpp
448 471