1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 22:53:53 +00:00
openmw/apps/opencs/model/tools/search.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

96 lines
2.7 KiB
C++
Raw Normal View History

#ifndef CSM_TOOLS_SEARCH_H
#define CSM_TOOLS_SEARCH_H
2015-03-28 11:05:49 +00:00
#include <set>
#include <string>
#include <QMetaType>
#include <QRegularExpression>
class QModelIndex;
namespace CSMDoc
{
class Messages;
2015-04-16 16:50:22 +00:00
class Document;
}
namespace CSMWorld
{
class IdTableBase;
class UniversalId;
}
namespace CSMTools
{
class Search
{
public:
enum Type
{
Type_Text = 0,
Type_TextRegEx = 1,
2015-03-28 10:54:32 +00:00
Type_Id = 2,
Type_IdRegEx = 3,
Type_RecordState = 4,
Type_None
};
2022-09-22 18:26:05 +00:00
private:
Type mType;
std::string mText;
QRegularExpression mRegExp;
int mValue;
2018-07-04 19:03:54 +00:00
bool mCase;
2015-03-28 11:05:49 +00:00
std::set<int> mColumns;
int mIdColumn;
int mTypeColumn;
2015-03-30 20:30:33 +00:00
int mPaddingBefore;
int mPaddingAfter;
2022-09-22 18:26:05 +00:00
void searchTextCell(const CSMWorld::IdTableBase* model, const QModelIndex& index,
2015-04-16 16:50:22 +00:00
const CSMWorld::UniversalId& id, bool writable, CSMDoc::Messages& messages) const;
2022-09-22 18:26:05 +00:00
void searchRegExCell(const CSMWorld::IdTableBase* model, const QModelIndex& index,
2015-04-16 16:50:22 +00:00
const CSMWorld::UniversalId& id, bool writable, CSMDoc::Messages& messages) const;
2022-09-22 18:26:05 +00:00
void searchRecordStateCell(const CSMWorld::IdTableBase* model, const QModelIndex& index,
2015-04-16 16:50:22 +00:00
const CSMWorld::UniversalId& id, bool writable, CSMDoc::Messages& messages) const;
2022-09-22 18:26:05 +00:00
2015-03-29 16:16:43 +00:00
QString formatDescription(const QString& description, int pos, int length) const;
2022-09-22 18:26:05 +00:00
QString flatten(const QString& text) const;
2022-09-22 18:26:05 +00:00
public:
Search();
2022-09-22 18:26:05 +00:00
2018-07-04 19:03:54 +00:00
Search(Type type, bool caseSensitive, const std::string& value);
2022-09-22 18:26:05 +00:00
Search(Type type, bool caseSensitive, const QRegularExpression& value);
2022-09-22 18:26:05 +00:00
2018-07-04 19:03:54 +00:00
Search(Type type, bool caseSensitive, int value);
2022-09-22 18:26:05 +00:00
// Configure search for the specified model.
void configure(const CSMWorld::IdTableBase* model);
2022-09-22 18:26:05 +00:00
// Search row in \a model and store results in \a messages.
//
// \attention *this needs to be configured for \a model.
void searchRow(const CSMWorld::IdTableBase* model, int row, CSMDoc::Messages& messages) const;
2022-09-22 18:26:05 +00:00
2015-03-30 20:30:33 +00:00
void setPadding(int before, int after);
2022-09-22 18:26:05 +00:00
2015-04-16 16:50:22 +00:00
// Configuring *this for the model is not necessary when calling this function.
void replace(CSMDoc::Document& document, CSMWorld::IdTableBase* model, const CSMWorld::UniversalId& id,
const std::string& messageHint, const std::string& replaceText) const;
2022-09-22 18:26:05 +00:00
// Check if model still matches search results.
bool verify(CSMDoc::Document& document, CSMWorld::IdTableBase* model, const CSMWorld::UniversalId& id,
const std::string& messageHint) const;
};
}
Q_DECLARE_METATYPE(CSMTools::Search)
#endif