mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
added search stages (cell table only for now)
This commit is contained in:
parent
78c6268891
commit
23cf859fee
13 changed files with 187 additions and 4 deletions
|
@ -40,7 +40,7 @@ opencs_units (model/tools
|
||||||
opencs_units_noqt (model/tools
|
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
|
startscriptcheck search searchoperation searchstage
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2380,6 +2380,11 @@ CSMWorld::UniversalId CSMDoc::Document::newSearch()
|
||||||
return mTools.newSearch();
|
return mTools.newSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMDoc::Document::runSearch (const CSMWorld::UniversalId& searchId, const CSMTools::Search& search)
|
||||||
|
{
|
||||||
|
return mTools.runSearch (searchId, search);
|
||||||
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::abortOperation (int type)
|
void CSMDoc::Document::abortOperation (int type)
|
||||||
{
|
{
|
||||||
if (type==State_Saving)
|
if (type==State_Saving)
|
||||||
|
|
|
@ -121,6 +121,8 @@ namespace CSMDoc
|
||||||
CSMWorld::UniversalId verify();
|
CSMWorld::UniversalId verify();
|
||||||
|
|
||||||
CSMWorld::UniversalId newSearch();
|
CSMWorld::UniversalId newSearch();
|
||||||
|
|
||||||
|
void runSearch (const CSMWorld::UniversalId& searchId, const CSMTools::Search& search);
|
||||||
|
|
||||||
void abortOperation (int type);
|
void abortOperation (int type);
|
||||||
|
|
||||||
|
|
33
apps/opencs/model/tools/searchoperation.cpp
Normal file
33
apps/opencs/model/tools/searchoperation.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
#include "searchoperation.hpp"
|
||||||
|
|
||||||
|
#include "../doc/state.hpp"
|
||||||
|
#include "../doc/document.hpp"
|
||||||
|
|
||||||
|
#include "../world/data.hpp"
|
||||||
|
#include "../world/idtablebase.hpp"
|
||||||
|
|
||||||
|
#include "searchstage.hpp"
|
||||||
|
|
||||||
|
CSMTools::SearchOperation::SearchOperation (CSMDoc::Document& document)
|
||||||
|
: CSMDoc::Operation (CSMDoc::State_Searching, false)
|
||||||
|
{
|
||||||
|
appendStage (new SearchStage (&dynamic_cast<CSMWorld::IdTableBase&> (*document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells))));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::SearchOperation::configure (const Search& search)
|
||||||
|
{
|
||||||
|
mSearch = search;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::SearchOperation::appendStage (SearchStage *stage)
|
||||||
|
{
|
||||||
|
CSMDoc::Operation::appendStage (stage);
|
||||||
|
stage->setOperation (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
const CSMTools::Search& CSMTools::SearchOperation::getSearch() const
|
||||||
|
{
|
||||||
|
return mSearch;
|
||||||
|
}
|
38
apps/opencs/model/tools/searchoperation.hpp
Normal file
38
apps/opencs/model/tools/searchoperation.hpp
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef CSM_TOOLS_SEARCHOPERATION_H
|
||||||
|
#define CSM_TOOLS_SEARCHOPERATION_H
|
||||||
|
|
||||||
|
#include "../doc/operation.hpp"
|
||||||
|
|
||||||
|
#include "search.hpp"
|
||||||
|
|
||||||
|
namespace CSMDoc
|
||||||
|
{
|
||||||
|
class Document;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSMTools
|
||||||
|
{
|
||||||
|
class SearchStage;
|
||||||
|
|
||||||
|
class SearchOperation : public CSMDoc::Operation
|
||||||
|
{
|
||||||
|
Search mSearch;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SearchOperation (CSMDoc::Document& document);
|
||||||
|
|
||||||
|
/// \attention Do not call this function while a search is running.
|
||||||
|
void configure (const Search& search);
|
||||||
|
|
||||||
|
void appendStage (SearchStage *stage);
|
||||||
|
///< The ownership of \a stage is transferred to *this.
|
||||||
|
///
|
||||||
|
/// \attention Do no call this function while this Operation is running.
|
||||||
|
|
||||||
|
const Search& getSearch() const;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
30
apps/opencs/model/tools/searchstage.cpp
Normal file
30
apps/opencs/model/tools/searchstage.cpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
|
||||||
|
#include "searchstage.hpp"
|
||||||
|
|
||||||
|
#include "../world/idtablebase.hpp"
|
||||||
|
|
||||||
|
#include "searchoperation.hpp"
|
||||||
|
|
||||||
|
CSMTools::SearchStage::SearchStage (const CSMWorld::IdTableBase *model)
|
||||||
|
: mModel (model), mOperation (0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
int CSMTools::SearchStage::setup()
|
||||||
|
{
|
||||||
|
if (mOperation)
|
||||||
|
mSearch = mOperation->getSearch();
|
||||||
|
|
||||||
|
mSearch.configure (mModel);
|
||||||
|
|
||||||
|
return mModel->rowCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::SearchStage::perform (int stage, CSMDoc::Messages& messages)
|
||||||
|
{
|
||||||
|
mSearch.searchRow (mModel, stage, messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::SearchStage::setOperation (const SearchOperation *operation)
|
||||||
|
{
|
||||||
|
mOperation = operation;
|
||||||
|
}
|
37
apps/opencs/model/tools/searchstage.hpp
Normal file
37
apps/opencs/model/tools/searchstage.hpp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef CSM_TOOLS_SEARCHSTAGE_H
|
||||||
|
#define CSM_TOOLS_SEARCHSTAGE_H
|
||||||
|
|
||||||
|
#include "../doc/stage.hpp"
|
||||||
|
|
||||||
|
#include "search.hpp"
|
||||||
|
|
||||||
|
namespace CSMWorld
|
||||||
|
{
|
||||||
|
class IdTableBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSMTools
|
||||||
|
{
|
||||||
|
class SearchOperation;
|
||||||
|
|
||||||
|
class SearchStage : public CSMDoc::Stage
|
||||||
|
{
|
||||||
|
const CSMWorld::IdTableBase *mModel;
|
||||||
|
Search mSearch;
|
||||||
|
const SearchOperation *mOperation;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SearchStage (const CSMWorld::IdTableBase *model);
|
||||||
|
|
||||||
|
virtual int setup();
|
||||||
|
///< \return number of steps
|
||||||
|
|
||||||
|
virtual void perform (int stage, CSMDoc::Messages& messages);
|
||||||
|
///< Messages resulting from this stage will be appended to \a messages.
|
||||||
|
|
||||||
|
void setOperation (const SearchOperation *operation);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -25,6 +25,7 @@
|
||||||
#include "bodypartcheck.hpp"
|
#include "bodypartcheck.hpp"
|
||||||
#include "referencecheck.hpp"
|
#include "referencecheck.hpp"
|
||||||
#include "startscriptcheck.hpp"
|
#include "startscriptcheck.hpp"
|
||||||
|
#include "searchoperation.hpp"
|
||||||
|
|
||||||
CSMDoc::OperationHolder *CSMTools::Tools::get (int type)
|
CSMDoc::OperationHolder *CSMTools::Tools::get (int type)
|
||||||
{
|
{
|
||||||
|
@ -108,6 +109,12 @@ CSMTools::Tools::Tools (CSMDoc::Document& document)
|
||||||
// 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));
|
||||||
mActiveReports.insert (std::make_pair (CSMDoc::State_Loading, 0));
|
mActiveReports.insert (std::make_pair (CSMDoc::State_Loading, 0));
|
||||||
|
|
||||||
|
connect (&mSearch, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
|
||||||
|
connect (&mSearch, SIGNAL (done (int, bool)), this, SIGNAL (done (int, bool)));
|
||||||
|
connect (&mSearch,
|
||||||
|
SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)),
|
||||||
|
this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMTools::Tools::~Tools()
|
CSMTools::Tools::~Tools()
|
||||||
|
@ -145,6 +152,21 @@ CSMWorld::UniversalId CSMTools::Tools::newSearch()
|
||||||
return CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Search, mNextReportNumber-1);
|
return CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Search, mNextReportNumber-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMTools::Tools::runSearch (const CSMWorld::UniversalId& searchId, const Search& search)
|
||||||
|
{
|
||||||
|
mActiveReports[CSMDoc::State_Searching] = searchId.getIndex();
|
||||||
|
|
||||||
|
if (!mSearchOperation)
|
||||||
|
{
|
||||||
|
mSearchOperation = new SearchOperation (mDocument);
|
||||||
|
mSearch.setOperation (mSearchOperation);
|
||||||
|
}
|
||||||
|
|
||||||
|
mSearchOperation->configure (search);
|
||||||
|
|
||||||
|
mSearch.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))
|
||||||
|
|
|
@ -22,6 +22,8 @@ namespace CSMDoc
|
||||||
namespace CSMTools
|
namespace CSMTools
|
||||||
{
|
{
|
||||||
class ReportModel;
|
class ReportModel;
|
||||||
|
class Search;
|
||||||
|
class SearchOperation;
|
||||||
|
|
||||||
class Tools : public QObject
|
class Tools : public QObject
|
||||||
{
|
{
|
||||||
|
@ -31,7 +33,7 @@ namespace CSMTools
|
||||||
CSMWorld::Data& mData;
|
CSMWorld::Data& mData;
|
||||||
CSMDoc::Operation *mVerifierOperation;
|
CSMDoc::Operation *mVerifierOperation;
|
||||||
CSMDoc::OperationHolder mVerifier;
|
CSMDoc::OperationHolder mVerifier;
|
||||||
CSMDoc::Operation *mSearchOperation;
|
SearchOperation *mSearchOperation;
|
||||||
CSMDoc::OperationHolder mSearch;
|
CSMDoc::OperationHolder mSearch;
|
||||||
std::map<int, ReportModel *> mReports;
|
std::map<int, ReportModel *> mReports;
|
||||||
int mNextReportNumber;
|
int mNextReportNumber;
|
||||||
|
@ -60,6 +62,8 @@ namespace CSMTools
|
||||||
|
|
||||||
/// Return ID of the report for this search.
|
/// Return ID of the report for this search.
|
||||||
CSMWorld::UniversalId newSearch();
|
CSMWorld::UniversalId newSearch();
|
||||||
|
|
||||||
|
void runSearch (const CSMWorld::UniversalId& searchId, const Search& search);
|
||||||
|
|
||||||
void abortOperation (int type);
|
void abortOperation (int type);
|
||||||
///< \attention The operation is not aborted immediately.
|
///< \attention The operation is not aborted immediately.
|
||||||
|
|
|
@ -18,6 +18,7 @@ void CSVDoc::Operation::updateLabel (int threads)
|
||||||
{
|
{
|
||||||
case CSMDoc::State_Saving: name = "saving"; break;
|
case CSMDoc::State_Saving: name = "saving"; break;
|
||||||
case CSMDoc::State_Verifying: name = "verifying"; break;
|
case CSMDoc::State_Verifying: name = "verifying"; break;
|
||||||
|
case CSMDoc::State_Searching: name = "searching"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|
|
@ -447,7 +447,7 @@ void CSVDoc::View::updateDocumentState()
|
||||||
|
|
||||||
static const int operations[] =
|
static const int operations[] =
|
||||||
{
|
{
|
||||||
CSMDoc::State_Saving, CSMDoc::State_Verifying,
|
CSMDoc::State_Saving, CSMDoc::State_Verifying, CSMDoc::State_Searching,
|
||||||
-1 // end marker
|
-1 // end marker
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "searchbox.hpp"
|
#include "searchbox.hpp"
|
||||||
|
|
||||||
CSVTools::SearchSubView::SearchSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
CSVTools::SearchSubView::SearchSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||||
: CSVDoc::SubView (id)
|
: CSVDoc::SubView (id), mDocument (document)
|
||||||
{
|
{
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
|
|
||||||
|
@ -32,6 +32,9 @@ CSVTools::SearchSubView::SearchSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
||||||
|
|
||||||
connect (&document, SIGNAL (stateChanged (int, CSMDoc::Document *)),
|
connect (&document, SIGNAL (stateChanged (int, CSMDoc::Document *)),
|
||||||
this, SLOT (stateChanged (int, CSMDoc::Document *)));
|
this, SLOT (stateChanged (int, CSMDoc::Document *)));
|
||||||
|
|
||||||
|
connect (&mSearchBox, SIGNAL (startSearch (const CSMTools::Search&)),
|
||||||
|
this, SLOT (startSearch (const CSMTools::Search&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVTools::SearchSubView::setEditLock (bool locked)
|
void CSVTools::SearchSubView::setEditLock (bool locked)
|
||||||
|
@ -48,3 +51,8 @@ void CSVTools::SearchSubView::stateChanged (int state, CSMDoc::Document *documen
|
||||||
{
|
{
|
||||||
mSearchBox.setSearchMode (!(state & CSMDoc::State_Searching));
|
mSearchBox.setSearchMode (!(state & CSMDoc::State_Searching));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVTools::SearchSubView::startSearch (const CSMTools::Search& search)
|
||||||
|
{
|
||||||
|
mDocument.runSearch (getUniversalId(), search);
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace CSVTools
|
||||||
|
|
||||||
ReportTable *mTable;
|
ReportTable *mTable;
|
||||||
SearchBox mSearchBox;
|
SearchBox mSearchBox;
|
||||||
|
CSMDoc::Document& mDocument;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -35,6 +36,8 @@ namespace CSVTools
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void stateChanged (int state, CSMDoc::Document *document);
|
void stateChanged (int state, CSMDoc::Document *document);
|
||||||
|
|
||||||
|
void startSearch (const CSMTools::Search& search);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue