-rw-r--r-- | noncore/settings/backup/backuprestore.cpp | 107 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestore.h | 6 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestorebase.ui | 129 |
3 files changed, 192 insertions, 50 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index 2eccdfe..3889744 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp @@ -1,12 +1,16 @@ #include "backuprestore.h" #include "errordialog.h" + /* OPIE */ #include <opie2/odebug.h> #include <opie2/ostorageinfo.h> -#include <qpe/qpeapplication.h> using namespace Opie::Core; +#include <qpe/qpeapplication.h> +#include <qpe/resource.h> +#include <qpe/config.h> + /* QT */ #include <qapplication.h> #include <qmultilineedit.h> @@ -16,15 +20,13 @@ using namespace Opie::Core; #include <qlistview.h> #include <qpushbutton.h> #include <qheader.h> -#include <qpe/resource.h> -#include <qpe/config.h> #include <qmessagebox.h> #include <qcombobox.h> #include <qlist.h> -#include <stdlib.h> #include <qregexp.h> #include <qtextstream.h> #include <qtextview.h> +#include <qlineedit.h> /* STD */ #include <errno.h> @@ -46,16 +48,14 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags f { backupList->header()->hide(); restoreList->header()->hide(); - connect(backupButton, SIGNAL(clicked()), - this, SLOT(backup())); - connect(restoreButton, SIGNAL(clicked()), - this, SLOT(restore())); - connect(backupList, SIGNAL(clicked(QListViewItem*)), - this, SLOT(selectItem(QListViewItem*))); - connect(restoreSource, SIGNAL(activated(int)), - this, SLOT(sourceDirChanged(int))); - connect(updateList, SIGNAL(clicked()), - this, SLOT( fileListUpdate())); + locationList->header()->hide(); + connect( backupButton, SIGNAL( clicked() ), this, SLOT( backup() ) ); + connect( restoreButton, SIGNAL( clicked() ), this, SLOT( restore() ) ); + connect( backupList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectItem( QListViewItem* ) ) ); + connect( restoreSource, SIGNAL( activated( int ) ), this, SLOT( sourceDirChanged( int ) ) ); + connect( addLocationButton, SIGNAL( clicked() ), this, SLOT( addLocation() ) ); + connect( removeLocationButton, SIGNAL( clicked() ), this, SLOT( removeLocation() ) ); + connect( saveLocationsButton, SIGNAL( clicked() ), this, SLOT( saveLocations() ) ); //add directorys for backing up applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); @@ -66,25 +66,8 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags f selectItem(documents); scanForApplicationSettings(); - - Opie::Core::OStorageInfo storage; - - backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); - if ( storage.hasCf() ) - { - backupLocations.insert( "CF", storage.cfPath() ); - odebug << "Cf Path: " + storage.cfPath() << oendl; - } - if ( storage.hasSd() ) - { - backupLocations.insert( "SD", storage.sdPath() ); - odebug << " Sd Path: " + storage.sdPath() << oendl; - } - if ( storage.hasMmc() ) - { - backupLocations.insert( "MMC", storage.mmcPath() ); - odebug << "Mmc Path: " + storage.mmcPath() << oendl; - } + refreshBackupLocations(); + refreshLocations(); Config config("BackupAndRestore"); //read last locations @@ -160,6 +143,32 @@ BackupAndRestore::~BackupAndRestore() QFile::remove( tempFileName ); } +void BackupAndRestore::refreshBackupLocations() +{ + backupLocations.clear(); + // Add cards + Opie::Core::OStorageInfo storage; + backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); + if ( storage.hasCf() ) + { + backupLocations.insert( "CF", storage.cfPath() ); + odebug << "Cf Path: " + storage.cfPath() << oendl; + } + if ( storage.hasSd() ) + { + backupLocations.insert( "SD", storage.sdPath() ); + 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 +} + QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list) { while(item) @@ -524,5 +533,37 @@ QString BackupAndRestore::getExcludeFile() return excludeFileName; } +void BackupAndRestore::refreshLocations() +{ + locationList->clear(); + //todo: implement add locations + odebug << "not implemented yet" << oendl; +} + +void BackupAndRestore::addLocation() +{ + if ( ( !locationEdit->text().isEmpty() ) && + ( QDir( locationEdit->text() ).exists() ) ) + { + (void) new QListViewItem( locationList, locationEdit->text() ); + locationEdit->setText( "" ); + } +} + +void BackupAndRestore::removeLocation() +{ + if ( locationList->selectedItem() ) + { + delete( locationList->selectedItem() ); + } +} + +void BackupAndRestore::saveLocation() +{ + //todo: implement + odebug << "not implemented yet" << oendl; +} + + // backuprestore.cpp diff --git a/noncore/settings/backup/backuprestore.h b/noncore/settings/backup/backuprestore.h index 0d88f8d..527b3cf 100644 --- a/noncore/settings/backup/backuprestore.h +++ b/noncore/settings/backup/backuprestore.h @@ -28,12 +28,18 @@ private slots: void rescanFolder(QString directory); void fileListUpdate(); + void addLocation(); + void removeLocation(); + void saveLocation(); + 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; diff --git a/noncore/settings/backup/backuprestorebase.ui b/noncore/settings/backup/backuprestorebase.ui index a52b42d..b4624bb 100644 --- a/noncore/settings/backup/backuprestorebase.ui +++ b/noncore/settings/backup/backuprestorebase.ui @@ -11,8 +11,8 @@ <rect> <x>0</x> <y>0</y> - <width>231</width> - <height>275</height> + <width>290</width> + <height>243</height> </rect> </property> <property stdset="1"> @@ -22,6 +22,9 @@ <property> <name>layoutMargin</name> </property> + <property> + <name>layoutSpacing</name> + </property> <vbox> <property stdset="1"> <name>margin</name> @@ -29,7 +32,7 @@ </property> <property stdset="1"> <name>spacing</name> - <number>6</number> + <number>0</number> </property> <widget> <class>QTabWidget</class> @@ -40,6 +43,9 @@ <property> <name>layoutMargin</name> </property> + <property> + <name>layoutSpacing</name> + </property> <widget> <class>QWidget</class> <property stdset="1"> @@ -53,11 +59,11 @@ <grid> <property stdset="1"> <name>margin</name> - <number>11</number> + <number>4</number> </property> <property stdset="1"> <name>spacing</name> - <number>6</number> + <number>4</number> </property> <widget row="0" column="0" > <class>QLabel</class> @@ -132,11 +138,11 @@ <grid> <property stdset="1"> <name>margin</name> - <number>11</number> + <number>4</number> </property> <property stdset="1"> <name>spacing</name> - <number>6</number> + <number>4</number> </property> <widget row="0" column="1" > <class>QComboBox</class> @@ -146,6 +152,28 @@ </property> </widget> <widget row="2" column="0" rowspan="1" colspan="2" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>restoreButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&Restore</string> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Select Source</string> + </property> + </widget> + <widget row="1" column="0" rowspan="1" colspan="2" > <class>QListView</class> <column> <property> @@ -173,37 +201,104 @@ </size> </property> </widget> - <widget row="3" column="0" rowspan="1" colspan="2" > + </grid> + </widget> + <widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>tab</cstring> + </property> + <attribute> + <name>title</name> + <string>Locations</string> + </attribute> + <grid> + <property stdset="1"> + <name>margin</name> + <number>4</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>4</number> + </property> + <widget row="0" column="0" rowspan="1" colspan="3" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>locationEdit</cstring> + </property> + </widget> + <widget row="0" column="3" > + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>locationSelectBtn</cstring> + </property> + <property stdset="1"> + <name>maximumSize</name> + <size> + <width>20</width> + <height>30</height> + </size> + </property> + <property stdset="1"> + <name>text</name> + <string>...</string> + </property> + </widget> + <widget row="1" column="0" rowspan="1" colspan="4" > + <class>QListView</class> + <column> + <property> + <name>text</name> + <string>Locations</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <property stdset="1"> + <name>name</name> + <cstring>locationList</cstring> + </property> + </widget> + <widget row="2" column="0" > <class>QPushButton</class> <property stdset="1"> <name>name</name> - <cstring>restoreButton</cstring> + <cstring>addLocationButton</cstring> </property> <property stdset="1"> <name>text</name> - <string>&Restore</string> + <string>Add</string> </property> </widget> - <widget row="0" column="0" > - <class>QLabel</class> + <widget row="2" column="1" > + <class>QPushButton</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1_2</cstring> + <cstring>removeLocationButton</cstring> </property> <property stdset="1"> <name>text</name> - <string>Select Source</string> + <string>Remove</string> </property> </widget> - <widget row="1" column="0" rowspan="1" colspan="2" > + <widget row="2" column="2" rowspan="1" colspan="2" > <class>QPushButton</class> <property stdset="1"> <name>name</name> - <cstring>updateList</cstring> + <cstring>saveLocationsButton</cstring> </property> <property stdset="1"> <name>text</name> - <string>Update Filelist</string> + <string>Save</string> </property> </widget> </grid> |