forked from mirror/openmw-tes3mp
Merge branch 'run'
Conflicts: apps/opencs/model/world/columns.cpp apps/opencs/model/world/columns.hpp apps/opencs/model/world/data.cpp components/CMakeLists.txtdeque
commit
d1d861e1be
@ -0,0 +1,157 @@
|
||||
|
||||
#include "runner.hpp"
|
||||
|
||||
#include <QTemporaryFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "operation.hpp"
|
||||
|
||||
CSMDoc::Runner::Runner (const boost::filesystem::path& projectPath)
|
||||
: mRunning (false), mStartup (0), mProjectPath (projectPath)
|
||||
{
|
||||
connect (&mProcess, SIGNAL (finished (int, QProcess::ExitStatus)),
|
||||
this, SLOT (finished (int, QProcess::ExitStatus)));
|
||||
|
||||
connect (&mProcess, SIGNAL (readyReadStandardOutput()),
|
||||
this, SLOT (readyReadStandardOutput()));
|
||||
|
||||
mProcess.setProcessChannelMode (QProcess::MergedChannels);
|
||||
|
||||
mProfile.blank();
|
||||
}
|
||||
|
||||
CSMDoc::Runner::~Runner()
|
||||
{
|
||||
if (mRunning)
|
||||
{
|
||||
disconnect (&mProcess, 0, this, 0);
|
||||
mProcess.kill();
|
||||
mProcess.waitForFinished();
|
||||
}
|
||||
}
|
||||
|
||||
void CSMDoc::Runner::start (bool delayed)
|
||||
{
|
||||
if (mStartup)
|
||||
{
|
||||
delete mStartup;
|
||||
mStartup = 0;
|
||||
}
|
||||
|
||||
if (!delayed)
|
||||
{
|
||||
mLog.clear();
|
||||
|
||||
QString path = "openmw";
|
||||
#ifdef Q_OS_WIN
|
||||
path.append(QString(".exe"));
|
||||
#elif defined(Q_OS_MAC)
|
||||
QDir dir(QCoreApplication::applicationDirPath());
|
||||
path = dir.absoluteFilePath(name);
|
||||
#else
|
||||
path.prepend(QString("./"));
|
||||
#endif
|
||||
|
||||
mStartup = new QTemporaryFile (this);
|
||||
mStartup->open();
|
||||
|
||||
{
|
||||
QTextStream stream (mStartup);
|
||||
|
||||
if (!mStartupInstruction.empty())
|
||||
stream << QString::fromUtf8 (mStartupInstruction.c_str()) << '\n';
|
||||
|
||||
stream << QString::fromUtf8 (mProfile.mScriptText.c_str());
|
||||
}
|
||||
|
||||
mStartup->close();
|
||||
|
||||
QStringList arguments;
|
||||
arguments << "--skip-menu";
|
||||
|
||||
if (mProfile.mFlags & ESM::DebugProfile::Flag_BypassNewGame)
|
||||
arguments << "--new-game=0";
|
||||
else
|
||||
arguments << "--new-game=1";
|
||||
|
||||
arguments << ("--script-run="+mStartup->fileName());;
|
||||
|
||||
arguments <<
|
||||
QString::fromUtf8 (("--data="+mProjectPath.parent_path().string()).c_str());
|
||||
|
||||
for (std::vector<std::string>::const_iterator iter (mContentFiles.begin());
|
||||
iter!=mContentFiles.end(); ++iter)
|
||||
{
|
||||
arguments << QString::fromUtf8 (("--content="+*iter).c_str());
|
||||
}
|
||||
|
||||
arguments
|
||||
<< QString::fromUtf8 (("--content="+mProjectPath.filename().string()).c_str());
|
||||
|
||||
mProcess.start (path, arguments);
|
||||
}
|
||||
|
||||
mRunning = true;
|
||||
emit runStateChanged();
|
||||
}
|
||||
|
||||
void CSMDoc::Runner::stop()
|
||||
{
|
||||
delete mStartup;
|
||||
mStartup = 0;
|
||||
|
||||
if (mProcess.state()==QProcess::NotRunning)
|
||||
{
|
||||
mRunning = false;
|
||||
emit runStateChanged();
|
||||
}
|
||||
else
|
||||
mProcess.kill();
|
||||
}
|
||||
|
||||
bool CSMDoc::Runner::isRunning() const
|
||||
{
|
||||
return mRunning;
|
||||
}
|
||||
|
||||
void CSMDoc::Runner::configure (const ESM::DebugProfile& profile,
|
||||
const std::vector<std::string>& contentFiles, const std::string& startupInstruction)
|
||||
{
|
||||
mProfile = profile;
|
||||
mContentFiles = contentFiles;
|
||||
mStartupInstruction = startupInstruction;
|
||||
}
|
||||
|
||||
void CSMDoc::Runner::finished (int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
mRunning = false;
|
||||
emit runStateChanged();
|
||||
}
|
||||
|
||||
QTextDocument *CSMDoc::Runner::getLog()
|
||||
{
|
||||
return &mLog;
|
||||
}
|
||||
|
||||
void CSMDoc::Runner::readyReadStandardOutput()
|
||||
{
|
||||
mLog.setPlainText (
|
||||
mLog.toPlainText() + QString::fromUtf8 (mProcess.readAllStandardOutput()));
|
||||
}
|
||||
|
||||
|
||||
CSMDoc::SaveWatcher::SaveWatcher (Runner *runner, Operation *operation)
|
||||
: QObject (runner), mRunner (runner)
|
||||
{
|
||||
connect (operation, SIGNAL (done (int, bool)), this, SLOT (saveDone (int, bool)));
|
||||
}
|
||||
|
||||
void CSMDoc::SaveWatcher::saveDone (int type, bool failed)
|
||||
{
|
||||
if (failed)
|
||||
mRunner->stop();
|
||||
else
|
||||
mRunner->start();
|
||||
|
||||
deleteLater();
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
#ifndef CSM_DOC_RUNNER_H
|
||||
#define CSM_DOC_RUNNER_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QTextDocument>
|
||||
|
||||
#include <components/esm/debugprofile.hpp>
|
||||
|
||||
class QTemporaryFile;
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
class Runner : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QProcess mProcess;
|
||||
bool mRunning;
|
||||
ESM::DebugProfile mProfile;
|
||||
std::vector<std::string> mContentFiles;
|
||||
std::string mStartupInstruction;
|
||||
QTemporaryFile *mStartup;
|
||||
QTextDocument mLog;
|
||||
boost::filesystem::path mProjectPath;
|
||||
|
||||
public:
|
||||
|
||||
Runner (const boost::filesystem::path& projectPath);
|
||||
|
||||
~Runner();
|
||||
|
||||
/// \param delayed Flag as running but do not start the OpenMW process yet (the
|
||||
/// process must be started by another call of start with delayed==false)
|
||||
void start (bool delayed = false);
|
||||
|
||||
void stop();
|
||||
|
||||
/// \note Running state is entered when the start function is called. This
|
||||
/// is not necessarily identical to the moment the child process is started.
|
||||
bool isRunning() const;
|
||||
|
||||
void configure (const ESM::DebugProfile& profile,
|
||||
const std::vector<std::string>& contentFiles,
|
||||
const std::string& startupInstruction);
|
||||
|
||||
QTextDocument *getLog();
|
||||
|
||||
signals:
|
||||
|
||||
void runStateChanged();
|
||||
|
||||
private slots:
|
||||
|
||||
void finished (int exitCode, QProcess::ExitStatus exitStatus);
|
||||
|
||||
void readyReadStandardOutput();
|
||||
};
|
||||
|
||||
class Operation;
|
||||
|
||||
/// \brief Watch for end of save operation and restart or stop runner
|
||||
class SaveWatcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Runner *mRunner;
|
||||
|
||||
public:
|
||||
|
||||
/// *this attaches itself to runner
|
||||
SaveWatcher (Runner *runner, Operation *operation);
|
||||
|
||||
private slots:
|
||||
|
||||
void saveDone (int type, bool failed);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
#ifndef CSM_FILTER_FILTER_H
|
||||
#define CSM_FILTER_FILTER_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <components/esm/filter.hpp>
|
||||
|
||||
namespace CSMFilter
|
||||
{
|
||||
/// \brief Wrapper for Filter record
|
||||
struct Filter : public ESM::Filter
|
||||
{
|
||||
enum Scope
|
||||
{
|
||||
Scope_Project = 0, // per project
|
||||
Scope_Session = 1, // exists only for one editing session; not saved
|
||||
Scope_Content = 2 // embedded in the edited content file
|
||||
};
|
||||
|
||||
Scope mScope;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,25 @@
|
||||
|
||||
#include "scope.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
CSMWorld::Scope CSMWorld::getScopeFromId (const std::string& id)
|
||||
{
|
||||
// get root namespace
|
||||
std::string namespace_;
|
||||
|
||||
std::string::size_type i = id.find ("::");
|
||||
|
||||
if (i!=std::string::npos)
|
||||
namespace_ = Misc::StringUtils::lowerCase (id.substr (0, i));
|
||||
|
||||
if (namespace_=="project")
|
||||
return Scope_Project;
|
||||
|
||||
if (namespace_=="session")
|
||||
return Scope_Session;
|
||||
|
||||
return Scope_Content;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#ifndef CSM_WOLRD_SCOPE_H
|
||||
#define CSM_WOLRD_SCOPE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
enum Scope
|
||||
{
|
||||
// record stored in content file
|
||||
Scope_Content = 1,
|
||||
|
||||
// record stored in project file
|
||||
Scope_Project = 2,
|
||||
|
||||
// record that exists only for the duration of one editing session
|
||||
Scope_Session = 4
|
||||
};
|
||||
|
||||
Scope getScopeFromId (const std::string& id);
|
||||
}
|
||||
|
||||
#endif
|
@ -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()));
|
||||
}
|
@ -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
|
@ -0,0 +1,20 @@
|
||||
|
||||
#include "runlogsubview.hpp"
|
||||
|
||||
#include <QTextEdit>
|
||||
|
||||
CSVDoc::RunLogSubView::RunLogSubView (const CSMWorld::UniversalId& id,
|
||||
CSMDoc::Document& document)
|
||||
: SubView (id)
|
||||
{
|
||||
QTextEdit *edit = new QTextEdit (this);
|
||||
edit->setDocument (document.getRunLog());
|
||||
edit->setReadOnly (true);
|
||||
|
||||
setWidget (edit);
|
||||
}
|
||||
|
||||
void CSVDoc::RunLogSubView::setEditLock (bool locked)
|
||||
{
|
||||
// ignored since this SubView does not have editing
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef CSV_DOC_RUNLOGSUBVIEW_H
|
||||
#define CSV_DOC_RUNLOGSUBVIEW_H
|
||||
|
||||
#include "subview.hpp"
|
||||
|
||||
namespace CSVDoc
|
||||
{
|
||||
class RunLogSubView : public SubView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
RunLogSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
|
||||
|
||||
virtual void setEditLock (bool locked);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,77 +0,0 @@
|
||||
|
||||
#include "filtercreator.hpp"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
|
||||
#include "../../model/filter/filter.hpp"
|
||||
|
||||
#include "../../model/world/data.hpp"
|
||||
#include "../../model/world/commands.hpp"
|
||||
#include "../../model/world/columns.hpp"
|
||||
#include "../../model/world/idtable.hpp"
|
||||
|
||||
std::string CSVFilter::FilterCreator::getNamespace() const
|
||||
{
|
||||
switch (mScope->currentIndex())
|
||||
{
|
||||
case CSMFilter::Filter::Scope_Project: return "project::";
|
||||
case CSMFilter::Filter::Scope_Session: return "session::";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void CSVFilter::FilterCreator::update()
|
||||
{
|
||||
mNamespace->setText (QString::fromUtf8 (getNamespace().c_str()));
|
||||
GenericCreator::update();
|
||||
}
|
||||
|
||||
std::string CSVFilter::FilterCreator::getId() const
|
||||
{
|
||||
return getNamespace() + GenericCreator::getId();
|
||||
}
|
||||
|
||||
void CSVFilter::FilterCreator::configureCreateCommand (CSMWorld::CreateCommand& command) const
|
||||
{
|
||||
int index =
|
||||
dynamic_cast<CSMWorld::IdTable&> (*getData().getTableModel (getCollectionId())).
|
||||
findColumnIndex (CSMWorld::Columns::ColumnId_Scope);
|
||||
|
||||
command.addValue (index, mScope->currentIndex());
|
||||
}
|
||||
|
||||
CSVFilter::FilterCreator::FilterCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id)
|
||||
: GenericCreator (data, undoStack, id)
|
||||
{
|
||||
mNamespace = new QLabel ("::", this);
|
||||
insertAtBeginning (mNamespace, false);
|
||||
|
||||
mScope = new QComboBox (this);
|
||||
|
||||
mScope->addItem ("Project");
|
||||
mScope->addItem ("Session");
|
||||
/// \todo re-enable for OpenMW 1.1
|
||||
// mScope->addItem ("Content");
|
||||
|
||||
connect (mScope, SIGNAL (currentIndexChanged (int)), this, SLOT (setScope (int)));
|
||||
|
||||
insertAtBeginning (mScope, false);
|
||||
|
||||
QLabel *label = new QLabel ("Scope", this);
|
||||
insertAtBeginning (label, false);
|
||||
|
||||
mScope->setCurrentIndex (1);
|
||||
}
|
||||
|
||||
void CSVFilter::FilterCreator::reset()
|
||||
{
|
||||
GenericCreator::reset();
|
||||
}
|
||||
|
||||
void CSVFilter::FilterCreator::setScope (int index)
|
||||
{
|
||||
update();
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
#ifndef CSV_FILTER_FILTERCREATOR_H
|
||||
#define CSV_FILTER_FILTERCREATOR_H
|
||||
|
||||
class QComboBox;
|
||||
class QLabel;
|
||||
|
||||
#include "../world/genericcreator.hpp"
|
||||
|
||||
namespace CSVFilter
|
||||
{
|
||||
class FilterCreator : public CSVWorld::GenericCreator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QComboBox *mScope;
|
||||
QLabel *mNamespace;
|
||||
|
||||
private:
|
||||
|
||||
std::string getNamespace() const;
|
||||
|
||||
protected:
|
||||
|
||||
void update();
|
||||
|
||||
virtual std::string getId() const;
|
||||
|
||||
virtual void configureCreateCommand (CSMWorld::CreateCommand& command) const;
|
||||
|
||||
public:
|
||||
|
||||
FilterCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id);
|
||||
|
||||
virtual void reset();
|
||||
|
||||
private slots:
|
||||
|
||||
void setScope (int index);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,151 @@
|
||||
|
||||
#include "scenetoolrun.hpp"
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include <QFrame>
|
||||
#include <QTableWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QApplication>
|
||||
|
||||
void CSVWidget::SceneToolRun::adjustToolTips()
|
||||
{
|
||||
QString toolTip = mToolTip;
|
||||
|
||||
if (mSelected==mProfiles.end())
|
||||
toolTip += "<p>No debug profile selected (function disabled)";
|
||||
else
|
||||
{
|
||||
toolTip += "<p>Debug profile: " + QString::fromUtf8 (mSelected->c_str());
|
||||
toolTip += "<p>(right click to switch to a different profile)";
|
||||
}
|
||||
|
||||
setToolTip (toolTip);
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolRun::updateIcon()
|
||||
{
|
||||
setIcon (QIcon (mSelected==mProfiles.end() ? mIconDisabled : mIcon));
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolRun::updatePanel()
|
||||
{
|
||||
mTable->setRowCount (mProfiles.size());
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (std::set<std::string>::const_iterator iter (mProfiles.begin()); iter!=mProfiles.end();
|
||||
++iter, ++i)
|
||||
{
|
||||
mTable->setItem (i, 0, new QTableWidgetItem (QString::fromUtf8 (iter->c_str())));
|
||||
|
||||
mTable->setItem (i, 1, new QTableWidgetItem (
|
||||
QApplication::style()->standardIcon (QStyle::SP_TitleBarCloseButton), ""));
|
||||
}
|
||||
}
|
||||
|
||||
CSVWidget::SceneToolRun::SceneToolRun (SceneToolbar *parent, const QString& toolTip,
|
||||
const QString& icon, const QString& iconDisabled, const std::vector<std::string>& profiles)
|
||||
: SceneTool (parent, Type_TopAction), mProfiles (profiles.begin(), profiles.end()),
|
||||
mSelected (mProfiles.begin()), mToolTip (toolTip), mIcon (icon),
|
||||
mIconDisabled (iconDisabled)
|
||||
{
|
||||
updateIcon();
|
||||
adjustToolTips();
|
||||
|
||||
mPanel = new QFrame (this, Qt::Popup);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout (mPanel);
|
||||
|
||||
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||
|
||||
mTable = new QTableWidget (0, 2, this);
|
||||
|
||||
mTable->setShowGrid (false);
|
||||
mTable->verticalHeader()->hide();
|
||||
mTable->horizontalHeader()->hide();
|
||||
mTable->horizontalHeader()->setResizeMode (0, QHeaderView::Stretch);
|
||||
mTable->horizontalHeader()->setResizeMode (1, QHeaderView::ResizeToContents);
|
||||
mTable->setSelectionMode (QAbstractItemView::NoSelection);
|
||||
|
||||
layout->addWidget (mTable);
|
||||
|
||||
connect (mTable, SIGNAL (clicked (const QModelIndex&)),
|
||||
this, SLOT (clicked (const QModelIndex&)));
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolRun::showPanel (const QPoint& position)
|
||||
{
|
||||
updatePanel();
|
||||
|
||||
mPanel->move (position);
|
||||
mPanel->show();
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolRun::activate()
|
||||
{
|
||||
if (mSelected!=mProfiles.end())
|
||||
emit runRequest (*mSelected);
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolRun::removeProfile (const std::string& profile)
|
||||
{
|
||||
std::set<std::string>::iterator iter = mProfiles.find (profile);
|
||||
|
||||
if (iter!=mProfiles.end())
|
||||
{
|
||||
if (iter==mSelected)
|
||||
{
|
||||
if (iter!=mProfiles.begin())
|
||||
--mSelected;
|
||||
else
|
||||
++mSelected;
|
||||
}
|
||||
|
||||
mProfiles.erase (iter);
|
||||
|
||||
if (mSelected==mProfiles.end())
|
||||
updateIcon();
|
||||
|
||||
adjustToolTips();
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolRun::addProfile (const std::string& profile)
|
||||
{
|
||||
std::set<std::string>::iterator iter = mProfiles.find (profile);
|
||||
|
||||
if (iter==mProfiles.end())
|
||||
{
|
||||
mProfiles.insert (profile);
|
||||
|
||||
if (mSelected==mProfiles.end())
|
||||
{
|
||||
mSelected = mProfiles.begin();
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
adjustToolTips();
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolRun::clicked (const QModelIndex& index)
|
||||
{
|
||||
if (index.column()==0)
|
||||
{
|
||||
// select profile
|
||||
mSelected = mProfiles.begin();
|
||||
std::advance (mSelected, index.row());
|
||||
mPanel->hide();
|
||||
adjustToolTips();
|
||||
}
|
||||
else if (index.column()==1)
|
||||
{
|
||||
// remove profile from list
|
||||
std::set<std::string>::iterator iter = mProfiles.begin();
|
||||
std::advance (iter, index.row());
|
||||
removeProfile (*iter);
|
||||
updatePanel();
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
#ifndef CSV_WIDGET_SCENETOOLRUN_H
|
||||
#define CSV_WIDGET_SCENETOOLRUN_H
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "scenetool.hpp"
|
||||
|
||||
class QFrame;
|
||||
class QTableWidget;
|
||||
class QModelIndex;
|
||||
|
||||
namespace CSVWidget
|
||||
{
|
||||
class SceneToolRun : public SceneTool
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
std::set<std::string> mProfiles;
|
||||
std::set<std::string>::iterator mSelected;
|
||||
QString mToolTip;
|
||||
QString mIcon;
|
||||
QString mIconDisabled;
|
||||
QFrame *mPanel;
|
||||
QTableWidget *mTable;
|
||||
|
||||
private:
|
||||
|
||||
void adjustToolTips();
|
||||
|
||||
void updateIcon();
|
||||
|
||||
void updatePanel();
|
||||
|
||||
public:
|
||||
|
||||
SceneToolRun (SceneToolbar *parent, const QString& toolTip, const QString& icon,
|
||||
const QString& iconDisabled, const std::vector<std::string>& profiles);
|
||||
|
||||
virtual void showPanel (const QPoint& position);
|
||||
|
||||
virtual void activate();
|
||||
|
||||
/// \attention This function does not remove the profile from the profile selection
|
||||
/// panel.
|
||||
void removeProfile (const std::string& profile);
|
||||
|
||||
/// \attention This function doe not add the profile to the profile selection
|
||||
/// panel. This only happens when the panel is re-opened.
|
||||
///
|
||||
/// \note Adding profiles that are already listed is a no-op.
|
||||
void addProfile (const std::string& profile);
|
||||
|
||||
private slots:
|
||||
|
||||
void clicked (const QModelIndex& index);
|
||||
|
||||
signals:
|
||||
|
||||
void runRequest (const std::string& profile);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,17 +0,0 @@
|
||||
#include "omwloader.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
|
||||
OmwLoader::OmwLoader(Loading::Listener& listener)
|
||||
: ContentLoader(listener)
|
||||
{
|
||||
}
|
||||
|
||||
void OmwLoader::load(const boost::filesystem::path& filepath, int& index)
|
||||
{
|
||||
ContentLoader::load(filepath.filename(), index);
|
||||
}
|
||||
|
||||
} /* namespace MWWorld */
|
||||
|
@ -1,21 +0,0 @@
|
||||
#ifndef OMWLOADER_HPP
|
||||
#define OMWLOADER_HPP
|
||||
|
||||
#include "contentloader.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Placeholder for real OpenMW content loader
|
||||
*/
|
||||
struct OmwLoader : public ContentLoader
|
||||
{
|
||||
OmwLoader(Loading::Listener& listener);
|
||||
|
||||
void load(const boost::filesystem::path& filepath, int& index);
|
||||
};
|
||||
|
||||
} /* namespace MWWorld */
|
||||
|
||||
#endif /* OMWLOADER_HPP */
|
@ -0,0 +1,29 @@
|
||||
|
||||
#include "debugprofile.hpp"
|
||||
|
||||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
#include "defs.hpp"
|
||||
|
||||
unsigned int ESM::DebugProfile::sRecordId = REC_DBGP;
|
||||
|
||||
void ESM::DebugProfile::load (ESMReader& esm)
|
||||
{
|
||||
mDescription = esm.getHNString ("DESC");
|
||||
mScriptText = esm.getHNString ("SCRP");
|
||||
esm.getHNT (mFlags, "FLAG");
|
||||
}
|
||||
|
||||
void ESM::DebugProfile::save (ESMWriter& esm) const
|
||||
{
|
||||
esm.writeHNCString ("DESC", mDescription);
|
||||
esm.writeHNCString ("SCRP", mScriptText);
|
||||
esm.writeHNT ("FLAG", mFlags);
|
||||
}
|
||||
|
||||
void ESM::DebugProfile::blank()
|
||||
{
|
||||
mDescription.clear();
|
||||
mScriptText.clear();
|
||||
mFlags = 0;
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
#ifndef COMPONENTS_ESM_DEBUGPROFILE_H
|
||||
#define COMPONENTS_ESM_DEBUGPROFILE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
class ESMWriter;
|
||||
|
||||
struct DebugProfile
|
||||
{
|
||||
static unsigned int sRecordId;
|
||||
|
||||
enum Flags
|
||||
{
|
||||
Flag_Default = 1, // add to newly opened scene subviews
|
||||
Flag_BypassNewGame = 2, // bypass regular game startup
|
||||
Flag_Global = 4 // make available from main menu (i.e. not location specific)
|
||||
};
|
||||
|
||||
std::string mId;
|
||||
|
||||
std::string mDescription;
|
||||
|
||||
std::string mScriptText;
|
||||
|
||||
unsigned int mFlags;
|
||||
|
||||
void load (ESMReader& esm);
|
||||
void save (ESMWriter& esm) const;
|
||||
|
||||
/// Set record to default state (does not touch the ID).
|
||||
void blank();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue