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.cpp68
1 files changed, 34 insertions, 34 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp
index 922523b..1c854d9 100644
--- a/noncore/settings/backup/backuprestore.cpp
+++ b/noncore/settings/backup/backuprestore.cpp
@@ -38,6 +38,6 @@ const QString tempFileName = "/tmp/backup.err";
38 38
39 39
40BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) 40BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl)
41 : BackupAndRestoreBase(parent, name){ 41 : BackupAndRestoreBase(parent, name, fl){
42 this->showMaximized(); 42 this->showMaximized();
43 backupList->header()->hide(); 43 backupList->header()->hide();
@@ -48,9 +48,9 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name)
48 this, SLOT(restore())); 48 this, SLOT(restore()));
49 connect(backupList, SIGNAL(clicked( QListViewItem * )), 49 connect(backupList, SIGNAL(clicked( QListViewItem * )),
50 this, SLOT(selectItem(QListViewItem*))); 50 this, SLOT(selectItem(QListViewItem*)));
51 connect(restoreSource, SIGNAL(activated( int )), 51 connect(restoreSource, SIGNAL(activated( int )),
52 this, SLOT(sourceDirChanged(int))); 52 this, SLOT(sourceDirChanged(int)));
53 connect(updateList, SIGNAL(clicked()), 53 connect(updateList, SIGNAL(clicked()),
54 this, SLOT( fileListUpdate())); 54 this, SLOT( fileListUpdate()));
55 55
56 applicationSettings = new QListViewItem(backupList, "Application Settings", "", 56 applicationSettings = new QListViewItem(backupList, "Application Settings", "",
@@ -63,11 +63,11 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name)
63 QDir::homeDirPath() + "/Documents/"); 63 QDir::homeDirPath() + "/Documents/");
64 selectItem(documents); 64 selectItem(documents);
65 65
66 scanForApplicationSettings(); 66 scanForApplicationSettings();
67 67
68 Config config("BackupAndRestore"); 68 Config config("BackupAndRestore");
69 config.setGroup("General"); 69 config.setGroup("General");
70 int totalLocations = config.readNumEntry("totalLocations",0); 70 int totalLocations = config.readNumEntry("totalLocations",0);
71 71
72//todo make less static here and use Storage class to get infos 72//todo make less static here and use Storage class to get infos
73 if(totalLocations == 0){ 73 if(totalLocations == 0){
@@ -87,6 +87,6 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name)
87 restoreSource->insertItem(it.key()); 87 restoreSource->insertItem(it.key());
88 } 88 }
89 89
90 // Read the list of items to ignore. 90 // Read the list of items to ignore.
91 QList<QString> dontBackupList; 91 QList<QString> dontBackupList;
92 dontBackupList.setAutoDelete(true); 92 dontBackupList.setAutoDelete(true);
@@ -99,5 +99,5 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name)
99 QList<QListViewItem> list; 99 QList<QListViewItem> list;
100 getAllItems(backupList->firstChild(), list); 100 getAllItems(backupList->firstChild(), list);
101 101
102 for(uint i = 0; i < list.count(); i++){ 102 for(uint i = 0; i < list.count(); i++){
103 QString text = list.at(i)->text(HEADER_NAME); 103 QString text = list.at(i)->text(HEADER_NAME);
@@ -114,9 +114,9 @@ BackupAndRestore::~BackupAndRestore(){
114 QList<QListViewItem> list; 114 QList<QListViewItem> list;
115 getAllItems(backupList->firstChild(), list); 115 getAllItems(backupList->firstChild(), list);
116 116
117 Config config("BackupAndRestore"); 117 Config config("BackupAndRestore");
118 config.setGroup("DontBackup"); 118 config.setGroup("DontBackup");
119 config.clearGroup(); 119 config.clearGroup();
120 120
121 int count = 0; 121 int count = 0;
122 for(uint i = 0; i < list.count(); i++){ 122 for(uint i = 0; i < list.count(); i++){
@@ -136,5 +136,5 @@ QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QL
136 while(item){ 136 while(item){
137 if(item->childCount() > 0) 137 if(item->childCount() > 0)
138 getAllItems(item->firstChild(), list); 138 getAllItems(item->firstChild(), list);
139 list.append(item); 139 list.append(item);
140 item = item->nextSibling(); 140 item = item->nextSibling();
@@ -180,8 +180,8 @@ void BackupAndRestore::scanForApplicationSettings(){
180/** 180/**
181 * The "Backup" button has been pressed. Get a list of all of the files that 181 * The "Backup" button has been pressed. Get a list of all of the files that
182 * should be backed up. If there are no files, emit and error and exit. 182 * should be backed up. If there are no files, emit and error and exit.
183 * Determine the file name to store the backup in. Backup the file(s) using 183 * Determine the file name to store the backup in. Backup the file(s) using
184 * tar and gzip --best. Report failure or success 184 * tar and gzip --best. Report failure or success
185 */ 185 */
186void BackupAndRestore::backupPressed(){ 186void BackupAndRestore::backupPressed(){
187 QString backupFiles; 187 QString backupFiles;
@@ -189,5 +189,5 @@ void BackupAndRestore::backupPressed(){
189 QMessageBox::critical(this, "Message", 189 QMessageBox::critical(this, "Message",
190 "No items selected.",QString("Ok") ); 190 "No items selected.",QString("Ok") );
191 return; 191 return;
192 } 192 }
193 193
@@ -196,9 +196,9 @@ void BackupAndRestore::backupPressed(){
196 196
197 QDateTime datetime = QDateTime::currentDateTime(); 197 QDateTime datetime = QDateTime::currentDateTime();
198 QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + 198 QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') +
199 QString::number( datetime.date().day() ).rightJustify(2, '0'); 199 QString::number( datetime.date().day() ).rightJustify(2, '0');
200 200
201 outputFile += "/" + dateString; 201 outputFile += "/" + dateString;
202 202
203 QString t = outputFile; 203 QString t = outputFile;
204 int c = 1; 204 int c = 1;
@@ -208,5 +208,5 @@ void BackupAndRestore::backupPressed(){
208 } 208 }
209 209
210 // We execute tar and compressing its output with gzip.. 210 // We execute tar and compressing its output with gzip..
211 // The error output will be written into a temp-file which could be provided 211 // The error output will be written into a temp-file which could be provided
212 // for debugging.. 212 // for debugging..
@@ -229,5 +229,5 @@ void BackupAndRestore::backupPressed(){
229 QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); 229 QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno );
230 230
231 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n" 231 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n"
232 + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ){ 232 + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ){
233 233
@@ -243,5 +243,5 @@ void BackupAndRestore::backupPressed(){
243 } 243 }
244 errorFile.close(); 244 errorFile.close();
245 245
246 pErrDialog->m_textarea->setText( s ); 246 pErrDialog->m_textarea->setText( s );
247 }else{ 247 }else{
@@ -254,9 +254,9 @@ void BackupAndRestore::backupPressed(){
254 } 254 }
255 setCaption(tr("Backup and Restore.. Failed !!")); 255 setCaption(tr("Backup and Restore.. Failed !!"));
256 return; 256 return;
257 } 257 }
258 else{ 258 else{
259 QMessageBox::information(this, tr( "Message" ), tr( "Backup Successfull." ), QString(tr( "Ok" ) ) ); 259 QMessageBox::information(this, tr( "Message" ), tr( "Backup Successfull." ), QString(tr( "Ok" ) ) );
260 260
261 } 261 }
262 setCaption(tr("Backup and Restore")); 262 setCaption(tr("Backup and Restore"));
@@ -265,5 +265,5 @@ void BackupAndRestore::backupPressed(){
265/*** 265/***
266 * Get a list of all of the files to backup. 266 * Get a list of all of the files to backup.
267 */ 267 */
268int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent){ 268int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent){
269 QListViewItem * currentItem; 269 QListViewItem * currentItem;
@@ -275,5 +275,5 @@ int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent
275 currentHome = parent->text(BACKUP_LOCATION); 275 currentHome = parent->text(BACKUP_LOCATION);
276 } 276 }
277 277
278 uint count = 0; 278 uint count = 0;
279 while( currentItem != 0 ){ 279 while( currentItem != 0 ){
@@ -318,5 +318,5 @@ void BackupAndRestore::rescanFolder(QString directory){
318 if(!d.exists()) 318 if(!d.exists())
319 return; 319 return;
320 320
321 d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); 321 d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs);
322 const QFileInfoList *list = d.entryInfoList(); 322 const QFileInfoList *list = d.entryInfoList();
@@ -342,5 +342,5 @@ void BackupAndRestore::rescanFolder(QString directory){
342 * Restore a backup file. 342 * Restore a backup file.
343 * Report errors or success 343 * Report errors or success
344 */ 344 */
345void BackupAndRestore::restore(){ 345void BackupAndRestore::restore(){
346 QListViewItem *restoreItem = restoreList->currentItem(); 346 QListViewItem *restoreItem = restoreList->currentItem();
@@ -348,12 +348,12 @@ void BackupAndRestore::restore(){
348 QMessageBox::critical(this, tr( "Message" ), 348 QMessageBox::critical(this, tr( "Message" ),
349 tr( "Please select something to restore." ),QString( tr( "Ok") ) ); 349 tr( "Please select something to restore." ),QString( tr( "Ok") ) );
350 return; 350 return;
351 } 351 }
352 setCaption(tr("Backup and Restore... working...")); 352 setCaption(tr("Backup and Restore... working..."));
353 353
354 QString restoreFile = backupLocations[restoreSource->currentText()]; 354 QString restoreFile = backupLocations[restoreSource->currentText()];
355 355
356 restoreFile += "/" + restoreItem->text(0); 356 restoreFile += "/" + restoreItem->text(0);
357 357
358 int r = system(QString("tar -C / -zxf %1 2> %3") 358 int r = system(QString("tar -C / -zxf %1 2> %3")
359 .arg( restoreFile.latin1() ) 359 .arg( restoreFile.latin1() )
@@ -361,5 +361,5 @@ void BackupAndRestore::restore(){
361 if(r != 0){ 361 if(r != 0){
362 QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); 362 QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno );
363 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n" 363 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n"
364 + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) { 364 + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) {
365 case 1: 365 case 1:
@@ -374,5 +374,5 @@ void BackupAndRestore::restore(){
374 } 374 }
375 errorFile.close(); 375 errorFile.close();
376 376
377 pErrDialog->m_textarea->setText( s ); 377 pErrDialog->m_textarea->setText( s );
378 }else{ 378 }else{
@@ -384,5 +384,5 @@ void BackupAndRestore::restore(){
384 384
385 setCaption(tr("Backup and Restore.. Failed !!")); 385 setCaption(tr("Backup and Restore.. Failed !!"));
386 return; 386 return;
387 387
388 break; 388 break;