mirror of
git://slackware.nl/current.git
synced 2025-01-10 05:25:51 +01:00
102 lines
3.7 KiB
Diff
102 lines
3.7 KiB
Diff
|
From 5cffbe5ecf1f82369abbad1a06154368459f7845 Mon Sep 17 00:00:00 2001
|
||
|
From: Dag Andersen <danders@get2net.dk>
|
||
|
Date: Mon, 22 Aug 2016 09:20:32 +0200
|
||
|
Subject: [PATCH 67/80] Backport: Plan: Fix insert file
|
||
|
|
||
|
Use KUrl instead of QString for filename
|
||
|
KoDocument::openUrl() opens the url (not KoPart)
|
||
|
---
|
||
|
plan/kptmaindocument.cpp | 23 ++++++++++-------------
|
||
|
plan/kptmaindocument.h | 4 ++--
|
||
|
plan/kptview.cpp | 2 +-
|
||
|
3 files changed, 13 insertions(+), 16 deletions(-)
|
||
|
|
||
|
diff --git a/plan/kptmaindocument.cpp b/plan/kptmaindocument.cpp
|
||
|
index 2343471..e418972 100644
|
||
|
--- a/plan/kptmaindocument.cpp
|
||
|
+++ b/plan/kptmaindocument.cpp
|
||
|
@@ -947,35 +947,32 @@ bool MainDocument::loadAndParse(KoStore *store, const QString &filename, KoXmlDo
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
-void MainDocument::insertFile( const QString &filename, Node *parent, Node *after )
|
||
|
+void MainDocument::insertFile( const KUrl &url, Node *parent, Node *after )
|
||
|
{
|
||
|
Part *part = new Part( this );
|
||
|
MainDocument *doc = new MainDocument( part );
|
||
|
part->setDocument( doc );
|
||
|
doc->disconnect(); // doc shall not handle feedback from openUrl()
|
||
|
doc->setAutoSave( 0 ); //disable
|
||
|
- doc->m_insertFileInfo.url = filename;
|
||
|
+ doc->m_insertFileInfo.url = url;
|
||
|
doc->m_insertFileInfo.parent = parent;
|
||
|
doc->m_insertFileInfo.after = after;
|
||
|
connect(doc, SIGNAL(completed()), SLOT(insertFileCompleted()));
|
||
|
connect(doc, SIGNAL(canceled(QString)), SLOT(insertFileCancelled(QString)));
|
||
|
|
||
|
- doc->openUrl( KUrl( filename ) );
|
||
|
+ doc->openUrl( url );
|
||
|
}
|
||
|
|
||
|
void MainDocument::insertFileCompleted()
|
||
|
{
|
||
|
kDebug(planDbg())<<sender();
|
||
|
- Part *part = qobject_cast<Part*>( sender() );
|
||
|
- if ( part ) {
|
||
|
- MainDocument *doc = qobject_cast<MainDocument*>( part->document() );
|
||
|
- if ( doc ) {
|
||
|
- Project &p = doc->getProject();
|
||
|
- insertProject( p, doc->m_insertFileInfo.parent, doc->m_insertFileInfo.after );
|
||
|
- } else {
|
||
|
- KMessageBox::error( 0, i18n("Internal error, failed to insert file.") );
|
||
|
- }
|
||
|
- part->deleteLater(); // also deletes document
|
||
|
+ MainDocument *doc = qobject_cast<MainDocument*>( sender() );
|
||
|
+ if ( doc ) {
|
||
|
+ Project &p = doc->getProject();
|
||
|
+ insertProject( p, doc->m_insertFileInfo.parent, doc->m_insertFileInfo.after );
|
||
|
+ doc->documentPart()->deleteLater(); // also deletes document
|
||
|
+ } else {
|
||
|
+ KMessageBox::error( 0, i18n("Internal error, failed to insert file.") );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
diff --git a/plan/kptmaindocument.h b/plan/kptmaindocument.h
|
||
|
index 5ead4ea..c467e1f 100644
|
||
|
--- a/plan/kptmaindocument.h
|
||
|
+++ b/plan/kptmaindocument.h
|
||
|
@@ -117,7 +117,7 @@ public:
|
||
|
Package *loadWorkPackageXML( Project& project, QIODevice*, const KoXmlDocument& document, const KUrl& url );
|
||
|
QMap<KDateTime, Package*> workPackages() const { return m_workpackages; }
|
||
|
|
||
|
- void insertFile( const QString &filename, Node *parent, Node *after = 0 );
|
||
|
+ void insertFile( const KUrl &url, Node *parent, Node *after = 0 );
|
||
|
bool insertProject( Project &project, Node *parent, Node *after );
|
||
|
|
||
|
KPlatoAboutPage &aboutPage() { return m_aboutPage; }
|
||
|
@@ -165,7 +165,7 @@ protected:
|
||
|
|
||
|
// used by insert file
|
||
|
struct InsertFileInfo {
|
||
|
- QString url;
|
||
|
+ KUrl url;
|
||
|
Node *parent;
|
||
|
Node *after;
|
||
|
} m_insertFileInfo;
|
||
|
diff --git a/plan/kptview.cpp b/plan/kptview.cpp
|
||
|
index 6876c3e..b38d8b6 100644
|
||
|
--- a/plan/kptview.cpp
|
||
|
+++ b/plan/kptview.cpp
|
||
|
@@ -1452,7 +1452,7 @@ void View::slotInsertFileFinished( int result )
|
||
|
return;
|
||
|
}
|
||
|
if ( result == QDialog::Accepted ) {
|
||
|
- getPart()->insertFile( dlg->url().url(), dlg->parentNode(), dlg->afterNode() );
|
||
|
+ getPart()->insertFile( dlg->url(), dlg->parentNode(), dlg->afterNode() );
|
||
|
}
|
||
|
dlg->deleteLater();
|
||
|
}
|
||
|
--
|
||
|
2.7.4
|
||
|
|