forked from qt-creator/qt-creator
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.
This commit is contained in:
@@ -39,20 +39,23 @@ OpenPagesModel::OpenPagesModel(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
int OpenPagesModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int OpenPagesModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return parent.isValid() ? 0 : m_pages.count();
|
||||
}
|
||||
|
||||
int OpenPagesModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user