2015-09-15 18:49:24 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vtablesearch.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 15 9, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-09-15 18:49:24 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2015-09-15 18:49:24 +02:00
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef VTABLESEARCH_H
|
|
|
|
#define VTABLESEARCH_H
|
|
|
|
|
2016-08-26 15:16:06 +02:00
|
|
|
#include <QObject>
|
2015-09-15 18:49:24 +02:00
|
|
|
#include <QList>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QString>
|
2015-09-15 18:49:24 +02:00
|
|
|
#include <QTableWidget>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QtGlobal>
|
|
|
|
|
2022-08-12 17:50:13 +02:00
|
|
|
#include "../vmisc/defglobal.h"
|
|
|
|
|
2016-08-26 15:16:06 +02:00
|
|
|
class VTableSearch: public QObject
|
2015-09-15 18:49:24 +02:00
|
|
|
{
|
2022-08-12 17:50:13 +02:00
|
|
|
Q_OBJECT // NOLINT
|
2015-09-15 18:49:24 +02:00
|
|
|
public:
|
2016-08-26 15:16:06 +02:00
|
|
|
explicit VTableSearch(QTableWidget *table, QObject *parent = nullptr);
|
2015-09-15 18:49:24 +02:00
|
|
|
|
|
|
|
void Find(const QString &term);
|
|
|
|
void FindPrevious();
|
|
|
|
void FindNext();
|
|
|
|
void RemoveRow(int row);
|
2023-02-09 16:23:11 +01:00
|
|
|
void AddRow(vsizetype row);
|
2015-09-15 18:49:24 +02:00
|
|
|
void RefreshList(const QString &term);
|
|
|
|
|
2021-11-22 14:24:48 +01:00
|
|
|
void SetMatchCase(bool value);
|
|
|
|
auto IsMatchCase() const -> bool;
|
|
|
|
|
|
|
|
void SetMatchWord(bool value);
|
|
|
|
auto IsMatchWord() const -> bool;
|
|
|
|
|
|
|
|
void SetMatchRegexp(bool value);
|
|
|
|
auto IsMatchRegexp() const -> bool;
|
|
|
|
|
|
|
|
void SetUseUnicodePreperties(bool value);
|
|
|
|
auto IsUseUnicodePreperties() const -> bool;
|
|
|
|
|
2023-02-09 16:23:11 +01:00
|
|
|
auto MatchIndex() const -> vsizetype;
|
|
|
|
auto MatchCount() const -> vsizetype;
|
2021-11-22 14:24:48 +01:00
|
|
|
|
|
|
|
auto SearchPlaceholder() const -> QString;
|
|
|
|
|
|
|
|
static const int MaxHistoryRecords;
|
|
|
|
|
2016-08-26 15:16:06 +02:00
|
|
|
signals:
|
|
|
|
void HasResult(bool state);
|
|
|
|
|
2015-09-15 18:49:24 +02:00
|
|
|
private:
|
2022-08-12 17:50:13 +02:00
|
|
|
// cppcheck-suppress unknownMacro
|
|
|
|
Q_DISABLE_COPY_MOVE(VTableSearch) // NOLINT
|
2015-09-15 18:49:24 +02:00
|
|
|
|
|
|
|
QTableWidget *table;
|
2023-02-09 16:23:11 +01:00
|
|
|
vsizetype searchIndex{-1};
|
2021-11-22 14:24:48 +01:00
|
|
|
QList<QTableWidgetItem *> searchList{};
|
|
|
|
|
|
|
|
bool m_matchCase{false};
|
|
|
|
bool m_matchWord{false};
|
|
|
|
bool m_matchRegexp{false};
|
|
|
|
bool m_useUnicodePreperties{false};
|
2015-09-15 18:49:24 +02:00
|
|
|
|
|
|
|
void Clear();
|
2023-02-09 16:23:11 +01:00
|
|
|
void ShowNext(vsizetype newIndex);
|
2021-11-22 14:24:48 +01:00
|
|
|
auto FindTableItems(QString term) -> QList<QTableWidgetItem *>;
|
|
|
|
auto FindCurrentMatchIndex() const -> int;
|
2015-09-15 18:49:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTABLESEARCH_H
|