forked from teamnwah/openmw-tes3coop
full implementation of global run menu item (replaces earlier placeholder implementation)
This commit is contained in:
parent
67dfaa7f35
commit
a728d6d77a
5 changed files with 161 additions and 9 deletions
|
@ -44,7 +44,7 @@ opencs_units_noqt (model/tools
|
|||
|
||||
opencs_units (view/doc
|
||||
viewmanager view operations operation subview startup filedialog newgame
|
||||
filewidget adjusterwidget loader
|
||||
filewidget adjusterwidget loader globaldebugprofilemenu
|
||||
)
|
||||
|
||||
|
||||
|
|
93
apps/opencs/view/doc/globaldebugprofilemenu.cpp
Normal file
93
apps/opencs/view/doc/globaldebugprofilemenu.cpp
Normal file
|
@ -0,0 +1,93 @@
|
|||
|
||||
#include "globaldebugprofilemenu.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include <QActionGroup>
|
||||
|
||||
#include "../../model/world/idtable.hpp"
|
||||
#include "../../model/world/record.hpp"
|
||||
|
||||
void CSVDoc::GlobalDebugProfileMenu::rebuild()
|
||||
{
|
||||
clear();
|
||||
|
||||
delete mActions;
|
||||
mActions = 0;
|
||||
|
||||
int idColumn = mDebugProfiles->findColumnIndex (CSMWorld::Columns::ColumnId_Id);
|
||||
int stateColumn = mDebugProfiles->findColumnIndex (CSMWorld::Columns::ColumnId_Modification);
|
||||
int globalColumn = mDebugProfiles->findColumnIndex (
|
||||
CSMWorld::Columns::ColumnId_GlobalProfile);
|
||||
|
||||
int size = mDebugProfiles->rowCount();
|
||||
|
||||
std::vector<QString> ids;
|
||||
|
||||
for (int i=0; i<size; ++i)
|
||||
{
|
||||
int state = mDebugProfiles->data (mDebugProfiles->index (i, stateColumn)).toInt();
|
||||
|
||||
bool global = mDebugProfiles->data (mDebugProfiles->index (i, globalColumn)).toInt();
|
||||
|
||||
if (state!=CSMWorld::RecordBase::State_Deleted && global)
|
||||
ids.push_back (
|
||||
mDebugProfiles->data (mDebugProfiles->index (i, idColumn)).toString());
|
||||
}
|
||||
|
||||
mActions = new QActionGroup (this);
|
||||
connect (mActions, SIGNAL (triggered (QAction *)), this, SLOT (actionTriggered (QAction *)));
|
||||
|
||||
std::sort (ids.begin(), ids.end());
|
||||
|
||||
for (std::vector<QString>::const_iterator iter (ids.begin()); iter!=ids.end(); ++iter)
|
||||
{
|
||||
mActions->addAction (addAction (*iter));
|
||||
}
|
||||
}
|
||||
|
||||
CSVDoc::GlobalDebugProfileMenu::GlobalDebugProfileMenu (CSMWorld::IdTable *debugProfiles,
|
||||
QWidget *parent)
|
||||
: QMenu (parent), mDebugProfiles (debugProfiles), mActions (0)
|
||||
{
|
||||
rebuild();
|
||||
|
||||
connect (mDebugProfiles, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
||||
this, SLOT (profileAboutToBeRemoved (const QModelIndex&, int, int)));
|
||||
|
||||
connect (mDebugProfiles, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
||||
this, SLOT (profileInserted (const QModelIndex&, int, int)));
|
||||
|
||||
connect (mDebugProfiles, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
|
||||
this, SLOT (profileChanged (const QModelIndex&, const QModelIndex&)));
|
||||
}
|
||||
|
||||
void CSVDoc::GlobalDebugProfileMenu::updateActions (bool running)
|
||||
{
|
||||
if (mActions)
|
||||
mActions->setEnabled (!running);
|
||||
}
|
||||
|
||||
void CSVDoc::GlobalDebugProfileMenu::profileAboutToBeRemoved (const QModelIndex& parent,
|
||||
int start, int end)
|
||||
{
|
||||
rebuild();
|
||||
}
|
||||
|
||||
void CSVDoc::GlobalDebugProfileMenu::profileInserted (const QModelIndex& parent, int start,
|
||||
int end)
|
||||
{
|
||||
rebuild();
|
||||
}
|
||||
|
||||
void CSVDoc::GlobalDebugProfileMenu::profileChanged (const QModelIndex& topLeft,
|
||||
const QModelIndex& bottomRight)
|
||||
{
|
||||
rebuild();
|
||||
}
|
||||
|
||||
void CSVDoc::GlobalDebugProfileMenu::actionTriggered (QAction *action)
|
||||
{
|
||||
emit triggered (std::string (action->text().toUtf8().constData()));
|
||||
}
|
49
apps/opencs/view/doc/globaldebugprofilemenu.hpp
Normal file
49
apps/opencs/view/doc/globaldebugprofilemenu.hpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
#ifndef CSV_DOC_GLOBALDEBUGPROFILEMENU_H
|
||||
#define CSV_DOC_GLOBALDEBUGPROFILEMENU_H
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
class QModelIndex;
|
||||
class QActionGroup;
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
class IdTable;
|
||||
}
|
||||
|
||||
namespace CSVDoc
|
||||
{
|
||||
class GlobalDebugProfileMenu : public QMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
CSMWorld::IdTable *mDebugProfiles;
|
||||
QActionGroup *mActions;
|
||||
|
||||
private:
|
||||
|
||||
void rebuild();
|
||||
|
||||
public:
|
||||
|
||||
GlobalDebugProfileMenu (CSMWorld::IdTable *debugProfiles, QWidget *parent = 0);
|
||||
|
||||
void updateActions (bool running);
|
||||
|
||||
private slots:
|
||||
|
||||
void profileAboutToBeRemoved (const QModelIndex& parent, int start, int end);
|
||||
|
||||
void profileInserted (const QModelIndex& parent, int start, int end);
|
||||
|
||||
void profileChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
||||
|
||||
void actionTriggered (QAction *action);
|
||||
|
||||
signals:
|
||||
|
||||
void triggered (const std::string& profile);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -12,6 +12,8 @@
|
|||
#include "../../model/doc/document.hpp"
|
||||
#include "../../model/settings/usersettings.hpp"
|
||||
|
||||
#include "../../model/world/idtable.hpp"
|
||||
|
||||
#include "../world/subviews.hpp"
|
||||
|
||||
#include "../tools/subviews.hpp"
|
||||
|
@ -19,6 +21,7 @@
|
|||
#include "viewmanager.hpp"
|
||||
#include "operations.hpp"
|
||||
#include "subview.hpp"
|
||||
#include "globaldebugprofilemenu.hpp"
|
||||
|
||||
void CSVDoc::View::closeEvent (QCloseEvent *event)
|
||||
{
|
||||
|
@ -242,9 +245,15 @@ void CSVDoc::View::setupDebugMenu()
|
|||
|
||||
debug->addSeparator();
|
||||
|
||||
mRunDebug = new QAction (tr ("Run OpenMW"), this);
|
||||
connect (mRunDebug, SIGNAL (triggered()), this, SLOT (run()));
|
||||
debug->addAction (mRunDebug);
|
||||
mGlobalDebugProfileMenu = new GlobalDebugProfileMenu (
|
||||
&dynamic_cast<CSMWorld::IdTable&> (*mDocument->getData().getTableModel (
|
||||
CSMWorld::UniversalId::Type_DebugProfiles)), this);
|
||||
|
||||
connect (mGlobalDebugProfileMenu, SIGNAL (triggered (const std::string&)),
|
||||
this, SLOT (run (const std::string&)));
|
||||
|
||||
QAction *runDebug = debug->addMenu (mGlobalDebugProfileMenu);
|
||||
runDebug->setText (tr ("Run OpenMW"));
|
||||
|
||||
mStopDebug = new QAction (tr ("Shutdown OpenMW"), this);
|
||||
connect (mStopDebug, SIGNAL (triggered()), this, SLOT (stop()));
|
||||
|
@ -292,7 +301,7 @@ void CSVDoc::View::updateActions()
|
|||
mSave->setEnabled (!(mDocument->getState() & CSMDoc::State_Saving) && !running);
|
||||
mVerify->setEnabled (!(mDocument->getState() & CSMDoc::State_Verifying));
|
||||
|
||||
mRunDebug->setEnabled (!running);
|
||||
mGlobalDebugProfileMenu->updateActions (running);
|
||||
mStopDebug->setEnabled (running);
|
||||
}
|
||||
|
||||
|
@ -620,9 +629,9 @@ void CSVDoc::View::loadErrorLog()
|
|||
addSubView (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_LoadErrorLog, 0));
|
||||
}
|
||||
|
||||
void CSVDoc::View::run()
|
||||
void CSVDoc::View::run (const std::string& profile, const std::string& startupInstruction)
|
||||
{
|
||||
mDocument->startRunning ("", "");
|
||||
mDocument->startRunning (profile, startupInstruction);
|
||||
}
|
||||
|
||||
void CSVDoc::View::stop()
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace CSVDoc
|
|||
{
|
||||
class ViewManager;
|
||||
class Operations;
|
||||
class GlobalDebugProfileMenu;
|
||||
|
||||
class View : public QMainWindow
|
||||
{
|
||||
|
@ -39,12 +40,12 @@ namespace CSVDoc
|
|||
QAction *mSave;
|
||||
QAction *mVerify;
|
||||
QAction *mShowStatusBar;
|
||||
QAction *mRunDebug;
|
||||
QAction *mStopDebug;
|
||||
std::vector<QAction *> mEditingActions;
|
||||
Operations *mOperations;
|
||||
SubViewFactoryManager mSubViewFactory;
|
||||
QMainWindow mSubViewWindow;
|
||||
GlobalDebugProfileMenu *mGlobalDebugProfileMenu;
|
||||
|
||||
|
||||
// not implemented
|
||||
|
@ -204,7 +205,7 @@ namespace CSVDoc
|
|||
|
||||
void loadErrorLog();
|
||||
|
||||
void run();
|
||||
void run (const std::string& profile, const std::string& startupInstruction = "");
|
||||
|
||||
void stop();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue