Commit 5e12c14c authored by Harald Hvaal's avatar Harald Hvaal
Browse files

Adding support for renaming already existing files in archivehandler and in overwritequery.

Progress dialog is now centered on screen for batch extract.

svn path=/trunk/KDE/kdeutils/ark/; revision=857849
parent f938fb09
......@@ -31,6 +31,8 @@
#include <QDir>
#include <QCoreApplication>
#include <QApplication>
#include <QDesktopWidget>
void BatchExtractJob::addExtraction(Kerfuffle::Archive* archive,bool preservePaths, QString destinationFolder)
{
......@@ -197,6 +199,16 @@ bool BatchExtract::startExtraction()
}
tracker->registerJob(allJobs);
//center the progress widget on screen
QWidget *assignedWidget = qobject_cast<KWidgetJobTracker*>(tracker)->widget(allJobs);
if (assignedWidget) {
QRect rect = assignedWidget->geometry();
QRect screen = QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen());
rect.moveCenter(screen.center());
assignedWidget->setGeometry(rect);
}
connect(allJobs, SIGNAL(finished(KJob*)),
QCoreApplication::instance(), SLOT(quit()));
......
......@@ -65,9 +65,11 @@ namespace Kerfuffle
i18n("File already exists"),
KUrl(m_data.value("filename").toString()),
KUrl(m_data.value("filename").toString()),
(KIO::RenameDialog_Mode)(KIO::M_OVERWRITE | KIO::M_MULTI));
(KIO::RenameDialog_Mode)(KIO::M_OVERWRITE | KIO::M_MULTI | KIO::M_SKIP));
dialog.exec();
m_data["newFilename"] = dialog.newDestUrl().path();
setResponse(dialog.result());
}
......@@ -84,5 +86,19 @@ namespace Kerfuffle
return m_data.value("response").toInt() == KIO::R_OVERWRITE;
}
bool OverwriteQuery::responseRename()
{
return m_data.value("response").toInt() == KIO::R_RENAME;
}
bool OverwriteQuery::responseSkip()
{
return m_data.value("response").toInt() == KIO::R_SKIP;
}
QString OverwriteQuery::newFilename()
{
return m_data.value("newFilename").toString();
}
}
......@@ -79,6 +79,9 @@ namespace Kerfuffle
bool responseCancelled();
bool responseOverwriteAll();
bool responseOverwrite();
bool responseRename();
bool responseSkip();
QString newFilename();
};
}
......
......@@ -187,8 +187,10 @@ bool LibArchiveInterface::copyFiles( const QList<QVariant> & files, const QStrin
while ( archive_read_next_header( arch, &entry ) == ARCHIVE_OK )
{
const bool entryIsDir = S_ISDIR(archive_entry_mode( entry ));
//we skip directories of not preserving paths
if (!preservePaths && S_ISDIR(archive_entry_mode( entry ))) {
if (!preservePaths && entryIsDir) {
archive_read_data_skip( arch );
continue;
}
......@@ -223,7 +225,7 @@ bool LibArchiveInterface::copyFiles( const QList<QVariant> & files, const QStrin
entryFI = QFileInfo(truncatedFilename);
}
if (!overwriteAll) {
if (!overwriteAll & !entryIsDir) {
if (entryFI.exists()) {
Kerfuffle::OverwriteQuery query(entryName);
emit userQuery(&query);
......@@ -232,8 +234,21 @@ bool LibArchiveInterface::copyFiles( const QList<QVariant> & files, const QStrin
if (query.responseCancelled()) {
entries.removeAll( entryName );
archive_read_data_skip( arch );
archive_entry_clear( entry );
break;
}
if (query.responseSkip()) {
entries.removeAll( entryName );
archive_read_data_skip( arch );
archive_entry_clear( entry );
continue;
}
if (query.responseRename()) {
QString newName = query.newFilename();
archive_entry_copy_pathname(entry, QFile::encodeName(newName).constData());
}
if (query.responseOverwriteAll())
overwriteAll = true;
......
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