Disable buttons Find Next and Find Previous if the search field is empty.
--HG-- branch : develop
This commit is contained in:
parent
c35f050b66
commit
6baa623be3
|
@ -1984,6 +1984,15 @@ void TMainWindow::InitWindow()
|
||||||
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, [=] (){search->FindPrevious();});
|
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, [=] (){search->FindPrevious();});
|
||||||
connect(ui->toolButtonFindNext, &QToolButton::clicked, [=] (){search->FindNext();});
|
connect(ui->toolButtonFindNext, &QToolButton::clicked, [=] (){search->FindNext();});
|
||||||
|
|
||||||
|
connect(search.data(), &VTableSearch::HasResult, [this] (bool state)
|
||||||
|
{
|
||||||
|
ui->toolButtonFindPrevious->setEnabled(state);
|
||||||
|
});
|
||||||
|
connect(search.data(), &VTableSearch::HasResult, [this] (bool state)
|
||||||
|
{
|
||||||
|
ui->toolButtonFindNext->setEnabled(state);
|
||||||
|
});
|
||||||
|
|
||||||
ui->plainTextEditNotes->setPlainText(m->Notes());
|
ui->plainTextEditNotes->setPlainText(m->Notes());
|
||||||
connect(ui->plainTextEditNotes, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveNotes);
|
connect(ui->plainTextEditNotes, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveNotes);
|
||||||
|
|
||||||
|
@ -2433,8 +2442,16 @@ void TMainWindow::MFields(bool enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->lineEditFind->setEnabled(enabled);
|
ui->lineEditFind->setEnabled(enabled);
|
||||||
|
if (enabled && not ui->lineEditFind->text().isEmpty())
|
||||||
|
{
|
||||||
ui->toolButtonFindPrevious->setEnabled(enabled);
|
ui->toolButtonFindPrevious->setEnabled(enabled);
|
||||||
ui->toolButtonFindNext->setEnabled(enabled);
|
ui->toolButtonFindNext->setEnabled(enabled);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->toolButtonFindPrevious->setEnabled(false);
|
||||||
|
ui->toolButtonFindNext->setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -113,6 +113,15 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
||||||
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, [=](){search->FindPrevious();});
|
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, [=](){search->FindPrevious();});
|
||||||
connect(ui->toolButtonFindNext, &QToolButton::clicked, [=](){search->FindNext();});
|
connect(ui->toolButtonFindNext, &QToolButton::clicked, [=](){search->FindNext();});
|
||||||
|
|
||||||
|
connect(search.data(), &VTableSearch::HasResult, [this] (bool state)
|
||||||
|
{
|
||||||
|
ui->toolButtonFindPrevious->setEnabled(state);
|
||||||
|
});
|
||||||
|
connect(search.data(), &VTableSearch::HasResult, [this] (bool state)
|
||||||
|
{
|
||||||
|
ui->toolButtonFindNext->setEnabled(state);
|
||||||
|
});
|
||||||
|
|
||||||
if (ui->tableWidgetIncrement->rowCount() > 0)
|
if (ui->tableWidgetIncrement->rowCount() > 0)
|
||||||
{
|
{
|
||||||
ui->tableWidgetIncrement->selectRow(0);
|
ui->tableWidgetIncrement->selectRow(0);
|
||||||
|
|
|
@ -37,8 +37,9 @@
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VTableSearch::VTableSearch(QTableWidget *table)
|
VTableSearch::VTableSearch(QTableWidget *table, QObject *parent)
|
||||||
:table(table),
|
: QObject(parent),
|
||||||
|
table(table),
|
||||||
searchIndex(-1),
|
searchIndex(-1),
|
||||||
searchList()
|
searchList()
|
||||||
{
|
{
|
||||||
|
@ -69,6 +70,8 @@ void VTableSearch::Clear()
|
||||||
|
|
||||||
searchList.clear();
|
searchList.clear();
|
||||||
searchIndex = -1;
|
searchIndex = -1;
|
||||||
|
|
||||||
|
emit HasResult(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -112,6 +115,8 @@ void VTableSearch::Find(const QString &term)
|
||||||
QTableWidgetItem *item = searchList.at(searchIndex);
|
QTableWidgetItem *item = searchList.at(searchIndex);
|
||||||
item->setBackground(Qt::red);
|
item->setBackground(Qt::red);
|
||||||
table->scrollToItem(item);
|
table->scrollToItem(item);
|
||||||
|
|
||||||
|
emit HasResult(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,5 +222,11 @@ void VTableSearch::RefreshList(const QString &term)
|
||||||
QTableWidgetItem *item = searchList.at(searchIndex);
|
QTableWidgetItem *item = searchList.at(searchIndex);
|
||||||
item->setBackground(Qt::red);
|
item->setBackground(Qt::red);
|
||||||
table->scrollToItem(item);
|
table->scrollToItem(item);
|
||||||
|
|
||||||
|
emit HasResult(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emit HasResult(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#ifndef VTABLESEARCH_H
|
#ifndef VTABLESEARCH_H
|
||||||
#define VTABLESEARCH_H
|
#define VTABLESEARCH_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
|
@ -37,10 +38,11 @@
|
||||||
class QTableWidget;
|
class QTableWidget;
|
||||||
class QTableWidgetItem;
|
class QTableWidgetItem;
|
||||||
|
|
||||||
class VTableSearch
|
class VTableSearch: public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit VTableSearch(QTableWidget *table);
|
explicit VTableSearch(QTableWidget *table, QObject *parent = nullptr);
|
||||||
|
|
||||||
void Find(const QString &term);
|
void Find(const QString &term);
|
||||||
void FindPrevious();
|
void FindPrevious();
|
||||||
|
@ -49,6 +51,9 @@ public:
|
||||||
void AddRow(int row);
|
void AddRow(int row);
|
||||||
void RefreshList(const QString &term);
|
void RefreshList(const QString &term);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void HasResult(bool state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VTableSearch)
|
Q_DISABLE_COPY(VTableSearch)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user