2015-03-25 10:56:14 +00:00
|
|
|
#ifndef CSM_TOOLS_SEARCH_H
|
|
|
|
#define CSM_TOOLS_SEARCH_H
|
|
|
|
|
|
|
|
#include <string>
|
2015-03-28 11:05:49 +00:00
|
|
|
#include <set>
|
2015-03-25 10:56:14 +00:00
|
|
|
|
|
|
|
#include <QRegExp>
|
|
|
|
#include <QMetaType>
|
|
|
|
|
|
|
|
class QModelIndex;
|
|
|
|
|
|
|
|
namespace CSMDoc
|
|
|
|
{
|
|
|
|
class Messages;
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2015-03-25 10:56:14 +00:00
|
|
|
Type_RecordState = 4,
|
|
|
|
Type_None
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
Type mType;
|
|
|
|
std::string mText;
|
|
|
|
QRegExp mRegExp;
|
|
|
|
int mValue;
|
2015-03-28 11:05:49 +00:00
|
|
|
std::set<int> mColumns;
|
2015-03-25 10:56:14 +00:00
|
|
|
int mIdColumn;
|
|
|
|
int mTypeColumn;
|
|
|
|
|
|
|
|
void searchTextCell (const CSMWorld::IdTableBase *model, const QModelIndex& index,
|
2015-03-28 11:05:49 +00:00
|
|
|
const CSMWorld::UniversalId& id, CSMDoc::Messages& messages) const;
|
2015-03-25 10:56:14 +00:00
|
|
|
|
|
|
|
void searchRegExCell (const CSMWorld::IdTableBase *model, const QModelIndex& index,
|
2015-03-28 11:05:49 +00:00
|
|
|
const CSMWorld::UniversalId& id, CSMDoc::Messages& messages) const;
|
2015-03-25 10:56:14 +00:00
|
|
|
|
|
|
|
void searchRecordStateCell (const CSMWorld::IdTableBase *model,
|
|
|
|
const QModelIndex& index, const CSMWorld::UniversalId& id,
|
|
|
|
CSMDoc::Messages& messages) const;
|
2015-03-27 18:10:45 +00:00
|
|
|
|
2015-03-29 16:16:43 +00:00
|
|
|
QString formatDescription (const QString& description, int pos, int length) const;
|
2015-03-25 10:56:14 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Search();
|
|
|
|
|
|
|
|
Search (Type type, const std::string& value);
|
|
|
|
|
|
|
|
Search (Type type, const QRegExp& value);
|
|
|
|
|
|
|
|
Search (Type type, int value);
|
|
|
|
|
|
|
|
// Configure search for the specified model.
|
|
|
|
void configure (const CSMWorld::IdTableBase *model);
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE (CSMTools::Search)
|
|
|
|
|
|
|
|
#endif
|