mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
ark: mark URL as modified in the part upon adding or deleting
required the following commit from kdelibs to actually save: 319ebf4d2089a167b2a9e1f746eb52cd54dec150 Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
763d88a96d
commit
bc2a235c3b
3 changed files with 59 additions and 32 deletions
|
@ -251,9 +251,10 @@ void MainWindow::newArchive()
|
||||||
|
|
||||||
kDebug() << "Supported mimetypes are" << mimeTypes.join( QLatin1String( " " ));
|
kDebug() << "Supported mimetypes are" << mimeTypes.join( QLatin1String( " " ));
|
||||||
|
|
||||||
const KUrl saveFileUrl =
|
const KUrl saveFileUrl = KFileDialog::getSaveUrl(
|
||||||
KFileDialog::getSaveUrl(KUrl("kfiledialog:///ArkNewDir"),
|
KUrl("kfiledialog:///ArkNewDir"),
|
||||||
mimeTypes.join(QLatin1String(" ")));
|
mimeTypes.join(QLatin1String(" "))
|
||||||
|
);
|
||||||
|
|
||||||
m_openArgs.metaData()[QLatin1String( "createNewArchive" )] = QLatin1String( "true" );
|
m_openArgs.metaData()[QLatin1String( "createNewArchive" )] = QLatin1String( "true" );
|
||||||
|
|
||||||
|
|
|
@ -390,29 +390,37 @@ KAboutData* Part::createAboutData()
|
||||||
|
|
||||||
bool Part::openFile()
|
bool Part::openFile()
|
||||||
{
|
{
|
||||||
const QString localFile(localFilePath());
|
const QString localFile = localFilePath();
|
||||||
const QFileInfo localFileInfo(localFile);
|
const QFileInfo localFileInfo(localFile);
|
||||||
const bool creatingNewArchive =
|
const bool creatingNewArchive =
|
||||||
arguments().metaData()[QLatin1String("createNewArchive")] == QLatin1String("true");
|
arguments().metaData()[QLatin1String("createNewArchive")] == QLatin1String("true");
|
||||||
|
|
||||||
if (localFileInfo.isDir()) {
|
if (localFileInfo.isDir()) {
|
||||||
KMessageBox::error(NULL, i18nc("@info",
|
KMessageBox::error(
|
||||||
"<tt>%1</tt> is a directory.",
|
NULL,
|
||||||
localFile));
|
i18nc("@info", "<tt>%1</tt> is a directory.", localFile)
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (creatingNewArchive) {
|
if (creatingNewArchive) {
|
||||||
if (localFileInfo.exists()) {
|
if (localFileInfo.exists()) {
|
||||||
int overwrite = KMessageBox::questionYesNo(NULL, i18nc("@info", "The archive <tt>%1</tt> already exists. Would you like to open it instead?", localFile), i18nc("@title:window", "File Exists"), KGuiItem(i18n("Open File")), KStandardGuiItem::cancel());
|
int overwrite = KMessageBox::questionYesNo(
|
||||||
|
NULL,
|
||||||
|
i18nc("@info", "The archive <tt>%1</tt> already exists. Would you like to open it instead?", localFile),
|
||||||
|
i18nc("@title:window", "File Exists"), KGuiItem(i18n("Open File")), KStandardGuiItem::cancel()
|
||||||
|
);
|
||||||
if (overwrite == KMessageBox::No) {
|
if (overwrite == KMessageBox::No) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!localFileInfo.exists()) {
|
if (!localFileInfo.exists()) {
|
||||||
KMessageBox::sorry(NULL, i18nc("@info", "The archive <tt>%1</tt> was not found.", localFile), i18nc("@title:window", "Error Opening Archive"));
|
KMessageBox::sorry(
|
||||||
|
NULL,
|
||||||
|
i18nc("@info", "The archive <tt>%1</tt> was not found.", localFile),
|
||||||
|
i18nc("@title:window", "Error Opening Archive")
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -440,7 +448,7 @@ bool Part::openFile()
|
||||||
QStringList mimeComments(mimeTypes.values());
|
QStringList mimeComments(mimeTypes.values());
|
||||||
mimeComments.sort();
|
mimeComments.sort();
|
||||||
|
|
||||||
bool ok;
|
bool ok = false;
|
||||||
QString item;
|
QString item;
|
||||||
|
|
||||||
if (creatingNewArchive) {
|
if (creatingNewArchive) {
|
||||||
|
@ -465,7 +473,11 @@ bool Part::openFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!archive) {
|
if (!archive) {
|
||||||
KMessageBox::sorry(NULL, i18nc("@info", "Ark was not able to open the archive <tt>%1</tt>. No plugin capable of handling the file was found.", localFile), i18nc("@title:window", "Error Opening Archive"));
|
KMessageBox::sorry(
|
||||||
|
NULL,
|
||||||
|
i18nc("@info", "Ark was not able to open the archive <tt>%1</tt>. No plugin capable of handling the file was found.", localFile),
|
||||||
|
i18nc("@title:window", "Error Opening Archive")
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +511,11 @@ void Part::slotLoadingFinished(KJob *job)
|
||||||
{
|
{
|
||||||
if (job->error() != KJob::NoError) {
|
if (job->error() != KJob::NoError) {
|
||||||
if (arguments().metaData()[QLatin1String( "createNewArchive" )] != QLatin1String( "true" )) {
|
if (arguments().metaData()[QLatin1String( "createNewArchive" )] != QLatin1String( "true" )) {
|
||||||
KMessageBox::sorry(NULL, i18nc("@info", "Loading the archive <tt>%1</tt> failed with the following error: <i>%2</i>", localFilePath(), job->errorText()), i18nc("@title:window", "Error Opening Archive"));
|
KMessageBox::sorry(
|
||||||
|
NULL,
|
||||||
|
i18nc("@info", "Loading the archive <tt>%1</tt> failed with the following error: <i>%2</i>", localFilePath(), job->errorText()),
|
||||||
|
i18nc("@title:window", "Error Opening Archive")
|
||||||
|
);
|
||||||
|
|
||||||
// The file failed to open, so reset the open archive, info panel and caption.
|
// The file failed to open, so reset the open archive, info panel and caption.
|
||||||
m_model->setArchive(NULL);
|
m_model->setArchive(NULL);
|
||||||
|
@ -585,8 +601,7 @@ void Part::slotPreviewExtracted(KJob *job)
|
||||||
// if there's an error or an overwrite dialog,
|
// if there's an error or an overwrite dialog,
|
||||||
// the preview dialog will be launched anyway
|
// the preview dialog will be launched anyway
|
||||||
if (!job->error()) {
|
if (!job->error()) {
|
||||||
const ArchiveEntry& entry =
|
const ArchiveEntry& entry = m_model->entryForIndex(m_view->selectionModel()->currentIndex());
|
||||||
m_model->entryForIndex(m_view->selectionModel()->currentIndex());
|
|
||||||
|
|
||||||
ExtractJob *extractJob = qobject_cast<ExtractJob*>(job);
|
ExtractJob *extractJob = qobject_cast<ExtractJob*>(job);
|
||||||
Q_ASSERT(extractJob);
|
Q_ASSERT(extractJob);
|
||||||
|
@ -799,8 +814,7 @@ void Part::slotAddFiles(const QStringList& filesToAdd, const QString& path)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(job, SIGNAL(result(KJob*)),
|
connect(job, SIGNAL(result(KJob*)), this, SLOT(slotAddFilesDone(KJob*)));
|
||||||
this, SLOT(slotAddFilesDone(KJob*)));
|
|
||||||
registerJob(job);
|
registerJob(job);
|
||||||
job->start();
|
job->start();
|
||||||
}
|
}
|
||||||
|
@ -842,6 +856,8 @@ void Part::slotAddFilesDone(KJob* job)
|
||||||
{
|
{
|
||||||
if (job->error() != KJob::NoError) {
|
if (job->error() != KJob::NoError) {
|
||||||
KMessageBox::error(widget(), job->errorString());
|
KMessageBox::error(widget(), job->errorString());
|
||||||
|
} else {
|
||||||
|
setModified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,6 +865,8 @@ void Part::slotDeleteFilesDone(KJob* job)
|
||||||
{
|
{
|
||||||
if (job->error() != KJob::NoError) {
|
if (job->error() != KJob::NoError) {
|
||||||
KMessageBox::error(widget(), job->errorString());
|
KMessageBox::error(widget(), job->errorString());
|
||||||
|
} else {
|
||||||
|
setModified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -869,8 +887,7 @@ void Part::slotDeleteFiles()
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteJob *job = m_model->deleteFiles(selectedFilesWithChildren());
|
DeleteJob *job = m_model->deleteFiles(selectedFilesWithChildren());
|
||||||
connect(job, SIGNAL(result(KJob*)),
|
connect(job, SIGNAL(result(KJob*)), this, SLOT(slotDeleteFilesDone(KJob*)));
|
||||||
this, SLOT(slotDeleteFilesDone(KJob*)));
|
|
||||||
registerJob(job);
|
registerJob(job);
|
||||||
job->start();
|
job->start();
|
||||||
}
|
}
|
||||||
|
@ -899,15 +916,20 @@ void Part::saveSplitterSizes()
|
||||||
|
|
||||||
void Part::slotSaveAs()
|
void Part::slotSaveAs()
|
||||||
{
|
{
|
||||||
KUrl saveUrl = KFileDialog::getSaveUrl(KUrl(QLatin1String( "kfiledialog:///ArkSaveAs/" ) + url().fileName()), QString(), widget());
|
KUrl saveUrl = KFileDialog::getSaveUrl(
|
||||||
|
KUrl(QLatin1String( "kfiledialog:///ArkSaveAs/" ) + url().fileName()),
|
||||||
|
QString(),
|
||||||
|
widget()
|
||||||
|
);
|
||||||
|
|
||||||
if ((saveUrl.isValid()) && (!saveUrl.isEmpty())) {
|
if ((saveUrl.isValid()) && (!saveUrl.isEmpty())) {
|
||||||
if (KIO::NetAccess::exists(saveUrl, KIO::NetAccess::DestinationSide, widget())) {
|
if (KIO::NetAccess::exists(saveUrl, KIO::NetAccess::DestinationSide, widget())) {
|
||||||
int overwrite = KMessageBox::warningContinueCancel(widget(),
|
int overwrite = KMessageBox::warningContinueCancel(
|
||||||
|
widget(),
|
||||||
i18nc("@info", "An archive named <tt>%1</tt> already exists. Are you sure you want to overwrite it?", saveUrl.fileName()),
|
i18nc("@info", "An archive named <tt>%1</tt> already exists. Are you sure you want to overwrite it?", saveUrl.fileName()),
|
||||||
QString(),
|
QString(),
|
||||||
KStandardGuiItem::overwrite());
|
KStandardGuiItem::overwrite()
|
||||||
|
);
|
||||||
if (overwrite != KMessageBox::Continue) {
|
if (overwrite != KMessageBox::Continue) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -917,9 +939,10 @@ void Part::slotSaveAs()
|
||||||
|
|
||||||
if (!QFile::exists(localFilePath())) {
|
if (!QFile::exists(localFilePath())) {
|
||||||
if (url().isLocalFile()) {
|
if (url().isLocalFile()) {
|
||||||
KMessageBox::error(widget(),
|
KMessageBox::error(
|
||||||
i18nc("@info", "The archive <tt>%1</tt> cannot be copied to the specified location. The archive does not exist anymore.", localFilePath()));
|
widget(),
|
||||||
|
i18nc("@info", "The archive <tt>%1</tt> cannot be copied to the specified location. The archive does not exist anymore.", localFilePath())
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
srcUrl = url();
|
srcUrl = url();
|
||||||
|
@ -929,8 +952,10 @@ void Part::slotSaveAs()
|
||||||
KIO::Job *copyJob = KIO::file_copy(srcUrl, saveUrl, -1, KIO::Overwrite);
|
KIO::Job *copyJob = KIO::file_copy(srcUrl, saveUrl, -1, KIO::Overwrite);
|
||||||
|
|
||||||
if (!KIO::NetAccess::synchronousRun(copyJob, widget())) {
|
if (!KIO::NetAccess::synchronousRun(copyJob, widget())) {
|
||||||
KMessageBox::error(widget(),
|
KMessageBox::error(
|
||||||
i18nc("@info", "The archive could not be saved as <tt>%1</tt>. Try saving it to another location.", saveUrl.pathOrUrl()));
|
widget(),
|
||||||
|
i18nc("@info", "The archive could not be saved as <tt>%1</tt>. Try saving it to another location.", saveUrl.pathOrUrl())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,10 +55,11 @@ public:
|
||||||
|
|
||||||
Part(QWidget *parentWidget, QObject *parent, const QVariantList &);
|
Part(QWidget *parentWidget, QObject *parent, const QVariantList &);
|
||||||
~Part();
|
~Part();
|
||||||
|
|
||||||
static KAboutData* createAboutData();
|
static KAboutData* createAboutData();
|
||||||
|
|
||||||
virtual bool openFile();
|
bool openFile() final;
|
||||||
virtual bool saveFile();
|
bool saveFile() final;
|
||||||
|
|
||||||
bool isBusy() const;
|
bool isBusy() const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue