author | mickeyl <mickeyl> | 2003-12-20 00:53:04 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-12-20 00:53:04 (UTC) |
commit | f495453bc1c2157f3c0a9a7957d15d3b5f434a72 (patch) (unidiff) | |
tree | b3b3618608b1cb04642b8643cc905bc89d79cec6 | |
parent | 11c6b3b8ba56b28b160965387b4ffeffe2a2f143 (diff) | |
download | opie-f495453bc1c2157f3c0a9a7957d15d3b5f434a72.zip opie-f495453bc1c2157f3c0a9a7957d15d3b5f434a72.tar.gz opie-f495453bc1c2157f3c0a9a7957d15d3b5f434a72.tar.bz2 |
fix bug in line 73 - it helps to actually call the functions ;)
-rw-r--r-- | noncore/settings/backup/backuprestore.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index 7d0daf7..cfba907 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp | |||
@@ -1,169 +1,169 @@ | |||
1 | 1 | ||
2 | #include "backuprestore.h" | 2 | #include "backuprestore.h" |
3 | //#include "output.h" | 3 | //#include "output.h" |
4 | #include "errordialog.h" | 4 | #include "errordialog.h" |
5 | 5 | ||
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | #include <qmultilineedit.h> | 7 | #include <qmultilineedit.h> |
8 | 8 | ||
9 | #include <qdir.h> | 9 | #include <qdir.h> |
10 | #include <qfile.h> | 10 | #include <qfile.h> |
11 | #include <qfileinfo.h> | 11 | #include <qfileinfo.h> |
12 | #include <qlistview.h> | 12 | #include <qlistview.h> |
13 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
14 | #include <qheader.h> | 14 | #include <qheader.h> |
15 | #include <qpe/resource.h> | 15 | #include <qpe/resource.h> |
16 | #include <qpe/config.h> | 16 | #include <qpe/config.h> |
17 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
18 | #include <qcombobox.h> | 18 | #include <qcombobox.h> |
19 | #include <qlist.h> | 19 | #include <qlist.h> |
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <qregexp.h> | 21 | #include <qregexp.h> |
22 | #include <qtextstream.h> | 22 | #include <qtextstream.h> |
23 | #include <qtextview.h> | 23 | #include <qtextview.h> |
24 | #include <qpe/storage.h> | 24 | #include <qpe/storage.h> |
25 | 25 | ||
26 | #include <errno.h> | 26 | #include <errno.h> |
27 | #include <stdlib.h> | 27 | #include <stdlib.h> |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #include <dirent.h> | 30 | #include <dirent.h> |
31 | 31 | ||
32 | #define HEADER_NAME 0 | 32 | #define HEADER_NAME 0 |
33 | #define HEADER_BACKUP 1 | 33 | #define HEADER_BACKUP 1 |
34 | #define BACKUP_LOCATION 2 | 34 | #define BACKUP_LOCATION 2 |
35 | 35 | ||
36 | #define EXTENSION ".bck" | 36 | #define EXTENSION ".bck" |
37 | 37 | ||
38 | const QString tempFileName = "/tmp/backup.err"; | 38 | const QString tempFileName = "/tmp/backup.err"; |
39 | 39 | ||
40 | 40 | ||
41 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) | 41 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) |
42 | : BackupAndRestoreBase(parent, name, fl) | 42 | : BackupAndRestoreBase(parent, name, fl) |
43 | { | 43 | { |
44 | this->showMaximized(); | 44 | this->showMaximized(); |
45 | backupList->header()->hide(); | 45 | backupList->header()->hide(); |
46 | restoreList->header()->hide(); | 46 | restoreList->header()->hide(); |
47 | connect(backupButton, SIGNAL(clicked()), | 47 | connect(backupButton, SIGNAL(clicked()), |
48 | this, SLOT(backup())); | 48 | this, SLOT(backup())); |
49 | connect(restoreButton, SIGNAL(clicked()), | 49 | connect(restoreButton, SIGNAL(clicked()), |
50 | this, SLOT(restore())); | 50 | this, SLOT(restore())); |
51 | connect(backupList, SIGNAL(clicked( QListViewItem * )), | 51 | connect(backupList, SIGNAL(clicked( QListViewItem * )), |
52 | this, SLOT(selectItem(QListViewItem*))); | 52 | this, SLOT(selectItem(QListViewItem*))); |
53 | connect(restoreSource, SIGNAL(activated( int )), | 53 | connect(restoreSource, SIGNAL(activated( int )), |
54 | this, SLOT(sourceDirChanged(int))); | 54 | this, SLOT(sourceDirChanged(int))); |
55 | connect(updateList, SIGNAL(clicked()), | 55 | connect(updateList, SIGNAL(clicked()), |
56 | this, SLOT( fileListUpdate())); | 56 | this, SLOT( fileListUpdate())); |
57 | 57 | ||
58 | //add directorys for backing up | 58 | //add directorys for backing up |
59 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); | 59 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); |
60 | selectItem(applicationSettings); | 60 | selectItem(applicationSettings); |
61 | applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); | 61 | applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); |
62 | selectItem(applicationSettings); | 62 | selectItem(applicationSettings); |
63 | documents= new QListViewItem(backupList, "Documents", "", "Documents/"); | 63 | documents= new QListViewItem(backupList, "Documents", "", "Documents/"); |
64 | selectItem(documents); | 64 | selectItem(documents); |
65 | 65 | ||
66 | scanForApplicationSettings(); | 66 | scanForApplicationSettings(); |
67 | 67 | ||
68 | backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); | 68 | backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); |
69 | if (StorageInfo::hasCf()) | 69 | if (StorageInfo::hasCf()) |
70 | { | 70 | { |
71 | backupLocations.insert("CF", "/mnt/cf"); | 71 | backupLocations.insert("CF", "/mnt/cf"); |
72 | } | 72 | } |
73 | if (StorageInfo::hasSd || StorageInfo::hasMmc) | 73 | if (StorageInfo::hasSd() || StorageInfo::hasMmc()) |
74 | { | 74 | { |
75 | backupLocations.insert("SD", "/mnt/card"); | 75 | backupLocations.insert("SD", "/mnt/card"); |
76 | } | 76 | } |
77 | 77 | ||
78 | QMap<QString, QString>::Iterator it; | 78 | QMap<QString, QString>::Iterator it; |
79 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) | 79 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) |
80 | { | 80 | { |
81 | storeToLocation->insertItem(it.key()); | 81 | storeToLocation->insertItem(it.key()); |
82 | restoreSource->insertItem(it.key()); | 82 | restoreSource->insertItem(it.key()); |
83 | } | 83 | } |
84 | 84 | ||
85 | // Read the list of items to ignore. | 85 | // Read the list of items to ignore. |
86 | Config config("BackupAndRestore"); | 86 | Config config("BackupAndRestore"); |
87 | 87 | ||
88 | QList<QString> dontBackupList; | 88 | QList<QString> dontBackupList; |
89 | dontBackupList.setAutoDelete(true); | 89 | dontBackupList.setAutoDelete(true); |
90 | config.setGroup("DontBackup"); | 90 | config.setGroup("DontBackup"); |
91 | int total = config.readNumEntry("Total", 0); | 91 | int total = config.readNumEntry("Total", 0); |
92 | for(int i = 0; i < total; i++) | 92 | for(int i = 0; i < total; i++) |
93 | { | 93 | { |
94 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); | 94 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); |
95 | } | 95 | } |
96 | 96 | ||
97 | QList<QListViewItem> list; | 97 | QList<QListViewItem> list; |
98 | getAllItems(backupList->firstChild(), list); | 98 | getAllItems(backupList->firstChild(), list); |
99 | 99 | ||
100 | for(uint i = 0; i < list.count(); i++) | 100 | for(uint i = 0; i < list.count(); i++) |
101 | { | 101 | { |
102 | QString text = list.at(i)->text(HEADER_NAME); | 102 | QString text = list.at(i)->text(HEADER_NAME); |
103 | for(uint i2 = 0; i2 < dontBackupList.count(); i2++) | 103 | for(uint i2 = 0; i2 < dontBackupList.count(); i2++) |
104 | { | 104 | { |
105 | if(*dontBackupList.at(i2) == text) | 105 | if(*dontBackupList.at(i2) == text) |
106 | { | 106 | { |
107 | selectItem(list.at(i)); | 107 | selectItem(list.at(i)); |
108 | break; | 108 | break; |
109 | } | 109 | } |
110 | } | 110 | } |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | BackupAndRestore::~BackupAndRestore() | 114 | BackupAndRestore::~BackupAndRestore() |
115 | { | 115 | { |
116 | QList<QListViewItem> list; | 116 | QList<QListViewItem> list; |
117 | getAllItems(backupList->firstChild(), list); | 117 | getAllItems(backupList->firstChild(), list); |
118 | 118 | ||
119 | Config config("BackupAndRestore"); | 119 | Config config("BackupAndRestore"); |
120 | config.setGroup("DontBackup"); | 120 | config.setGroup("DontBackup"); |
121 | config.clearGroup(); | 121 | config.clearGroup(); |
122 | 122 | ||
123 | int count = 0; | 123 | int count = 0; |
124 | for(uint i = 0; i < list.count(); i++) | 124 | for(uint i = 0; i < list.count(); i++) |
125 | { | 125 | { |
126 | if(list.at(i)->text(HEADER_BACKUP) == "") | 126 | if(list.at(i)->text(HEADER_BACKUP) == "") |
127 | { | 127 | { |
128 | config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); | 128 | config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); |
129 | count++; | 129 | count++; |
130 | } | 130 | } |
131 | } | 131 | } |
132 | config.writeEntry("Total", count); | 132 | config.writeEntry("Total", count); |
133 | 133 | ||
134 | // Remove Temp File | 134 | // Remove Temp File |
135 | if ( QFile::exists( tempFileName ) ) | 135 | if ( QFile::exists( tempFileName ) ) |
136 | QFile::remove( tempFileName ); | 136 | QFile::remove( tempFileName ); |
137 | } | 137 | } |
138 | 138 | ||
139 | QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list) | 139 | QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list) |
140 | { | 140 | { |
141 | while(item) | 141 | while(item) |
142 | { | 142 | { |
143 | if(item->childCount() > 0) | 143 | if(item->childCount() > 0) |
144 | getAllItems(item->firstChild(), list); | 144 | getAllItems(item->firstChild(), list); |
145 | list.append(item); | 145 | list.append(item); |
146 | item = item->nextSibling(); | 146 | item = item->nextSibling(); |
147 | } | 147 | } |
148 | return list; | 148 | return list; |
149 | } | 149 | } |
150 | 150 | ||
151 | /** | 151 | /** |
152 | * Selects and unselects the item by setting the HEADER_BACKUP to B or !. | 152 | * Selects and unselects the item by setting the HEADER_BACKUP to B or !. |
153 | * and changing the icon to match | 153 | * and changing the icon to match |
154 | * @param currentItem the item to swich the selection choice. | 154 | * @param currentItem the item to swich the selection choice. |
155 | */ | 155 | */ |
156 | void BackupAndRestore::selectItem(QListViewItem *currentItem) | 156 | void BackupAndRestore::selectItem(QListViewItem *currentItem) |
157 | { | 157 | { |
158 | if(!currentItem) | 158 | if(!currentItem) |
159 | return; | 159 | return; |
160 | 160 | ||
161 | if(currentItem->text(HEADER_BACKUP) == "B") | 161 | if(currentItem->text(HEADER_BACKUP) == "B") |
162 | { | 162 | { |
163 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null")); | 163 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null")); |
164 | currentItem->setText(HEADER_BACKUP, ""); | 164 | currentItem->setText(HEADER_BACKUP, ""); |
165 | } | 165 | } |
166 | else | 166 | else |
167 | { | 167 | { |
168 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check")); | 168 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check")); |
169 | currentItem->setText(HEADER_BACKUP, "B"); | 169 | currentItem->setText(HEADER_BACKUP, "B"); |