Debian Codegraph @

Source/Test/Evaluation/CReasonerEvaluationUpdaterThread.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CReasonerEvaluationUpdaterThread.h"
22
23
24 namespace Konclude {
25
26 namespace Test {
27
28 namespace Evaluation {
29
30
31
32 CReasonerEvaluationUpdaterThread::CReasonerEvaluationUpdaterThread() : CThread("ReasonerEvaluationUpdaterThread") {
33 startThread();
34 }
35
36
37 CReasonerEvaluationUpdaterThread::~CReasonerEvaluationUpdaterThread() {
38 }
39
40
41 void CReasonerEvaluationUpdaterThread::addProgramFile(const QString& changedFile) {
42 postEvent(new CReasonerEvaluationUpdateEvent(changedFile));
43 }
44
45 void CReasonerEvaluationUpdaterThread::threadStarted() {
46 CThread::threadStarted();
47 mSystemWatcher = new QFileSystemWatcher(this);
48 connect(mSystemWatcher,SIGNAL(fileChanged(const QString&)),this,SLOT(watchedProgramFileChanged(const QString&)));
49 }
50
51 void CReasonerEvaluationUpdaterThread::threadStopped() {
52 CThread::threadStopped();
53 disconnect(mSystemWatcher,SIGNAL(fileChanged(const QString&)),this,SLOT(watchedProgramFileChanged(const QString&)));
54 }
55
56 bool CReasonerEvaluationUpdaterThread::processCustomsEvents(QEvent::Type type, CCustomEvent* event) {
57 if (CThread::processCustomsEvents(type,event)) {
58 return true;
59 } else {
60 if (type == CReasonerEvaluationUpdateEvent::EVENTTYPE) {
61 CReasonerEvaluationUpdateEvent* repe = (CReasonerEvaluationUpdateEvent*)event;
62 QString programString = repe->getProgramFile();
63 mSystemWatcher->addPath(programString);
64 return true;
65 } else if (type == CReasonerEvaluationProgramFileChangedEvent::EVENTTYPE) {
66 CReasonerEvaluationProgramFileChangedEvent* repfce = (CReasonerEvaluationProgramFileChangedEvent*)event;
67 QString changedFile = repfce->getChangedFile();
68 return true;
69 }
70 }
71 return false;
72 }
73
74 void CReasonerEvaluationUpdaterThread::watchedProgramFileChanged(const QString& changedFile) {
75 postEvent(new CReasonerEvaluationProgramFileChangedEvent(changedFile));
76 }
77
78
79 }; // end namespace Evaluation
80
81 }; // end namespace Test
82
83 }; // end namespace Konclude