summaryrefslogtreecommitdiff
path: root/noncore/settings/backup/backuprestore.cpp
Unidiff
Diffstat (limited to 'noncore/settings/backup/backuprestore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/backup/backuprestore.cpp13
1 files changed, 13 insertions, 0 deletions
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,33 +1,36 @@
1#include "backuprestore.h" 1#include "backuprestore.h"
2#include "errordialog.h" 2#include "errordialog.h"
3 3
4 4
5/* OPIE */ 5/* OPIE */
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7#include <opie2/ostorageinfo.h> 7#include <opie2/ostorageinfo.h>
8using namespace Opie::Core; 8using namespace Opie::Core;
9 9
10#include <opie2/ofiledialog.h>
11using namespace Opie::Ui;
12
10#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
11#include <qpe/resource.h> 14#include <qpe/resource.h>
12#include <qpe/config.h> 15#include <qpe/config.h>
13 16
14/* QT */ 17/* QT */
15#include <qapplication.h> 18#include <qapplication.h>
16#include <qmultilineedit.h> 19#include <qmultilineedit.h>
17#include <qdir.h> 20#include <qdir.h>
18#include <qfile.h> 21#include <qfile.h>
19#include <qfileinfo.h> 22#include <qfileinfo.h>
20#include <qlistview.h> 23#include <qlistview.h>
21#include <qpushbutton.h> 24#include <qpushbutton.h>
22#include <qheader.h> 25#include <qheader.h>
23#include <qmessagebox.h> 26#include <qmessagebox.h>
24#include <qcombobox.h> 27#include <qcombobox.h>
25#include <qlist.h> 28#include <qlist.h>
26#include <qregexp.h> 29#include <qregexp.h>
27#include <qtextstream.h> 30#include <qtextstream.h>
28#include <qtextview.h> 31#include <qtextview.h>
29#include <qlineedit.h> 32#include <qlineedit.h>
30#include <qstringlist.h> 33#include <qstringlist.h>
31 34
32/* STD */ 35/* STD */
33#include <errno.h> 36#include <errno.h>
@@ -36,48 +39,49 @@ using namespace Opie::Core;
36#include <sys/stat.h> 39#include <sys/stat.h>
37#include <dirent.h> 40#include <dirent.h>
38 41
39#define HEADER_NAME 0 42#define HEADER_NAME 0
40#define HEADER_BACKUP 1 43#define HEADER_BACKUP 1
41#define BACKUP_LOCATION 2 44#define BACKUP_LOCATION 2
42 45
43#define EXTENSION ".bck" 46#define EXTENSION ".bck"
44 47
45const QString tempFileName = "/tmp/backup.err"; 48const QString tempFileName = "/tmp/backup.err";
46 49
47BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) 50BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl)
48 : BackupAndRestoreBase(parent, name, fl) 51 : BackupAndRestoreBase(parent, name, fl)
49{ 52{
50 backupList->header()->hide(); 53 backupList->header()->hide();
51 restoreList->header()->hide(); 54 restoreList->header()->hide();
52 locationList->header()->hide(); 55 locationList->header()->hide();
53 connect( backupButton, SIGNAL( clicked() ), this, SLOT( backup() ) ); 56 connect( backupButton, SIGNAL( clicked() ), this, SLOT( backup() ) );
54 connect( restoreButton, SIGNAL( clicked() ), this, SLOT( restore() ) ); 57 connect( restoreButton, SIGNAL( clicked() ), this, SLOT( restore() ) );
55 connect( backupList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectItem( QListViewItem* ) ) ); 58 connect( backupList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectItem( QListViewItem* ) ) );
56 connect( restoreSource, SIGNAL( activated( int ) ), this, SLOT( sourceDirChanged( int ) ) ); 59 connect( restoreSource, SIGNAL( activated( int ) ), this, SLOT( sourceDirChanged( int ) ) );
57 connect( addLocationButton, SIGNAL( clicked() ), this, SLOT( addLocation() ) ); 60 connect( addLocationButton, SIGNAL( clicked() ), this, SLOT( addLocation() ) );
58 connect( removeLocationButton, SIGNAL( clicked() ), this, SLOT( removeLocation() ) ); 61 connect( removeLocationButton, SIGNAL( clicked() ), this, SLOT( removeLocation() ) );
59 connect( saveLocationsButton, SIGNAL( clicked() ), this, SLOT( saveLocations() ) ); 62 connect( saveLocationsButton, SIGNAL( clicked() ), this, SLOT( saveLocations() ) );
63 connect( selectLocationButton, SIGNAL( clicked() ), this, SLOT( selectLocation() ) );
60 64
61 //add directorys for backing up 65 //add directorys for backing up
62 applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); 66 applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/");
63 selectItem(applicationSettings); 67 selectItem(applicationSettings);
64 applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); 68 applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/");
65 selectItem(applicationSettings); 69 selectItem(applicationSettings);
66 documents= new QListViewItem(backupList, "Documents", "", "Documents/"); 70 documents= new QListViewItem(backupList, "Documents", "", "Documents/");
67 selectItem(documents); 71 selectItem(documents);
68 72
69 scanForApplicationSettings(); 73 scanForApplicationSettings();
70 refreshLocations(); 74 refreshLocations();
71 refreshBackupLocations(); 75 refreshBackupLocations();
72 76
73 // Read the list of items to ignore. 77 // Read the list of items to ignore.
74 QList<QString> dontBackupList; 78 QList<QString> dontBackupList;
75 dontBackupList.setAutoDelete(true); 79 dontBackupList.setAutoDelete(true);
76 Config config("BackupAndRestore"); 80 Config config("BackupAndRestore");
77 config.setGroup("DontBackup"); 81 config.setGroup("DontBackup");
78 int total = config.readNumEntry("Total", 0); 82 int total = config.readNumEntry("Total", 0);
79 for(int i = 0; i < total; i++) 83 for(int i = 0; i < total; i++)
80 { 84 {
81 dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); 85 dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), "")));
82 } 86 }
83 87
@@ -568,26 +572,35 @@ void BackupAndRestore::addLocation()
568 572
569void BackupAndRestore::removeLocation() 573void BackupAndRestore::removeLocation()
570{ 574{
571 if ( locationList->selectedItem() ) 575 if ( locationList->selectedItem() )
572 { 576 {
573 delete( locationList->selectedItem() ); 577 delete( locationList->selectedItem() );
574 } 578 }
575} 579}
576 580
577void BackupAndRestore::saveLocations() 581void BackupAndRestore::saveLocations()
578{ 582{
579 Config config("BackupAndRestore"); 583 Config config("BackupAndRestore");
580 config.setGroup("Locations"); 584 config.setGroup("Locations");
581 585
582 QStringList locations; 586 QStringList locations;
583 for ( QListViewItemIterator it( locationList ); it.current(); ++it ) 587 for ( QListViewItemIterator it( locationList ); it.current(); ++it )
584 { 588 {
585 locations.append( it.current()->text( 0 ) ); 589 locations.append( it.current()->text( 0 ) );
586 } 590 }
587 config.writeEntry( "locations", locations, '|' ); 591 config.writeEntry( "locations", locations, '|' );
588 592
589 refreshBackupLocations(); 593 refreshBackupLocations();
590} 594}
591 595
596void BackupAndRestore::selectLocation()
597{
598 QString location = OFileDialog::getDirectory( OFileSelector::DIRECTORYSELECTOR );
599 if ( !location.isEmpty() )
600 {
601 locationEdit->setText( location );
602 }
603}
604
592// backuprestore.cpp 605// backuprestore.cpp
593 606