diff --git a/qt/arbit_assignments.cpp b/qt/arbit_assignments.cpp index a70c243..f1f7360 100644 --- a/qt/arbit_assignments.cpp +++ b/qt/arbit_assignments.cpp @@ -97,6 +97,11 @@ ArbitAssignments::ArbitAssignments(QWidget *parent, PublicGame *iGame) SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(enableAssignmentButtons())); + // Emit the "playerSelected" signal when appropriate + QObject::connect(treeViewPlayers->selectionModel(), + SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), + this, SLOT(emitPlayerSelected())); + // Move assignment QObject::connect(buttonSelectMaster, SIGNAL(clicked()), this, SLOT(assignMasterMove())); @@ -304,6 +309,14 @@ bool ArbitAssignments::hasSelectedPlayer() const } +void ArbitAssignments::emitPlayerSelected() +{ + QSet playersIdSet = getSelectedPlayers(); + if (playersIdSet.size() == 1) + emit playerSelected(*playersIdSet.begin()); +} + + QSet ArbitAssignments::getSelectedPlayers() const { QSet playersIdSet; diff --git a/qt/arbit_assignments.h b/qt/arbit_assignments.h index af4a1d1..3a296c7 100644 --- a/qt/arbit_assignments.h +++ b/qt/arbit_assignments.h @@ -60,6 +60,7 @@ signals: void notifyProblem(QString iMsg); void notifyInfo(QString iMsg); void endOfTurn(); + void playerSelected(unsigned playerId); public slots: void refresh(); @@ -72,6 +73,7 @@ public slots: private slots: void on_checkBoxHideAssigned_toggled(bool); + void emitPlayerSelected(); void showMasterPreview(); void populatePlayersMenu(QMenu &iMenu, const QPoint &iPoint); void assignTopMove(); diff --git a/qt/arbitration_widget.cpp b/qt/arbitration_widget.cpp index 514c67d..2ec92b4 100644 --- a/qt/arbitration_widget.cpp +++ b/qt/arbitration_widget.cpp @@ -69,6 +69,8 @@ ArbitrationWidget::ArbitrationWidget(QWidget *parent, this, SIGNAL(notifyInfo(QString))); QObject::connect(m_assignmentsWidget, SIGNAL(endOfTurn()), this, SLOT(endOfTurnRefresh())); + QObject::connect(m_assignmentsWidget, SIGNAL(playerSelected(unsigned)), + this, SIGNAL(playerSelected(unsigned))); m_keyAccum = new KeyAccumulator(this, 400); diff --git a/qt/arbitration_widget.h b/qt/arbitration_widget.h index e78adbd..99a131d 100644 --- a/qt/arbitration_widget.h +++ b/qt/arbitration_widget.h @@ -54,6 +54,7 @@ signals: void notifyInfo(QString iMsg); void rackUpdated(const QString &iRack); void requestDefinition(QString iWord); + void playerSelected(unsigned playerId); public slots: void refresh(); diff --git a/qt/main_window.cpp b/qt/main_window.cpp index c171b1f..5f48ecc 100644 --- a/qt/main_window.cpp +++ b/qt/main_window.cpp @@ -157,15 +157,15 @@ MainWindow::MainWindow(QWidget *iParent) #if 1 // History - HistoryTabWidget *historyTab = new HistoryTabWidget; + m_historyTabWidget = new HistoryTabWidget; QObject::connect(this, SIGNAL(gameChanged(const PublicGame*)), - historyTab, SLOT(setGame(const PublicGame*))); + m_historyTabWidget, SLOT(setGame(const PublicGame*))); QObject::connect(this, SIGNAL(gameUpdated()), - historyTab, SLOT(refresh())); - QObject::connect(historyTab, SIGNAL(requestDefinition(QString)), + m_historyTabWidget, SLOT(refresh())); + QObject::connect(m_historyTabWidget, SIGNAL(requestDefinition(QString)), this, SLOT(showDefinition(QString))); QHBoxLayout *hlayout2 = new QHBoxLayout; - hlayout2->addWidget(historyTab); + hlayout2->addWidget(m_historyTabWidget); m_ui.groupBoxHistory->setLayout(hlayout2); #else m_ui.groupBoxHistory->hide(); @@ -412,6 +412,10 @@ void MainWindow::updateForGame(PublicGame *iGame) m_arbitrationWidget, SLOT(refresh())); // Connect with the dictionary tools only if needed linkArbitrationAnd7P1(); + + // When a player is selected, show his history + QObject::connect(m_arbitrationWidget, SIGNAL(playerSelected(unsigned)), + this, SLOT(onPlayerSelected(unsigned))); } else { @@ -497,6 +501,14 @@ void MainWindow::showDefinition(QString iWord) } +void MainWindow::onPlayerSelected(unsigned iPlayerId) +{ + // Select the corresponding tab in the history widget + // Note: we don't do the same for the external history widget... + m_historyTabWidget->setCurrentIndex(1 + iPlayerId); +} + + void MainWindow::closeEvent(QCloseEvent *event) { if (m_game) diff --git a/qt/main_window.h b/qt/main_window.h index 996a1dd..4a713dd 100644 --- a/qt/main_window.h +++ b/qt/main_window.h @@ -37,6 +37,7 @@ class Bag; class Board; class History; class PublicGame; +class HistoryTabWidget; class PlayerTabWidget; class ScoreWidget; class TrainingWidget; @@ -109,6 +110,9 @@ private slots: /** Perform work when the preferences were updated */ void prefsUpdated(); + /** Select the correct tab in the history widget when the player changes */ + void onPlayerSelected(unsigned iPlayerId); + /** * Perform several updates when the game changes (title bar, status bar, * grey out some menu items, ...) @@ -131,6 +135,9 @@ private: /// The UI file generated with Qt Designer Ui::MainWindow m_ui; + /// Widget for the game history + HistoryTabWidget *m_historyTabWidget; + /// Widget for the players PlayerTabWidget *m_playersWidget;