aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-10-16 14:30:47 -0300
committerRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-10-16 14:30:47 -0300
commitcc79785d02cadd4066c967e7b373d6ac2bb39b1c (patch)
tree76870946c0f111959410407288be78ee4889fac5 /libqmenumodel
parenta98d5486c37d68e1c1ce8fc1b6ad0a9018dd534d (diff)
parentced307a448aeed3a20d1a1e4bdcbf4dcbe4b1e46 (diff)
downloadqmenumodel-cc79785d02cadd4066c967e7b373d6ac2bb39b1c.tar.gz
qmenumodel-cc79785d02cadd4066c967e7b373d6ac2bb39b1c.tar.bz2
qmenumodel-cc79785d02cadd4066c967e7b373d6ac2bb39b1c.zip
Merged mainline.
Diffstat (limited to 'libqmenumodel')
-rw-r--r--libqmenumodel/src/qmenumodel.cpp19
-rw-r--r--libqmenumodel/src/qmenumodel.h1
2 files changed, 14 insertions, 6 deletions
diff --git a/libqmenumodel/src/qmenumodel.cpp b/libqmenumodel/src/qmenumodel.cpp
index 1aaf210..a45e5ff 100644
--- a/libqmenumodel/src/qmenumodel.cpp
+++ b/libqmenumodel/src/qmenumodel.cpp
@@ -56,7 +56,7 @@ QMenuModel::QMenuModel(GMenuModel *other, QObject *parent)
/*! \internal */
QMenuModel::~QMenuModel()
{
- setMenuModel(NULL);
+ clearModel();
}
/*! \internal */
@@ -68,11 +68,7 @@ void QMenuModel::setMenuModel(GMenuModel *other)
beginResetModel();
- if (m_menuModel) {
- g_signal_handler_disconnect(m_menuModel, m_signalChangedId);
- m_signalChangedId = 0;
- g_object_unref(m_menuModel);
- }
+ clearModel();
m_menuModel = other;
@@ -95,6 +91,17 @@ GMenuModel *QMenuModel::menuModel() const
}
/*! \internal */
+void QMenuModel::clearModel()
+{
+ if (m_menuModel) {
+ g_signal_handler_disconnect(m_menuModel, m_signalChangedId);
+ m_signalChangedId = 0;
+ g_object_unref(m_menuModel);
+ m_menuModel = NULL;
+ }
+}
+
+/*! \internal */
QVariant QMenuModel::data(const QModelIndex &index, int role) const
{
QVariant attribute;
diff --git a/libqmenumodel/src/qmenumodel.h b/libqmenumodel/src/qmenumodel.h
index b5c76c0..22c30df 100644
--- a/libqmenumodel/src/qmenumodel.h
+++ b/libqmenumodel/src/qmenumodel.h
@@ -60,6 +60,7 @@ private:
QVariant getLink(const QModelIndex &index, const QString &linkName) const;
QVariant getExtraProperties(const QModelIndex &index) const;
QString parseExtraPropertyName(const QString &name) const;
+ void clearModel();
static void onItemsChanged(GMenuModel *model, gint position, gint removed, gint added, gpointer data);
};