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

Commit

Permalink
v0.9.0 - Hyperlinks, More Systems, Update notifications and more.
Browse files Browse the repository at this point in the history
  • Loading branch information
3vi1 committed Jun 8, 2017
1 parent 51f430c commit a1f6b2f
Show file tree
Hide file tree
Showing 12 changed files with 264 additions and 83 deletions.
25 changes: 21 additions & 4 deletions docs/RELEASES
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
0.8.10 - Added on Poller tab to skip loading of old intel channels at
restart.
0.9.0 - Automatic update checking! Versions beyond 0.9.0 should alert you
when a new release has been uploaded/committed.

Support for all systems! There is a 'maps' file in the
dictionaries directory that controls which maps are on the Maps
menu. You can customize it to add new ones, or pair it down
to only the ones you want to see.

Hyperlinks in the message view now work! You can click DScans
and other links from IMP now. They will open in the default
browser for your system. In the future I will let you
override that and/or open them in a tab within IMP itself.

Added option on Poller tab to skip loading of old intel channel
messages at restart. Some people without SSD's have complained
about the speed of the loading in the past, so this is a
workaround until I can investigate more.

Improved parsing so that IMP won't alert for system-a when people
say things like "red went from system-a to system-b", or
"red left system-a", or "red system-b was system-a".

0.8.9 - Fixes the bug where the first two menu dropdowns were no longer
working for Windows users.
Expand Down Expand Up @@ -262,8 +281,6 @@

Coming soon:

- Ignore system when worded like "from kbp", "was n-r", "left o-y"
- fix display of messages with backslashes.
- add support for hyperlinks in message list.
- additional sound/volume options for alerts, dependant on jump distance.
- better pilot cache/cleanup.
88 changes: 58 additions & 30 deletions src/chatitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
#include <QAbstractTextDocumentLayout>
#include <QApplication>
#include <QPainter>
#include <QTextDocument>


// OMG this class needs to be re-thunk. It works, but efficiency was not in my planning.

ChatItemDelegate::ChatItemDelegate(const MsgStyle* style, QObject *parent) : QStyledItemDelegate(parent),
m_msgStyle(style)
Expand All @@ -38,27 +40,10 @@ void ChatItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
QStyleOptionViewItem options = option;
initStyleOption(&options, index);

options.text = options.text.replace("<clear>", "<span style=\"color: " + m_msgStyle->getClearColor().name() + "\">");
options.text = options.text.replace("<info>", "<span style=\"color: " + m_msgStyle->getInfoColor().name() + "\">");
options.text = options.text.replace("<gate>", "<span style=\"color: " + m_msgStyle->getGateColor().name() + "\">");
options.text = options.text.replace("<location>", "<span style=\"color: " + m_msgStyle->getLocationColor().name() + "\">");
options.text = options.text.replace("<ship>", "<span style=\"color: " + m_msgStyle->getShipColor().name() + "\">");
options.text = options.text.replace("<stamp>", "<span style=\"color: " + m_msgStyle->getStampColor().name() + "\">");
options.text = options.text.replace("<status>", "<span style=\"color: " + m_msgStyle->getStatusColor().name() + "\">");
options.text = options.text.replace("<system>", "<span style=\"color: " + m_msgStyle->getSystemColor().name() + "\">");
options.text = options.text.replace("<warn>", "<span style=\"color: " + m_msgStyle->getWarnColor().name() + "\">");

painter->save();

QTextDocument doc;
doc.setHtml(options.text);

QTextOption textOption(doc.defaultTextOption());
textOption.setWrapMode(QTextOption::WordWrap);
doc.setDefaultTextOption(textOption);

int iconWidth = (options.icon.isNull() ? 0 : m_avatarSize.width());
doc.setTextWidth(options.rect.width() - iconWidth - padding.width());
QTextDocument* doc = document(options);

options.text = "";
options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);
Expand All @@ -77,8 +62,10 @@ void ChatItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
*/

ctx.clip = clip;
doc.documentLayout()->draw(painter, ctx);
doc->documentLayout()->draw(painter, ctx);
painter->restore();

doc->deleteLater();
}
}

Expand All @@ -87,25 +74,66 @@ void ChatItemDelegate::setModel(ChatModel* model)
m_model = model;
}

QTextDocument* ChatItemDelegate::document(const QStyleOptionViewItem &option) const
{
QStyleOptionViewItem options = option;
options.text = options.text.replace("<clear>", "<span style=\"color: " + m_msgStyle->getClearColor().name() + "\">");
options.text = options.text.replace("<info>", "<span style=\"color: " + m_msgStyle->getInfoColor().name() + "\">");
options.text = options.text.replace("<gate>", "<span style=\"color: " + m_msgStyle->getGateColor().name() + "\">");
options.text = options.text.replace("<location>", "<span style=\"color: " + m_msgStyle->getLocationColor().name() + "\">");
options.text = options.text.replace("<ship>", "<span style=\"color: " + m_msgStyle->getShipColor().name() + "\">");
options.text = options.text.replace("<stamp>", "<span style=\"color: " + m_msgStyle->getStampColor().name() + "\">");
options.text = options.text.replace("<status>", "<span style=\"color: " + m_msgStyle->getStatusColor().name() + "\">");
options.text = options.text.replace("<system>", "<span style=\"color: " + m_msgStyle->getSystemColor().name() + "\">");
options.text = options.text.replace("<warn>", "<span style=\"color: " + m_msgStyle->getWarnColor().name() + "\">");

QTextDocument* doc = new QTextDocument();
doc->setHtml(options.text);

QTextOption textOption(doc->defaultTextOption());
textOption.setWrapMode(QTextOption::WordWrap);
doc->setDefaultTextOption(textOption);

int iconWidth = (options.icon.isNull() ? 0 : m_avatarSize.width());
doc->setTextWidth(options.rect.width() - iconWidth - padding.width());

return doc;
}

