diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-08-10 17:34:04 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:05 +0100 |
commit | 08ca2545eede86a0f6de42be596b063de1321ddb (patch) | |
tree | 9f1d9986b04d7db3ace13f9304eae704d9c189eb /src/webwindow/rekonqfactory.cpp | |
parent | FindBar. Rewamped and restored (diff) | |
download | rekonq-08ca2545eede86a0f6de42be596b063de1321ddb.tar.xz |
Manage Bookmarks Toolbar show/hide (&& create/delete)
Diffstat (limited to 'src/webwindow/rekonqfactory.cpp')
-rw-r--r-- | src/webwindow/rekonqfactory.cpp | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/webwindow/rekonqfactory.cpp b/src/webwindow/rekonqfactory.cpp index 78cd0367..8b09c0bd 100644 --- a/src/webwindow/rekonqfactory.cpp +++ b/src/webwindow/rekonqfactory.cpp @@ -44,20 +44,40 @@ #include <QDomElement> -QWidget *RekonqFactory::createWidget(const QString &name, QWidget *parent, KActionCollection *ac) +// Only used internally +bool readDocument(QDomDocument & document, const QString & filePath) { - QString xmlFilePath; - xmlFilePath = KStandardDirs::locateLocal( "data", "rekonq/rekonqui.rc"); - if (!QFile::exists(xmlFilePath)) + QFile sessionFile(filePath); + + if (!sessionFile.exists()) + return false; + + if (!sessionFile.open(QFile::ReadOnly)) { - xmlFilePath = KStandardDirs::locate( "data", "rekonq/rekonqui.rc"); - kDebug() << "general xmlfile: " << xmlFilePath; + kDebug() << "Unable to open xml file" << sessionFile.fileName(); + return false; } - QFile xmlFile(xmlFilePath); + if (!document.setContent(&sessionFile, false)) + { + kDebug() << "Unable to parse xml file" << sessionFile.fileName(); + return false; + } + + return true; +} + + +// --------------------------------------------------------------------------------------------------------- + +QWidget *RekonqFactory::createWidget(const QString &name, QWidget *parent, KActionCollection *ac) +{ QDomDocument document("rekonqui.rc"); - document.setContent(&xmlFile, false); + QString xmlFilePath = KStandardDirs::locate( "data", "rekonq/rekonqui.rc"); + + if (!readDocument(document, xmlFilePath)) + return 0; // Toolbars ---------------------------------------------------------------------- QDomNodeList elementToolbarList = document.elementsByTagName(QL1S("ToolBar")); |