From d4556a362fe246981a7ff9d2ecbd9b6c62b54443 Mon Sep 17 00:00:00 2001 From: Arto Jonsson Date: Sat, 31 Jul 2010 21:30:52 +0300 Subject: [PATCH] Add move numbers to the move list --- projects/gui/src/mainwindow.cpp | 1 + projects/gui/src/movelistmodel.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/projects/gui/src/mainwindow.cpp b/projects/gui/src/mainwindow.cpp index a1e1757..91d005e 100644 --- a/projects/gui/src/mainwindow.cpp +++ b/projects/gui/src/mainwindow.cpp @@ -158,6 +158,7 @@ void MainWindow::createDockWindows() moveListView->setModel(m_moveListModel); moveListView->setAlternatingRowColors(true); moveListView->setRootIsDecorated(false); + moveListView->header()->setResizeMode(0, QHeaderView::ResizeToContents); moveListDock->setWidget(moveListView); connect(m_moveListModel, SIGNAL(rowsInserted(QModelIndex, int, int)), diff --git a/projects/gui/src/movelistmodel.cpp b/projects/gui/src/movelistmodel.cpp index 5e64d15..d51847d 100644 --- a/projects/gui/src/movelistmodel.cpp +++ b/projects/gui/src/movelistmodel.cpp @@ -20,7 +20,7 @@ const QStringList MoveListModel::m_headers = (QStringList() << - tr("White") << tr("Black")); + QString("") << tr("White") << tr("Black")); MoveListModel::MoveListModel(QObject* parent) : QAbstractItemModel(parent), @@ -97,11 +97,14 @@ QVariant MoveListModel::data(const QModelIndex& index, int role) const { if (index.isValid() && role == Qt::DisplayRole) { + if (index.column() == 0) + return QString::number(index.row() + 1); + const QVector moves = m_game->pgn().moves(); - if (moves.size() > ((index.row() * 2) + index.column())) + if (moves.size() > ((index.row() * 2) + index.column() - 1)) { - const PgnGame::MoveData move = moves.at((index.row() * 2) + index.column()); + const PgnGame::MoveData move = moves.at((index.row() * 2) + index.column() - 1); if (move.comment.isEmpty()) return move.moveString; -- 2.11.4.GIT