1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
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
|