diff options
Diffstat (limited to 'src/backup.cpp')
-rw-r--r-- | src/backup.cpp | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/src/backup.cpp b/src/backup.cpp index 00bc660..6c0bd4e 100644 --- a/src/backup.cpp +++ b/src/backup.cpp @@ -26,16 +26,16 @@ #include "tools.h" #include "formatimporter.h" // To move a folder -#include <qhbox.h> -#include <qvbox.h> -#include <qlayout.h> -#include <qlabel.h> -#include <qpushbutton.h> +#include <tqhbox.h> +#include <tqvbox.h> +#include <tqlayout.h> +#include <tqlabel.h> +#include <tqpushbutton.h> #include <klocale.h> -#include <qdir.h> +#include <tqdir.h> #include <kapplication.h> #include <kaboutdata.h> -#include <qgroupbox.h> +#include <tqgroupbox.h> #include <kdirselectdialog.h> #include <krun.h> #include <kconfig.h> @@ -50,26 +50,26 @@ * Backups are wrapped in a .tar.gz, inside that folder name. * An archive is not a backup or is corrupted if data are not in that folder! */ -const QString backupMagicFolder = "BasKet-Note-Pads_Backup"; +const TQString backupMagicFolder = "BasKet-Note-Pads_Backup"; /** class BackupDialog: */ -BackupDialog::BackupDialog(QWidget *parent, const char *name) - : KDialogBase(parent, name, /*modal=*/true, i18n("Backup & Restore"), +BackupDialog::BackupDialog(TQWidget *tqparent, const char *name) + : KDialogBase(tqparent, name, /*modal=*/true, i18n("Backup & Restore"), KDialogBase::Close, KDialogBase::Close, /*separator=*/false) { - QVBox *page = makeVBoxMainWidget(); + TQVBox *page = makeVBoxMainWidget(); // page->setSpacing(spacingHint()); - QString savesFolder = Global::savesFolder(); + TQString savesFolder = Global::savesFolder(); savesFolder = savesFolder.left(savesFolder.length() - 1); // savesFolder ends with "/" - QGroupBox *folderGroup = new QGroupBox(1, Qt::Horizontal, i18n("Save Folder"), page); - new QLabel("<qt><nobr>" + i18n("Your baskets are currently stored in that folder:<br><b>%1</b>").arg(savesFolder), folderGroup); - QWidget *folderWidget = new QWidget(folderGroup); - QHBoxLayout *folderLayout = new QHBoxLayout(folderWidget, 0, spacingHint()); - QPushButton *moveFolder = new QPushButton(i18n("&Move to Another Folder..."), folderWidget); - QPushButton *useFolder = new QPushButton(i18n("&Use Another Existing Folder..."), folderWidget); + TQGroupBox *folderGroup = new TQGroupBox(1, Qt::Horizontal, i18n("Save Folder"), page); + new TQLabel("<qt><nobr>" + i18n("Your baskets are currently stored in that folder:<br><b>%1</b>").tqarg(savesFolder), folderGroup); + TQWidget *folderWidget = new TQWidget(folderGroup); + TQHBoxLayout *folderLayout = new TQHBoxLayout(folderWidget, 0, spacingHint()); + TQPushButton *moveFolder = new TQPushButton(i18n("&Move to Another Folder..."), folderWidget); + TQPushButton *useFolder = new TQPushButton(i18n("&Use Another Existing Folder..."), folderWidget); HelpLabel *helpLabel = new HelpLabel(i18n("Why to do that?"), i18n( "<p>You can move the folder where %1 store your baskets to:</p><ul>" "<li>Store your baskets in a visible place in your home folder, like ~/Notes or ~/Baskets, so you can manually backup them when you want.</li>" @@ -77,33 +77,33 @@ BackupDialog::BackupDialog(QWidget *parent, const char *name) "In this case, mount the shared-folder to the local file system and ask %2 to use that mount point.<br>" "Warning: you should not run %3 at the same time on both computers, or you risk to loss data while the two applications are desynced.</li>" "</ul><p>Please remember that you should not change the content of that folder manually (eg. adding a file in a basket folder will not add that file to the basket).</p>") - .arg(kapp->aboutData()->programName()) - .arg(kapp->aboutData()->programName()) - .arg(kapp->aboutData()->programName()), + .tqarg(kapp->aboutData()->programName()) + .tqarg(kapp->aboutData()->programName()) + .tqarg(kapp->aboutData()->programName()), folderWidget); folderLayout->addWidget(moveFolder); folderLayout->addWidget(useFolder); folderLayout->addWidget(helpLabel); folderLayout->addStretch(); - connect( moveFolder, SIGNAL(clicked()), this, SLOT(moveToAnotherFolder()) ); - connect( useFolder, SIGNAL(clicked()), this, SLOT(useAnotherExistingFolder()) ); - - QGroupBox *backupGroup = new QGroupBox(1, Qt::Horizontal, i18n("Backups"), page); - QWidget *backupWidget = new QWidget(backupGroup); - QHBoxLayout *backupLayout = new QHBoxLayout(backupWidget, 0, spacingHint()); - QPushButton *backupButton = new QPushButton(i18n("&Backup..."), backupWidget); - QPushButton *restoreButton = new QPushButton(i18n("&Restore a Backup..."), backupWidget); - m_lastBackup = new QLabel("", backupWidget); + connect( moveFolder, TQT_SIGNAL(clicked()), this, TQT_SLOT(moveToAnotherFolder()) ); + connect( useFolder, TQT_SIGNAL(clicked()), this, TQT_SLOT(useAnotherExistingFolder()) ); + + TQGroupBox *backupGroup = new TQGroupBox(1, Qt::Horizontal, i18n("Backups"), page); + TQWidget *backupWidget = new TQWidget(backupGroup); + TQHBoxLayout *backupLayout = new TQHBoxLayout(backupWidget, 0, spacingHint()); + TQPushButton *backupButton = new TQPushButton(i18n("&Backup..."), backupWidget); + TQPushButton *restoreButton = new TQPushButton(i18n("&Restore a Backup..."), backupWidget); + m_lastBackup = new TQLabel("", backupWidget); backupLayout->addWidget(backupButton); backupLayout->addWidget(restoreButton); backupLayout->addWidget(m_lastBackup); backupLayout->addStretch(); - connect( backupButton, SIGNAL(clicked()), this, SLOT(backup()) ); - connect( restoreButton, SIGNAL(clicked()), this, SLOT(restore()) ); + connect( backupButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(backup()) ); + connect( restoreButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(restore()) ); populateLastBackup(); - (new QWidget(page))->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + (new TQWidget(page))->tqsetSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding); } BackupDialog::~BackupDialog() @@ -112,9 +112,9 @@ BackupDialog::~BackupDialog() void BackupDialog::populateLastBackup() { - QString lastBackupText = i18n("Last backup: never"); + TQString lastBackupText = i18n("Last backup: never"); if (Settings::lastBackup().isValid()) - lastBackupText = i18n("Last backup: %1").arg(Settings::lastBackup().toString(Qt::LocalDate)); + lastBackupText = i18n("Last backup: %1").tqarg(Settings::lastBackup().toString(Qt::LocalDate)); m_lastBackup->setText(lastBackupText); } @@ -122,20 +122,20 @@ void BackupDialog::populateLastBackup() void BackupDialog::moveToAnotherFolder() { KURL selectedURL = KDirSelectDialog::selectDirectory( - /*startDir=*/Global::savesFolder(), /*localOnly=*/true, /*parent=*/0, + /*startDir=*/Global::savesFolder(), /*localOnly=*/true, /*tqparent=*/0, /*caption=*/i18n("Choose a Folder Where to Move Baskets")); if (!selectedURL.isEmpty()) { - QString folder = selectedURL.path(); - QDir dir(folder); + TQString folder = selectedURL.path(); + TQDir dir(folder); // The folder should not exists, or be empty (because KDirSelectDialog will likely create it anyway): if (dir.exists()) { // Get the content of the folder: - QStringList content = dir.entryList(); + TQStringList content = dir.entryList(); if (content.count() > 2) { // "." and ".." int result = KMessageBox::questionYesNo( 0, - "<qt>" + i18n("The folder <b>%1</b> is not empty. Do you want to override it?").arg(folder), + "<qt>" + i18n("The folder <b>%1</b> is not empty. Do you want to override it?").tqarg(folder), i18n("Override Folder?"), KGuiItem(i18n("&Override"), "filesave") ); @@ -153,7 +153,7 @@ void BackupDialog::moveToAnotherFolder() void BackupDialog::useAnotherExistingFolder() { KURL selectedURL = KDirSelectDialog::selectDirectory( - /*startDir=*/Global::savesFolder(), /*localOnly=*/true, /*parent=*/0, + /*startDir=*/Global::savesFolder(), /*localOnly=*/true, /*tqparent=*/0, /*caption=*/i18n("Choose an Existing Folder to Store Baskets")); if (!selectedURL.isEmpty()) { @@ -163,19 +163,19 @@ void BackupDialog::useAnotherExistingFolder() void BackupDialog::backup() { - QDir dir; + TQDir dir; // Compute a default file name & path (eg. "Baskets_2007-01-31.tar.gz"): KConfig *config = KGlobal::config(); config->setGroup("Backups"); - QString folder = config->readEntry("lastFolder", QDir::homeDirPath()) + "/"; - QString fileName = i18n("Backup filename (without extension), %1 is the date", "Baskets_%1") - .arg(QDate::currentDate().toString(Qt::ISODate)); - QString url = folder + fileName; + TQString folder = config->readEntry("lastFolder", TQDir::homeDirPath()) + "/"; + TQString fileName = i18n("Backup filename (without extension), %1 is the date", "Baskets_%1") + .tqarg(TQDate::tqcurrentDate().toString(Qt::ISODate)); + TQString url = folder + fileName; // Ask a file name & path to the user: - QString filter = "*.tar.gz|" + i18n("Tar Archives Compressed by Gzip") + "\n*|" + i18n("All Files"); - QString destination = url; + TQString filter = "*.tar.gz|" + i18n("Tar Archives Compressed by Gzip") + "\n*|" + i18n("All Files"); + TQString destination = url; for (bool askAgain = true; askAgain; ) { // Ask: destination = KFileDialog::getSaveFileName(destination, filter, 0, i18n("Backup Baskets")); @@ -187,7 +187,7 @@ void BackupDialog::backup() int result = KMessageBox::questionYesNoCancel( 0, "<qt>" + i18n("The file <b>%1</b> already exists. Do you really want to override it?") - .arg(KURL(destination).fileName()), + .tqarg(KURL(destination).fileName()), i18n("Override File?"), KGuiItem(i18n("&Override"), "filesave") ); @@ -216,7 +216,7 @@ void BackupDialog::backup() usleep(300); // Not too long because if the backup process is finished, we wait for nothing } - Settings::setLastBackup(QDate::currentDate()); + Settings::setLastBackup(TQDate::tqcurrentDate()); Settings::saveConfig(); populateLastBackup(); } @@ -226,35 +226,35 @@ void BackupDialog::restore() // Get last backup folder: KConfig *config = KGlobal::config(); config->setGroup("Backups"); - QString folder = config->readEntry("lastFolder", QDir::homeDirPath()) + "/"; + TQString folder = config->readEntry("lastFolder", TQDir::homeDirPath()) + "/"; // Ask a file name to the user: - QString filter = "*.tar.gz|" + i18n("Tar Archives Compressed by Gzip") + "\n*|" + i18n("All Files"); - QString path = KFileDialog::getOpenFileName(folder, filter, this, i18n("Open Basket Archive")); + TQString filter = "*.tar.gz|" + i18n("Tar Archives Compressed by Gzip") + "\n*|" + i18n("All Files"); + TQString path = KFileDialog::getOpenFileName(folder, filter, this, i18n("Open Basket Archive")); if (path.isEmpty()) // User has canceled return; // Before replacing the basket data folder with the backup content, we safely backup the current baskets to the home folder. // So if the backup is corrupted or something goes wrong while restoring (power cut...) the user will be able to restore the old working data: - QString safetyPath = Backup::newSafetyFolder(); + TQString safetyPath = Backup::newSafetyFolder(); FormatImporter copier; copier.moveFolder(Global::savesFolder(), safetyPath); // Add the README file for user to cancel a bad restoration: - QString readmePath = safetyPath + i18n("README.txt"); - QFile file(readmePath); + TQString readmePath = safetyPath + i18n("README.txt"); + TQFile file(readmePath); if (file.open(IO_WriteOnly)) { - QTextStream stream(&file); - stream << i18n("This is a safety copy of your baskets like they were before you started to restore the backup %1.").arg(KURL(path).fileName()) + "\n\n" + TQTextStream stream(&file); + stream << i18n("This is a safety copy of your baskets like they were before you started to restore the backup %1.").tqarg(KURL(path).fileName()) + "\n\n" << i18n("If the restoration was a success and you restored what you wanted to restore, you can remove this folder.") + "\n\n" << i18n("If something went wrong during the restoration process, you can re-use this folder to store your baskets and nothing will be lost.") + "\n\n" << i18n("Choose \"Basket\" -> \"Backup & Restore...\" -> \"Use Another Existing Folder...\" and select that folder.") + "\n"; file.close(); } - QString message = - "<p><nobr>" + i18n("Restoring <b>%1</b>. Please wait...").arg(KURL(path).fileName()) + "</nobr></p><p>" + - i18n("If something goes wrong during the restoration process, read the file <b>%1</b>.").arg(readmePath); + TQString message = + "<p><nobr>" + i18n("Restoring <b>%1</b>. Please wait...").tqarg(KURL(path).fileName()) + "</nobr></p><p>" + + i18n("If something goes wrong during the restoration process, read the file <b>%1</b>.").tqarg(readmePath); KProgressDialog *dialog = new KProgressDialog(0, 0, i18n("Restore Baskets"), message, /*modal=*/true); dialog->setAllowCancel(false); @@ -282,7 +282,7 @@ void BackupDialog::restore() // Check for errors: if (!thread.success()) { // Restore the old baskets: - QDir dir; + TQDir dir; dir.remove(readmePath); copier.moveFolder(safetyPath, Global::savesFolder()); // Tell the user: @@ -299,11 +299,11 @@ void BackupDialog::restore() /** class Backup: */ -QString Backup::binaryPath = ""; +TQString Backup::binaryPath = ""; #include <iostream> -void Backup::figureOutBinaryPath(const char *argv0, QApplication &app) +void Backup::figureOutBinaryPath(const char *argv0, TQApplication &app) { /* The application can be launched by two ways: @@ -311,18 +311,18 @@ void Backup::figureOutBinaryPath(const char *argv0, QApplication &app) - In KDevelop or with an absolute path (app.applicationFilePath() is wrong) This function is called at the very start of main() so that the current directory has not been changed yet. - Command line (argv[0]) QDir(argv[0]).canonicalPath() app.applicationFilePath() + Command line (argv[0]) TQDir(argv[0]).canonicalPath() app.applicationFilePath() ====================== ============================================= ========================= "basket" "" "/opt/kde3/bin/basket" "./src/.libs/basket" "/home/seb/prog/basket/debug/src/.lib/basket" "/opt/kde3/bin/basket" */ - binaryPath = QDir(argv0).canonicalPath(); + binaryPath = TQDir(argv0).canonicalPath(); if (binaryPath.isEmpty()) binaryPath = app.applicationFilePath(); } -void Backup::setFolderAndRestart(const QString &folder, const QString &message) +void Backup::setFolderAndRestart(const TQString &folder, const TQString &message) { // Set the folder: Settings::setDataFolder(folder); @@ -332,7 +332,7 @@ void Backup::setFolderAndRestart(const QString &folder, const QString &message) // This is important for users to trust the application in such a critical phase and understands what's happening: KMessageBox::information( 0, - "<qt>" + message.arg( + "<qt>" + message.tqarg( (folder.endsWith("/") ? folder.left(folder.length() - 1) : folder), kapp->aboutData()->programName()), i18n("Restart") @@ -343,17 +343,17 @@ void Backup::setFolderAndRestart(const QString &folder, const QString &message) exit(0); } -QString Backup::newSafetyFolder() +TQString Backup::newSafetyFolder() { - QDir dir; - QString fullPath; + TQDir dir; + TQString fullPath; - fullPath = QDir::homeDirPath() + "/" + i18n("Safety folder name before restoring a basket data archive", "Baskets Before Restoration") + "/"; + fullPath = TQDir::homeDirPath() + "/" + i18n("Safety folder name before restoring a basket data archive", "Baskets Before Restoration") + "/"; if (!dir.exists(fullPath)) return fullPath; for (int i = 2; ; ++i) { - fullPath = QDir::homeDirPath() + "/" + i18n("Safety folder name before restoring a basket data archive", "Baskets Before Restoration (%1)").arg(i) + "/"; + fullPath = TQDir::homeDirPath() + "/" + i18n("Safety folder name before restoring a basket data archive", "Baskets Before Restoration (%1)").tqarg(i) + "/"; if (!dir.exists(fullPath)) return fullPath; } @@ -363,7 +363,7 @@ QString Backup::newSafetyFolder() /** class BackupThread: */ -BackupThread::BackupThread(const QString &tarFile, const QString &folderToBackup) +BackupThread::BackupThread(const TQString &tarFile, const TQString &folderToBackup) : m_tarFile(tarFile), m_folderToBackup(folderToBackup) { } @@ -374,9 +374,9 @@ void BackupThread::run() tar.open(IO_WriteOnly); tar.addLocalDirectory(m_folderToBackup, backupMagicFolder); // KArchive does not add hidden files. Basket description files (".basket") are hidden, we add them manually: - QDir dir(m_folderToBackup + "baskets/"); - QStringList baskets = dir.entryList(QDir::Dirs); - for (QStringList::Iterator it = baskets.begin(); it != baskets.end(); ++it) { + TQDir dir(m_folderToBackup + "baskets/"); + TQStringList baskets = dir.entryList(TQDir::Dirs); + for (TQStringList::Iterator it = baskets.begin(); it != baskets.end(); ++it) { tar.addLocalFile( m_folderToBackup + "baskets/" + *it + "/.basket", backupMagicFolder + "/baskets/" + *it + "/.basket" @@ -388,7 +388,7 @@ void BackupThread::run() /** class RestoreThread: */ -RestoreThread::RestoreThread(const QString &tarFile, const QString &destFolder) +RestoreThread::RestoreThread(const TQString &tarFile, const TQString &destFolder) : m_tarFile(tarFile), m_destFolder(destFolder) { } @@ -400,7 +400,7 @@ void RestoreThread::run() tar.open(IO_ReadOnly); if (tar.isOpened()) { const KArchiveDirectory *directory = tar.directory(); - if (directory->entries().contains(backupMagicFolder)) { + if (directory->entries().tqcontains(backupMagicFolder)) { const KArchiveEntry *entry = directory->entry(backupMagicFolder); if (entry->isDirectory()) { ((const KArchiveDirectory*) entry)->copyTo(m_destFolder); |