-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovitel.cpp
114 lines (91 loc) · 3.39 KB
/
provitel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "provitel.h"
#include "ui_provitel.h"
#include <QDebug>
#include <QTimer>
#include <QFile>
#include <QDir>
#include <QListIterator>
#include <QRegExp>
#include <QStandardPaths>
#include "intelchannellogparser.h"
#include "intel.h"
ProviTel::ProviTel(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ProviTel)
{
ui->setupUi(this);
channelList.append("TheCitadel");
channelList.append("4THINTEL");
channelList.append("North Provi Intel");
QTimer::singleShot(1500, this, SLOT(getLatestIntelChannels()));
firstShown = false;
connect(this->ui->dockWidget, SIGNAL(topLevelChanged(bool)), this, SLOT(mapUndock(bool)));
}
ProviTel::~ProviTel()
{
delete ui;
}
void ProviTel::getLatestIntelChannels()
{
const QString documentsFolder = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/EVE/logs/Chatlogs";
QDir dir;
dir.setPath(documentsFolder);
QFileInfoList list = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs, QDir::Time);
QList<QFileInfo>::iterator i;
QString fileName;
for (i = list.begin(); i != list.end(); ++i)
{
fileName = ((QFileInfo)*i).baseName();
fileName.replace(QRegExp("\\_.*$"), "");
if(channelList.contains(fileName))
{
//IntelChannelLogParser* intel = new IntelChannelLogParser(this, fileName, ((QFileInfo)*i).baseName() + ".txt");
intelChannelList.push_back(new IntelChannelLogParser(this, fileName, ((QFileInfo)*i).baseName() + ".txt"));
channelList.removeOne(fileName);
}
if(channelList.isEmpty())
break;
}
}
void ProviTel::processIntel(QString channelName, QString intelMessage)
{
//ProviMap *proviMap = this->findChild<ProviMap *>(QString(), Qt::FindChildrenRecursively);
//std::vector<Planets*> planets = proviMap->getPlanets();
QList<System*> planetList = this->findChildren<System *>(QString(), Qt::FindChildrenRecursively);
QRegularExpression regex("\\[(.*)\\]");
QRegularExpressionMatch match = regex.match(intelMessage);
QString dateTime = match.captured(1);
//qDebug() << dateTime.trimmed();
intelMessage.replace(QRegExp("\\[(.*)\\]"), "");
QRegularExpression regex2("(.*)>");
QRegularExpressionMatch match2 = regex2.match(intelMessage);
QString reporterName = match2.captured(1);
//qDebug() << reporterName.trimmed();
intelMessage.replace(QRegExp("(.*)>"), "");
//qDebug() << intelMessage.trimmed();
IntelMessages *intelMessages = this->findChild<IntelMessages *>(QString(), Qt::FindChildrenRecursively);
Intel *intel = new Intel(intelMessages, "", reporterName.trimmed(), dateTime.trimmed(), intelMessage.trimmed(), channelName);
intelMessages->addIntel(intel);
QList<System*>::iterator i;
for (i = planetList.begin(); i != planetList.end(); ++i)
{
System *planet = (System*)(*i);
planet->checkKeywords(intelMessage);
}
}
void ProviTel::showEvent(QShowEvent * event){
if(!firstShown){
firstShown = true;
}
}
void ProviTel::mapUndock(bool topLevel){
if(topLevel){
this->ui->proviMap->setMinimumSize(500, 500);
this->ui->dockWidget->setMinimumSize(500, 500);
}
else{
this->ui->dockWidget->setMinimumHeight(847);
//this->ui->proviMap->setMinimumSize(1100, 825);
//this->ui->dockWidget->setMinimumSize(1100, 847);
}
}