From 0cf2bc3b4301374756a7823507c71d9b49bfbb01 Mon Sep 17 00:00:00 2001 From: kh1 <qt-info@nokia.com> Date: Mon, 29 Mar 2010 17:27:04 +0200 Subject: [PATCH] Fix dots showing up in second column of the widget. Since we use a two column model/treeview we need to prevent returning some text data, otherwise we will see dots in the secound column. We also need to emit pagesChanged once we init the model. --- src/plugins/help/openpagesmanager.cpp | 2 ++ src/plugins/help/openpagesmodel.cpp | 13 ++++++++----- src/plugins/help/openpagesmodel.h | 2 +- src/plugins/help/openpageswidget.cpp | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/plugins/help/openpagesmanager.cpp b/src/plugins/help/openpagesmanager.cpp index 0b7f0171b9c..d56a1853e54 100644 --- a/src/plugins/help/openpagesmanager.cpp +++ b/src/plugins/help/openpagesmanager.cpp @@ -153,6 +153,8 @@ void OpenPagesManager::setupInitialPages() for (int i = 0; i < m_model->rowCount(); ++i) CentralWidget::instance()->addPage(m_model->pageAt(i)); + + emit pagesChanged(); setCurrentPage(initialPage); } diff --git a/src/plugins/help/openpagesmodel.cpp b/src/plugins/help/openpagesmodel.cpp index c2eae41afce..55541533ebe 100644 --- a/src/plugins/help/openpagesmodel.cpp +++ b/src/plugins/help/openpagesmodel.cpp @@ -39,20 +39,23 @@ OpenPagesModel::OpenPagesModel(QObject *parent) { } -int OpenPagesModel::columnCount(const QModelIndex &/*parent*/) const +int OpenPagesModel::rowCount(const QModelIndex &parent) const { - return 2; + return parent.isValid() ? 0 : m_pages.count(); } -int OpenPagesModel::rowCount(const QModelIndex &parent) const +int OpenPagesModel::columnCount(const QModelIndex &/*parent*/) const { - return parent.isValid() ? 0 : m_pages.count(); + return 2; } QVariant OpenPagesModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || index.row() >= rowCount() || role != Qt::DisplayRole) + if (!index.isValid() || role != Qt::DisplayRole + || index.row() >= rowCount() || index.column() >= columnCount() - 1) + return QVariant(); + QString title = m_pages.at(index.row())->title(); title.replace(QLatin1Char('&'), QLatin1String("&&")); return title.isEmpty() ? tr("(Untitled)") : title; diff --git a/src/plugins/help/openpagesmodel.h b/src/plugins/help/openpagesmodel.h index 0fe32c017dd..2dc7c878819 100644 --- a/src/plugins/help/openpagesmodel.h +++ b/src/plugins/help/openpagesmodel.h @@ -46,8 +46,8 @@ class OpenPagesModel : public QAbstractTableModel public: OpenPagesModel(QObject *parent); - int columnCount(const QModelIndex &parent) const; int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; void addPage(const QUrl &url, qreal zoom = 0); diff --git a/src/plugins/help/openpageswidget.cpp b/src/plugins/help/openpageswidget.cpp index 25a0230f35f..3d197782612 100644 --- a/src/plugins/help/openpageswidget.cpp +++ b/src/plugins/help/openpageswidget.cpp @@ -98,7 +98,7 @@ OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model) header()->setStretchLastSection(false); header()->setResizeMode(0, QHeaderView::Stretch); header()->setResizeMode(1, QHeaderView::Fixed); - header()->resizeSection(1, 16); + header()->resizeSection(1, 18); installEventFilter(this); setUniformRowHeights(true); -- GitLab