forked from teamnwah/openmw-tes3coop
added merge operation (doesn't do anything yet)
This commit is contained in:
parent
708cacdec4
commit
904ad94952
8 changed files with 97 additions and 8 deletions
|
@ -42,6 +42,7 @@ opencs_units_noqt (model/tools
|
||||||
mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
|
mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
|
||||||
birthsigncheck spellcheck referencecheck referenceablecheck scriptcheck bodypartcheck
|
birthsigncheck spellcheck referencecheck referenceablecheck scriptcheck bodypartcheck
|
||||||
startscriptcheck search searchoperation searchstage pathgridcheck soundgencheck
|
startscriptcheck search searchoperation searchstage pathgridcheck soundgencheck
|
||||||
|
mergeoperation
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2388,6 +2388,12 @@ void CSMDoc::Document::runSearch (const CSMWorld::UniversalId& searchId, const C
|
||||||
emit stateChanged (getState(), this);
|
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)
|
void CSMDoc::Document::abortOperation (int type)
|
||||||
{
|
{
|
||||||
if (type==State_Saving)
|
if (type==State_Saving)
|
||||||
|
|
|
@ -130,6 +130,8 @@ namespace CSMDoc
|
||||||
|
|
||||||
void runSearch (const CSMWorld::UniversalId& searchId, const CSMTools::Search& search);
|
void runSearch (const CSMWorld::UniversalId& searchId, const CSMTools::Search& search);
|
||||||
|
|
||||||
|
void runMerge (const boost::filesystem::path& target);
|
||||||
|
|
||||||
void abortOperation (int type);
|
void abortOperation (int type);
|
||||||
|
|
||||||
const CSMWorld::Data& getData() const;
|
const CSMWorld::Data& getData() const;
|
||||||
|
@ -173,4 +175,3 @@ namespace CSMDoc
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
15
apps/opencs/model/tools/mergeoperation.cpp
Normal file
15
apps/opencs/model/tools/mergeoperation.cpp
Normal 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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
28
apps/opencs/model/tools/mergeoperation.hpp
Normal file
28
apps/opencs/model/tools/mergeoperation.hpp
Normal 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
|
|
@ -28,6 +28,7 @@
|
||||||
#include "searchoperation.hpp"
|
#include "searchoperation.hpp"
|
||||||
#include "pathgridcheck.hpp"
|
#include "pathgridcheck.hpp"
|
||||||
#include "soundgencheck.hpp"
|
#include "soundgencheck.hpp"
|
||||||
|
#include "mergeoperation.hpp"
|
||||||
|
|
||||||
CSMDoc::OperationHolder *CSMTools::Tools::get (int type)
|
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_Verifying: return &mVerifier;
|
||||||
case CSMDoc::State_Searching: return &mSearch;
|
case CSMDoc::State_Searching: return &mSearch;
|
||||||
|
case CSMDoc::State_Merging: return &mMerge;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -116,7 +118,7 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
|
||||||
|
|
||||||
CSMTools::Tools::Tools (CSMDoc::Document& document)
|
CSMTools::Tools::Tools (CSMDoc::Document& document)
|
||||||
: mDocument (document), mData (document.getData()), mVerifierOperation (0),
|
: mDocument (document), mData (document.getData()), mVerifierOperation (0),
|
||||||
mSearchOperation (0), mNextReportNumber (0)
|
mSearchOperation (0), mMergeOperation (0), mNextReportNumber (0)
|
||||||
{
|
{
|
||||||
// index 0: load error log
|
// index 0: load error log
|
||||||
mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel));
|
mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel));
|
||||||
|
@ -142,6 +144,12 @@ CSMTools::Tools::~Tools()
|
||||||
delete mSearchOperation;
|
delete mSearchOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mMergeOperation)
|
||||||
|
{
|
||||||
|
mMerge.abortAndWait();
|
||||||
|
delete mMergeOperation;
|
||||||
|
}
|
||||||
|
|
||||||
for (std::map<int, ReportModel *>::iterator iter (mReports.begin()); iter!=mReports.end(); ++iter)
|
for (std::map<int, ReportModel *>::iterator iter (mReports.begin()); iter!=mReports.end(); ++iter)
|
||||||
delete iter->second;
|
delete iter->second;
|
||||||
}
|
}
|
||||||
|
@ -183,6 +191,21 @@ void CSMTools::Tools::runSearch (const CSMWorld::UniversalId& searchId, const Se
|
||||||
mSearch.start();
|
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)
|
void CSMTools::Tools::abortOperation (int type)
|
||||||
{
|
{
|
||||||
if (CSMDoc::OperationHolder *operation = get (type))
|
if (CSMDoc::OperationHolder *operation = get (type))
|
||||||
|
@ -195,6 +218,7 @@ int CSMTools::Tools::getRunningOperations() const
|
||||||
{
|
{
|
||||||
CSMDoc::State_Verifying,
|
CSMDoc::State_Verifying,
|
||||||
CSMDoc::State_Searching,
|
CSMDoc::State_Searching,
|
||||||
|
CSMDoc::State_Merging,
|
||||||
-1
|
-1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -225,4 +249,3 @@ void CSMTools::Tools::verifierMessage (const CSMDoc::Message& message, int type)
|
||||||
if (iter!=mActiveReports.end())
|
if (iter!=mActiveReports.end())
|
||||||
mReports[iter->second]->add (message);
|
mReports[iter->second]->add (message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#ifndef CSM_TOOLS_TOOLS_H
|
#ifndef CSM_TOOLS_TOOLS_H
|
||||||
#define CSM_TOOLS_TOOLS_H
|
#define CSM_TOOLS_TOOLS_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <map>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
#include "../doc/operationholder.hpp"
|
#include "../doc/operationholder.hpp"
|
||||||
|
|
||||||
|
@ -24,6 +26,7 @@ namespace CSMTools
|
||||||
class ReportModel;
|
class ReportModel;
|
||||||
class Search;
|
class Search;
|
||||||
class SearchOperation;
|
class SearchOperation;
|
||||||
|
class MergeOperation;
|
||||||
|
|
||||||
class Tools : public QObject
|
class Tools : public QObject
|
||||||
{
|
{
|
||||||
|
@ -35,6 +38,8 @@ namespace CSMTools
|
||||||
CSMDoc::OperationHolder mVerifier;
|
CSMDoc::OperationHolder mVerifier;
|
||||||
SearchOperation *mSearchOperation;
|
SearchOperation *mSearchOperation;
|
||||||
CSMDoc::OperationHolder mSearch;
|
CSMDoc::OperationHolder mSearch;
|
||||||
|
MergeOperation *mMergeOperation;
|
||||||
|
CSMDoc::OperationHolder mMerge;
|
||||||
std::map<int, ReportModel *> mReports;
|
std::map<int, ReportModel *> mReports;
|
||||||
int mNextReportNumber;
|
int mNextReportNumber;
|
||||||
std::map<int, int> mActiveReports; // type, report number
|
std::map<int, int> mActiveReports; // type, report number
|
||||||
|
@ -68,6 +73,8 @@ namespace CSMTools
|
||||||
|
|
||||||
void runSearch (const CSMWorld::UniversalId& searchId, const Search& search);
|
void runSearch (const CSMWorld::UniversalId& searchId, const Search& search);
|
||||||
|
|
||||||
|
void runMerge (const boost::filesystem::path& target);
|
||||||
|
|
||||||
void abortOperation (int type);
|
void abortOperation (int type);
|
||||||
///< \attention The operation is not aborted immediately.
|
///< \attention The operation is not aborted immediately.
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,9 @@ CSVTools::Merge::Merge (QWidget *parent)
|
||||||
QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Cancel, Qt::Horizontal, this);
|
QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Cancel, Qt::Horizontal, this);
|
||||||
|
|
||||||
connect (buttons->button (QDialogButtonBox::Cancel), SIGNAL (clicked()), this, SLOT (reject()));
|
connect (buttons->button (QDialogButtonBox::Cancel), SIGNAL (clicked()), this, SLOT (reject()));
|
||||||
|
|
||||||
mOkay = new QPushButton ("Merge", this);
|
mOkay = new QPushButton ("Merge", this);
|
||||||
|
connect (mOkay, SIGNAL (clicked()), this, SLOT (accept()));
|
||||||
mOkay->setDefault (true);
|
mOkay->setDefault (true);
|
||||||
buttons->addButton (mOkay, QDialogButtonBox::AcceptRole);
|
buttons->addButton (mOkay, QDialogButtonBox::AcceptRole);
|
||||||
|
|
||||||
|
@ -109,6 +111,12 @@ void CSVTools::Merge::cancel()
|
||||||
void CSVTools::Merge::accept()
|
void CSVTools::Merge::accept()
|
||||||
{
|
{
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
|
|
||||||
|
if ((mDocument->getState() & CSMDoc::State_Merging)==0)
|
||||||
|
{
|
||||||
|
mDocument->runMerge (mAdjuster->getPath());
|
||||||
|
hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVTools::Merge::reject()
|
void CSVTools::Merge::reject()
|
||||||
|
|
Loading…
Reference in a new issue