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:
@@ -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)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenPagesModel::columnCount(const QModelIndex &/*parent*/) const
|
|
||||||
{
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
int OpenPagesModel::rowCount(const QModelIndex &parent) const
|
int OpenPagesModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return parent.isValid() ? 0 : m_pages.count();
|
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
|
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
|
|||||||
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)
|
|||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user