From 15ac92ca2c3a0bfb66288fd270b61891569a9016 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Sat, 1 Dec 2012 17:37:46 -0300 Subject: QMenuModel now keeps cache of any link element. --- libqmenumodel/src/qmenumodel.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libqmenumodel/src/qmenumodel.h') diff --git a/libqmenumodel/src/qmenumodel.h b/libqmenumodel/src/qmenumodel.h index 9371bd8..de49368 100644 --- a/libqmenumodel/src/qmenumodel.h +++ b/libqmenumodel/src/qmenumodel.h @@ -28,6 +28,8 @@ typedef void* gpointer; typedef struct _GMenuModel GMenuModel; typedef struct _GObject GObject; +class CacheData; + class QMenuModel : public QAbstractListModel { Q_OBJECT @@ -60,7 +62,11 @@ protected: void setMenuModel(GMenuModel *model); GMenuModel *menuModel() const; + // help function for test + QList cache() const; + private: + QList m_cache; GMenuModel *m_menuModel; guint m_signalChangedId; -- cgit v1.2.3 From 5c529632253bb8e864b3cc81eaabbd0a423112aa Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Mon, 3 Dec 2012 09:36:59 -0300 Subject: Changed getLink function to not be const. --- libqmenumodel/src/qmenumodel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libqmenumodel/src/qmenumodel.h') diff --git a/libqmenumodel/src/qmenumodel.h b/libqmenumodel/src/qmenumodel.h index de49368..e0f69f2 100644 --- a/libqmenumodel/src/qmenumodel.h +++ b/libqmenumodel/src/qmenumodel.h @@ -71,7 +71,7 @@ private: guint m_signalChangedId; QVariant getStringAttribute(const QModelIndex &index, const QString &attribute) const; - QVariant getLink(const QModelIndex &index, const QString &linkName) const; + QVariant getLink(const QModelIndex &index, const QString &linkName); QVariant getExtraProperties(const QModelIndex &index) const; QString parseExtraPropertyName(const QString &name) const; void clearModel(); -- cgit v1.2.3 From 2f3299465de87c5801a5016c39b0fdb129347895 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 3 Dec 2012 18:52:59 +0100 Subject: Simplify the caching mechanism using a a QHash that associates indexes (int) to QMenuModel*. --- libqmenumodel/src/qmenumodel.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libqmenumodel/src/qmenumodel.h') diff --git a/libqmenumodel/src/qmenumodel.h b/libqmenumodel/src/qmenumodel.h index e0f69f2..fef75e4 100644 --- a/libqmenumodel/src/qmenumodel.h +++ b/libqmenumodel/src/qmenumodel.h @@ -21,6 +21,7 @@ #define QMENUMODEL_H #include +#include typedef int gint; typedef unsigned int guint; @@ -28,8 +29,6 @@ typedef void* gpointer; typedef struct _GMenuModel GMenuModel; typedef struct _GObject GObject; -class CacheData; - class QMenuModel : public QAbstractListModel { Q_OBJECT @@ -63,10 +62,10 @@ protected: GMenuModel *menuModel() const; // help function for test - QList cache() const; + QHash cache() const; private: - QList m_cache; + QHash m_cache; GMenuModel *m_menuModel; guint m_signalChangedId; -- cgit v1.2.3 From 7b2badf6f2c2d5d4596ca3778b4cf924d498e2d7 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 4 Dec 2012 08:30:24 +0100 Subject: Make the cache a pointer, to enforce const correctness. --- libqmenumodel/src/qmenumodel.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'libqmenumodel/src/qmenumodel.h') diff --git a/libqmenumodel/src/qmenumodel.h b/libqmenumodel/src/qmenumodel.h index fef75e4..f77f472 100644 --- a/libqmenumodel/src/qmenumodel.h +++ b/libqmenumodel/src/qmenumodel.h @@ -21,7 +21,6 @@ #define QMENUMODEL_H #include -#include typedef int gint; typedef unsigned int guint; @@ -65,12 +64,12 @@ protected: QHash cache() const; private: - QHash m_cache; + QHash* m_cache; GMenuModel *m_menuModel; guint m_signalChangedId; QVariant getStringAttribute(const QModelIndex &index, const QString &attribute) const; - QVariant getLink(const QModelIndex &index, const QString &linkName); + QVariant getLink(const QModelIndex &index, const QString &linkName) const; QVariant getExtraProperties(const QModelIndex &index) const; QString parseExtraPropertyName(const QString &name) const; void clearModel(); -- cgit v1.2.3 From ac9450d43d09d817d0f8855ac8c691cab11eddbe Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 4 Dec 2012 09:31:46 +0100 Subject: Better comment. --- libqmenumodel/src/qmenumodel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libqmenumodel/src/qmenumodel.h') diff --git a/libqmenumodel/src/qmenumodel.h b/libqmenumodel/src/qmenumodel.h index f77f472..54a5c42 100644 --- a/libqmenumodel/src/qmenumodel.h +++ b/libqmenumodel/src/qmenumodel.h @@ -60,7 +60,7 @@ protected: void setMenuModel(GMenuModel *model); GMenuModel *menuModel() const; - // help function for test + // helper getter intended for use in tests only QHash cache() const; private: -- cgit v1.2.3