summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Tanner <trtanner@btinternet.com>2015-12-25 21:57:23 +0000
committerThomas Tanner <trtanner@btinternet.com>2015-12-25 21:57:23 +0000
commit3869eaaf2bfacf4a44733b8346d790999588c37f (patch)
treeac83109ee9d5036920022565405783384debcd5a /src
parent6edf12f2f7089364611c7f979ad20fa867604477 (diff)
Transferring the savegame widget into gamebryo + some cleanup
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp40
-rw-r--r--src/mainwindow.h7
-rw-r--r--src/savegameinfowidgetgamebryo.cpp4
-rw-r--r--src/transfersavesdialog.cpp4
4 files changed, 24 insertions, 31 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 8f71f636..0a690a8e 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -29,6 +29,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "iplugingame.h"
#include "iplugindiagnose.h"
#include "isavegame.h"
+#include "isavegameinfowidget.h"
#include "nexusinterface.h"
#include "organizercore.h"
#include "pluginlistsortproxy.h"
@@ -864,33 +865,25 @@ void MainWindow::setBrowserGeometry(const QByteArray &geometry)
m_IntegratedBrowser.restoreGeometry(geometry);
}
-ISaveGame const *MainWindow::getSaveGame(QListWidgetItem *item)
+void MainWindow::displaySaveGameInfo(QListWidgetItem *newItem)
{
- try {
+ QString const &save = newItem->data(Qt::UserRole).toString();
+ if (m_CurrentSaveView == nullptr) {
+ //FIXME Is this the right place?
IPluginGame const *game = m_OrganizerCore.managedGame();
SaveGameInfo const *info = game->feature<SaveGameInfo>();
if (info != nullptr) {
- return info->getSaveGameInfo(item->data(Qt::UserRole).toString());
+ m_CurrentSaveView = info->getSaveGameWidget(this);
+ }
+ if (m_CurrentSaveView == nullptr) {
+ return;
}
- //SaveGameGamebryo *saveGame = new SaveGameGamebryo(/*this,*/ item->data(Qt::UserRole).toString(), game);
- //saveGame->setParent(item->listWidget());
- //return saveGame;
- } catch (const std::exception &e) {
- reportError(tr("failed to read savegame: %1").arg(e.what()));
- }
- return nullptr;
-}
-
-void MainWindow::displaySaveGameInfo(MOBase::ISaveGame const *save, QPoint pos)
-{
- if (m_CurrentSaveView == nullptr) {
- m_CurrentSaveView = new SaveGameInfoWidgetGamebryo(save, m_OrganizerCore.pluginList(), this);
- } else {
- m_CurrentSaveView->setSave(save);
}
+ m_CurrentSaveView->setSave(save);
QRect screenRect = QApplication::desktop()->availableGeometry(m_CurrentSaveView);
+ QPoint pos = QCursor::pos();
if (pos.x() + m_CurrentSaveView->width() > screenRect.right()) {
pos.rx() -= (m_CurrentSaveView->width() + 2);
} else {
@@ -905,8 +898,9 @@ void MainWindow::displaySaveGameInfo(MOBase::ISaveGame const *save, QPoint pos)
m_CurrentSaveView->move(pos);
m_CurrentSaveView->show();
+ m_CurrentSaveView->setProperty("displayItem", qVariantFromValue(static_cast<void *>(newItem)));
+
ui->savegameList->activateWindow();
- connect(m_CurrentSaveView, SIGNAL(closeSaveInfo()), this, SLOT(hideSaveGameInfo()));
}
@@ -915,20 +909,14 @@ void MainWindow::saveSelectionChanged(QListWidgetItem *newItem)
if (newItem == nullptr) {
hideSaveGameInfo();
} else if (m_CurrentSaveView == nullptr || newItem != m_CurrentSaveView->property("displayItem").value<void*>()) {
- MOBase::ISaveGame const *save = getSaveGame(newItem);
- if (save != nullptr) {
- displaySaveGameInfo(save, QCursor::pos());
- m_CurrentSaveView->setProperty("displayItem", qVariantFromValue(static_cast<void *>(newItem)));
- }
+ displaySaveGameInfo(newItem);
}
}
-
void MainWindow::hideSaveGameInfo()
{
if (m_CurrentSaveView != nullptr) {
- disconnect(m_CurrentSaveView, SIGNAL(closeSaveInfo()), this, SLOT(hideSaveGameInfo()));
m_CurrentSaveView->deleteLater();
m_CurrentSaveView = nullptr;
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 07f24540..0fd15d85 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -256,9 +256,7 @@ private:
void setCategoryListVisible(bool visible);
- MOBase::ISaveGame const *getSaveGame(QListWidgetItem *item);
-
- void displaySaveGameInfo(MOBase::ISaveGame const *save, QPoint pos);
+ void displaySaveGameInfo(QListWidgetItem *newItem);
HANDLE nextChildProcess();
@@ -333,7 +331,8 @@ private:
QTimer m_UpdateProblemsTimer;
QTime m_StartTime;
- SaveGameInfoWidget *m_CurrentSaveView;
+ //SaveGameInfoWidget *m_CurrentSaveView;
+ MOBase::ISaveGameInfoWidget *m_CurrentSaveView;
OrganizerCore &m_OrganizerCore;
PluginContainer &m_PluginContainer;
diff --git a/src/savegameinfowidgetgamebryo.cpp b/src/savegameinfowidgetgamebryo.cpp
index 854043a3..1836a8f2 100644
--- a/src/savegameinfowidgetgamebryo.cpp
+++ b/src/savegameinfowidgetgamebryo.cpp
@@ -54,7 +54,9 @@ void SaveGameInfoWidgetGamebryo::setSave(MOBase::ISaveGame const *saveGame)
layout->addWidget(header);
int count = 0;
for (QString const &pluginName : gamebryoSave->getPlugins()) {
- if (m_PluginList->isEnabled(pluginName)) {
+ //if (m_PluginList->isEnabled(pluginName)) {
+ //should use IPluginList * in interface
+ if (m_PluginList->state(pluginName) == MOBase::IPluginList::STATE_ACTIVE) {
continue;
}
diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp
index 2f1c41a1..cb3d0d61 100644
--- a/src/transfersavesdialog.cpp
+++ b/src/transfersavesdialog.cpp
@@ -90,6 +90,10 @@ public:
return {};
}
+ MOBase::ISaveGameInfoWidget *getSaveGameWidget(QWidget *) const override
+ {
+ return nullptr;
+ }
};
} //end anonymous namespace