1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-19 17:09:40 +00:00

added merge operation (doesn't do anything yet)

This commit is contained in:
Marc Zinnschlag 2015-08-13 12:03:20 +02:00
parent 708cacdec4
commit 904ad94952
8 changed files with 97 additions and 8 deletions

View file

@ -42,6 +42,7 @@ opencs_units_noqt (model/tools
mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
birthsigncheck spellcheck referencecheck referenceablecheck scriptcheck bodypartcheck
startscriptcheck search searchoperation searchstage pathgridcheck soundgencheck
mergeoperation
)

View file

@ -2388,6 +2388,12 @@ void CSMDoc::Document::runSearch (const CSMWorld::UniversalId& searchId, const C
emit stateChanged (getState(), this);
}
void CSMDoc::Document::runMerge (const boost::filesystem::path& target)
{
mTools.runMerge (target);
emit stateChanged (getState(), this);
}
void CSMDoc::Document::abortOperation (int type)
{
if (type==State_Saving)

View file

@ -129,7 +129,9 @@ namespace CSMDoc
CSMWorld::UniversalId newSearch();
void runSearch (const CSMWorld::UniversalId& searchId, const CSMTools::Search& search);
void runMerge (const boost::filesystem::path& target);
void abortOperation (int type);
const CSMWorld::Data& getData() const;
@ -173,4 +175,3 @@ namespace CSMDoc
}
#endif

View file

@ -0,0 +1,15 @@
#include "mergeoperation.hpp"
#include "../doc/state.hpp"
CSMTools::MergeOperation::MergeOperation (CSMDoc::Document& document)
: CSMDoc::Operation (CSMDoc::State_Merging, true)
{
}
void CSMTools::MergeOperation::setTarget (const boost::filesystem::path& target)
{
}

View file

@ -0,0 +1,28 @@
#ifndef CSM_TOOLS_MERGEOPERATION_H
#define CSM_TOOLS_MERGEOPERATION_H
#include <boost/filesystem/path.hpp>
#include "../doc/operation.hpp"
namespace CSMDoc
{
class Document;
}
namespace CSMTools
{
class MergeOperation : public CSMDoc::Operation
{
public:
MergeOperation (CSMDoc::Document& document);
/// \attention Do not call this function while a merge is running.
void setTarget (const boost::filesystem::path& target);
};
}
#endif

View file

@ -28,6 +28,7 @@
#include "searchoperation.hpp"
#include "pathgridcheck.hpp"
#include "soundgencheck.hpp"
#include "mergeoperation.hpp"
CSMDoc::OperationHolder *CSMTools::Tools::get (int type)
{
@ -35,6 +36,7 @@ CSMDoc::OperationHolder *CSMTools::Tools::get (int type)
{
case CSMDoc::State_Verifying: return &mVerifier;
case CSMDoc::State_Searching: return &mSearch;
case CSMDoc::State_Merging: return &mMerge;
}
return 0;
@ -53,7 +55,7 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
std::vector<QString> settings;
settings.push_back ("script-editor/warnings");
mVerifierOperation->configureSettings (settings);
connect (&mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
@ -116,7 +118,7 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
CSMTools::Tools::Tools (CSMDoc::Document& document)
: mDocument (document), mData (document.getData()), mVerifierOperation (0),
mSearchOperation (0), mNextReportNumber (0)
mSearchOperation (0), mMergeOperation (0), mNextReportNumber (0)
{
// index 0: load error log
mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel));
@ -142,6 +144,12 @@ CSMTools::Tools::~Tools()
delete mSearchOperation;
}
if (mMergeOperation)
{
mMerge.abortAndWait();
delete mMergeOperation;
}
for (std::map<int, ReportModel *>::iterator iter (mReports.begin()); iter!=mReports.end(); ++iter)
delete iter->second;
}
@ -153,7 +161,7 @@ CSMWorld::UniversalId CSMTools::Tools::runVerifier (const CSMWorld::UniversalId&
if (mReports.find (reportNumber)==mReports.end())
mReports.insert (std::make_pair (reportNumber, new ReportModel));
mActiveReports[CSMDoc::State_Verifying] = reportNumber;
getVerifier()->start();
@ -183,6 +191,21 @@ void CSMTools::Tools::runSearch (const CSMWorld::UniversalId& searchId, const Se
mSearch.start();
}
void CSMTools::Tools::runMerge (const boost::filesystem::path& target)
{
// not setting an active report, because merge does not produce messages
if (!mMergeOperation)
{
mMergeOperation = new MergeOperation (mDocument);
mMerge.setOperation (mMergeOperation);
}
mMergeOperation->setTarget (target);
mMerge.start();
}
void CSMTools::Tools::abortOperation (int type)
{
if (CSMDoc::OperationHolder *operation = get (type))
@ -195,6 +218,7 @@ int CSMTools::Tools::getRunningOperations() const
{
CSMDoc::State_Verifying,
CSMDoc::State_Searching,
CSMDoc::State_Merging,
-1
};
@ -225,4 +249,3 @@ void CSMTools::Tools::verifierMessage (const CSMDoc::Message& message, int type)
if (iter!=mActiveReports.end())
mReports[iter->second]->add (message);
}

View file

@ -1,9 +1,11 @@
#ifndef CSM_TOOLS_TOOLS_H
#define CSM_TOOLS_TOOLS_H
#include <map>
#include <QObject>
#include <map>
#include <boost/filesystem/path.hpp>
#include "../doc/operationholder.hpp"
@ -24,6 +26,7 @@ namespace CSMTools
class ReportModel;
class Search;
class SearchOperation;
class MergeOperation;
class Tools : public QObject
{
@ -35,6 +38,8 @@ namespace CSMTools
CSMDoc::OperationHolder mVerifier;
SearchOperation *mSearchOperation;
CSMDoc::OperationHolder mSearch;
MergeOperation *mMergeOperation;
CSMDoc::OperationHolder mMerge;
std::map<int, ReportModel *> mReports;
int mNextReportNumber;
std::map<int, int> mActiveReports; // type, report number
@ -67,7 +72,9 @@ namespace CSMTools
CSMWorld::UniversalId newSearch();
void runSearch (const CSMWorld::UniversalId& searchId, const Search& search);
void runMerge (const boost::filesystem::path& target);
void abortOperation (int type);
///< \attention The operation is not aborted immediately.

View file

@ -66,7 +66,9 @@ CSVTools::Merge::Merge (QWidget *parent)
QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Cancel, Qt::Horizontal, this);
connect (buttons->button (QDialogButtonBox::Cancel), SIGNAL (clicked()), this, SLOT (reject()));
mOkay = new QPushButton ("Merge", this);
connect (mOkay, SIGNAL (clicked()), this, SLOT (accept()));
mOkay->setDefault (true);
buttons->addButton (mOkay, QDialogButtonBox::AcceptRole);
@ -109,6 +111,12 @@ void CSVTools::Merge::cancel()
void CSVTools::Merge::accept()
{
QDialog::accept();
if ((mDocument->getState() & CSMDoc::State_Merging)==0)
{
mDocument->runMerge (mAdjuster->getPath());
hide();
}
}
void CSVTools::Merge::reject()