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
@@ -22,16 +22,17 @@ using namespace Opie::Core;
#include <qheader.h>
#include <qmessagebox.h>
#include <qcombobox.h>
#include <qlist.h>
#include <qregexp.h>
#include <qtextstream.h>
#include <qtextview.h>
#include <qlineedit.h>
+#include <qstringlist.h>
/* STD */
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
@@ -61,43 +62,23 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags f
applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/");
selectItem(applicationSettings);
applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/");
selectItem(applicationSettings);
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++)
{
dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), "")));
}
QList<QListViewItem> list;
@@ -160,18 +141,46 @@ void BackupAndRestore::refreshBackupLocations()
odebug << " Sd Path: " + storage.sdPath() << oendl;
}
if ( storage.hasMmc() )
{
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)
{
while(item)
{
if(item->childCount() > 0)
getAllItems(item->firstChild(), list);
@@ -305,17 +314,16 @@ void BackupAndRestore::backup()
break;
}
setCaption(tr("Backup and Restore.. Failed !!"));
return;
}
else
{
QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) );
-
}
//write store-location
Config config( "BackupAndRestore" );
config.setGroup( "LastLocation" );
config.writeEntry( "LastStoreLocation", storeToLocation->currentText() );
setCaption(tr("Backup and Restore"));
@@ -531,18 +539,26 @@ QString BackupAndRestore::getExcludeFile()
}
return excludeFileName;
}
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()
{
if ( ( !locationEdit->text().isEmpty() ) &&
( QDir( locationEdit->text() ).exists() ) )
{
(void) new QListViewItem( locationList, locationEdit->text() );
@@ -553,17 +569,25 @@ void BackupAndRestore::addLocation()
void BackupAndRestore::removeLocation()
{
if ( locationList->selectedItem() )
{
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
@@ -2,16 +2,17 @@
#define WINDOW_H
#include <qmainwindow.h>
#include "backuprestorebase.h"
#include <qmap.h>
#include <qlist.h>
class QListViewItem;
+class QStringList;
class BackupAndRestore : public BackupAndRestoreBase
{
Q_OBJECT
public:
@@ -25,29 +26,28 @@ private slots:
void restore();
void selectItem(QListViewItem *currentItem);
void sourceDirChanged(int);
void rescanFolder(QString directory);
void fileListUpdate();
void addLocation();
void removeLocation();
- void saveLocation();
+ void saveLocations();
private:
void scanForApplicationSettings();
int getBackupFiles(QString &backupFiles, QListViewItem *parent);
QString getExcludeFile();
QMap<QString, QString> backupLocations;
QList<QListViewItem> getAllItems(QListViewItem *item, QList<QListViewItem> &list);
void refreshBackupLocations();
void refreshLocations();
QListViewItem *systemSettings;
QListViewItem *applicationSettings;
QListViewItem *documents;
-
};
#endif
// backuprestore.h