QSize ChatItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex &index) const
{
QStyleOptionViewItem options = option;
initStyleOption(&options, index);

QTextDocument doc;
doc.setHtml(options.text);

QTextOption textOption(doc.defaultTextOption());
textOption.setWrapMode(QTextOption::WordWrap);
doc.setDefaultTextOption(textOption);
QTextDocument* doc = document(options);

int iconWidth = (options.icon.isNull() ? 0 : m_avatarSize.width());
doc.setTextWidth(options.rect.width() - iconWidth - padding.width());

QSize textSize = QSize(doc.idealWidth() + iconWidth,
doc.size().height() > m_avatarSize.height() ?
doc.size().height() + padding.height() :
QSize textSize = QSize(doc->idealWidth() + iconWidth,
doc->size().height() > m_avatarSize.height() ?
doc->size().height() + padding.height() :
m_avatarSize.height() + padding.height());

return textSize;
}

QString ChatItemDelegate::anchorAt(const QStyleOptionViewItem& option,
const QModelIndex &index,
const QPoint &point)
{
QStyleOptionViewItem options = option;
initStyleOption(&options, index);

QTextDocument* doc = document(options);
QAbstractTextDocumentLayout* textLayout = doc->documentLayout();
doc->deleteLater();

Q_ASSERT(textLayout != 0);

// Need to shift the click position if there was an avatar/icon.
int iconWidth = (options.icon.isNull() ? 0 : m_avatarSize.width());
QPoint p = point;
p.setX(p.x() - iconWidth - padding.width());

return textLayout->anchorAt(p);
}
5 changes: 5 additions & 0 deletions src/chatitemdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <QItemDelegate>
#include <QObject>
#include <QTextDocument>
#include <QStyledItemDelegate>

#include "chatmodel.h"
Expand All @@ -39,6 +40,8 @@ class ChatItemDelegate : public QStyledItemDelegate
void setModel(ChatModel* model);
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;

QString anchorAt(const QStyleOptionViewItem &option, const QModelIndex &index, const QPoint &point);

signals:
public slots:

Expand All @@ -48,6 +51,8 @@ public slots:
QSize padding = QSize(2,1);

const MsgStyle* m_msgStyle;

QTextDocument* document(const QStyleOptionViewItem &options) const;
};

#endif // CHATITEMDELEGATE_H
2 changes: 1 addition & 1 deletion src/chatmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ bool ChatModel::removeRows(int row, int count, const QModelIndex &parent)
return true;
}

Q_ASSERT(row < row+count-1);
Q_ASSERT(row <= row+count-1);
beginRemoveRows(parent, row, (row + count) - 1);
if(row == 0 && count == items.count())
{
Expand Down
15 changes: 11 additions & 4 deletions src/imp.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = imp
TEMPLATE = app

VERSION = 0.8.10
VERSION = 0.9.0
QMAKE_TARGET_COMPANY = EternalDusk
QMAKE_TARGET_DESCRIPTION = Eve Online Intelligence Management Program
QMAKE_TARGET_COPYRIGHT = (c) Copyright 2016-2017 Jesse Litton
QMAKE_TARGET_PRODUCT = IMP

DEFINES += VERSION=\\\"$VERSION\\\"

include(../ThirdParty/QSimpleUpdater/QSimpleUpdater.pri)

SOURCES += \
main.cpp\
mainwindow.cpp \
Expand All @@ -45,7 +47,8 @@ SOURCES += \
abstract_os.cpp \
themecustomizationdialog.cpp \
msgstyle.cpp \
utility.cpp
utility.cpp \
chatview.cpp

HEADERS += \
mainwindow.h \
Expand All @@ -72,7 +75,8 @@ HEADERS += \
abstract_os.h \
themecustomizationdialog.h \
msgstyle.h \
utility.h
utility.h \
chatview.h

FORMS += \
mainwindow.ui \
Expand All @@ -86,8 +90,10 @@ FORMS += \
DISTFILES += \
../data/dictionaries/clear \
../data/dictionaries/common \
../data/dictionaries/left \
../data/dictionaries/local \
../data/dictionaries/location \
../data/dictionaries/maps \
../data/dictionaries/pockets \
../data/dictionaries/ships \
../data/dictionaries/status \
Expand All @@ -96,7 +102,8 @@ DISTFILES += \
../docs/RELEASES \
../docs/RULES \
../docs/THEMES \
../docs/CREDITS
../docs/CREDITS \
../docs/DICTIONARIES

RESOURCES += \
resources.qrc
Expand Down
Loading

0 comments on commit a1f6b2f

Please sign in to comment.