Skip to content

Commit a2ee541

Browse files
committed
support search
- Ctrl+E C to toggle the search dock;
1 parent d404360 commit a2ee541

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2668
-269
lines changed

src/dialog/vexportdialog.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void VExportDialog::setupUI()
7575
// Notes to export.
7676
m_srcCB = VUtils::getComboBox();
7777
m_srcCB->setToolTip(tr("Choose notes to export"));
78-
m_srcCB->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
78+
m_srcCB->setSizeAdjustPolicy(QComboBox::AdjustToContents);
7979
connect(m_srcCB, SIGNAL(currentIndexChanged(int)),
8080
this, SLOT(handleCurrentSrcChanged(int)));
8181

@@ -580,7 +580,7 @@ void VExportDialog::startExport()
580580

581581
if (opt.m_outputSuffix.isEmpty()
582582
|| opt.m_cmd.isEmpty()
583-
|| opt.m_allInOne && opt.m_folderSep.isEmpty()) {
583+
|| (opt.m_allInOne && opt.m_folderSep.isEmpty())) {
584584
appendLogLine(tr("Invalid configurations for custom export."));
585585
m_inExport = false;
586586
m_exportBtn->setEnabled(true);
@@ -1274,11 +1274,11 @@ int VExportDialog::doExportCustomAllInOne(const QList<QString> &p_files,
12741274
QWidget *VExportDialog::setupCustomAdvancedSettings()
12751275
{
12761276
// Source format.
1277-
m_customSrcFormatCB = VUtils::getComboBox();
1277+
m_customSrcFormatCB = VUtils::getComboBox(this);
12781278
m_customSrcFormatCB->setToolTip(tr("Choose format of the input"));
12791279

12801280
// Output suffix.
1281-
m_customSuffixEdit = new VLineEdit();
1281+
m_customSuffixEdit = new VLineEdit(this);
12821282
m_customSuffixEdit->setPlaceholderText(tr("Without the preceding dot"));
12831283
m_customSuffixEdit->setToolTip(tr("Suffix of the output file without the preceding dot"));
12841284
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
@@ -1288,11 +1288,12 @@ QWidget *VExportDialog::setupCustomAdvancedSettings()
12881288
QLabel *tipsLabel = new QLabel(tr("<span><span style=\"font-weight:bold;\">%0</span> for the input file; "
12891289
"<span style=\"font-weight:bold;\">%1</span> for the output file; "
12901290
"<span style=\"font-weight:bold;\">%2</span> for the rendering CSS style file; "
1291-
"<span style=\"font-weight:bold;\">%3</span> for the input file directory.</span>"));
1291+
"<span style=\"font-weight:bold;\">%3</span> for the input file directory.</span>"),
1292+
this);
12921293
tipsLabel->setWordWrap(true);
12931294

12941295
// Enable All In One.
1295-
m_customAllInOneCB = new QCheckBox(tr("Enable All In One"));
1296+
m_customAllInOneCB = new QCheckBox(tr("Enable All In One"), this);
12961297
m_customAllInOneCB->setToolTip(tr("Pass a list of input files to the custom command"));
12971298
connect(m_customAllInOneCB, &QCheckBox::stateChanged,
12981299
this, [this](int p_state) {
@@ -1302,13 +1303,13 @@ QWidget *VExportDialog::setupCustomAdvancedSettings()
13021303
});
13031304

13041305
// Input directory separator.
1305-
m_customFolderSepEdit = new VLineEdit();
1306+
m_customFolderSepEdit = new VLineEdit(this);
13061307
m_customFolderSepEdit->setPlaceholderText(tr("Separator to concatenate input files directories"));
13071308
m_customFolderSepEdit->setToolTip(tr("Separator to concatenate input files directories"));
13081309
m_customFolderSepEdit->setEnabled(false);
13091310

13101311
// Target file name for all in one.
1311-
m_customTargetFileNameEdit = new VLineEdit();
1312+
m_customTargetFileNameEdit = new VLineEdit(this);
13121313
m_customTargetFileNameEdit->setPlaceholderText(tr("Empty to use the name of the first source file"));
13131314
m_customTargetFileNameEdit->setToolTip(tr("Name of the generated All-In-One file"));
13141315
validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
@@ -1317,7 +1318,7 @@ QWidget *VExportDialog::setupCustomAdvancedSettings()
13171318
m_customTargetFileNameEdit->setEnabled(false);
13181319

13191320
// Cmd edit.
1320-
m_customCmdEdit = new QPlainTextEdit();
1321+
m_customCmdEdit = new QPlainTextEdit(this);
13211322
m_customCmdEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
13221323
QString cmdExamp("pandoc --resource-path=.:\"%3\" --css=\"%2\" -s -o \"%1\" \"%0\"");
13231324
m_customCmdEdit->setPlaceholderText(cmdExamp);
@@ -1348,12 +1349,12 @@ QWidget *VExportDialog::setupCustomAdvancedSettings()
13481349
QWidget *wid = new QWidget();
13491350
wid->setLayout(advLayout);
13501351

1351-
m_customCmdEdit->setMaximumHeight(100);
1352+
m_customCmdEdit->setMaximumHeight(m_customSrcFormatCB->height() * 3);
13521353

13531354
return wid;
13541355
}
13551356

