From 1f9dd45e498b812a4884ce8221f9ee8250f475df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 7 Apr 2015 01:21:03 +0200 Subject: [PATCH] GH-329 update description text in MainWindow when instance Minecraft version changes --- application/MainWindow.cpp | 13 +++++++++++++ application/MainWindow.h | 2 ++ logic/minecraft/OneSixInstance.cpp | 1 + 3 files changed, 16 insertions(+) diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index 07f0d02f..5b56ca31 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -480,6 +480,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi view->setFrameShape(QFrame::NoFrame); view->setModel(proxymodel); + connect(proxymodel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector)), SLOT(instanceDataChanged(QModelIndex,QModelIndex))); + view->setContextMenuPolicy(Qt::CustomContextMenu); connect(view, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showInstanceContextMenu(const QPoint &))); @@ -1939,6 +1941,17 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex & } } +void MainWindow::instanceDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight) +{ + auto current = view->selectionModel()->currentIndex(); + QItemSelection test(topLeft, bottomRight); + if(test.contains(current)) + { + instanceChanged(current, current); + } +} + + void MainWindow::selectionBad() { // start by reseting everything... diff --git a/application/MainWindow.h b/application/MainWindow.h index 96d9c7bb..97111e04 100644 --- a/application/MainWindow.h +++ b/application/MainWindow.h @@ -154,6 +154,8 @@ slots: void instanceChanged(const QModelIndex ¤t, const QModelIndex &previous); + void instanceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + void selectionBad(); void startTask(Task *task); diff --git a/logic/minecraft/OneSixInstance.cpp b/logic/minecraft/OneSixInstance.cpp index 915314d0..7a29c4b4 100644 --- a/logic/minecraft/OneSixInstance.cpp +++ b/logic/minecraft/OneSixInstance.cpp @@ -264,6 +264,7 @@ bool OneSixInstance::setIntendedVersionId(QString version) { clearProfile(); } + emit propertiesChanged(this); return true; }