summaryrefslogtreecommitdiffstats
path: root/examples/xml/dombookmarks/xbeltree.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2016-10-31 11:09:00 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-02-17 05:55:19 +0000
commit8d71fae08078afbf4aa2de7429302f46d46fb43f (patch)
treedd67e91f7dc00c38582930a774981865c6d8d850 /examples/xml/dombookmarks/xbeltree.h
parent146f6d261ba743b643825d62cdb2deb1e701d3d2 (diff)
Polish the XML bookmarks examples
- Use Qt 5 connect syntax. - Streamline code, remove unused members. - Add a context menu for copying and opening the URLs. - Add const to XML code. - In the XML code, show the use of QStringLiteral in static inline functions to create strings versus QLatin1String in comparison overloads to avoid allocating strings from const char * literals. Change-Id: Ib5e62ca188e271ffe01996dff3c9ea8e0b60739a Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'examples/xml/dombookmarks/xbeltree.h')
-rw-r--r--examples/xml/dombookmarks/xbeltree.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/examples/xml/dombookmarks/xbeltree.h b/examples/xml/dombookmarks/xbeltree.h
index bf4b55ea74..f6c7ef8bfe 100644
--- a/examples/xml/dombookmarks/xbeltree.h
+++ b/examples/xml/dombookmarks/xbeltree.h
@@ -52,7 +52,6 @@
#define XBELTREE_H
#include <QDomDocument>
-#include <QHash>
#include <QIcon>
#include <QTreeWidget>
@@ -64,10 +63,15 @@ public:
XbelTree(QWidget *parent = 0);
bool read(QIODevice *device);
- bool write(QIODevice *device);
+ bool write(QIODevice *device) const;
+
+protected:
+#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
+ void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE;
+#endif
private slots:
- void updateDomElement(QTreeWidgetItem *item, int column);
+ void updateDomElement(const QTreeWidgetItem *item, int column);
private:
void parseFolderElement(const QDomElement &element,
@@ -76,7 +80,6 @@ private:
QTreeWidgetItem *parentItem = 0);
QDomDocument domDocument;
- QHash<QTreeWidgetItem *, QDomElement> domElementForItem;
QIcon folderIcon;
QIcon bookmarkIcon;
};