CommandSearch: Begin basic functionality (prints filename of result)
This commit is contained in:
والد
623eea80ec
کامیت
cfe30ae5fd
@ -1 +1,35 @@
|
|||||||
|
#include <QCommandLineParser>
|
||||||
#include "commandsearch.h"
|
#include "commandsearch.h"
|
||||||
|
#include "databasefactory.h"
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
|
int CommandSearch::handle(QStringList arguments)
|
||||||
|
{
|
||||||
|
QCommandLineParser parser;
|
||||||
|
parser.addOptions({
|
||||||
|
{{"r", "reverse"}, "Print most-recent changed files first"},
|
||||||
|
{"pattern",
|
||||||
|
"Only delete files from index matching the pattern, e. g. */.git/*. Only applies to --deleted or standalone.",
|
||||||
|
"pattern"},
|
||||||
|
});
|
||||||
|
|
||||||
|
parser.addHelpOption();
|
||||||
|
parser.addPositionalArgument("delete", "Delete paths from the index", "delete [paths...]");
|
||||||
|
|
||||||
|
parser.process(arguments);
|
||||||
|
bool reverse = parser.isSet("reverse");
|
||||||
|
if(reverse)
|
||||||
|
{
|
||||||
|
throw QSSGeneralException("Reverse option to be implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList files = parser.positionalArguments();
|
||||||
|
QString queryStrings = files.join(' ');
|
||||||
|
|
||||||
|
auto results = dbService->search(queryStrings);
|
||||||
|
|
||||||
|
for(SearchResult &result : results)
|
||||||
|
{
|
||||||
|
Logger::info() << result.fileData.absPath << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -8,10 +8,7 @@ class CommandSearch : public Command
|
|||||||
public:
|
public:
|
||||||
using Command::Command;
|
using Command::Command;
|
||||||
|
|
||||||
int handle(QStringList arguments) override
|
int handle(QStringList arguments) override;
|
||||||
{
|
|
||||||
return 23;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COMMANDSEARCH_H
|
#endif // COMMANDSEARCH_H
|
||||||
|
@ -21,6 +21,13 @@ bool SqliteDbService::fileExistsInDatabase(QString path, qint64 mtime)
|
|||||||
return query.value(0).toBool();
|
return query.value(0).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<SearchResult> SqliteDbService::search(QString searchQuery)
|
||||||
|
{
|
||||||
|
auto connection = dbFactory->forCurrentThread();
|
||||||
|
SqliteSearch searcher(connection);
|
||||||
|
return searcher.search(searchQuery);
|
||||||
|
}
|
||||||
|
|
||||||
bool SqliteDbService::fileExistsInDatabase(QString path)
|
bool SqliteDbService::fileExistsInDatabase(QString path)
|
||||||
{
|
{
|
||||||
auto query = QSqlQuery(dbFactory->forCurrentThread());
|
auto query = QSqlQuery(dbFactory->forCurrentThread());
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "pagedata.h"
|
#include "pagedata.h"
|
||||||
#include "filedata.h"
|
#include "filedata.h"
|
||||||
|
#include "../shared/sqlitesearch.h"
|
||||||
enum SaveFileResult
|
enum SaveFileResult
|
||||||
{
|
{
|
||||||
OK,
|
OK,
|
||||||
@ -25,6 +26,7 @@ class SqliteDbService
|
|||||||
bool deleteFile(QString path);
|
bool deleteFile(QString path);
|
||||||
bool fileExistsInDatabase(QString path);
|
bool fileExistsInDatabase(QString path);
|
||||||
bool fileExistsInDatabase(QString path, qint64 mtime);
|
bool fileExistsInDatabase(QString path, qint64 mtime);
|
||||||
|
QVector<SearchResult> search(QString searchQuery);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SQLITEDBSERVICE_H
|
#endif // SQLITEDBSERVICE_H
|
||||||
|
بارگذاری…
مرجع در شماره جدید
Block a user