parent
f16ca99a55
commit
176c92ace8
|
@ -1,14 +1,105 @@
|
|||
#include "searchdialog.h"
|
||||
#include "ui_searchdialog.h"
|
||||
#include <QTabBar>
|
||||
|
||||
SearchDialog::SearchDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::SearchDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
mTabBar = new QTabBar();
|
||||
mTabBar->addTab(tr("Find"));
|
||||
mTabBar->addTab(tr("Find in files"));
|
||||
mTabBar->addTab(tr("Replace"));
|
||||
mTabBar->addTab(tr("Replace in files"));
|
||||
ui->dialogLayout->insertWidget(0,mTabBar);
|
||||
connect(mTabBar,&QTabBar::currentChanged,this, &SearchDialog::onTabChanged);
|
||||
}
|
||||
|
||||
SearchDialog::~SearchDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SearchDialog::find(const QString &text)
|
||||
{
|
||||
mTabBar->setCurrentIndex(0);
|
||||
ui->cbFind->setCurrentText(text);
|
||||
show();
|
||||
}
|
||||
|
||||
void SearchDialog::findInFiles(const QString &text)
|
||||
{
|
||||
mTabBar->setCurrentIndex(1);
|
||||
ui->cbFind->setCurrentText(text);
|
||||
show();
|
||||
}
|
||||
|
||||
void SearchDialog::replace(const QString &sFind, const QString &sReplace)
|
||||
{
|
||||
mTabBar->setCurrentIndex(2);
|
||||
ui->cbFind->setCurrentText(sFind);
|
||||
ui->cbReplace->setCurrentText(sReplace);
|
||||
show();
|
||||
}
|
||||
|
||||
void SearchDialog::replaceInFiles(const QString &sFind, const QString &sReplace)
|
||||
{
|
||||
mTabBar->setCurrentIndex(3);
|
||||
ui->cbFind->setCurrentText(sFind);
|
||||
ui->cbReplace->setCurrentText(sReplace);
|
||||
show();
|
||||
}
|
||||
|
||||
void SearchDialog::onTabChanged()
|
||||
{
|
||||
bool isfind = (mTabBar->currentIndex() == 0);
|
||||
bool isfindfiles = (mTabBar->currentIndex() == 1);
|
||||
bool isreplace = (mTabBar->currentIndex() == 2);
|
||||
bool isreplacefiles = (mTabBar->currentIndex() == 3);
|
||||
|
||||
ui->lblReplace->setVisible(isreplace || isreplacefiles);
|
||||
ui->cbReplace->setVisible(isreplace || isreplacefiles);
|
||||
|
||||
ui->grpOrigin->setVisible(isfind || isreplace);
|
||||
ui->grpScope->setVisible(isfind || isreplace);
|
||||
ui->grpWhere->setVisible(isfindfiles || isreplacefiles);
|
||||
ui->grpDirection->setVisible(isfind || isreplace);
|
||||
// grpOption is always visible
|
||||
|
||||
// Disable project search option when none is open
|
||||
// rbProjectFiles.Enabled := Assigned(MainForm.Project);
|
||||
ui->rbProject->setEnabled(false);
|
||||
// if not Assigned(MainForm.Project) then
|
||||
// rbOpenFiles.Checked := true;
|
||||
|
||||
// Disable prompt when doing finds
|
||||
ui->chkPrompt->setEnabled(isreplace or isreplacefiles);
|
||||
|
||||
if (isfind || not isfindfiles) {
|
||||
ui->btnExecute->setText(tr("Find"));
|
||||
} else {
|
||||
ui->btnExecute->setText(tr("Replace"));
|
||||
}
|
||||
setWindowTitle(mTabBar->tabText(mTabBar->currentIndex()));
|
||||
}
|
||||
|
||||
void SearchDialog::on_cbFind_currentTextChanged(const QString &)
|
||||
{
|
||||
ui->btnExecute->setEnabled(!ui->cbFind->currentText().isEmpty());
|
||||
}
|
||||
|
||||
void SearchDialog::on_btnCancel_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
void SearchDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
this->deleteLater();
|
||||
}
|
||||
|
||||
void SearchDialog::on_btnExecute_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace Ui {
|
|||
class SearchDialog;
|
||||
}
|
||||
|
||||
class QTabBar;
|
||||
class SearchDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -14,9 +15,25 @@ class SearchDialog : public QDialog
|
|||
public:
|
||||
explicit SearchDialog(QWidget *parent = nullptr);
|
||||
~SearchDialog();
|
||||
void find(const QString& text);
|
||||
void findInFiles(const QString& text);
|
||||
void replace(const QString& sFind, const QString& sReplace);
|
||||
void replaceInFiles(const QString& sFind, const QString& sReplace);
|
||||
private slots:
|
||||
void onTabChanged();
|
||||
void on_cbFind_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_btnCancel_clicked();
|
||||
|
||||
void on_btnExecute_clicked();
|
||||
|
||||
private:
|
||||
Ui::SearchDialog *ui;
|
||||
QTabBar *mTabBar;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // SEARCHDIALOG_H
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="dialogLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -39,10 +39,268 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Text to Find</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblFind">
|
||||
<property name="text">
|
||||
<string>Text to Find:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cbFind">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::InsertAtTop</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cbReplace">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::InsertAtTop</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblReplace">
|
||||
<property name="text">
|
||||
<string>Replace with:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="grpOptions">
|
||||
<property name="title">
|
||||
<string>Options:</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkCaseSensetive">
|
||||
<property name="text">
|
||||
<string>Case Sensitive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkWholeWord">
|
||||
<property name="text">
|
||||
<string>Whole words only</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkRegExp">
|
||||
<property name="text">
|
||||
<string>Regular Expression</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkPrompt">
|
||||
<property name="text">
|
||||
<string>Prompt on replace</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="grpScope">
|
||||
<property name="title">
|
||||
<string>Scope:</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbGlobal">
|
||||
<property name="text">
|
||||
<string>Global</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbSelection">
|
||||
<property name="text">
|
||||
<string>Selection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QGroupBox" name="grpOrigin">
|
||||
<property name="title">
|
||||
<string>Origin:</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbFromCursor">
|
||||
<property name="text">
|
||||
<string>From cursor</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbEntireScope">
|
||||
<property name="text">
|
||||
<string>Entire scope</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QWidget" name="widget_4" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>7</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="grpDirection">
|
||||
<property name="title">
|
||||
<string>Direction:</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbForward">
|
||||
<property name="text">
|
||||
<string>Forward</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbBackward">
|
||||
<property name="text">
|
||||
<string>Backward</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="grpWhere">
|
||||
<property name="title">
|
||||
<string>Where:</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbCurrentFile">
|
||||
<property name="text">
|
||||
<string>current file</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbProject">
|
||||
<property name="text">
|
||||
<string>Files In project</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbOpenFiles">
|
||||
<property name="text">
|
||||
<string>Open files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -53,7 +311,7 @@
|
|||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>445</height>
|
||||
<height>134</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
@ -84,14 +342,14 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<widget class="QPushButton" name="btnExecute">
|
||||
<property name="text">
|
||||
<string>Find</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<widget class="QPushButton" name="btnCancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
|
|
Loading…
Reference in New Issue