added Common namespace. cli: use settings instead of env for db path
Este cometimento está contido em:
ascendente
277d466a45
cometimento
13fb901044
@ -10,6 +10,7 @@
|
||||
#include <QSqlError>
|
||||
#include <QMap>
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
#include <functional>
|
||||
#include <exception>
|
||||
#include "encodingdetector.h"
|
||||
@ -23,6 +24,8 @@
|
||||
#include "commandsearch.h"
|
||||
#include "databasefactory.h"
|
||||
#include "logger.h"
|
||||
#include "../shared/common.h"
|
||||
|
||||
void printUsage(QString argv0)
|
||||
{
|
||||
qInfo() << "Usage: " << argv0 << "command";
|
||||
@ -52,8 +55,9 @@ Command *commandFromName(QString name, SqliteDbService &dbService)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
Common::setupAppInfo();
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
QStringList args = app.arguments();
|
||||
QString argv0 = args.takeFirst();
|
||||
if(args.length() < 1)
|
||||
@ -63,7 +67,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
QString commandName = args.first();
|
||||
QString connectionString = QProcessEnvironment::systemEnvironment().value("QSS_PATH");
|
||||
QSettings settings;
|
||||
QString connectionString = settings.value("dbpath").toString();
|
||||
DatabaseFactory dbFactory(connectionString);
|
||||
SqliteDbService dbService(dbFactory);
|
||||
Command *cmd = commandFromName(commandName, dbService);
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
#include <QSettings>
|
||||
#include "mainwindow.h"
|
||||
#include "searchresult.h"
|
||||
#include "pdfpreview.h"
|
||||
#include "../shared/common.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication::setOrganizationName("quitesimple.org");
|
||||
QCoreApplication::setOrganizationDomain("quitesimple.org");
|
||||
QCoreApplication::setApplicationName("qss");
|
||||
Common::setupAppInfo();
|
||||
QApplication a(argc, argv);
|
||||
qRegisterMetaType<QVector<SearchResult>>("QVector<SearchResult>");
|
||||
qRegisterMetaType<QVector<PdfPreview>>("QVector<PdfPreview>");
|
||||
|
8
shared/common.cpp
Ficheiro normal
8
shared/common.cpp
Ficheiro normal
@ -0,0 +1,8 @@
|
||||
#include "common.h"
|
||||
|
||||
void Common::setupAppInfo()
|
||||
{
|
||||
QCoreApplication::setOrganizationName("quitesimple.org");
|
||||
QCoreApplication::setOrganizationDomain("quitesimple.org");
|
||||
QCoreApplication::setApplicationName("qss");
|
||||
}
|
9
shared/common.h
Ficheiro normal
9
shared/common.h
Ficheiro normal
@ -0,0 +1,9 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace Common
|
||||
{
|
||||
void setupAppInfo();
|
||||
}
|
||||
#endif
|
@ -26,14 +26,16 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
SOURCES += sqlitesearch.cpp \
|
||||
qssgeneralexception.cpp \
|
||||
qssquery.cpp
|
||||
qssquery.cpp \
|
||||
common.cpp
|
||||
|
||||
HEADERS += sqlitesearch.h \
|
||||
filedata.h \
|
||||
searchresult.h \
|
||||
qssgeneralexception.h \
|
||||
token.h \
|
||||
qssquery.h
|
||||
qssquery.h \
|
||||
common.h
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
INSTALLS += target
|
||||
|
Carregando…
Criar uma nova questão referindo esta
Bloquear um utilizador