From 08ca2545eede86a0f6de42be596b063de1321ddb Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 10 Aug 2012 17:34:04 +0200 Subject: Manage Bookmarks Toolbar show/hide (&& create/delete) --- src/webwindow/rekonqfactory.cpp | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'src/webwindow/rekonqfactory.cpp') 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 -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")); -- cgit v1.2.1