summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Fischer <[email protected]>2014-10-21 10:43:09 +0200
committerAndi Fischer <[email protected]>2014-10-21 20:17:50 +0200
commitb3fa5a7d30978df688c9448a81614f28d2a07015 (patch)
tree19666e86148d0068b8392d4cf24313692d0bb7e9
parentc0948694daa5b6172cbfb08be22fc18eb8bea2e3 (diff)
KUrl --> QUrl
-rw-r--r--umbrello/codegenerators/codegenobjectwithtextblocks.cpp43
-rw-r--r--umbrello/codegenwizard/codegenstatuspage.cpp2
-rw-r--r--umbrello/codeimpwizard/codeimpstatuspage.cpp2
-rw-r--r--umbrello/dialogs/umlfiledialog.cpp10
-rw-r--r--umbrello/dialogs/umlfiledialog.h9
-rw-r--r--umbrello/docgenerators/docbookgenerator.cpp6
-rw-r--r--umbrello/folder.cpp6
-rw-r--r--umbrello/main.cpp8
-rw-r--r--umbrello/uml.cpp4
-rw-r--r--umbrello/umldoc.cpp95
-rw-r--r--umbrello/umldoc.h15
-rw-r--r--umbrello/umllistview.cpp4
-rw-r--r--umbrello/umlviewimageexporter.cpp12
-rw-r--r--umbrello/umlviewimageexporter.h7
-rw-r--r--umbrello/umlviewimageexporterall.cpp7
15 files changed, 98 insertions, 132 deletions
diff --git a/umbrello/codegenerators/codegenobjectwithtextblocks.cpp b/umbrello/codegenerators/codegenobjectwithtextblocks.cpp
index 45b88fa..b5073ea 100644
--- a/umbrello/codegenerators/codegenobjectwithtextblocks.cpp
+++ b/umbrello/codegenerators/codegenobjectwithtextblocks.cpp
@@ -336,48 +336,7 @@ void CodeGenObjectWithTextBlocks::resetTextBlocks()
TextBlock *tb;
for (TextBlockListIt it(m_textblockVector); (tb = it.current()) != NULL; ++it)
delete tb;
- ************** else the following crash happens on loading an XMI file:
- Invalid read of size 4
- at 0x8134BAA: QString::QString(QString const&) (qstring.h:650)
- by 0x8331EE5: TextBlock::getTag() const (textblock.cpp:103)
- by 0x82C4634: ClassifierCodeDocument::findCodeClassFieldTextBlockByTag(QString const&) (classifiercodedocument.cpp:730)
- by 0x82F3940: HierarchicalCodeBlock::findCodeClassFieldTextBlockByTag(QString const&) (hierarchicalcodeblock.cpp:366)
- by 0x82D71DC: CodeGenObjectWithTextBlocks::loadChildTextBlocksFromNode(QDomElement&) (codegenobjectwithtextblocks.cpp:422)
- by 0x82D6DFF: CodeGenObjectWithTextBlocks::setAttributesFromNode(QDomElement&) (codegenobjectwithtextblocks.cpp:373)
- by 0x82F3412: HierarchicalCodeBlock::setAttributesFromNode(QDomElement&) (hierarchicalcodeblock.cpp:290)
- by 0x82F3248: HierarchicalCodeBlock::loadFromXMI(QDomElement&) (hierarchicalcodeblock.cpp:269)
- by 0x82D760F: CodeGenObjectWithTextBlocks::loadChildTextBlocksFromNode(QDomElement&) (codegenobjectwithtextblocks.cpp:453)
- by 0x82D6DFF: CodeGenObjectWithTextBlocks::setAttributesFromNode(QDomElement&) (codegenobjectwithtextblocks.cpp:373)
- by 0x82CFB9C: CodeDocument::setAttributesFromNode(QDomElement&) (codedocument.cpp:414)
- by 0x82C3CAE: ClassifierCodeDocument::setAttributesFromNode(QDomElement&) (classifiercodedocument.cpp:595)
- by 0x82C4388: ClassifierCodeDocument::loadFromXMI(QDomElement&) (classifiercodedocument.cpp:687)
- by 0x82D372E: CodeGenerator::loadFromXMI(QDomElement&) (codegenerator.cpp:205)
- by 0x8356381: UMLDoc::loadExtensionsFromXMI(QDomNode&) (umldoc.cpp:1774)
- by 0x8353F16: UMLDoc::loadFromXMI(QIODevice&, short) (umldoc.cpp:1480)
- by 0x834DBB6: UMLDoc::openDocument(KUrl const&, char const*) (umldoc.cpp:475)
- by 0x833F0DE: UMLApp::openDocumentFile(KUrl const&) (uml.cpp:642)
- by 0x83098D9: initDocument(KCmdLineArgs*) (main.cpp:125)
- by 0x830974D: main (main.cpp:101)
- Address 0x66539DC is 12 bytes inside a block of size 68 free'd
- at 0x401D567: operator delete(void*) (vg_replace_malloc.c:244)
- by 0x8204CA2: CPPSourceCodeAccessorMethod::~CPPSourceCodeAccessorMethod() (cppsourcecodeaccessormethod.cpp:51)
- by 0x82D6C6D: CodeGenObjectWithTextBlocks::resetTextBlocks() (codegenobjectwithtextblocks.cpp:333)
- by 0x82D6001: CodeGenObjectWithTextBlocks::~CodeGenObjectWithTextBlocks() (codegenobjectwithtextblocks.cpp:42)
- by 0x82F272A: HierarchicalCodeBlock::~HierarchicalCodeBlock() (hierarchicalcodeblock.cpp:41)
- by 0x82D6C6D: CodeGenObjectWithTextBlocks::resetTextBlocks() (codegenobjectwithtextblocks.cpp:333)
- by 0x82CF294: CodeDocument::resetTextBlocks() (codedocument.cpp:330)
- by 0x82026EC: CPPSourceCodeDocument::resetTextBlocks() (cppsourcecodedocument.cpp:111)
- by 0x82D6DE7: CodeGenObjectWithTextBlocks::setAttributesFromNode(QDomElement&) (codegenobjectwithtextblocks.cpp:370)
- by 0x82CFB9C: CodeDocument::setAttributesFromNode(QDomElement&) (codedocument.cpp:414)
- by 0x82C3CAE: ClassifierCodeDocument::setAttributesFromNode(QDomElement&) (classifiercodedocument.cpp:595)
- by 0x82C4388: ClassifierCodeDocument::loadFromXMI(QDomElement&) (classifiercodedocument.cpp:687)
- by 0x82D372E: CodeGenerator::loadFromXMI(QDomElement&) (codegenerator.cpp:205)
- by 0x8356381: UMLDoc::loadExtensionsFromXMI(QDomNode&) (umldoc.cpp:1774)
- by 0x8353F16: UMLDoc::loadFromXMI(QIODevice&, short) (umldoc.cpp:1480)
- by 0x834DBB6: UMLDoc::openDocument(KUrl const&, char const*) (umldoc.cpp:475)
- by 0x833F0DE: UMLApp::openDocumentFile(KUrl const&) (uml.cpp:642)
- by 0x83098D9: initDocument(KCmdLineArgs*) (main.cpp:125)
- by 0x830974D: main (main.cpp:101)
+ ************** else crash happens on loading an XMI file
*************/
m_textBlockTagMap.clear();
diff --git a/umbrello/codegenwizard/codegenstatuspage.cpp b/umbrello/codegenwizard/codegenstatuspage.cpp
index ca4156d..b535534 100644
--- a/umbrello/codegenwizard/codegenstatuspage.cpp
+++ b/umbrello/codegenwizard/codegenstatuspage.cpp
@@ -211,7 +211,7 @@ void CodeGenStatusPage::loggerClear()
void CodeGenStatusPage::loggerExport()
{
const QString caption = i18n("Umbrello Code Generation - Logger Export");
- QString fileName = KFileDialog::getSaveFileName(KUrl(), QString(), 0, caption);
+ QString fileName = KFileDialog::getSaveFileName(QUrl(), QString(), 0, caption);
if (!fileName.isEmpty()) {
QFile file(fileName);
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
diff --git a/umbrello/codeimpwizard/codeimpstatuspage.cpp b/umbrello/codeimpwizard/codeimpstatuspage.cpp
index fb52dae..258ca40 100644
--- a/umbrello/codeimpwizard/codeimpstatuspage.cpp
+++ b/umbrello/codeimpwizard/codeimpstatuspage.cpp
@@ -327,7 +327,7 @@ void CodeImpStatusPage::loggerClear()
void CodeImpStatusPage::loggerExport()
{
const QString caption = i18n("Umbrello Code Import - Logger Export");
- QString fileName = KFileDialog::getSaveFileName(KUrl(), QString(), 0, caption);
+ QString fileName = KFileDialog::getSaveFileName(QUrl(), QString(), 0, caption);
if (!fileName.isEmpty()) {
QFile file(fileName);
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
diff --git a/umbrello/dialogs/umlfiledialog.cpp b/umbrello/dialogs/umlfiledialog.cpp
index ee5b0df..400277f 100644
--- a/umbrello/dialogs/umlfiledialog.cpp
+++ b/umbrello/dialogs/umlfiledialog.cpp
@@ -21,7 +21,7 @@
static QStringList mime2KdeFilter(const QStringList &mimeTypes, QString *allExtensions = 0)
{
- const KUrl emptyUrl;
+ const QUrl emptyUrl;
QStringList kdeFilter;
QStringList allExt;
QMimeDatabase db;
@@ -46,7 +46,7 @@ static QStringList mime2KdeFilter(const QStringList &mimeTypes, QString *allExte
}
-UMLFileDialog::UMLFileDialog(const KUrl &startDir, const QString &filter, QWidget *parent, QWidget *widget)
+UMLFileDialog::UMLFileDialog(const QUrl &startDir, const QString &filter, QWidget *parent, QWidget *widget)
: m_dialog(new KFileDialog(startDir, filter, parent, widget))
{
}
@@ -73,12 +73,12 @@ void UMLFileDialog::setOperationMode(KFileDialog::OperationMode mode)
m_dialog->setOperationMode(mode);
}
-void UMLFileDialog::setUrl(const KUrl &url, bool clearforward)
+void UMLFileDialog::setUrl(const QUrl &url, bool clearforward)
{
m_dialog->setUrl(url, clearforward);
}
-KUrl UMLFileDialog::selectedUrl()
+QUrl UMLFileDialog::selectedUrl()
{
return m_dialog->selectedUrl();
}
@@ -104,7 +104,7 @@ void UMLFileDialog::setMimeFilter(const QStringList &types, const QString &defau
*/
QString UMLFileDialog::currentMimeFilter()
{
- KUrl url = m_dialog->selectedUrl();
+ QUrl url = m_dialog->selectedUrl();
QFileInfo fi(url.toLocalFile());
return UMLViewImageExporterModel::imageTypeToMimeType(fi.suffix());
}
diff --git a/umbrello/dialogs/umlfiledialog.h b/umbrello/dialogs/umlfiledialog.h
index 22206e4..44fce0e 100644
--- a/umbrello/dialogs/umlfiledialog.h
+++ b/umbrello/dialogs/umlfiledialog.h
@@ -12,7 +12,8 @@
#define UMLFILEDIALOG_H
#include <kfiledialog.h>
-#include <kurl.h>
+
+#include <QUrl>
/**
* Wrapper class for KFileDialog supporting graphviz *.dot files.
@@ -27,14 +28,14 @@ class UMLFileDialog : public QObject
{
Q_OBJECT
public:
- UMLFileDialog(const KUrl &startDir, const QString &filter, QWidget *parent, QWidget *widget=0);
+ UMLFileDialog(const QUrl &startDir, const QString &filter, QWidget *parent, QWidget *widget=0);
~UMLFileDialog();
int exec();
void setCaption(const QString &caption);
void setOperationMode(KFileDialog::OperationMode mode);
- void setUrl(const KUrl &url, bool clearforward=true);
- KUrl selectedUrl();
+ void setUrl(const QUrl &url, bool clearforward=true);
+ QUrl selectedUrl();
void setSelection(const QString &name);
void setMimeFilter(const QStringList &types, const QString &defaultType=QString());
QString currentMimeFilter();
diff --git a/umbrello/docgenerators/docbookgenerator.cpp b/umbrello/docgenerators/docbookgenerator.cpp
index 959968f..107d3aa 100644
--- a/umbrello/docgenerators/docbookgenerator.cpp
+++ b/umbrello/docgenerators/docbookgenerator.cpp
@@ -59,10 +59,10 @@ DocbookGenerator::~DocbookGenerator()
*/
bool DocbookGenerator::generateDocbookForProject()
{
- KUrl url = m_umlDoc->url();
+ QUrl url = m_umlDoc->url();
QString fileName = url.fileName();
fileName.remove(QRegExp(QLatin1String(".xmi$")));
- url.setFileName(fileName);
+ url.setPath(url.path() + QLatin1Char('/') + fileName);
uDebug() << "Exporting to directory: " << url;
generateDocbookForProjectInto(url);
return true;
@@ -104,7 +104,7 @@ void DocbookGenerator::slotDocbookGenerationFinished(const QString& tmpFileName)
fileName.replace(QRegExp(QLatin1String(".xmi$")), QLatin1String(".docbook"));
url.setPath(m_destDir.path() + QLatin1Char('/') + fileName);
- KIO::Job* job = KIO::file_copy(KUrl::fromPath(tmpFileName), url, -1, KIO::Overwrite | KIO::HideProgressInfo);
+ KIO::Job* job = KIO::file_copy(QUrl(tmpFileName), url, -1, KIO::Overwrite | KIO::HideProgressInfo);
if (KIO::NetAccess::synchronousRun(job, (QWidget*)UMLApp::app())) {
m_umlDoc->writeToStatusBar(i18n("Docbook Generation Complete..."));
m_pStatus = true;
diff --git a/umbrello/folder.cpp b/umbrello/folder.cpp
index 239c8b8..7dc1647 100644
--- a/umbrello/folder.cpp
+++ b/umbrello/folder.cpp
@@ -324,7 +324,8 @@ void UMLFolder::saveToXMI(QDomDocument& qDoc, QDomElement& qElement)
// See if we can create the external file.
// If not then internalize the folder.
UMLDoc *umldoc = UMLApp::app()->document();
- QString fileName = umldoc->url().directory() + QLatin1Char('/') + m_folderFile;
+ QUrl directory = umldoc->url().adjusted(QUrl::RemoveFilename);
+ QString fileName = directory.path() + m_folderFile;
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly)) {
uError() << m_folderFile << QLatin1String(": ")
@@ -480,7 +481,8 @@ bool UMLFolder::load(QDomElement& element)
if (!loadDiagramsFromXMI(diagramNode))
totalSuccess = false;
} else if (xtag == QLatin1String("external_file")) {
- const QString rootDir(umldoc->url().directory());
+ QUrl directory = umldoc->url().adjusted(QUrl::RemoveFilename);
+ const QString rootDir(directory.path());
QString fileName = el.attribute(QLatin1String("name"));
const QString path(rootDir + QLatin1Char('/') + fileName);
if (loadFolderFile(path))
diff --git a/umbrello/main.cpp b/umbrello/main.cpp
index 005c44d..ac06689 100644
--- a/umbrello/main.cpp
+++ b/umbrello/main.cpp
@@ -139,7 +139,7 @@ void initDocument(KCmdLineArgs *args)
bool last = UmbrelloSettings::loadlast();
QString file = UmbrelloSettings::lastFile();
if(last && !file.isEmpty()) {
- UMLApp::app()->openDocumentFile(KUrl(file));
+ UMLApp::app()->openDocumentFile(QUrl(file));
} else {
UMLApp::app()->newDocument();
}
@@ -153,17 +153,17 @@ void exportAllViews(KCmdLineArgs *args, const QStringList &exportOpt)
// export to the specified directory, or the directory where the file is saved
// if no directory was specified
- KUrl directory;
+ QUrl directory;
QStringList directoryOpt = args->getOptionList("directory");
if (directoryOpt.size() > 0) {
directory = KCmdLineArgs::makeURL(directoryOpt.last().toLocal8Bit());
} else {
- directory = KUrl(UMLApp::app()->document()->url().directory());
+ directory = UMLApp::app()->document()->url().adjusted(QUrl::RemoveFilename);
}
bool useFolders = args->isSet("use-folders");
- uDebug() << "directory: " << directory.prettyUrl();
+ uDebug() << "directory: " << directory.toDisplayString();
// the event is posted so when the Qt loop begins it's processed. UMLApp process this event executing
// the method it provides for exporting the views. Once all the views were exported, a quit event
diff --git a/umbrello/uml.cpp b/umbrello/uml.cpp
index dabac3e..a3afe06 100644
--- a/umbrello/uml.cpp
+++ b/umbrello/uml.cpp
@@ -960,7 +960,7 @@ void UMLApp::saveOptions()
UmbrelloSettings::setLastFile(QString());
}
else {
- UmbrelloSettings::setLastFile(m_doc->url().prettyUrl());
+ UmbrelloSettings::setLastFile(m_doc->url().toDisplayString());
}
UmbrelloSettings::setImageMimeType(imageMimeType());
@@ -1426,7 +1426,7 @@ void UMLApp::slotFilePrint()
QPrintDialog *printDialog =
KdePrint::createPrintDialog(m_printer, QList<QWidget*>() << m_printSettings, this);
- printDialog->setWindowTitle(i18n("Print %1", m_doc->url().prettyUrl()));
+ printDialog->setWindowTitle(i18n("Print %1", m_doc->url().toDisplayString()));
if (printDialog->exec()) {
m_doc->print(m_printer, m_printSettings);
diff --git a/umbrello/umldoc.cpp b/umbrello/umldoc.cpp
index 88b7978..71eb92f 100644
--- a/umbrello/umldoc.cpp
+++ b/umbrello/umldoc.cpp
@@ -82,7 +82,7 @@ UMLDoc::UMLDoc()
m_modelID("m1"),
m_count(0),
m_modified(false),
- m_doc_url(KUrl()),
+ m_doc_url(QUrl()),
m_pChangeLog(0),
m_bLoading(false),
m_Doc(QString()),
@@ -244,19 +244,19 @@ void UMLDoc::removeView(UMLView *view, bool enforceCurrentView)
/**
* Sets the URL of the document.
*
- * @param url The KUrl to set.
+ * @param url The URL to set.
*/
-void UMLDoc::setUrl(const KUrl &url)
+void UMLDoc::setUrl(const QUrl &url)
{
m_doc_url = url;
}
/**
- * Returns the KUrl of the document.
+ * Returns the URL of the document.
*
- * @return The KUrl of this UMLDoc.
+ * @return The URL of this UMLDoc.
*/
-const KUrl& UMLDoc::url() const
+const QUrl& UMLDoc::url() const
{
return m_doc_url;
}
@@ -369,7 +369,7 @@ bool UMLDoc::newDocument()
{
closeDocument();
UMLApp::app()->setCurrentView(0);
- m_doc_url.setFileName(i18n("Untitled"));
+ setFileName(m_doc_url, i18n("Untitled"));
//see if we need to start with a new diagram
Settings::OptionState optionState = Settings::optionState();
Uml::DiagramType::Enum dt = optionState.generalState.diagram;
@@ -396,11 +396,11 @@ bool UMLDoc::newDocument()
* Loads the document by filename and format and emits the
* updateViews() signal.
*
- * @param url The filename in KUrl format.
+ * @param url The filename in URL format.
* @param format The format (optional.)
* @return True if operation successful.
*/
-bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
+bool UMLDoc::openDocument(const QUrl& url, const char* format /* =0 */)
{
Q_UNUSED(format);
if (url.fileName().length() == 0) {
@@ -419,8 +419,8 @@ bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
KIO::NetAccess::download(url, tmpfile, UMLApp::app());
QFile file(tmpfile);
if (!file.exists()) {
- KMessageBox::error(0, i18n("The file %1 does not exist.", url.pathOrUrl()), i18n("Load Error"));
- m_doc_url.setFileName(i18n("Untitled"));
+ KMessageBox::error(0, i18n("The file %1 does not exist.", url.url(QUrl::PreferLocalFile)), i18n("Load Error"));
+ setFileName(m_doc_url, i18n("Untitled"));
m_bLoading = false;
newDocument();
return false;
@@ -441,9 +441,9 @@ bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
if (mimetype.isEmpty() == false) {
KTar archive(tmpfile, mimetype);
if (archive.open(QIODevice::ReadOnly) == false) {
- KMessageBox::error(0, i18n("The file %1 seems to be corrupted.", url.pathOrUrl()), i18n("Load Error"));
+ KMessageBox::error(0, i18n("The file %1 seems to be corrupted.", url.url(QUrl::PreferLocalFile)), i18n("Load Error"));
KIO::NetAccess::removeTempFile(tmpfile);
- m_doc_url.setFileName(i18n("Untitled"));
+ setFileName(m_doc_url, i18n("Untitled"));
m_bLoading = false;
newDocument();
return false;
@@ -479,10 +479,10 @@ bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
// try to cast the file entry in the archive to an archive entry
entry = const_cast<KArchiveEntry*>(rootDir->entry(*it));
if (entry == 0) {
- KMessageBox::error(0, i18n("There was no XMI file found in the compressed file %1.", url.pathOrUrl()),
+ KMessageBox::error(0, i18n("There was no XMI file found in the compressed file %1.", url.url(QUrl::PreferLocalFile)),
i18n("Load Error"));
KIO::NetAccess::removeTempFile(tmpfile);
- m_doc_url.setFileName(i18n("Untitled"));
+ setFileName(m_doc_url, i18n("Untitled"));
m_bLoading = false;
newDocument();
return false;
@@ -492,10 +492,10 @@ bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
// extract the file
fileEntry = dynamic_cast<KArchiveFile*>(entry);
if (fileEntry == 0) {
- KMessageBox::error(0, i18n("There was no XMI file found in the compressed file %1.", url.pathOrUrl()),
+ KMessageBox::error(0, i18n("There was no XMI file found in the compressed file %1.", url.url(QUrl::PreferLocalFile)),
i18n("Load Error"));
KIO::NetAccess::removeTempFile(tmpfile);
- m_doc_url.setFileName(i18n("Untitled"));
+ setFileName(m_doc_url, i18n("Untitled"));
m_bLoading = false;
newDocument();
return false;
@@ -507,10 +507,10 @@ bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
// now open the extracted file for reading
QFile xmi_file(tmp_dir.name() + *it);
if(!xmi_file.open(QIODevice::ReadOnly)) {
- KMessageBox::error(0, i18n("There was a problem loading the extracted file: %1", url.pathOrUrl()),
+ KMessageBox::error(0, i18n("There was a problem loading the extracted file: %1", url.url(QUrl::PreferLocalFile)),
i18n("Load Error"));
KIO::NetAccess::removeTempFile(tmpfile);
- m_doc_url.setFileName(i18n("Untitled"));
+ setFileName(m_doc_url, i18n("Untitled"));
m_bLoading = false;
newDocument();
return false;
@@ -521,10 +521,10 @@ bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
// close the extracted file and the temporary directory
xmi_file.close();
} else {
- KMessageBox::error(0, i18n("There was no XMI file found in the compressed file %1.", url.pathOrUrl()),
+ KMessageBox::error(0, i18n("There was no XMI file found in the compressed file %1.", url.url(QUrl::PreferLocalFile)),
i18n("Load Error"));
KIO::NetAccess::removeTempFile(tmpfile);
- m_doc_url.setFileName(i18n("Untitled"));
+ setFileName(m_doc_url, i18n("Untitled"));
m_bLoading = false;
newDocument();
return false;
@@ -534,16 +534,16 @@ bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
} else {
// no, it seems to be an ordinary file
if (!file.open(QIODevice::ReadOnly)) {
- KMessageBox::error(0, i18n("There was a problem loading file: %1", url.pathOrUrl()),
+ KMessageBox::error(0, i18n("There was a problem loading file: %1", url.url(QUrl::PreferLocalFile)),
i18n("Load Error"));
KIO::NetAccess::removeTempFile(tmpfile);
- m_doc_url.setFileName(i18n("Untitled"));
+ setFileName(m_doc_url, i18n("Untitled"));
m_bLoading = false;
newDocument();
return false;
}
if (filetype.endsWith(QLatin1String(".mdl"))) {
- m_doc_url.setFileName(i18n("Untitled"));
+ setFileName(m_doc_url, i18n("Untitled"));
m_bTypesAreResolved = false;
status = Import_Rose::loadFromMDL(file);
if (status) {
@@ -555,7 +555,7 @@ bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
}
}
else if (filetype.endsWith(QLatin1String(".zargo"))) {
- m_doc_url.setFileName(i18n("Untitled"));
+ setFileName(m_doc_url, i18n("Untitled"));
status = Import_Argo::loadFromZArgoFile(file);
}
else {
@@ -570,7 +570,7 @@ bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
m_bLoading = false;
m_bTypesAreResolved = true;
if (!status) {
- KMessageBox::error(0, i18n("There was a problem loading file: %1", url.pathOrUrl()),
+ KMessageBox::error(0, i18n("There was a problem loading file: %1", url.url(QUrl::PreferLocalFile)),
i18n("Load Error"));
newDocument();
return false;
@@ -589,18 +589,18 @@ bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
/**
* Saves the document using the given filename and format.
*
- * @param url The filename in KUrl format.
+ * @param url The filename in URL format.
* @param format The format (optional.)
* @return True if operation successful.
*/
-bool UMLDoc::saveDocument(const KUrl& url, const char * format)
+bool UMLDoc::saveDocument(const QUrl& url, const char * format)
{
Q_UNUSED(format);
m_doc_url = url;
bool uploaded = true;
// first, we have to find out which format to use
- QString strFileName = url.path(KUrl::RemoveTrailingSlash);
+ QString strFileName = url.path();
QFileInfo fileInfo(strFileName);
QString fileExt = fileInfo.completeSuffix();
QString fileFormat = QLatin1String("xmi");
@@ -639,7 +639,7 @@ bool UMLDoc::saveDocument(const KUrl& url, const char * format)
// now check if we can write to the file
if (archive->open(QIODevice::WriteOnly) == false) {
- KMessageBox::error(0, i18n("There was a problem saving file: %1", url.pathOrUrl()), i18n("Save Error"));
+ KMessageBox::error(0, i18n("There was a problem saving file: %1", url.url(QUrl::PreferLocalFile)), i18n("Save Error"));
delete archive;
return false;
}
@@ -649,7 +649,7 @@ bool UMLDoc::saveDocument(const KUrl& url, const char * format)
QTemporaryFile tmp_xmi_file;
tmp_xmi_file.setAutoRemove(false);
if (!tmp_xmi_file.open()) {
- KMessageBox::error(0, i18n("There was a problem saving file: %1", url.pathOrUrl()), i18n("Save Error"));
+ KMessageBox::error(0, i18n("There was a problem saving file: %1", url.url(QUrl::PreferLocalFile)), i18n("Save Error"));
delete archive;
return false;
}
@@ -666,7 +666,7 @@ bool UMLDoc::saveDocument(const KUrl& url, const char * format)
archive->addLocalFile(tmp_xmi_file.fileName(), tmpQString);
if (!archive->close()) {
- KMessageBox::error(0, i18n("There was a problem saving file: %1", url.pathOrUrl()), i18n("Save Error"));
+ KMessageBox::error(0, i18n("There was a problem saving file: %1", url.url(QUrl::PreferLocalFile)), i18n("Save Error"));
delete archive;
return false;
}
@@ -699,7 +699,7 @@ bool UMLDoc::saveDocument(const KUrl& url, const char * format)
// lets open the file for writing
if (!tmpfile.open()) {
- KMessageBox::error(0, i18n("There was a problem saving file: %1", url.pathOrUrl()), i18n("Save Error"));
+ KMessageBox::error(0, i18n("There was a problem saving file: %1", url.url(QUrl::PreferLocalFile)), i18n("Save Error"));
return false;
}
saveToXMI(tmpfile); // save the xmi stuff to it
@@ -717,15 +717,15 @@ bool UMLDoc::saveDocument(const KUrl& url, const char * format)
KIO::FileCopyJob* fcj = KIO::file_move(QUrl::fromLocalFile(tmpfile.fileName()), url, -1, KIO::Overwrite);
#endif
if (KIO::NetAccess::synchronousRun(fcj, (QWidget*)UMLApp::app()) == false) {
- KMessageBox::error(0, i18n("There was a problem saving file: %1", url.pathOrUrl()), i18n("Save Error"));
- m_doc_url.setFileName(i18n("Untitled"));
+ KMessageBox::error(0, i18n("There was a problem saving file: %1", url.url(QUrl::PreferLocalFile)), i18n("Save Error"));
+ setFileName(m_doc_url, i18n("Untitled"));
return false;
}
}
}
if (!uploaded) {
- KMessageBox::error(0, i18n("There was a problem uploading file: %1", url.pathOrUrl()), i18n("Save Error"));
- m_doc_url.setFileName(i18n("Untitled"));
+ KMessageBox::error(0, i18n("There was a problem uploading file: %1", url.url(QUrl::PreferLocalFile)), i18n("Save Error"));
+ setFileName(m_doc_url, i18n("Untitled"));
}
setModified(false);
return uploaded;
@@ -2913,26 +2913,23 @@ void UMLDoc::slotAutoSave()
if (!m_modified) {
return;
}
- KUrl tempUrl = m_doc_url;
+ QUrl tempUrl = m_doc_url;
if (tempUrl.fileName() == i18n("Untitled")) {
tempUrl.setPath(QDir::homePath() + i18n("/autosave%1", QLatin1String(".xmi")));
saveDocument(tempUrl);
- m_doc_url.setFileName(i18n("Untitled"));
+ setFileName(m_doc_url, i18n("Untitled"));
m_modified = true;
UMLApp::app()->setModified(m_modified);
} else {
- // 2004-05-17 Achim Spangler
- KUrl orgDocUrl = m_doc_url;
+ QUrl orgDocUrl = m_doc_url;
QString orgFileName = m_doc_url.fileName();
// don't overwrite manually saved file with autosave content
QString fileName = tempUrl.fileName();
Settings::OptionState optionState = Settings::optionState();
fileName.replace(QLatin1String(".xmi"), optionState.generalState.autosavesuffix);
- tempUrl.setFileName(fileName);
- // End Achim Spangler
+ setFileName(tempUrl, fileName);
saveDocument(tempUrl);
- // 2004-05-17 Achim Spangler
// re-activate m_modified if autosave is writing to other file
// than the main project file->autosave-suffix != ".xmi"
if (optionState.generalState.autosavesuffix != QLatin1String(".xmi")) {
@@ -2944,7 +2941,6 @@ void UMLDoc::slotAutoSave()
setUrl(orgDocUrl);
UMLApp * pApp = UMLApp::app();
pApp->setCaption(orgFileName, isModified());
- // End Achim Spangler
}
}
@@ -3087,3 +3083,12 @@ bool UMLDoc::tagEq (const QString& inTag, const QString& inPattern)
QString tagEnd = tag.section(QLatin1Char('.'), -patSections);
return (tagEnd.toLower() == pattern.toLower());
}
+
+/**
+ * Function for setting the file name of m_doc_url.
+ */
+void UMLDoc::setFileName(QUrl url, const QString& name)
+{
+ url.adjusted(QUrl::RemoveFilename);
+ url.setPath(url.path() + name);
+}
diff --git a/umbrello/umldoc.h b/umbrello/umldoc.h
index 0f647a3..14abc0d 100644
--- a/umbrello/umldoc.h
+++ b/umbrello/umldoc.h
@@ -24,8 +24,8 @@
#include "umlstereotypelist.h"
#include "umlpackagelist.h"
-// kde includes
-#include <kurl.h>
+// qt includes
+#include <QUrl>
// system includes
#include <typeinfo>
@@ -85,11 +85,11 @@ public:
bool newDocument();
void closeDocument();
- bool openDocument(const KUrl& url, const char *format = 0);
- bool saveDocument(const KUrl& url, const char *format = 0);
+ bool openDocument(const QUrl& url, const char *format = 0);
+ bool saveDocument(const QUrl& url, const char *format = 0);
- const KUrl& url() const;
- void setUrl(const KUrl& url);
+ const QUrl& url() const;
+ void setUrl(const QUrl& url);
void setupSignals();
@@ -223,6 +223,7 @@ public:
private:
void initSaveTimer();
void createDatatypeFolder();
+ void setFileName(QUrl url, const QString& name);
/**
* Array of predefined root folders.
@@ -248,7 +249,7 @@ private:
Uml::ID::Type m_modelID; ///< xmi.id of this model in the <UML:Model>
int m_count; ///< auxiliary counter for the progress bar
bool m_modified;
- KUrl m_doc_url;
+ QUrl m_doc_url;
/**
* Contains all the UMLObject id changes of paste session.
diff --git a/umbrello/umllistview.cpp b/umbrello/umllistview.cpp
index c0c1752..eb90e83 100644
--- a/umbrello/umllistview.cpp
+++ b/umbrello/umllistview.cpp
@@ -481,7 +481,7 @@ void UMLListView::slotMenuSelection(QAction* action, const QPoint &position)
return;
}
// configure & show the file dialog
- const QString rootDir(m_doc->url().directory());
+ const QString rootDir(m_doc->url().adjusted(QUrl::RemoveFilename).path());
QPointer<KFileDialog> fileDialog = new KFileDialog(QUrl(rootDir), QLatin1String("*.xml"), this);
#if 0 //FIXME KF5
fileDialog->setCaption(i18n("Externalize Folder"));
@@ -492,7 +492,7 @@ void UMLListView::slotMenuSelection(QAction* action, const QPoint &position)
defaultFilename.replace(QRegExp(QLatin1String("\\W+")), QLatin1String("_"));
defaultFilename.append(QLatin1String(".xml")); // default extension
fileDialog->setSelection(defaultFilename);
- KUrl selURL;
+ QUrl selURL;
if (fileDialog->exec() == QDialog::Accepted) {
selURL = fileDialog->selectedUrl();
}
diff --git a/umbrello/umlviewimageexporter.cpp b/umbrello/umlviewimageexporter.cpp
index 7cc1dc8..6508db5 100644
--- a/umbrello/umlviewimageexporter.cpp
+++ b/umbrello/umlviewimageexporter.cpp
@@ -22,7 +22,6 @@
//kde include files
#include <klocale.h>
#include <kfiledialog.h>
-#include <kurl.h>
#include <kmessagebox.h>
#include <kio/netaccess.h>
@@ -102,7 +101,7 @@ bool UMLViewImageExporter::prepareExport()
// check if the file exists
if (KIO::NetAccess::exists(m_imageURL, KIO::NetAccess::SourceSide, UMLApp::app())) {
int wantSave = KMessageBox::warningContinueCancel(0,
- i18n("The selected file %1 exists.\nDo you want to overwrite it?", m_imageURL.pathOrUrl()),
+ i18n("The selected file %1 exists.\nDo you want to overwrite it?", m_imageURL.url(QUrl::PreferLocalFile)),
i18n("File Already Exists"), KGuiItem(i18n("&Overwrite")));
if (wantSave == KMessageBox::Continue) {
exportPrepared = true;
@@ -127,7 +126,7 @@ bool UMLViewImageExporter::getParametersFromUser()
bool success = true;
// configure & show the file dialog
- KUrl url;
+ QUrl url;
QPointer<UMLFileDialog> dialog = new UMLFileDialog(url, QString(), UMLApp::app());
prepareFileDialog(dialog);
dialog->exec();
@@ -168,11 +167,10 @@ void UMLViewImageExporter::prepareFileDialog(UMLFileDialog *fileDialog)
// set a sensible default filename
if (m_imageURL.isEmpty()) {
- KUrl docURL = UMLApp::app()->document()->url();
- KUrl directory = docURL;
- directory.setPath(docURL.directory());
+ QUrl docURL = UMLApp::app()->document()->url();
+ docURL.adjusted(QUrl::RemoveFilename);
- fileDialog->setUrl(directory);
+ fileDialog->setUrl(docURL);
fileDialog->setSelection(m_scene->name() + QLatin1Char('.') + UMLViewImageExporterModel::mimeTypeToImageType(m_imageMimeType));
} else {
fileDialog->setUrl(m_imageURL);
diff --git a/umbrello/umlviewimageexporter.h b/umbrello/umlviewimageexporter.h
index 6c2aae2..ec68f49 100644
--- a/umbrello/umlviewimageexporter.h
+++ b/umbrello/umlviewimageexporter.h
@@ -13,9 +13,8 @@
#include "umlviewimageexportermodel.h"
-#include <kurl.h>
-
#include <QString>
+#include <QUrl>
class UMLScene;
class UMLFileDialog;
@@ -34,13 +33,13 @@ public:
void exportView();
- KUrl getImageURL() const { return m_imageURL; }
+ QUrl getImageURL() const { return m_imageURL; }
QString getImageMimeType() const { return m_imageMimeType; }
private:
UMLScene* m_scene; ///< The scene to export.
- KUrl m_imageURL; ///< The URL used to save the image.
+ QUrl m_imageURL; ///< The URL used to save the image.
QString m_imageMimeType; ///< The mime type used to save the image.
bool getParametersFromUser();
diff --git a/umbrello/umlviewimageexporterall.cpp b/umbrello/umlviewimageexporterall.cpp
index 50ccd4f..11d537e 100644
--- a/umbrello/umlviewimageexporterall.cpp
+++ b/umbrello/umlviewimageexporterall.cpp
@@ -19,7 +19,6 @@
// kde include files
#include <klocale.h>
-#include <kurl.h>
#include <kurlrequester.h>
#include <kfilefiltercombo.h>
#include <kmessagebox.h>
@@ -64,7 +63,9 @@ void UMLViewImageExporterAll::exportAllViews()
// default url can't be set when creating the action because the
// document wasn't loaded
if (m_dialog->m_kURL->url().isEmpty()) {
- m_dialog->m_kURL->setUrl(QUrl(umlDoc->url().directory()));
+ QUrl directory(umlDoc->url());
+ directory.adjusted(QUrl::RemoveFilename);
+ m_dialog->m_kURL->setUrl(directory);
}
if (m_dialog->exec() == QDialog::Rejected) {
@@ -77,7 +78,7 @@ void UMLViewImageExporterAll::exportAllViews()
umlDoc->writeToStatusBar(i18n("Exporting all views..."));
QStringList errors = UMLViewImageExporterModel().exportAllViews(
UMLViewImageExporterModel::mimeTypeToImageType(m_dialog->m_imageType->currentFilter()),
- KUrl(m_dialog->m_kURL->url()), m_dialog->m_useFolders->isChecked());
+ QUrl(m_dialog->m_kURL->url()), m_dialog->m_useFolders->isChecked());
if (!errors.empty()) {
KMessageBox::errorList(app, i18n("Some errors happened when exporting the images:"), errors);
}