Skip to content
This repository has been archived by the owner on Aug 26, 2020. It is now read-only.

Commit

Permalink
- Stop "x4" from setting off alarms in X-4. x[2-9] are no longer cons…
Browse files Browse the repository at this point in the history
…idered

  potential system abbreviations.

- Message view can now be sized smaller.

- Renamed Regions menu to Map and added a "Reset Rotation" option, just in
  case someone manages to desync system/map rotation before I make that
  system smarter.

- Fixed a couple of potential crashes when clicking map/subsetting messages.

- Fixed it so that IMP will not add the intel channels multiple times if
  you have joined them with multiple pilots.

- Shout outs to Fenix Inferni and Subelectro Shanzaar for the donations!
  • Loading branch information
3vi1 committed Mar 18, 2017
1 parent 24efa36 commit 6d02136
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 38 deletions.
16 changes: 16 additions & 0 deletions docs/RELEASES
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
0.7.6 - Stop "x4" from setting off alarms in X-4. x[2-9] are no longer considered
potential system abbreviations.

Message view can now be sized smaller.

Renamed Regions menu to Map and added a "Reset Rotation" option, just in
case someone manages to desync system/map rotation before I make that
system smarter.

Fixed a couple of potential crashes when clicking map/subsetting messages.

Fixed it so that IMP will not add the intel channels multiple times if
you have joined them with multiple pilots.

Shout outs to Fenix Inferni and Subelectro Shanzaar for the donations!

0.7.5 - Added option to disable portraits.

Added option to use Ctrl-Cx2 for KOS checks.
Expand Down
25 changes: 16 additions & 9 deletions src/chatmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void ChatModel::setPilotCache(QMap<QString, PilotEntry>* pilotCache)

void ChatModel::addEntry(const MessageInfo& message)
{
beginInsertRows(QModelIndex(), items.size(), items.size());
beginInsertRows(QModelIndex(), items.size(), items.size()+1);

items.append(message);

Expand Down Expand Up @@ -117,6 +117,7 @@ bool ChatModel::removeRows(int row, int count, const QModelIndex &parent)
return true;
}

Q_ASSERT(row < row+count-1);
beginRemoveRows(parent, row, (row + count) - 1);
if(row == 0 && count == items.count())
{
Expand Down Expand Up @@ -148,13 +149,16 @@ void ChatModel::subsetForSystem(const QString& system)
subsetOnSystem = false;
}

beginRemoveRows(QModelIndex(), 0, visibleItems.count() - 1);
visibleItems.clear();
endRemoveRows();
if(visibleItems.count() >0)
{
beginRemoveRows(QModelIndex(), 0, visibleItems.count() - 1);
visibleItems.clear();
endRemoveRows();
}

