From d61db324b7bac184b067b6f798ec3c85749bac15 Mon Sep 17 00:00:00 2001 From: ar Date: Sun, 25 Jul 2004 21:41:01 +0000 Subject: - implementation of custom backup- and restore-locations --- 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 @@ -27,6 +27,7 @@ using namespace Opie::Core; #include #include #include +#include /* STD */ #include @@ -66,33 +67,13 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags f 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::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 dontBackupList; dontBackupList.setAutoDelete(true); + Config config("BackupAndRestore"); config.setGroup("DontBackup"); int total = config.readNumEntry("Total", 0); for(int i = 0; i < total; i++) @@ -165,8 +146,36 @@ void BackupAndRestore::refreshBackupLocations() 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::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 BackupAndRestore::getAllItems(QListViewItem *item, QList &list) @@ -310,7 +319,6 @@ void BackupAndRestore::backup() else { QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) ); - } //write store-location @@ -536,8 +544,16 @@ 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() @@ -558,12 +574,20 @@ void BackupAndRestore::removeLocation() } } -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 @@ -7,6 +7,7 @@ #include class QListViewItem; +class QStringList; class BackupAndRestore : public BackupAndRestoreBase { @@ -30,7 +31,7 @@ private slots: void addLocation(); void removeLocation(); - void saveLocation(); + void saveLocations(); private: void scanForApplicationSettings(); @@ -44,7 +45,6 @@ private: QListViewItem *systemSettings; QListViewItem *applicationSettings; QListViewItem *documents; - }; #endif -- cgit v0.9.0.2