Sandboxie/SandboxiePlus/MiscHelpers/Common/Finder.h

85 lines
2.2 KiB
C
Raw Normal View History

2021-10-15 16:04:52 +01:00
#pragma once
2020-06-01 17:11:56 +01:00
#include "../mischelpers_global.h"
2021-10-15 16:04:52 +01:00
class MISCHELPERS_EXPORT CFinder: public QWidget
{
Q_OBJECT
public:
2023-01-08 10:49:09 +00:00
CFinder(QObject* pFilterTarget, QWidget *parent = NULL, int iOptions = eRegExp | eCaseSens | eHighLight);
2021-10-15 16:04:52 +01:00
~CFinder();
2023-01-12 22:10:50 +00:00
void SetTree(QTreeView* pTree);
2023-02-04 13:42:45 +00:00
void SetModel(QAbstractItemModel* pModel) { m_pModel = pModel; }
2023-01-12 22:10:50 +00:00
2021-10-15 16:04:52 +01:00
static void SetDarkMode(bool bDarkMode) { m_DarkMode = bDarkMode; }
2023-01-08 10:49:09 +00:00
static bool GetDarkMode() { return m_DarkMode; }
2021-10-15 16:04:52 +01:00
2023-01-12 22:10:50 +00:00
static QWidget* AddFinder(QTreeView* pTree, QObject* pFilterTarget, int iOptions = eRegExp | eCaseSens | eHighLight, CFinder** ppFinder = NULL);
2021-10-15 16:04:52 +01:00
2023-01-12 22:10:50 +00:00
QRegularExpression GetSearchExp() const { return m_RegExp; }
2023-01-08 10:49:09 +00:00
enum EOptions
{
eRegExp = 0x01,
eCaseSens = 0x02,
eHighLight = 0x04,
2023-01-12 22:10:50 +00:00
eHighLightDefault = eHighLight | 0x08,
2023-01-08 10:49:09 +00:00
};
2021-10-15 16:04:52 +01:00
2023-04-22 21:59:42 +01:00
static QString m_CaseInsensitive;
static QString m_RegExpStr;
static QString m_Highlight;
static QString m_CloseStr;
static QString m_FindStr;
static QString m_AllColumns;
2021-10-15 16:04:52 +01:00
signals:
2023-01-08 10:49:09 +00:00
void SetFilter(const QString& Exp, int iOptions = 0, int Column = -1);
2021-10-15 16:04:52 +01:00
void SelectNext();
public slots:
void Open();
void Close();
private slots:
void OnUpdate();
void OnText();
void OnReturn();
2023-01-12 22:10:50 +00:00
void OnSelectNext();
2021-10-15 16:04:52 +01:00
protected:
2023-01-12 22:10:50 +00:00
bool GetCaseSensitive() const { return m_pCaseSensitive ? m_pCaseSensitive->isChecked() : false; }
bool GetRegExp() const { return m_pRegExp ? m_pRegExp->isChecked() : false; }
bool GetHighLight() const { return m_pHighLight ? m_pHighLight->isChecked() : false; }
int GetColumn() const { return m_pColumn ? m_pColumn->currentData().toInt() : -1; }
2021-10-15 16:04:52 +01:00
bool eventFilter(QObject* source, QEvent* event);
2023-01-12 22:10:50 +00:00
virtual bool MatchString(const QString& value);
bool MatchCell(QModelIndex idx, int column);
bool MatchRow(QModelIndex idx);
2023-02-05 17:33:18 +00:00
QModelIndex FindRow(QModelIndex par, int start, bool reverse);
QModelIndex FindRow(bool reverse);
2023-01-12 22:10:50 +00:00
2021-10-15 16:04:52 +01:00
private:
QHBoxLayout* m_pSearchLayout;
QLineEdit* m_pSearch;
QCheckBox* m_pCaseSensitive;
QCheckBox* m_pRegExp;
QComboBox* m_pColumn;
QCheckBox* m_pHighLight;
2023-01-12 22:10:50 +00:00
QRegularExpression m_RegExp;
QTreeView* m_pTree;
2023-01-13 15:53:53 +00:00
QAbstractItemModel* m_pModel;
2021-10-15 16:04:52 +01:00
QTimer* m_pTimer;
static bool m_DarkMode;
2020-06-01 17:11:56 +01:00
};