author | ar <ar> | 2004-08-14 19:24:28 (UTC) |
---|---|---|
committer | ar <ar> | 2004-08-14 19:24:28 (UTC) |
commit | 6b3277b1ff29c9fba53e62fc1b83a045b73a17af (patch) (side-by-side diff) | |
tree | 1cee073c95061330c8e0b32a44bd5f694b8193c1 | |
parent | b7e50e77e0b22b3dd0feee43b15d0152d9ca8abb (diff) | |
download | opie-6b3277b1ff29c9fba53e62fc1b83a045b73a17af.zip opie-6b3277b1ff29c9fba53e62fc1b83a045b73a17af.tar.gz opie-6b3277b1ff29c9fba53e62fc1b83a045b73a17af.tar.bz2 |
- use OFileDialog::getDirectory() to select directory in locations tab.
-rw-r--r-- | noncore/settings/backup/backup.pro | 2 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestore.cpp | 13 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestore.h | 1 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestorebase.ui | 59 | ||||
-rw-r--r-- | noncore/settings/backup/config.in | 2 |
5 files changed, 49 insertions, 28 deletions
diff --git a/noncore/settings/backup/backup.pro b/noncore/settings/backup/backup.pro index 2adb428..390c599 100644 --- a/noncore/settings/backup/backup.pro +++ b/noncore/settings/backup/backup.pro @@ -1,10 +1,10 @@ CONFIG = qt warn_on quick-app HEADERS = backuprestore.h SOURCES = main.cpp backuprestore.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -lopiecore2 +LIBS += -lqpe -lopiecore2 -lopieui2 INTERFACES = backuprestorebase.ui errordialog.ui TARGET = backup include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index 478b22f..36b101c 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp @@ -1,123 +1,127 @@ #include "backuprestore.h" #include "errordialog.h" /* OPIE */ #include <opie2/odebug.h> #include <opie2/ostorageinfo.h> using namespace Opie::Core; +#include <opie2/ofiledialog.h> +using namespace Opie::Ui; + #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> /* QT */ #include <qapplication.h> #include <qmultilineedit.h> #include <qdir.h> #include <qfile.h> #include <qfileinfo.h> #include <qlistview.h> #include <qpushbutton.h> #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> #define HEADER_NAME 0 #define HEADER_BACKUP 1 #define BACKUP_LOCATION 2 #define EXTENSION ".bck" const QString tempFileName = "/tmp/backup.err"; BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) : BackupAndRestoreBase(parent, name, fl) { backupList->header()->hide(); restoreList->header()->hide(); 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() ) ); + connect( selectLocationButton, SIGNAL( clicked() ), this, SLOT( selectLocation() ) ); //add directorys for backing up 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(); refreshLocations(); 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; getAllItems(backupList->firstChild(), list); for(uint i = 0; i < list.count(); i++) { QString text = list.at(i)->text(HEADER_NAME); for(uint i2 = 0; i2 < dontBackupList.count(); i2++) { if(*dontBackupList.at(i2) == text) { selectItem(list.at(i)); break; } } } QPEApplication::showWidget( this ); } BackupAndRestore::~BackupAndRestore() { QList<QListViewItem> list; getAllItems(backupList->firstChild(), list); Config config("BackupAndRestore"); config.setGroup("DontBackup"); config.clearGroup(); int count = 0; for(uint i = 0; i < list.count(); i++) { if(list.at(i)->text(HEADER_BACKUP) == "") { config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); count++; } } config.writeEntry("Total", count); // Remove Temp File if ( QFile::exists( tempFileName ) ) @@ -528,66 +532,75 @@ QString BackupAndRestore::getExcludeFile() QFile excludeFile( excludeFileName); if ( excludeFile.open( IO_WriteOnly ) == true ) { QTextStream writeStream( &excludeFile ); writeStream << "*.bck" << "\n"; excludeFile.close(); } else { return QString::null; } } return excludeFileName; } void BackupAndRestore::refreshLocations() { locationList->clear(); //todo: implement add locations 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() ); locationEdit->setText( "" ); } } void BackupAndRestore::removeLocation() { if ( locationList->selectedItem() ) { delete( locationList->selectedItem() ); } } void BackupAndRestore::saveLocations() { 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(); } +void BackupAndRestore::selectLocation() +{ + QString location = OFileDialog::getDirectory( OFileSelector::DIRECTORYSELECTOR ); + if ( !location.isEmpty() ) + { + locationEdit->setText( location ); + } +} + // backuprestore.cpp diff --git a/noncore/settings/backup/backuprestore.h b/noncore/settings/backup/backuprestore.h index caf6243..332123a 100644 --- a/noncore/settings/backup/backuprestore.h +++ b/noncore/settings/backup/backuprestore.h @@ -1,53 +1,54 @@ #ifndef WINDOW_H #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: BackupAndRestore( QWidget* parent = 0, const char* name = 0, WFlags fl = 0); ~BackupAndRestore(); static QString appName() { return QString::fromLatin1("backup"); } private slots: void backup(); void restore(); void selectItem(QListViewItem *currentItem); void sourceDirChanged(int); void rescanFolder(QString directory); void fileListUpdate(); void addLocation(); void removeLocation(); void saveLocations(); + void selectLocation(); 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 diff --git a/noncore/settings/backup/backuprestorebase.ui b/noncore/settings/backup/backuprestorebase.ui index b4624bb..b464556 100644 --- a/noncore/settings/backup/backuprestorebase.ui +++ b/noncore/settings/backup/backuprestorebase.ui @@ -1,78 +1,78 @@ <!DOCTYPE UI><UI> <class>BackupAndRestoreBase</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>BackupAndRestoreBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>290</width> + <width>282</width> <height>243</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Backup And Restore</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>0</number> </property> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>tabWidget</cstring> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>Widget2</cstring> </property> <attribute> <name>title</name> <string>Backup</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" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1</cstring> </property> <property stdset="1"> <name>text</name> <string>Save To</string> </property> </widget> @@ -161,149 +161,156 @@ <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> <name>text</name> <string>Column 1</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>restoreList</cstring> </property> <property stdset="1"> <name>minimumSize</name> <size> <width>0</width> <height>100</height> </size> </property> </widget> </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>addLocationButton</cstring> </property> <property stdset="1"> <name>text</name> <string>Add</string> </property> </widget> <widget row="2" column="1" > <class>QPushButton</class> <property stdset="1"> <name>name</name> <cstring>removeLocationButton</cstring> </property> <property stdset="1"> <name>text</name> <string>Remove</string> </property> </widget> <widget row="2" column="2" rowspan="1" colspan="2" > <class>QPushButton</class> <property stdset="1"> <name>name</name> <cstring>saveLocationsButton</cstring> </property> <property stdset="1"> <name>text</name> <string>Save</string> </property> </widget> + <widget row="0" column="3" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>selectLocationButton</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </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="0" column="0" rowspan="1" colspan="3" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>locationEdit</cstring> + </property> + </widget> </grid> </widget> </widget> </vbox> </widget> </UI> diff --git a/noncore/settings/backup/config.in b/noncore/settings/backup/config.in index 27a5408..fddde4b 100644 --- a/noncore/settings/backup/config.in +++ b/noncore/settings/backup/config.in @@ -1,4 +1,4 @@ config BACKUP boolean "opie-backup (save and restore current Opie settings)" default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI |