From 6d02136da7fc4190799f9ee0b9a4497930b3d5eb Mon Sep 17 00:00:00 2001 From: Jesse Litton Date: Sat, 18 Mar 2017 16:04:54 -0500 Subject: [PATCH] - 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! --- docs/RELEASES | 16 ++++++++++++++++ src/chatmodel.cpp | 25 ++++++++++++++++--------- src/logcatcher.cpp | 24 ++++++++++++++++++++++-- src/logcatcher.h | 5 ++++- src/mainwindow.cpp | 26 +++++++++++++++++--------- src/mainwindow.h | 2 ++ src/mainwindow.ui | 13 ++++++++++--- src/map.cpp | 9 +++++++-- src/meta.h | 2 +- src/options.ui | 2 +- src/parser.cpp | 2 +- src/parser.h | 2 +- src/svgmapview.cpp | 32 ++++++++++++++++++++++++++------ src/svgmapview.h | 5 +++-- 14 files changed, 127 insertions(+), 38 deletions(-) diff --git a/docs/RELEASES b/docs/RELEASES index b75b879..185333b 100644 --- a/docs/RELEASES +++ b/docs/RELEASES @@ -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. diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 240cbd7..2313f3a 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -33,7 +33,7 @@ void ChatModel::setPilotCache(QMap* pilotCache) void ChatModel::addEntry(const MessageInfo& message) { - beginInsertRows(QModelIndex(), items.size(), items.size()); + beginInsertRows(QModelIndex(), items.size(), items.size()+1); items.append(message); @@ -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()) { @@ -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]); @@ -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]); diff --git a/src/logcatcher.cpp b/src/logcatcher.cpp index d55a6dc..51f7d2d 100644 --- a/src/logcatcher.cpp +++ b/src/logcatcher.cpp @@ -24,8 +24,9 @@ #include #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) @@ -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()) { @@ -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 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); } } diff --git a/src/logcatcher.h b/src/logcatcher.h index b890713..5fb37fa 100644 --- a/src/logcatcher.h +++ b/src/logcatcher.h @@ -45,6 +45,8 @@ #include #include +#include "options.h" + using namespace std; @@ -52,7 +54,7 @@ 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); @@ -67,6 +69,7 @@ public slots: void fallbackPoller(); private: + Options* m_options; QFileSystemWatcher dirWatcher; QFileInfoList infoList; QString logDir; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a99dfc4..263bb19 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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); } @@ -566,7 +566,7 @@ void MainWindow::initParsing() { lc->deleteLater(); } - lc = new LogCatcher(); + lc = new LogCatcher(&options); lc->setLogDir(options.getLogPath()); #ifdef USE_FALLBACK_POLLER @@ -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."); @@ -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()); @@ -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); } } @@ -1230,7 +1233,7 @@ void MainWindow::positionTo(const QString& systemName) void MainWindow::updatePosition() { - // TEMP + // TEMP - Roll this into the view later if(mapLoading) { @@ -1258,7 +1261,7 @@ void MainWindow::updatePosition() positionTimer->deleteLater(); positionTimer = NULL; - qDebug() << "positionTimer expired for"<< destinationPos; + //qDebug() << "positionTimer expired for"<< destinationPos; } } @@ -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); } @@ -1481,3 +1484,8 @@ void MainWindow::on_actionCustomize_triggered() dialog.sendChanges(m_theme); } } + +void MainWindow::on_actionReset_Rotation_triggered() +{ + ui->mapView->resetRotation(); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index d046614..a643d84 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -98,6 +98,8 @@ private slots: void on_actionFindMessages_triggered(); void on_actionCustomize_triggered(); + void on_actionReset_Rotation_triggered(); + private: void initParsing(); void initThemes(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 66f4b0a..e1b3fe5 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -68,7 +68,7 @@ - + 0 0 @@ -137,7 +137,7 @@ 0 0 1024 - 19 + 25 @@ -173,13 +173,15 @@ - Region + Map + + @@ -387,6 +389,11 @@ Customize + + + &Reset Rotation + + diff --git a/src/map.cpp b/src/map.cpp index 6a527ea..f080379 100755 --- a/src/map.cpp +++ b/src/map.cpp @@ -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; } diff --git a/src/meta.h b/src/meta.h index fb8677c..0960ca6 100644 --- a/src/meta.h +++ b/src/meta.h @@ -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 = ""; QString styleFooter1 = ""; diff --git a/src/options.ui b/src/options.ui index 8e8408c..0a6d076 100755 --- a/src/options.ui +++ b/src/options.ui @@ -40,7 +40,7 @@ QTabWidget::Rounded - 1 + 2 diff --git a/src/parser.cpp b/src/parser.cpp index 72e594a..0aea640 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -78,7 +78,7 @@ QSet Parser::getLocalChannels() return localChannels; } -QList Parser::fileChanged(const QString& path, int maxEntries) +QList Parser::fileChanged(const QString& path, int maxEntries, bool /*initialLoad*/) { QFile file(path); QTextStream input(&file); diff --git a/src/parser.h b/src/parser.h index bf30a05..c3053ba 100755 --- a/src/parser.h +++ b/src/parser.h @@ -71,7 +71,7 @@ class Parser : public QObject public: explicit Parser(QObject *parent = 0); void setMap(Map& map); - QList fileChanged(const QString& path, int maxEntries = 0); + QList fileChanged(const QString& path, int maxEntries = 0, bool initialLoad = false); QSet getLocalChannels(); signals: diff --git a/src/svgmapview.cpp b/src/svgmapview.cpp index 12812f4..f61c249 100755 --- a/src/svgmapview.cpp +++ b/src/svgmapview.cpp @@ -208,11 +208,6 @@ void SvgMapView::wheelEvent(QWheelEvent *event) event->accept(); } -float SvgMapView::getZoom() -{ - return zoom; -} - void SvgMapView::setZoom(float factor) { if(factor <= 0) @@ -221,7 +216,6 @@ void SvgMapView::setZoom(float factor) factor = 1; } - zoom *= factor; scale(factor, factor); } @@ -734,6 +728,32 @@ qreal SvgMapView::getSystemsRotation() return systemShapes.first()->rotation(); } +void SvgMapView::resetRotation() +{ + qreal mapScale = getTransform().m22(); + qDebug() << "SvgMapView::resetRotation() scale = " << mapScale; + resetTransform(); + + + for(int i=0; isetTransformOriginPoint(item->boundingRect().width() * .5, + item->boundingRect().height() * .5); + item->setRotation(0); + + MapShape* outlineItem = systemOutlines.values().at(i); + outlineItem->setTransformOriginPoint(outlineItem->boundingRect().width() * .5, + outlineItem->boundingRect().height() * .5); + outlineItem->setRotation(0); + } + + foreach(QGraphicsTextItem* t, m_texts.values()) + { + t->setRotation(0); + } +} + void SvgMapView::rotateSystems(qreal angle) { for(int i=0; i