From 011d2806da52d5640fe22d7005841e5e9d2ba345 Mon Sep 17 00:00:00 2001 From: Jesse Litton Date: Fri, 19 May 2017 18:56:31 -0500 Subject: [PATCH] v0.8.7 - Modified pocket expansion to only occur for status messages, since people are too often sending free-form messages to intel with the word "pocket" in them. This will stop the entire pocket from going red and us all getting an earful of red alert. - Changed the parser to not ignore two letter words as potentially being part of a pilots name. At least one red created an alt with a two char first and two char last name to fly under the radar. - Preliminary work to support HTTP links. --- docs/RELEASES | 14 ++++++++++ src/imp.pro | 8 ++++-- src/mainwindow.cpp | 27 ++++++++++++++++++ src/mainwindow.h | 4 ++- src/meta.h | 4 +-- src/parser.cpp | 70 ++++++++++------------------------------------ src/parser.h | 10 +++---- src/utility.cpp | 60 +++++++++++++++++++++++++++++++++++++++ src/utility.h | 28 +++++++++++++++++++ 9 files changed, 157 insertions(+), 68 deletions(-) create mode 100644 src/utility.cpp create mode 100644 src/utility.h diff --git a/docs/RELEASES b/docs/RELEASES index e83cb32..faaba9b 100644 --- a/docs/RELEASES +++ b/docs/RELEASES @@ -1,3 +1,16 @@ +0.8.7 - Fixed avatars not showing for some users on Windows due to missing + DLLs. + + Modified pocket expansion to only occur for status messages, since + people are too often sending free-form messages to intel with the + word "pocket" in them. This will stop the entire pocket from going + red and us all getting an earful of red alert. + + Changed the parser to not ignore two letter words as potentially + being part of a pilots name. At least one red created an alt with + a two char first and two char last name to fly under the + radar. + 0.8.6 - Fixed message view colors when resetting style to "-None-". Fixed initialization of jump bridges when bridgemap has changed @@ -239,6 +252,7 @@ Coming soon: - fix display of messages with backslashes. +- add support for hyperlinks in message list. - additional sound/volume options for alerts, dependant on jump distance. - better memory cache/cleanup. - investigate crash on region change. diff --git a/src/imp.pro b/src/imp.pro index ac4b2bb..bfb8e6a 100644 --- a/src/imp.pro +++ b/src/imp.pro @@ -12,7 +12,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = imp TEMPLATE = app -VERSION = 0.8.6 +VERSION = 0.8.7 QMAKE_TARGET_COMPANY = EternalDusk QMAKE_TARGET_DESCRIPTION = Eve Online Intelligence Management Program QMAKE_TARGET_COPYRIGHT = (c) Copyright 2016-2017 Jesse Litton @@ -44,7 +44,8 @@ SOURCES += \ findmessagesdialog.cpp \ abstract_os.cpp \ themecustomizationdialog.cpp \ - msgstyle.cpp + msgstyle.cpp \ + utility.cpp HEADERS += \ mainwindow.h \ @@ -70,7 +71,8 @@ HEADERS += \ findmessagesdialog.h \ abstract_os.h \ themecustomizationdialog.h \ - msgstyle.h + msgstyle.h \ + utility.h FORMS += \ mainwindow.ui \ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 62a4672..0399065 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -143,6 +143,17 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->mapView, &SvgMapView::sendOpacity, this, &MainWindow::gotOpacity); + + // Load pocket definitions + QStringList pocketsList = fromFile("pockets"); + foreach(QString pocket, pocketsList) + { + QStringList pocketList = pocket.split(","); + QString pocketName = pocketList[0]; + pocketList.removeFirst(); + pockets.insert(pocketName.trimmed(),pocketList); + } + ui->mapView->show(); } @@ -1065,6 +1076,10 @@ void MainWindow::fileChanged(const QString &absoluteFilePath) case MessageFlag::MOTD: break; + case MessageFlag::POCKET: + // Handled by STATUS. + break; + case MessageFlag::QUERY: case MessageFlag::STATUS: { @@ -1073,6 +1088,14 @@ void MainWindow::fileChanged(const QString &absoluteFilePath) break; } + // Expand pockets, if necessary + if (message.flags.contains(MessageFlag::POCKET) && + message.systems.count() >= 1 && + pockets.contains(message.systems[0])) + { + message.systems.append(pockets[message.systems[0]]); + } + bool play = false; foreach (QString system, message.systems) { @@ -1184,6 +1207,10 @@ void MainWindow::fileChanged(const QString &absoluteFilePath) } break; + case MessageFlag::LINK: + toBeAddedToList = true; + break; + default: qDebug() << "Unhandled flag " << flag << " found for message: " << message.text; break; diff --git a/src/mainwindow.h b/src/mainwindow.h index 879ac3f..c0d9d65 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -42,6 +42,7 @@ #include "parser.h" #include "theme.h" #include "themedialog.h" +#include "utility.h" namespace Ui { class MainWindow; @@ -113,7 +114,6 @@ private slots: void on_action_Frameless_Window_triggered(); void on_action_Menu_Toggle_triggered(); void on_action_Messages_triggered(); - //void on_dockWidget_visibilityChanged(bool visible); private: void initParsing(); @@ -203,6 +203,8 @@ private slots: LogInfo impLogInfo = { "*IMP*", QFileInfo(), "Khasm Kaotiqa", "None", 0 }; + QMap pockets; + // Used to restore system rotation until I take the time to figure out // how to pull it out of the transform matrix and level systems at // restart. diff --git a/src/meta.h b/src/meta.h index f3b1f31..8def76b 100644 --- a/src/meta.h +++ b/src/meta.h @@ -27,8 +27,8 @@ static const struct Version { Version(){} - QString release = "0.8.6"; //VERSION; - QString name = "Nah Loopy Just Lupine."; + QString release = "0.8.7"; //VERSION; + QString name = "Lupine Fresh Scent"; QString styleHeader1 = ""; QString styleFooter1 = ""; diff --git a/src/parser.cpp b/src/parser.cpp index 4ea5842..ad38fa5 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -20,6 +20,7 @@ #include "parser.h" #include "abstract_os.h" +#include "utility.h" #include #include @@ -33,7 +34,7 @@ using namespace std; Parser::Parser(QObject *parent) : QObject(parent) { - ignoreChars = "[\\\\_=!@#$%^&\\*,\\./\\[\\]\\(\\)\\{\\}\\?]"; // "\\_=!@#$%^&*,./[](){}?" + ignoreChars = "[\\\\_=!@#$%^&\\*,\\.\\[\\]\\(\\)\\{\\}\\?]"; // "\\_=!@#$%^&*,./[](){}?" // Load words, channels, and ships from files ignoreWords = QSet::fromList(fromFile("common")); @@ -43,14 +44,6 @@ Parser::Parser(QObject *parent) : QObject(parent) statusWords = QSet::fromList(fromFile("status")); ships = QSet::fromList(fromFile("ships")); - QStringList pocketsList = fromFile("pockets"); - foreach(QString pocket, pocketsList) - { - QStringList pocketList = pocket.split(","); - QString pocketName = pocketList[0]; - pocketList.removeFirst(); - pockets.insert(pocketName.trimmed(),pocketList); - } } void Parser::setMap(Map &map) @@ -58,38 +51,6 @@ void Parser::setMap(Map &map) regionMap = ↦ } -QStringList Parser::fromFile(const QString& fileName) -{ - QStringList stringList; - - QFile file(appFilesPath() + "/dictionaries/" + fileName); - - if(!file.open(QIODevice::ReadOnly)) - { - QMessageBox::critical(NULL, "Error Opening File", "Could not open file " + - appFilesPath() + "/dictionaries/" + fileName + - "."); - QApplication::exit(1); - } - else - { - QTextStream in(&file); - QString all = in.readAll(); - stringList = all.split('\n'); - stringList.removeAll(""); - - for(int i=stringList.length()-1; i>=0; i--) - { - if(stringList[i].trimmed()[0]=='#') - { - // Discard comments - stringList.removeAt(i); - } - } - } - - return stringList; -} QSet Parser::getLocalChannels() { @@ -229,10 +190,6 @@ MessageInfo Parser::parseLine(const QString& line) messageInfo.flags.append(MessageFlag::SYSTEM_CHANGE); return messageInfo; } - else - { - //qDebug() << " is not a system change message."; - } // Test to see if this is a MOTD message: @@ -339,10 +296,19 @@ void Parser::identifyObjects(MessageInfo& messageInfo) messageInfo.markedUpText += words[i]; messageInfo.markedUpText += ""; } - else if(lowerWord.startsWith("http://")) + else if(lowerWord == "pocket") { - //hhh + messageInfo.flags.append(MessageFlag::POCKET); } +/* Coming soon... + * else if(lowerWord.contains(QRegExp("^.{3,5}://.+"))) + { + messageInfo.markedUpText += ""; + messageInfo.markedUpText += words[i]; + messageInfo.markedUpText += ""; + + messageInfo.flags.append(MessageFlag::LINK); + } */ else { QString systemName = regionMap->getSystemByAbbreviation(words[i].toUpper()); @@ -376,7 +342,7 @@ void Parser::identifyObjects(MessageInfo& messageInfo) messageInfo.markedUpText += ""; } } - else if(lowerWord.length() >= 3) + else if(lowerWord.length() >= 2) { messageInfo.possiblePilots.append(words[i]); messageInfo.markedUpText += ""; @@ -394,12 +360,4 @@ void Parser::identifyObjects(MessageInfo& messageInfo) messageInfo.systems = theseSystems; messageInfo.ships = theseShips; messageInfo.gates = theseGates; - - // If this message pertains to a pocket, expand the systems. - if(messageInfo.text.toLower().contains("pocket") && - messageInfo.systems.length() == 1) - { - messageInfo.systems.append(pockets[messageInfo.systems[0]]); - } - } diff --git a/src/parser.h b/src/parser.h index ffb9977..457c665 100755 --- a/src/parser.h +++ b/src/parser.h @@ -34,8 +34,10 @@ #include "map.h" enum MessageFlag { UNKNOWN = 0, CLEAR, ESS, - LEFT, LOCATION, MOTD, POCKET, QUERY, - STATUS, SYSTEM_CHANGE, WARNING }; + LEFT, LINK, LOCATION, + MOTD, POCKET, QUERY, + STATUS, SYSTEM_CHANGE, WARNING + }; struct LogInfo { @@ -65,7 +67,6 @@ struct MessageInfo QStringList possiblePilots; QList flags; - }; class Parser : public QObject @@ -100,9 +101,6 @@ public slots: QMap fileMap; Map* regionMap; - QMap pockets; - - QStringList fromFile(const QString& fileName); void loadSet(QSet& set, QString& string); void identifyObjects(MessageInfo& messageInfo); QString systemAbbreviation(const QString& word); diff --git a/src/utility.cpp b/src/utility.cpp new file mode 100644 index 0000000..9bf3947 --- /dev/null +++ b/src/utility.cpp @@ -0,0 +1,60 @@ +/* + * Imp: Copyright 2016, 2017 Jesse Litton (imp@eternaldusk.com) + * + * This file is part of Imp. + * + * Imp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Imp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Imp. If not, see . + * + */ + +#include +#include +#include +#include + +#include "utility.h" +#include "abstract_os.h" + +QStringList fromFile(const QString& fileName) +{ + QStringList stringList; + + QFile file(appFilesPath() + "/dictionaries/" + fileName); + + if(!file.open(QIODevice::ReadOnly)) + { + QMessageBox::critical(NULL, "Error Opening File", "Could not open file " + + appFilesPath() + "/dictionaries/" + fileName + + "."); + QApplication::exit(1); + } + else + { + QTextStream in(&file); + QString all = in.readAll(); + stringList = all.split('\n'); + stringList.removeAll(""); + + for(int i=stringList.length()-1; i>=0; i--) + { + if(stringList[i].trimmed()[0]=='#') + { + // Discard comments + stringList.removeAt(i); + } + } + } + + return stringList; +} diff --git a/src/utility.h b/src/utility.h new file mode 100644 index 0000000..8e1a149 --- /dev/null +++ b/src/utility.h @@ -0,0 +1,28 @@ +/* + * Imp: Copyright 2016, 2017 Jesse Litton (imp@eternaldusk.com) + * + * This file is part of Imp. + * + * Imp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Imp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Imp. If not, see . + * + */ + +#ifndef UTILITY_H +#define UTILITY_H + +#include + +QStringList fromFile(const QString& fileName); + +#endif // UTILITY_H