Compare commits
No commits in common. "0b829215e5aa05680c99c19468db8f02db969bc5" and "590a8888fcf18881349d7ac5352bf88d31f5156b" have entirely different histories.
0b829215e5
...
590a8888fc
@ -23,7 +23,7 @@ void CommandAdd::indexerFinished()
|
||||
if(failedPathsCount > 0)
|
||||
{
|
||||
Logger::info() << "Failed paths: " << Qt::endl;
|
||||
for(const QString &paths : result.failedPaths())
|
||||
for(QString paths : result.failedPaths())
|
||||
{
|
||||
Logger::info() << paths << Qt::endl;
|
||||
}
|
||||
@ -95,8 +95,8 @@ int CommandAdd::handle(QStringList arguments)
|
||||
connect(indexer, &Indexer::pathsCountChanged, this,
|
||||
[](int pathsCount) { Logger::info() << "Found paths: " << pathsCount << Qt::endl; });
|
||||
connect(indexer, &Indexer::indexProgress, this,
|
||||
[](int pathsCount, unsigned int /*added*/, unsigned int /*skipped*/, unsigned int /*failed*/,
|
||||
unsigned int /*totalCount*/) { Logger::info() << "Processed files: " << pathsCount << Qt::endl; });
|
||||
[](int pathsCount, unsigned int added, unsigned int skipped, unsigned int failed, unsigned int totalCount)
|
||||
{ Logger::info() << "Processed files: " << pathsCount << Qt::endl; });
|
||||
connect(indexer, &Indexer::finished, this, &CommandAdd::indexerFinished);
|
||||
|
||||
this->autoFinish = false;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <QCommandLineParser>
|
||||
#include "commandlist.h"
|
||||
#include "databasefactory.h"
|
||||
#include "logger.h"
|
||||
|
||||
int CommandList::handle(QStringList arguments)
|
||||
|
@ -38,6 +38,7 @@ int CommandUpdate::handle(QStringList arguments)
|
||||
QThreadPool::globalInstance()->setMaxThreadCount(threadsCount.toInt());
|
||||
}
|
||||
|
||||
bool hasErrors = false;
|
||||
IndexSyncer *syncer = new IndexSyncer(*this->dbService);
|
||||
|
||||
FileSaverOptions fileOptions;
|
||||
@ -63,7 +64,7 @@ int CommandUpdate::handle(QStringList arguments)
|
||||
/* TODO: updated not printed, handled be verbose in FileSaver, but this can be improved */
|
||||
}
|
||||
connect(syncer, &IndexSyncer::finished, this,
|
||||
[this, dryRun, keepGoing](unsigned int totalUpdated, unsigned int totalRemoved, unsigned int totalErrors)
|
||||
[&](unsigned int totalUpdated, unsigned int totalRemoved, unsigned int totalErrors)
|
||||
{
|
||||
Logger::info() << "Syncing finished" << Qt::endl;
|
||||
|
||||
@ -75,7 +76,7 @@ int CommandUpdate::handle(QStringList arguments)
|
||||
}
|
||||
|
||||
int retval = 0;
|
||||
if(this->hasErrors && !keepGoing)
|
||||
if(hasErrors && !keepGoing)
|
||||
{
|
||||
retval = 1;
|
||||
}
|
||||
@ -85,7 +86,7 @@ int CommandUpdate::handle(QStringList arguments)
|
||||
[&](QString error)
|
||||
{
|
||||
Logger::error() << error << Qt::endl;
|
||||
this->hasErrors = true;
|
||||
hasErrors = true;
|
||||
});
|
||||
|
||||
this->autoFinish = false;
|
||||
|
@ -4,9 +4,6 @@
|
||||
#include "filesaver.h"
|
||||
class CommandUpdate : public Command
|
||||
{
|
||||
protected:
|
||||
bool hasErrors = false;
|
||||
|
||||
public:
|
||||
using Command::Command;
|
||||
int handle(QStringList arguments) override;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "../shared/sqlitesearch.h"
|
||||
#include "../shared/looqsgeneralexception.h"
|
||||
#include "../shared/common.h"
|
||||
#include "previewgenerator.h"
|
||||
#include "aboutdialog.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent, QString socketPath)
|
||||
@ -147,7 +148,7 @@ void MainWindow::connectSignals()
|
||||
connect(this->indexer, &Indexer::finished, this, &MainWindow::finishIndexing);
|
||||
|
||||
connect(ui->lstPaths->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
[&](const QItemSelection & /*selected*/, const QItemSelection & /*deselected*/)
|
||||
[&](const QItemSelection &selected, const QItemSelection &deselected)
|
||||
{ ui->btnDeletePath->setEnabled(this->ui->lstPaths->selectedItems().count() > 0); });
|
||||
|
||||
connect(ui->btnDeletePath, &QPushButton::clicked, this, [&] { qDeleteAll(ui->lstPaths->selectedItems()); });
|
||||
@ -167,29 +168,30 @@ void MainWindow::connectSignals()
|
||||
}
|
||||
});
|
||||
connect(ui->menuAboutAction, &QAction::triggered, this,
|
||||
[this](bool /*checked*/)
|
||||
[this](bool checked)
|
||||
{
|
||||
AboutDialog aboutDialog(this);
|
||||
|
||||
aboutDialog.exec();
|
||||
});
|
||||
connect(ui->menuAboutQtAction, &QAction::triggered, this,
|
||||
[this](bool /*checked*/) { QMessageBox::aboutQt(this, "About Qt"); });
|
||||
[this](bool checked) { QMessageBox::aboutQt(this, "About Qt"); });
|
||||
connect(ui->menuSyncIndexAction, &QAction::triggered, this, &MainWindow::startIndexSync);
|
||||
connect(ui->menuOpenUserManualAction, &QAction::triggered, this,
|
||||
[]() { QDesktopServices::openUrl(Common::userManualUrl()); });
|
||||
[this]() { QDesktopServices::openUrl(Common::userManualUrl()); });
|
||||
|
||||
connect(
|
||||
indexSyncer, &IndexSyncer::finished, this,
|
||||
[&](unsigned int totalUpdated, unsigned int totalDeleted, unsigned int totalErrored)
|
||||
{
|
||||
this->progressDialog.cancel();
|
||||
connect(indexSyncer, &IndexSyncer::finished, this,
|
||||
[&](unsigned int totalUpdated, unsigned int totalDeleted, unsigned int totalErrored)
|
||||
{
|
||||
this->progressDialog.cancel();
|
||||
|
||||
QMessageBox::information(
|
||||
this, "Syncing finished",
|
||||
QString("Syncing finished\n\nTotal updated: %1\nTotal deleted: %2\nTotal errors: %3\n")
|
||||
.arg(QString::number(totalUpdated), QString::number(totalDeleted), QString::number(totalErrored)));
|
||||
});
|
||||
QMessageBox::information(
|
||||
this, "Syncing finished",
|
||||
QString("Syncing finished\n\nTotal updated: %1\nTotal deleted: %2\nTotal errors: %3\n")
|
||||
.arg(QString::number(totalUpdated))
|
||||
.arg(QString::number(totalDeleted))
|
||||
.arg(QString::number(totalErrored)));
|
||||
});
|
||||
connect(this, &MainWindow::beginIndexSync, indexSyncer, &IndexSyncer::sync);
|
||||
connect(&this->progressDialog, &QProgressDialog::canceled, indexSyncer, &IndexSyncer::cancel);
|
||||
connect(ui->btnSaveSettings, &QPushButton::clicked, this, &MainWindow::saveSettings);
|
||||
@ -350,7 +352,7 @@ void MainWindow::finishIndexing()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::comboScaleChanged(int /*i*/)
|
||||
void MainWindow::comboScaleChanged(int i)
|
||||
{
|
||||
QSettings scaleSetting;
|
||||
scaleSetting.setValue("currentScale", ui->comboScale->currentText());
|
||||
@ -396,8 +398,7 @@ void MainWindow::processShortcut(int key)
|
||||
{
|
||||
ui->txtSearch->setFocus();
|
||||
QString currentText = ui->txtSearch->text().trimmed();
|
||||
static QRegularExpression separatorRegex("[\\s\\)]");
|
||||
int index = currentText.lastIndexOf(separatorRegex);
|
||||
int index = currentText.lastIndexOf(QRegularExpression("[\\s\\)]"));
|
||||
if(index != -1)
|
||||
{
|
||||
bool isFilter = (index == currentText.length() - 1);
|
||||
@ -677,7 +678,7 @@ void MainWindow::previewReceived()
|
||||
QFileInfo fileInfo{docPath};
|
||||
QMenu menu("labeRightClick", this);
|
||||
createSearchResultMenu(menu, fileInfo);
|
||||
menu.addAction("Copy page number", this,
|
||||
menu.addAction("Copy page number",
|
||||
[previewPage] { QGuiApplication::clipboard()->setText(QString::number(previewPage)); });
|
||||
menu.exec(QCursor::pos());
|
||||
};
|
||||
@ -915,7 +916,7 @@ void MainWindow::makePreviews(int page)
|
||||
ui->previewProcessBar->setMaximum(this->previewCoordinator.previewableCount());
|
||||
|
||||
QVector<QString> wordsToHighlight;
|
||||
static QRegularExpression extractor(R"#("([^"]*)"|([^\s]+))#");
|
||||
QRegularExpression extractor(R"#("([^"]*)"|([^\s]+))#");
|
||||
for(const Token &token : this->contentSearchQuery.getTokens())
|
||||
{
|
||||
if(token.type == FILTER_CONTENT_CONTAINS)
|
||||
@ -947,6 +948,7 @@ void MainWindow::makePreviews(int page)
|
||||
renderConfig.scaleY = QGuiApplication::primaryScreen()->physicalDotsPerInchY() * (currentScale / 100.);
|
||||
renderConfig.wordsToHighlight = wordsToHighlight;
|
||||
|
||||
int previewPos = 0;
|
||||
QVector<RenderTarget> targets;
|
||||
for(const SearchResult &sr : this->previewCoordinator.getPreviewableSearchResults())
|
||||
{
|
||||
@ -986,20 +988,20 @@ void MainWindow::handleSearchError(QString error)
|
||||
|
||||
void MainWindow::createSearchResultMenu(QMenu &menu, const QFileInfo &fileInfo)
|
||||
{
|
||||
menu.addAction("Copy filename to clipboard", this,
|
||||
menu.addAction("Copy filename to clipboard",
|
||||
[&fileInfo] { QGuiApplication::clipboard()->setText(fileInfo.fileName()); });
|
||||
menu.addAction("Copy full path to clipboard", this,
|
||||
menu.addAction("Copy full path to clipboard",
|
||||
[&fileInfo] { QGuiApplication::clipboard()->setText(fileInfo.absoluteFilePath()); });
|
||||
menu.addAction("Open containing folder", this, [this, &fileInfo] { this->openFile(fileInfo.absolutePath()); });
|
||||
menu.addAction("Open containing folder", [this, &fileInfo] { this->openFile(fileInfo.absolutePath()); });
|
||||
|
||||
auto previewables = this->previewCoordinator.getPreviewableSearchResults();
|
||||
auto result =
|
||||
std::find_if(previewables.begin(), previewables.end(),
|
||||
[&fileInfo](SearchResult &a) { return fileInfo.absoluteFilePath() == a.fileData.absPath; });
|
||||
[this, &fileInfo](SearchResult &a) { return fileInfo.absoluteFilePath() == a.fileData.absPath; });
|
||||
|
||||
if(result != previewables.end())
|
||||
{
|
||||
menu.addAction("Show previews for this file", this,
|
||||
menu.addAction("Show previews for this file",
|
||||
[this, &fileInfo]
|
||||
{
|
||||
ui->tabWidget->setCurrentIndex(1);
|
||||
@ -1035,7 +1037,7 @@ void MainWindow::openFile(QString path)
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||
}
|
||||
|
||||
void MainWindow::treeSearchItemActivated(QTreeWidgetItem *item, int /*i*/)
|
||||
void MainWindow::treeSearchItemActivated(QTreeWidgetItem *item, int i)
|
||||
{
|
||||
openFile(item->text(1));
|
||||
}
|
||||
@ -1063,7 +1065,7 @@ MainWindow::~MainWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent * /*event*/)
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
QStringList list = this->searchHistory.toList();
|
||||
QSettings settings;
|
||||
|
@ -57,7 +57,7 @@ class MainWindow : public QMainWindow
|
||||
void initSettingsTabs();
|
||||
int currentSelectedScale();
|
||||
void processShortcut(int key);
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
bool eventFilter(QObject *object, QEvent *event);
|
||||
|
||||
private slots:
|
||||
void lineEditReturnPressed();
|
||||
|
@ -24,7 +24,7 @@ QSharedPointer<PreviewResult> PreviewGeneratorOdt::generate(RenderConfig config,
|
||||
throw LooqsGeneralException("Error while reading content.xml of " + documentPath);
|
||||
}
|
||||
TagStripperProcessor tsp;
|
||||
QString content = tsp.process(entireContent).constFirst().content;
|
||||
QString content = tsp.process(entireContent).first().content;
|
||||
|
||||
PreviewGeneratorPlainText plainTextGenerator;
|
||||
result->setText(plainTextGenerator.generatePreviewText(content, config, info.fileName()));
|
||||
|
@ -195,7 +195,7 @@ QString PreviewGeneratorPlainText::generateLineBasedPreviewText(QTextStream &in,
|
||||
int totalWordsA = 0;
|
||||
int differentWordsB = 0;
|
||||
int totalWordsB = 0;
|
||||
for(int count : qAsConst(a.wordCountMap))
|
||||
for(int count : a.wordCountMap.values())
|
||||
{
|
||||
if(count > 0)
|
||||
{
|
||||
@ -203,7 +203,7 @@ QString PreviewGeneratorPlainText::generateLineBasedPreviewText(QTextStream &in,
|
||||
}
|
||||
totalWordsA += count;
|
||||
}
|
||||
for(int count : qAsConst(b.wordCountMap))
|
||||
for(int count : b.wordCountMap.values())
|
||||
{
|
||||
if(count > 0)
|
||||
{
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <optional>
|
||||
#include <algorithm>
|
||||
#include "looqsquery.h"
|
||||
#include "looqsgeneralexception.h"
|
||||
|
||||
const QVector<Token> &LooqsQuery::getTokens() const
|
||||
{
|
||||
@ -181,9 +180,8 @@ LooqsQuery LooqsQuery::build(QString expression, TokenType loneWordsTokenType, b
|
||||
|
||||
QStringList loneWords;
|
||||
LooqsQuery result;
|
||||
static QRegularExpression rx(
|
||||
"((?<filtername>(\\.|\\w)+):(?<args>\\((?<innerargs>[^\\)]+)\\)|([^\\s])+)|(?<boolean>AND|OR)"
|
||||
"|(?<negation>!)|(?<bracket>\\(|\\))|(?<loneword>[^\\s]+))");
|
||||
QRegularExpression rx("((?<filtername>(\\.|\\w)+):(?<args>\\((?<innerargs>[^\\)]+)\\)|([^\\s])+)|(?<boolean>AND|OR)"
|
||||
"|(?<negation>!)|(?<bracket>\\(|\\))|(?<loneword>[^\\s]+))");
|
||||
QRegularExpressionMatchIterator i = rx.globalMatch(expression);
|
||||
auto previousWasBool = [&result] { return !result.tokens.empty() && ((result.tokens.last().type & BOOL) == BOOL); };
|
||||
auto previousWas = [&result](TokenType t) { return !result.tokens.empty() && (result.tokens.last().type == t); };
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define LOOQSQUERY_H
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include "looqsgeneralexception.h"
|
||||
#include "token.h"
|
||||
/* Fields that can be queried or sorted */
|
||||
enum QueryField
|
||||
@ -45,7 +46,7 @@ class LooqsQuery
|
||||
void addToken(Token t);
|
||||
void updateTokensMask()
|
||||
{
|
||||
for(const Token &t : qAsConst(tokens))
|
||||
for(const Token &t : tokens)
|
||||
{
|
||||
this->tokensMask |= t.type;
|
||||
}
|
||||
@ -91,6 +92,14 @@ class LooqsQuery
|
||||
this->sortConditions = sortConditions;
|
||||
updateTokensMask();
|
||||
}
|
||||
|
||||
LooqsQuery(const LooqsQuery &o)
|
||||
{
|
||||
this->tokens = o.tokens;
|
||||
this->sortConditions = o.sortConditions;
|
||||
this->tokensMask = o.tokensMask;
|
||||
this->limit = o.limit;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // LOOQSQUERY_H
|
||||
|
@ -10,7 +10,7 @@ class NothingProcessor : public Processor
|
||||
NothingProcessor();
|
||||
|
||||
public:
|
||||
QVector<PageData> process(const QByteArray & /*data*/) const override
|
||||
QVector<PageData> process(const QByteArray &data) const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "odtprocessor.h"
|
||||
#include "tagstripperprocessor.h"
|
||||
|
||||
QVector<PageData> OdtProcessor::process(const QByteArray & /*data*/) const
|
||||
QVector<PageData> OdtProcessor::process(const QByteArray &data) const
|
||||
{
|
||||
throw LooqsGeneralException("Not implemented yet");
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "paralleldirscanner.h"
|
||||
|
||||
#include <QRunnable>
|
||||
#include <QMutex>
|
||||
#include <QDirIterator>
|
||||
@ -5,7 +7,7 @@
|
||||
#include <QThreadPool>
|
||||
#include <functional>
|
||||
#include "dirscanworker.h"
|
||||
#include "paralleldirscanner.h"
|
||||
#include "logger.h"
|
||||
|
||||
ParallelDirScanner::ParallelDirScanner()
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ QString SqliteSearch::createSortSql(const QVector<SortCondition> sortConditions)
|
||||
QString SqliteSearch::escapeFtsArgument(QString ftsArg)
|
||||
{
|
||||
QString result;
|
||||
static QRegularExpression extractor(R"#("([^"]*)"|([^\s]+))#");
|
||||
QRegularExpression extractor(R"#("([^"]*)"|([^\s]+))#");
|
||||
QRegularExpressionMatchIterator i = extractor.globalMatch(ftsArg);
|
||||
while(i.hasNext())
|
||||
{
|
||||
@ -149,6 +149,7 @@ QPair<QString, QVector<QString>> SqliteSearch::createSql(const Token &token)
|
||||
QSqlQuery SqliteSearch::makeSqlQuery(const LooqsQuery &query)
|
||||
{
|
||||
QString whereSql;
|
||||
QString joinSql;
|
||||
QVector<QString> bindValues;
|
||||
bool isContentSearch = (query.getTokensMask() & FILTER_CONTENT) == FILTER_CONTENT;
|
||||
if(query.getTokens().isEmpty())
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 44b9a17becf6882e1b3728cbf885ae9e5a6717af
|
||||
Subproject commit 769f729dc51f2feb8bc3cbb2a48ed91ff2d56bf3
|
불러오는 중...
Reference in New Issue
Block a user