From cbbaa029501d8833773d599b630aa44ded5d6c78 Mon Sep 17 00:00:00 2001 From: kh1 Date: Wed, 23 Jun 2010 16:19:37 +0200 Subject: Set the item data thru the model, so we actually emit dataChanged. Task-number: QTBUG-10629 Reviewed-by: kh --- tools/assistant/tools/assistant/bookmarkdialog.cpp | 3 +-- tools/assistant/tools/assistant/bookmarkmodel.cpp | 8 ++++++++ tools/assistant/tools/assistant/bookmarkmodel.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/assistant/tools/assistant/bookmarkdialog.cpp b/tools/assistant/tools/assistant/bookmarkdialog.cpp index 8b195c1..d9e9a53 100644 --- a/tools/assistant/tools/assistant/bookmarkdialog.cpp +++ b/tools/assistant/tools/assistant/bookmarkdialog.cpp @@ -160,8 +160,7 @@ void BookmarkDialog::accepted() QModelIndex index = ui.treeView->currentIndex(); if (index.isValid()) { index = bookmarkModel->addItem(bookmarkTreeModel->mapToSource(index)); - if (BookmarkItem *item = bookmarkModel->itemFromIndex(index)) - item->setData(DataVector() << m_title << m_url << false); + bookmarkModel->setData(index, DataVector() << m_title << m_url << false); } else rejected(); diff --git a/tools/assistant/tools/assistant/bookmarkmodel.cpp b/tools/assistant/tools/assistant/bookmarkmodel.cpp index e446ff0..4c30b42 100644 --- a/tools/assistant/tools/assistant/bookmarkmodel.cpp +++ b/tools/assistant/tools/assistant/bookmarkmodel.cpp @@ -261,6 +261,14 @@ BookmarkModel::data(const QModelIndex &index, int role) const return QVariant(); } +void BookmarkModel::setData(const QModelIndex &index, const DataVector &data) +{ + if (BookmarkItem *item = itemFromIndex(index)) { + item->setData(data); + emit dataChanged(index, index); + } +} + bool BookmarkModel::setData(const QModelIndex &index, const QVariant &value, int role) { diff --git a/tools/assistant/tools/assistant/bookmarkmodel.h b/tools/assistant/tools/assistant/bookmarkmodel.h index 6469258..f74baea 100644 --- a/tools/assistant/tools/assistant/bookmarkmodel.h +++ b/tools/assistant/tools/assistant/bookmarkmodel.h @@ -79,6 +79,7 @@ public: Qt::ItemFlags flags(const QModelIndex &index) const; QVariant data(const QModelIndex &index, int role) const; + void setData(const QModelIndex &index, const QVector &data); bool setData(const QModelIndex &index, const QVariant &value, int role); QVariant headerData(int section, Qt::Orientation orientation, int role) const; -- cgit v0.12