aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-12-14 22:15:05 -0300
committerRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-12-14 22:15:05 -0300
commit96a4d9c492d85c5e221cdf9117ba4d378a8c0e0f (patch)
tree3a85c8a3b42c9949e73be728e31b16d76444758d
parent9b94a0f9c2cad99fef925a7b33f852aa5e38913a (diff)
downloadqmenumodel-96a4d9c492d85c5e221cdf9117ba4d378a8c0e0f.tar.gz
qmenumodel-96a4d9c492d85c5e221cdf9117ba4d378a8c0e0f.tar.bz2
qmenumodel-96a4d9c492d85c5e221cdf9117ba4d378a8c0e0f.zip
Only checks for row index in cache.
Used Q_EMIT keywork for signals.
-rw-r--r--libqmenumodel/src/qmenumodel.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/libqmenumodel/src/qmenumodel.cpp b/libqmenumodel/src/qmenumodel.cpp
index c0d8c94..3da71d7 100644
--- a/libqmenumodel/src/qmenumodel.cpp
+++ b/libqmenumodel/src/qmenumodel.cpp
@@ -234,9 +234,7 @@ QVariant QMenuModel::getLink(const QModelIndex &index,
int key = index.row();
if (m_cache->contains(key)) {
QMenuModel* cached = m_cache->value(key);
- if (cached->menuModel() == link) {
- child = cached;
- }
+ child = cached;
}
if (child == 0) {
child = new QMenuModel(link);
@@ -297,7 +295,7 @@ void QMenuModel::onItemsChanged(GMenuModel *model,
int prevcount = g_menu_model_get_n_items(model) + removed - added;
if (removed > 0) {
- self->beginRemoveRows(QModelIndex(), position, position + removed - 1);
+ Q_EMIT self->beginRemoveRows(QModelIndex(), position, position + removed - 1);
self->m_rowCount -= removed;
// Remove invalidated menus from the cache
for (int i = position, iMax = position + removed; i < iMax; ++i) {
@@ -313,19 +311,19 @@ void QMenuModel::onItemsChanged(GMenuModel *model,
cache->insert(i - removed, cache->take(i));
}
}
- self->endRemoveRows();
+ Q_EMIT self->endRemoveRows();
}
if (added > 0) {
- self->beginInsertRows(QModelIndex(), position, position + added - 1);
+ Q_EMIT self->beginInsertRows(QModelIndex(), position, position + added - 1);
// Update the indexes of cached menus to account for the insertions
for (int i = prevcount - removed - 1; i >= position; --i) {
if (cache->contains(i)) {
cache->insert(i + added, cache->take(i));
}
}
- self->m_rowCount += removed;
- self->endInsertRows();
+ self->m_rowCount += added;
+ Q_EMIT self->endInsertRows();
}
}