1356-
int VExportDialog::outputAsHTML(QString &p_outputFolder,
1357+
int VExportDialog::outputAsHTML(const QString &p_outputFolder,
13571358
QString *p_errMsg,
13581359
QList<QString> *p_outputFiles)
13591360
{

src/dialog/vexportdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ private slots:
368368

369369
ExportFormat currentFormat() const;
370370

371-
int outputAsHTML(QString &p_outputFolder,
371+
int outputAsHTML(const QString &p_outputFolder,
372372
QString *p_errMsg = NULL,
373373
QList<QString> *p_outputFiles = NULL);
374374

src/dialog/vfindreplacedialog.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void VFindReplaceDialog::setupUI()
4949
m_replaceFindBtn->setProperty("FlatBtn", true);
5050
m_replaceAllBtn = new QPushButton(tr("Replace A&ll"));
5151
m_replaceAllBtn->setProperty("FlatBtn", true);
52-
m_advancedBtn = new QPushButton(tr("&Advanced >>"));
52+
m_advancedBtn = new QPushButton(tr("&Advanced >>>"));
5353
m_advancedBtn->setProperty("FlatBtn", true);
5454
m_advancedBtn->setCheckable(true);
5555

@@ -199,9 +199,9 @@ void VFindReplaceDialog::handleFindTextChanged(const QString &p_text)
199199
void VFindReplaceDialog::advancedBtnToggled(bool p_checked)
200200
{
201201
if (p_checked) {
202-
m_advancedBtn->setText("B&asic <<");
202+
m_advancedBtn->setText(tr("B&asic <<<"));
203203
} else {
204-
m_advancedBtn->setText("&Advanced <<");
204+
m_advancedBtn->setText(tr("&Advanced >>>"));
205205
}
206206

207207
m_caseSensitiveCheck->setVisible(p_checked);

src/dialog/vfindreplacedialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ private slots:
4848

4949
private:
5050
void setupUI();
51+
5152
// Bit OR of FindOption
5253
uint m_options;
5354
bool m_replaceAvailable;

src/isearchengine.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndef ISEARCHENGINE_H
2+
#define ISEARCHENGINE_H
3+
4+
#include <QObject>
5+
#include <QVector>
6+
7+
#include "vsearchconfig.h"
8+
9+
// Abstract class for search engine.
10+
class ISearchEngine : public QObject
11+
{
12+
Q_OBJECT
13+
public:
14+
explicit ISearchEngine(QObject *p_parent = nullptr)
15+
: QObject(p_parent)
16+
{
17+
}
18+
19+
virtual void search(const QSharedPointer<VSearchConfig> &p_config,
20+
const QSharedPointer<VSearchResult> &p_result) = 0;
21+
22+
virtual void stop() = 0;
23+
24+
virtual void clear() = 0;
25+
26+
signals:
27+
void finished(const QSharedPointer<VSearchResult> &p_result);
28+
29+
void resultItemAdded(const QSharedPointer<VSearchResultItem> &p_item);
30+
31+
protected:
32+
QSharedPointer<VSearchResult> m_result;
33+
};
34+
#endif // ISEARCHENGINE_H
Lines changed: 10 additions & 0 deletions
Loading

src/resources/icons/note_item.svg

Lines changed: 15 additions & 0 deletions
Loading

src/resources/icons/search.svg

Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 14 additions & 0 deletions
Loading
Lines changed: 12 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)