Commit 3e2122238286a86c0e5dacff3b6a397a91481eb0
1 parent
618b7fb6
Exists in
master
Adicionada classe Gercols para iniciar o desenvolvimento do módulo.
Showing
3 changed files
with
45 additions
and
4 deletions
Show diff stats
gercols/gercols.cpp
1 | 1 | #include "gercols.h" |
2 | 2 | |
3 | -Gercols::Gercols() | |
3 | +Gercols::Gercols(QObject *parent) : | |
4 | + QObject(parent) | |
4 | 5 | { |
6 | + | |
7 | +} | |
8 | + | |
9 | +void Gercols::run(QStringList argv, int argc) | |
10 | +{ | |
11 | + std::cout << "Gercols" << std::endl; | |
12 | + readConfig(); | |
13 | + std::cout << "Configuration file read." << std::endl; | |
5 | 14 | } |
6 | 15 | |
7 | 16 | void Gercols::readConfig() |
8 | 17 | { |
18 | + CCacic OCacic; | |
19 | + QString file = "configRequest.json"; | |
9 | 20 | |
21 | + this->configJson = OCacic.getJsonFromFile(file); | |
10 | 22 | } |
11 | 23 | |
12 | 24 | QJsonObject Gercols::getConfigJson() |
13 | 25 | { |
14 | - return QJsonObject(); | |
26 | + return configJson; | |
15 | 27 | } | ... | ... |
gercols/gercols.h
1 | 1 | #ifndef GERCOLS_H |
2 | 2 | #define GERCOLS_H |
3 | 3 | |
4 | +#include <QtCore> | |
5 | +#include <QObject> | |
4 | 6 | #include <QJsonObject> |
7 | +#include <QString> | |
8 | +#include <iostream> | |
9 | +#include <../src/ccacic.h> | |
5 | 10 | |
6 | -class Gercols | |
11 | +class Gercols : public QObject | |
7 | 12 | { |
13 | + Q_OBJECT | |
8 | 14 | public: |
9 | - Gercols(); | |
15 | + explicit Gercols(QObject *parent = 0); | |
10 | 16 | |
11 | 17 | void readConfig(); |
12 | 18 | QJsonObject getConfigJson(); |
19 | + | |
20 | +private: | |
21 | + QJsonObject configJson; | |
22 | + | |
23 | +signals: | |
24 | + void finished(); | |
25 | + | |
26 | +public slots: | |
27 | + void run(QStringList argv, int argc); | |
28 | + | |
13 | 29 | }; |
14 | 30 | |
15 | 31 | #endif // GERCOLS_H | ... | ... |
gercols/main.cpp
1 | 1 | #include <QCoreApplication> |
2 | +#include <gercols.h> | |
2 | 3 | |
3 | 4 | int main(int argc, char *argv[]) |
4 | 5 | { |
5 | 6 | QCoreApplication a(argc, argv); |
6 | 7 | |
8 | + QStringList args; | |
9 | + for (int i = 0; i<argc; i++) | |
10 | + args.append(argv[i]); | |
11 | + | |
12 | + Gercols *OGercols = new Gercols(&a); | |
13 | + | |
14 | + // This will cause the application to exit when | |
15 | + // the task signals finished. | |
16 | + QObject::connect(OGercols, SIGNAL(finished()), &a, SLOT(quit())); | |
17 | + | |
18 | + // This will run the task from the application event loop. | |
19 | + QMetaObject::invokeMethod(OGercols, "run", Qt::QueuedConnection, Q_ARG(QStringList, args), Q_ARG(int, argc)); | |
7 | 20 | return a.exec(); |
8 | 21 | } | ... | ... |