Commit fc66867d authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa
Browse files

Replace all the remaining cases of QPointer usage with QWeakPointer.

svn path=/trunk/KDE/kdeutils/ark/; revision=1186932
parent 53533a71
......@@ -43,8 +43,8 @@
#include <QDir>
#include <QFileInfo>
#include <QPointer>
#include <QTimer>
#include <QWeakPointer>
BatchExtract::BatchExtract()
: m_autoSubfolder(false),
......@@ -252,34 +252,35 @@ void BatchExtract::setPreservePaths(bool value)
bool BatchExtract::showExtractDialog()
{
QPointer<Kerfuffle::ExtractionDialog> dialog = new Kerfuffle::ExtractionDialog();
QWeakPointer<Kerfuffle::ExtractionDialog> dialog =
new Kerfuffle::ExtractionDialog;
if (m_inputs.size() > 1) {
dialog->batchModeOption();
dialog.data()->batchModeOption();
}
dialog->setAutoSubfolder(autoSubfolder());
dialog->setCurrentUrl(destinationFolder());
dialog->setPreservePaths(preservePaths());
dialog.data()->setAutoSubfolder(autoSubfolder());
dialog.data()->setCurrentUrl(destinationFolder());
dialog.data()->setPreservePaths(preservePaths());
if (m_inputs.size() == 1) {
if (m_inputs.at(0)->isSingleFolderArchive()) {
dialog->setSingleFolderArchive(true);
dialog.data()->setSingleFolderArchive(true);
}
dialog->setSubfolder(m_inputs.at(0)->subfolderName());
dialog.data()->setSubfolder(m_inputs.at(0)->subfolderName());
}
if (!dialog->exec()) {
delete dialog;
if (!dialog.data()->exec()) {
delete dialog.data();
return false;
}
setAutoSubfolder(dialog->autoSubfolders());
setDestinationFolder(dialog->destinationDirectory().pathOrUrl());
setOpenDestinationAfterExtraction(dialog->openDestinationAfterExtraction());
setPreservePaths(dialog->preservePaths());
setAutoSubfolder(dialog.data()->autoSubfolders());
setDestinationFolder(dialog.data()->destinationDirectory().pathOrUrl());
setOpenDestinationAfterExtraction(dialog.data()->openDestinationAfterExtraction());
setPreservePaths(dialog.data()->preservePaths());
delete dialog;
delete dialog.data();
return true;
}
......
......@@ -41,7 +41,7 @@
#include <QDragEnterEvent>
#include <QDragMoveEvent>
#include <QPointer>
#include <QWeakPointer>
static bool isValidArchiveDrag(const QMimeData *data)
{
......@@ -179,14 +179,14 @@ void MainWindow::editToolbars()
{
saveMainWindowSettings(KGlobal::config()->group(QLatin1String("MainWindow")));
QPointer<KEditToolBar> dlg = new KEditToolBar(factory(), this);
dlg->exec();
QWeakPointer<KEditToolBar> dlg = new KEditToolBar(factory(), this);
dlg.data()->exec();
createGUI(m_part);
applyMainWindowSettings(KGlobal::config()->group(QLatin1String("MainWindow")));
delete dlg;
delete dlg.data();
}
void MainWindow::openArchive()
......
......@@ -40,8 +40,8 @@
#include <QFileInfo>
#include <QDir>
#include <QPointer>
#include <QTimer>
#include <QWeakPointer>
namespace Kerfuffle
{
......@@ -76,23 +76,23 @@ void AddToArchive::setMimeType(const QString & mimeType)
bool AddToArchive::showAddDialog(void)
{
QPointer<Kerfuffle::AddDialog> dialog = new Kerfuffle::AddDialog(
QWeakPointer<Kerfuffle::AddDialog> dialog = new Kerfuffle::AddDialog(
m_inputs, // itemsToAdd
KUrl(m_firstPath), // startDir
QLatin1String( "" ), // filter
NULL, // parent
NULL); // widget
bool ret = dialog->exec();
bool ret = dialog.data()->exec();
if (ret) {
kDebug() << "Returned URL:" << dialog->selectedUrl();
kDebug() << "Returned mime:" << dialog->currentMimeFilter();
setFilename(dialog->selectedUrl());
setMimeType(dialog->currentMimeFilter());
kDebug() << "Returned URL:" << dialog.data()->selectedUrl();
kDebug() << "Returned mime:" << dialog.data()->currentMimeFilter();
setFilename(dialog.data()->selectedUrl());
setMimeType(dialog.data()->currentMimeFilter());
}
delete dialog;
delete dialog.data();
return ret;
}
......
......@@ -33,7 +33,7 @@
#include <kio/renamedialog.h>
#include <QApplication>
#include <QPointer>
#include <QWeakPointer>
namespace Kerfuffle
{
......@@ -91,19 +91,19 @@ void OverwriteQuery::execute()
sourceUrl.cleanPath();
destUrl.cleanPath();
QPointer<KIO::RenameDialog> dialog = new KIO::RenameDialog(
QWeakPointer<KIO::RenameDialog> dialog = new KIO::RenameDialog(
NULL,
i18n("File already exists"),
sourceUrl,
destUrl,
mode);
dialog->exec();
dialog.data()->exec();
m_data[QLatin1String( "newFilename" )] = dialog->newDestUrl().pathOrUrl();
m_data[QLatin1String("newFilename")] = dialog.data()->newDestUrl().pathOrUrl();
setResponse(dialog->result());
setResponse(dialog.data()->result());
delete dialog;
delete dialog.data();
QApplication::restoreOverrideCursor();
}
......@@ -173,23 +173,23 @@ void PasswordNeededQuery::execute()
// at the moment (#231974)
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
QPointer<KPasswordDialog> dlg = new KPasswordDialog;
dlg->setPrompt(i18n("The archive '%1' is password protected. Please enter the password to extract the file.", m_data.value(QLatin1String( "archiveFilename" )).toString()));
QWeakPointer<KPasswordDialog> dlg = new KPasswordDialog;
dlg.data()->setPrompt(i18n("The archive '%1' is password protected. Please enter the password to extract the file.", m_data.value(QLatin1String( "archiveFilename" )).toString()));
if (m_data.value(QLatin1String( "incorrectTryAgain" )).toBool()) {
dlg->showErrorMessage(i18n("Incorrect password, please try again."), KPasswordDialog::PasswordError);
if (m_data.value(QLatin1String("incorrectTryAgain")).toBool()) {
dlg.data()->showErrorMessage(i18n("Incorrect password, please try again."), KPasswordDialog::PasswordError);
}
if (!dlg->exec()) {
if (!dlg.data()->exec()) {
setResponse(false);
} else {
m_data[QLatin1String( "password" )] = dlg->password();
m_data[QLatin1String("password")] = dlg.data()->password();
setResponse(true);
}
QApplication::restoreOverrideCursor();
delete dlg;
delete dlg.data();
}
QString PasswordNeededQuery::password()
......
......@@ -60,10 +60,10 @@
#include <QMenu>
#include <QMimeData>
#include <QMouseEvent>
#include <QPointer>
#include <QSplitter>
#include <QTimer>
#include <QVBoxLayout>
#include <QWeakPointer>
#include <QtDBus/QtDBus>
using namespace Kerfuffle;
......@@ -578,28 +578,28 @@ void Part::slotExtractFiles()
return;
}
QPointer<Kerfuffle::ExtractionDialog> dialog = new Kerfuffle::ExtractionDialog();
QWeakPointer<Kerfuffle::ExtractionDialog> dialog = new Kerfuffle::ExtractionDialog;
if (m_view->selectionModel()->selectedRows().count() > 0) {
dialog->setShowSelectedFiles(true);
dialog.data()->setShowSelectedFiles(true);
}
dialog->setSingleFolderArchive(isSingleFolderArchive());
dialog->setSubfolder(detectSubfolder());
dialog.data()->setSingleFolderArchive(isSingleFolderArchive());
dialog.data()->setSubfolder(detectSubfolder());
dialog->setCurrentUrl(QFileInfo(m_model->archive()->fileName()).path());
dialog.data()->setCurrentUrl(QFileInfo(m_model->archive()->fileName()).path());
if (dialog->exec()) {
if (dialog.data()->exec()) {
//this is done to update the quick extract menu
updateActions();
m_destinationDirectory = dialog->destinationDirectory().pathOrUrl();
m_destinationDirectory = dialog.data()->destinationDirectory().pathOrUrl();
QVariantList files;
//if the user has chosen to extract only selected entries, fetch these
//from the listview
if (!dialog->extractAllFiles()) {
if (!dialog.data()->extractAllFiles()) {
files = selectedFilesWithChildren();
}
......@@ -607,8 +607,8 @@ void Part::slotExtractFiles()
Kerfuffle::ExtractionOptions options;
if (dialog->preservePaths())
options[QLatin1String( "PreservePaths" )] = true;
if (dialog.data()->preservePaths())
options[QLatin1String("PreservePaths")] = true;
ExtractJob *job = m_model->extractFiles(files, m_destinationDirectory, options);
registerJob(job);
......@@ -619,7 +619,7 @@ void Part::slotExtractFiles()
job->start();
}
delete dialog;
delete dialog.data();
}
QList<QVariant> Part::selectedFilesWithChildren()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment