forked from teamnwah/openmw-tes3coop
added search stages (cell table only for now)
parent
78c6268891
commit
23cf859fee
@ -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;
|
||||||
|
}
|
@ -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
|
@ -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;
|
||||||
|
}
|
@ -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
|
Loading…
Reference in New Issue