Compare commits

...

3 Melakukan

Penulis SHA1 Pesan Tanggal
8ba4ee5847 gui: Disable settingsTab while Indexer is running 2022-06-13 22:53:41 +02:00
451c79088a shared/gui: Don't consider non-content search results for previews
Not entirely ideal, since we may want to search for 'cake', and look at
a preview for 'cake.txt' even if there is no 'cake' inside.

But this will do for now
2022-06-13 22:46:14 +02:00
1a39118470 shared: LooqsQuery: has*Search(): Mark methods const 2022-06-13 22:43:23 +02:00
5 mengubah file dengan 14 tambahan dan 4 penghapusan

Melihat File

@ -249,6 +249,7 @@ void MainWindow::startIndexing()
ui->previewsTab->setEnabled(false); ui->previewsTab->setEnabled(false);
ui->resultsTab->setEnabled(false); ui->resultsTab->setEnabled(false);
ui->settingsTab->setEnabled(false);
ui->txtPathScanAdd->setEnabled(false); ui->txtPathScanAdd->setEnabled(false);
ui->txtSearch->setEnabled(false); ui->txtSearch->setEnabled(false);
ui->previewProcessBar->setValue(0); ui->previewProcessBar->setValue(0);
@ -285,6 +286,7 @@ void MainWindow::finishIndexing()
ui->btnStartIndexing->setText("Start indexing"); ui->btnStartIndexing->setText("Start indexing");
ui->previewsTab->setEnabled(true); ui->previewsTab->setEnabled(true);
ui->resultsTab->setEnabled(true); ui->resultsTab->setEnabled(true);
ui->settingsTab->setEnabled(true);
ui->txtPathScanAdd->setEnabled(true); ui->txtPathScanAdd->setEnabled(true);
ui->txtSearch->setEnabled(true); ui->txtSearch->setEnabled(true);
} }
@ -489,6 +491,11 @@ void MainWindow::handleSearchResults(const QVector<SearchResult> &results)
bool exists = pathInfo.exists(); bool exists = pathInfo.exists();
if(exists) if(exists)
{ {
if(!result.wasContentSearch)
{
continue;
}
if(!pathInfo.suffix().contains("htm")) // hack until we can preview them properly... if(!pathInfo.suffix().contains("htm")) // hack until we can preview them properly...
{ {
if(PreviewGenerator::get(pathInfo) != nullptr) if(PreviewGenerator::get(pathInfo) != nullptr)

Melihat File

@ -23,12 +23,12 @@ QueryType LooqsQuery::getQueryType()
return static_cast<QueryType>(tokensMask & COMBINED); return static_cast<QueryType>(tokensMask & COMBINED);
} }
bool LooqsQuery::hasContentSearch() bool LooqsQuery::hasContentSearch() const
{ {
return (this->getTokensMask() & FILTER_CONTENT) == FILTER_CONTENT; return (this->getTokensMask() & FILTER_CONTENT) == FILTER_CONTENT;
} }
bool LooqsQuery::hasPathSearch() bool LooqsQuery::hasPathSearch() const
{ {
return (this->getTokensMask() & FILTER_PATH) == FILTER_PATH; return (this->getTokensMask() & FILTER_PATH) == FILTER_PATH;
} }

Melihat File

@ -61,8 +61,8 @@ class LooqsQuery
{ {
this->limit = limit; this->limit = limit;
} }
bool hasContentSearch(); bool hasContentSearch() const;
bool hasPathSearch(); bool hasPathSearch() const;
void addSortCondition(SortCondition sc); void addSortCondition(SortCondition sc);
static bool checkParanthesis(QString query); static bool checkParanthesis(QString query);

Melihat File

@ -7,6 +7,7 @@ class SearchResult
public: public:
FileData fileData; FileData fileData;
QVector<unsigned int> pages; QVector<unsigned int> pages;
bool wasContentSearch = false;
}; };
#endif // SEARCHRESULT_H #endif // SEARCHRESULT_H

Melihat File

@ -213,6 +213,7 @@ QVector<SearchResult> SqliteSearch::search(const LooqsQuery &query)
throw LooqsGeneralException("SQL Error: " + dbQuery.lastError().text()); throw LooqsGeneralException("SQL Error: " + dbQuery.lastError().text());
} }
bool contentSearch = query.hasContentSearch();
while(dbQuery.next()) while(dbQuery.next())
{ {
SearchResult result; SearchResult result;
@ -229,6 +230,7 @@ QVector<SearchResult> SqliteSearch::search(const LooqsQuery &query)
result.pages.append(page.toUInt()); result.pages.append(page.toUInt());
} }
} }
result.wasContentSearch = contentSearch;
results.append(result); results.append(result);
} }
return results; return results;