for(int i = 0; i < items.count(); i++)
{
beginInsertRows(QModelIndex(), visibleItems.count(), 1);
beginInsertRows(QModelIndex(), visibleItems.count(), visibleItems.count()+1);
if(system == "" || items[i].systems.contains(system))
{
visibleItems.append(&items[i]);
Expand All @@ -168,13 +172,16 @@ void ChatModel::subsetForString(const QString& string)
subset = string;
subsetOnSystem = false;

beginRemoveRows(QModelIndex(), 0, visibleItems.count() - 1);
visibleItems.clear();
endRemoveRows();
if(visibleItems.count() >0)
{
beginRemoveRows(QModelIndex(), 0, visibleItems.count() - 1);
visibleItems.clear();
endRemoveRows();
}

for(int i = 0; i < items.count(); i++)
{
beginInsertRows(QModelIndex(), visibleItems.count(), 1);
beginInsertRows(QModelIndex(), visibleItems.count(), visibleItems.count()+1);
if(string == "" || items[i].text.contains(string))
{
visibleItems.append(&items[i]);
Expand Down
24 changes: 22 additions & 2 deletions src/logcatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
#include <QFileInfo>
#include "logcatcher.h"

LogCatcher::LogCatcher(QObject *parent) : QObject(parent)
LogCatcher::LogCatcher(Options* options, QObject *parent) : QObject(parent)
{
m_options = options;
}

void LogCatcher::setLogDir(QString logDir)
Expand Down Expand Up @@ -105,7 +106,7 @@ void LogCatcher::findCurrentLogs(const QString& dirName)
if(infoList.count() > 0)
infoList.clear();

QRegExp logNameRegEx(".*_[0-9]+_[0-9]+\\.txt$");
QRegExp logNameRegEx("(.*)_[0-9]+_[0-9]+\\.txt$");

foreach (QFileInfo fileInfo, QDir(dirName).entryInfoList()) {
if (fileInfo.isFile()) {
Expand All @@ -117,6 +118,25 @@ void LogCatcher::findCurrentLogs(const QString& dirName)
}

if (fileInfo.lastModified() > (QDateTime::currentDateTime().addDays(-1))) {

// We only put intel channels in the list once, no matter how many pilots
// are in them.

QString channelName = logNameRegEx.cap(1);
if(m_options->getIntelChannels().contains(channelName))
{
QMutableListIterator<QFileInfo> i(infoList);
while (i.hasNext()) {
QString iFileName = i.next().fileName();
QString iChanName = iFileName.left(iFileName.length() - 20);
if (iChanName == channelName) {
if (i.value().lastModified() < fileInfo.lastModified()) {
i.remove();
}
}
}
}

infoList.append(fileInfo);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/logcatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@
#include <QString>
#include <QTimer>

#include "options.h"

using namespace std;


class LogCatcher : public QObject
{
Q_OBJECT
public:
explicit LogCatcher(QObject *parent = 0);
explicit LogCatcher(Options* options, QObject *parent = 0);

void setLogDir(QString logDir);
void setPollerRefresh(int interval);
Expand All @@ -67,6 +69,7 @@ public slots:
void fallbackPoller();

private:
Options* m_options;
QFileSystemWatcher dirWatcher;
QFileInfoList infoList;
QString logDir;
Expand Down
26 changes: 17 additions & 9 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ void MainWindow::changeTheme(const QString& themeName, ThemeType themeType)
{
m_theme = new Theme(this);

connect(m_theme, SIGNAL(backColorChanged(const QColor&)),
/* connect(m_theme, SIGNAL(backColorChanged(const QColor&)),
ui->mapView, SLOT(gotBackColor(const QColor&)));
connect(m_theme, SIGNAL(lineColorChanged(const QColor&)),
ui->mapView, SLOT(gotLineColor(const QColor&)));

*/
connect(m_theme, &Theme::sendUpdate,
ui->mapView, &SvgMapView::receiveThemeUpdate);
}
Expand Down Expand Up @@ -566,7 +566,7 @@ void MainWindow::initParsing()
{
lc->deleteLater();
}
lc = new LogCatcher();
lc = new LogCatcher(&options);

lc->setLogDir(options.getLogPath());
#ifdef USE_FALLBACK_POLLER
Expand All @@ -591,7 +591,6 @@ void MainWindow::failedGettingRegionFile(QNetworkReply::NetworkError err)
{
qDebug() << "MainWindow::failedGettingRegionFile - Failed to retrieve region file.";
qDebug() << err;
qDebug() << "MainWindow::failedGettingRegionFile - Attempting to use local file if it exists." << endl;

changeImpStatus("Failed getting map, attempting to use last.");

Expand Down Expand Up @@ -840,11 +839,15 @@ void MainWindow::fileChanged(const QString &absoluteFilePath)

if(mapLoading && !parser->getLocalChannels().contains(shortName(absoluteFilePath)))
{
// We're loading, and this isn't a local channel. Load last 50 or so entries.

messages = parser->fileChanged(absoluteFilePath, options.getMaxEntries());
}
else
{
messages = parser->fileChanged(absoluteFilePath);
// Either we're not loading, or this is a local channel, so read all changes.

messages = parser->fileChanged(absoluteFilePath, 0, mapLoading);
}

QString status = "Parsing " + QString::number(messages.count());
Expand Down Expand Up @@ -1070,7 +1073,7 @@ void MainWindow::fileChanged(const QString &absoluteFilePath)

// If we just reloaded, there may be a lot of these, so let's process other
// events to keep the gui responsive until we rewrite multi-threaded.
QCoreApplication::processEvents(QEventLoop::AllEvents, 20);
QCoreApplication::processEvents(QEventLoop::AllEvents, 10);
}
}

Expand Down Expand Up @@ -1230,7 +1233,7 @@ void MainWindow::positionTo(const QString& systemName)

void MainWindow::updatePosition()
{
// TEMP
// TEMP - Roll this into the view later

if(mapLoading)
{
Expand Down Expand Up @@ -1258,7 +1261,7 @@ void MainWindow::updatePosition()
positionTimer->deleteLater();
positionTimer = NULL;

qDebug() << "positionTimer expired for"<< destinationPos;
//qDebug() << "positionTimer expired for"<< destinationPos;
}
}

Expand Down Expand Up @@ -1344,7 +1347,7 @@ void MainWindow::findLocation(const QString& location)
void MainWindow::logDirChanged(const QString& dir)
{
lc->deleteLater();
lc = new LogCatcher();
lc = new LogCatcher(&options);
connect(lc, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString)));
lc->setLogDir(dir);
}
Expand Down Expand Up @@ -1481,3 +1484,8 @@ void MainWindow::on_actionCustomize_triggered()
dialog.sendChanges(m_theme);
}
}

void MainWindow::on_actionReset_Rotation_triggered()
{
ui->mapView->resetRotation();
}
2 changes: 2 additions & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ private slots:
void on_actionFindMessages_triggered();
void on_actionCustomize_triggered();

void on_actionReset_Rotation_triggered();

private:
void initParsing();
void initThemes();
Expand Down
13 changes: 10 additions & 3 deletions src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<item row="1" column="0">
<widget class="QListView" name="listView">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -137,7 +137,7 @@
<x>0</x>
<y>0</y>
<width>1024</width>
<height>19</height>
<height>25</height>
</rect>
</property>
<property name="font">
Expand Down Expand Up @@ -173,13 +173,15 @@
</widget>
<widget class="QMenu" name="menuRegion">
<property name="title">
<string>Region</string>
<string>Map</string>
</property>
<addaction name="actionCatch"/>
<addaction name="actionProvidence"/>
<addaction name="actionQuerious"/>
<addaction name="separator"/>
<addaction name="actionShow_Bridges"/>
<addaction name="separator"/>
<addaction name="actionReset_Rotation"/>
</widget>
<widget class="QMenu" name="menuFind">
<property name="title">
Expand Down Expand Up @@ -387,6 +389,11 @@
<string>Customize</string>
</property>
</action>
<action name="actionReset_Rotation">
<property name="text">
<string>&amp;Reset Rotation</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
Expand Down
9 changes: 7 additions & 2 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,15 @@ QString Map::getSystemByAbbreviation(const QString& word)
}
else if(wordLength == 2)
{
// maybe just two letters (nr instead of n-r)
// Maybe just two letters (nr instead of n-r), but not
// x1 -
QString shortName = system.mid(dashPos-1) +
system.mid(dashPos+1);
if (shortName == upperWord)
if (shortName == upperWord &&
!(shortName[0] == 'X' &&
(shortName[1].isDigit() && shortName[1].digitValue() > 1)
)
)
{
return system;
}
Expand Down
2 changes: 1 addition & 1 deletion src/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
static const struct Version
{
QString release = "0.7.6";
QString name = "The Day after The Lycanthropic Hot Topic";
QString name = "Infernal Phoenix in a Lycanthropic Hot Topic";

QString styleHeader1 = "<span style=\" color:#0000ff;\">";
QString styleFooter1 = "</span>";
Expand Down
2 changes: 1 addition & 1 deletion src/options.ui
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<widget class="QWidget" name="alerts_tab">
<attribute name="title">
Expand Down
2 changes: 1 addition & 1 deletion src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ QSet<QString> Parser::getLocalChannels()
return localChannels;
}

QList<MessageInfo> Parser::fileChanged(const QString& path, int maxEntries)
QList<MessageInfo> Parser::fileChanged(const QString& path, int maxEntries, bool /*initialLoad*/)
{
QFile file(path);
QTextStream input(&file);
Expand Down
2 changes: 1 addition & 1 deletion src/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Parser : public QObject
public:
explicit Parser(QObject *parent = 0);
void setMap(Map& map);
QList<MessageInfo> fileChanged(const QString& path, int maxEntries = 0);
QList<MessageInfo> fileChanged(const QString& path, int maxEntries = 0, bool initialLoad = false);
QSet<QString> getLocalChannels();

signals:
Expand Down
Loading

0 comments on commit 6d02136

Please sign in to comment.