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
......@@ -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);
}
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment