Skip to content
Snippets Groups Projects
Commit 0cf2bc3b authored by kh1's avatar kh1
Browse files

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.
parent c71e1dd7
No related branches found
No related tags found
No related merge requests found
...@@ -153,6 +153,8 @@ void OpenPagesManager::setupInitialPages() ...@@ -153,6 +153,8 @@ void OpenPagesManager::setupInitialPages()
for (int i = 0; i < m_model->rowCount(); ++i) for (int i = 0; i < m_model->rowCount(); ++i)
CentralWidget::instance()->addPage(m_model->pageAt(i)); CentralWidget::instance()->addPage(m_model->pageAt(i));
emit pagesChanged();
setCurrentPage(initialPage); setCurrentPage(initialPage);
} }
......
...@@ -39,20 +39,23 @@ OpenPagesModel::OpenPagesModel(QObject *parent) ...@@ -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 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(); return QVariant();
QString title = m_pages.at(index.row())->title(); QString title = m_pages.at(index.row())->title();
title.replace(QLatin1Char('&'), QLatin1String("&&")); title.replace(QLatin1Char('&'), QLatin1String("&&"));
return title.isEmpty() ? tr("(Untitled)") : title; return title.isEmpty() ? tr("(Untitled)") : title;
......
...@@ -46,8 +46,8 @@ class OpenPagesModel : public QAbstractTableModel ...@@ -46,8 +46,8 @@ class OpenPagesModel : public QAbstractTableModel
public: public:
OpenPagesModel(QObject *parent); OpenPagesModel(QObject *parent);
int columnCount(const QModelIndex &parent) const;
int rowCount(const QModelIndex &parent = QModelIndex()) 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; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
void addPage(const QUrl &url, qreal zoom = 0); void addPage(const QUrl &url, qreal zoom = 0);
......
...@@ -98,7 +98,7 @@ OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model) ...@@ -98,7 +98,7 @@ OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model)
header()->setStretchLastSection(false); header()->setStretchLastSection(false);
header()->setResizeMode(0, QHeaderView::Stretch); header()->setResizeMode(0, QHeaderView::Stretch);
header()->setResizeMode(1, QHeaderView::Fixed); header()->setResizeMode(1, QHeaderView::Fixed);
header()->resizeSection(1, 16); header()->resizeSection(1, 18);
installEventFilter(this); installEventFilter(this);
setUniformRowHeights(true); setUniformRowHeights(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment