-rw-r--r-- | noncore/settings/backup/backuprestore.cpp | 84 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestore.h | 4 |
2 files changed, 56 insertions, 32 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index 3889744..478b22f 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp @@ -26,8 +26,9 @@ using namespace Opie::Core; #include <qregexp.h> #include <qtextstream.h> #include <qtextview.h> #include <qlineedit.h> +#include <qstringlist.h> /* STD */ #include <errno.h> #include <stdlib.h> @@ -65,35 +66,15 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags f documents= new QListViewItem(backupList, "Documents", "", "Documents/"); selectItem(documents); scanForApplicationSettings(); - refreshBackupLocations(); refreshLocations(); - - Config config("BackupAndRestore"); - //read last locations - config.setGroup("LastLocation"); - QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); - QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" ); - int locationIndex = 0; - - QMap<QString, QString>::Iterator it; - for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) - { - storeToLocation->insertItem(it.key()); - restoreSource->insertItem(it.key()); - - //check for last locations - if ( it.key() == lastStoreLocation ) - storeToLocation->setCurrentItem( locationIndex ); - if ( it.key() == lastRestoreLocation ) - restoreSource->setCurrentItem( locationIndex ); - locationIndex++; - } + refreshBackupLocations(); // Read the list of items to ignore. QList<QString> dontBackupList; dontBackupList.setAutoDelete(true); + Config config("BackupAndRestore"); config.setGroup("DontBackup"); int total = config.readNumEntry("Total", 0); for(int i = 0; i < total; i++) { @@ -164,10 +145,38 @@ void BackupAndRestore::refreshBackupLocations() backupLocations.insert( "MMC", storage.mmcPath() ); odebug << "Mmc Path: " + storage.mmcPath() << oendl; } - // Add own locations from locationList - // todo implementation + for ( QListViewItemIterator it( locationList ); it.current(); ++it ) + { + backupLocations.insert( it.current()->text( 0 ), it.current()->text( 0 ) ); + } + + //update QComboBox + storeToLocation->clear(); + restoreSource->clear(); + + //read last locations + Config config("BackupAndRestore"); + config.setGroup("LastLocation"); + QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); + QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" ); + int locationIndex = 0; + + //fill QComboBox + QMap<QString, QString>::Iterator it; + for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) + { + storeToLocation->insertItem(it.key()); + restoreSource->insertItem(it.key()); + + //check for last locations + if ( it.key() == lastStoreLocation ) + storeToLocation->setCurrentItem( locationIndex ); + if ( it.key() == lastRestoreLocation ) + restoreSource->setCurrentItem( locationIndex ); + locationIndex++; + } } QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list) { @@ -309,9 +318,8 @@ void BackupAndRestore::backup() } else { QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) ); - } //write store-location Config config( "BackupAndRestore" ); @@ -535,10 +543,18 @@ QString BackupAndRestore::getExcludeFile() void BackupAndRestore::refreshLocations() { locationList->clear(); + //todo: implement add locations - odebug << "not implemented yet" << oendl; + Config config( "BackupAndRestore" ); + config.setGroup( "Locations" ); + + QStringList locations( config.readListEntry( "locations", '|' ) ); + + for ( QStringList::Iterator it = locations.begin(); it != locations.end(); ++it ) { + (void) new QListViewItem( locationList, *it ); + } } void BackupAndRestore::addLocation() { @@ -557,13 +573,21 @@ void BackupAndRestore::removeLocation() delete( locationList->selectedItem() ); } } -void BackupAndRestore::saveLocation() +void BackupAndRestore::saveLocations() { - //todo: implement - odebug << "not implemented yet" << oendl; -} + Config config("BackupAndRestore"); + config.setGroup("Locations"); + QStringList locations; + for ( QListViewItemIterator it( locationList ); it.current(); ++it ) + { + locations.append( it.current()->text( 0 ) ); + } + config.writeEntry( "locations", locations, '|' ); + + refreshBackupLocations(); +} // backuprestore.cpp diff --git a/noncore/settings/backup/backuprestore.h b/noncore/settings/backup/backuprestore.h index 527b3cf..caf6243 100644 --- a/noncore/settings/backup/backuprestore.h +++ b/noncore/settings/backup/backuprestore.h @@ -6,8 +6,9 @@ #include <qmap.h> #include <qlist.h> class QListViewItem; +class QStringList; class BackupAndRestore : public BackupAndRestoreBase { @@ -29,9 +30,9 @@ private slots: void fileListUpdate(); void addLocation(); void removeLocation(); - void saveLocation(); + void saveLocations(); private: void scanForApplicationSettings(); int getBackupFiles(QString &backupFiles, QListViewItem *parent); @@ -43,9 +44,8 @@ private: QListViewItem *systemSettings; QListViewItem *applicationSettings; QListViewItem *documents; - }; #endif |