summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/backup/backuprestore.cpp84
-rw-r--r--noncore/settings/backup/backuprestore.h4
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
@@ -28,4 +28,5 @@ using namespace Opie::Core;
#include <qtextview.h>
#include <qlineedit.h>
+#include <qstringlist.h>
/* STD */
@@ -67,31 +68,11 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags f
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);
@@ -166,6 +147,34 @@ void BackupAndRestore::refreshBackupLocations()
}
- // 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++;
+ }
}
@@ -311,5 +320,4 @@ void BackupAndRestore::backup()
{
QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) );
-
}
@@ -537,6 +545,14 @@ 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 );
+ }
}
@@ -559,10 +575,18 @@ 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
@@ -8,4 +8,5 @@
class QListViewItem;
+class QStringList;
class BackupAndRestore : public BackupAndRestoreBase
@@ -31,5 +32,5 @@ private slots:
void addLocation();
void removeLocation();
- void saveLocation();
+ void saveLocations();
private:
@@ -45,5 +46,4 @@ private:
QListViewItem *applicationSettings;
QListViewItem *documents;
-
};