add score support, with icons etc.
This commit is contained in:
parent
707f1a0b08
commit
3494925eb6
5 changed files with 46 additions and 26 deletions
|
@ -38,6 +38,10 @@ void MessagesModel::setupIcons() {
|
||||||
m_readIcon = qApp->icons()->fromTheme(QSL("mail-mark-read"));
|
m_readIcon = qApp->icons()->fromTheme(QSL("mail-mark-read"));
|
||||||
m_unreadIcon = qApp->icons()->fromTheme(QSL("mail-mark-unread"));
|
m_unreadIcon = qApp->icons()->fromTheme(QSL("mail-mark-unread"));
|
||||||
m_enclosuresIcon = qApp->icons()->fromTheme(QSL("mail-attachment"));
|
m_enclosuresIcon = qApp->icons()->fromTheme(QSL("mail-attachment"));
|
||||||
|
|
||||||
|
for (double i = MSG_SCORE_MIN; i <= MSG_SCORE_MAX; i += 10.0) {
|
||||||
|
m_scoreIcons.append(generateIconForScore(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon MessagesModel::generateIconForScore(double score) {
|
QIcon MessagesModel::generateIconForScore(double score) {
|
||||||
|
@ -46,7 +50,7 @@ QIcon MessagesModel::generateIconForScore(double score) {
|
||||||
|
|
||||||
paint.setRenderHint(QPainter::RenderHint::Antialiasing);
|
paint.setRenderHint(QPainter::RenderHint::Antialiasing);
|
||||||
|
|
||||||
int level = std::min(MSG_SCORE_MAX, std::max(MSG_SCORE_MIN, int(std::floor(score / 10.0))));
|
int level = std::min(MSG_SCORE_MAX, std::max(MSG_SCORE_MIN, std::floor(score / 10.0)));
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
path.addRoundedRect(QRectF(2, 2, 60, 60), 5, 5);
|
path.addRoundedRect(QRectF(2, 2, 60, 60), 5, 5);
|
||||||
|
@ -62,11 +66,8 @@ QIcon MessagesModel::generateIconForScore(double score) {
|
||||||
|
|
||||||
int bar_height = 6 * level;
|
int bar_height = 6 * level;
|
||||||
|
|
||||||
// TODO: pokračovat tady, optimalizovat voláni vytváření těch ikon, skrýt text
|
|
||||||
// a zobrazit jen ikony, barva od červené do zelené
|
|
||||||
|
|
||||||
path.addRoundedRect(QRectF(2, 64 - bar_height - 2, 60, bar_height), 5, 5);
|
path.addRoundedRect(QRectF(2, 64 - bar_height - 2, 60, bar_height), 5, 5);
|
||||||
paint.fillPath(path, Qt::GlobalColor::green);
|
paint.fillPath(path, QColor::fromHsv(int(score), 200, 230));
|
||||||
|
|
||||||
return pix;
|
return pix;
|
||||||
}
|
}
|
||||||
|
@ -242,16 +243,25 @@ void MessagesModel::setupHeaderData() {
|
||||||
|
|
||||||
/*: Tooltip for indication of presence of enclosures.*/ tr("Has enclosures");
|
/*: Tooltip for indication of presence of enclosures.*/ tr("Has enclosures");
|
||||||
|
|
||||||
m_tooltipData <<
|
m_tooltipData
|
||||||
tr("Id of the message.") << tr("Is message read?") <<
|
<< tr("ID of the message.")
|
||||||
tr("Is message deleted?") << tr("Is message important?") <<
|
<< tr("Is message read?")
|
||||||
tr("Id of feed which this message belongs to.") <<
|
<< tr("Is message important?")
|
||||||
tr("Title of the message.") << tr("Url of the message.") <<
|
<< tr("Is message deleted?")
|
||||||
tr("Author of the message.") << tr("Creation date of the message.") <<
|
<< tr("Is message permanently deleted from recycle bin?")
|
||||||
tr("Contents of the message.") << tr("Is message permanently deleted from recycle bin?") <<
|
<< tr("ID of feed which this message belongs to.")
|
||||||
tr("List of attachments.") << tr("Account ID of the message.") << tr("Custom ID of the message") <<
|
<< tr("Title of the message.")
|
||||||
tr("Custom hash of the message.") << tr("Custom ID of feed of the message.") <<
|
<< tr("Url of the message.")
|
||||||
tr("Indication of enclosures presence within the message.");
|
<< tr("Author of the message.")
|
||||||
|
<< tr("Creation date of the message.")
|
||||||
|
<< tr("Contents of the message.")
|
||||||
|
<< tr("List of attachments.")
|
||||||
|
<< tr("Score of the message.")
|
||||||
|
<< tr("Account ID of the message.")
|
||||||
|
<< tr("Custom ID of the message")
|
||||||
|
<< tr("Custom hash of the message.")
|
||||||
|
<< tr("Custom ID of feed of the message.")
|
||||||
|
<< tr("Indication of enclosures presence within the message.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags MessagesModel::flags(const QModelIndex& index) const {
|
Qt::ItemFlags MessagesModel::flags(const QModelIndex& index) const {
|
||||||
|
@ -303,7 +313,8 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
|
||||||
}
|
}
|
||||||
else if (index_column != MSG_DB_IMPORTANT_INDEX &&
|
else if (index_column != MSG_DB_IMPORTANT_INDEX &&
|
||||||
index_column != MSG_DB_READ_INDEX &&
|
index_column != MSG_DB_READ_INDEX &&
|
||||||
index_column != MSG_DB_HAS_ENCLOSURES) {
|
index_column != MSG_DB_HAS_ENCLOSURES &&
|
||||||
|
index_column != MSG_DB_SCORE_INDEX) {
|
||||||
return QSqlQueryModel::data(idx, role);
|
return QSqlQueryModel::data(idx, role);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -415,8 +426,9 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
|
||||||
}
|
}
|
||||||
else if (index_column == MSG_DB_SCORE_INDEX) {
|
else if (index_column == MSG_DB_SCORE_INDEX) {
|
||||||
QVariant dta = QSqlQueryModel::data(idx);
|
QVariant dta = QSqlQueryModel::data(idx);
|
||||||
|
int level = std::min(MSG_SCORE_MAX, std::max(MSG_SCORE_MIN, std::floor(dta.toDouble() / 10.0)));
|
||||||
|
|
||||||
return generateIconForScore(dta.toDouble());
|
return m_scoreIcons.at(level);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -652,7 +664,10 @@ QVariant MessagesModel::headerData(int section, Qt::Orientation orientation, int
|
||||||
|
|
||||||
// Display textual headers for all columns except "read" and
|
// Display textual headers for all columns except "read" and
|
||||||
// "important" and "has enclosures" columns.
|
// "important" and "has enclosures" columns.
|
||||||
if (section != MSG_DB_READ_INDEX && section != MSG_DB_IMPORTANT_INDEX && section != MSG_DB_HAS_ENCLOSURES) {
|
if (section != MSG_DB_READ_INDEX &&
|
||||||
|
section != MSG_DB_IMPORTANT_INDEX &&
|
||||||
|
section != MSG_DB_SCORE_INDEX &&
|
||||||
|
section != MSG_DB_HAS_ENCLOSURES) {
|
||||||
return m_headerData.at(section);
|
return m_headerData.at(section);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -677,6 +692,9 @@ QVariant MessagesModel::headerData(int section, Qt::Orientation orientation, int
|
||||||
case MSG_DB_IMPORTANT_INDEX:
|
case MSG_DB_IMPORTANT_INDEX:
|
||||||
return m_favoriteIcon;
|
return m_favoriteIcon;
|
||||||
|
|
||||||
|
case MSG_DB_SCORE_INDEX:
|
||||||
|
return m_scoreIcons.at(5);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,7 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
||||||
QIcon m_readIcon;
|
QIcon m_readIcon;
|
||||||
QIcon m_unreadIcon;
|
QIcon m_unreadIcon;
|
||||||
QIcon m_enclosuresIcon;
|
QIcon m_enclosuresIcon;
|
||||||
|
QList<QIcon> m_scoreIcons;
|
||||||
int m_itemHeight;
|
int m_itemHeight;
|
||||||
bool m_displayFeedIcons;
|
bool m_displayFeedIcons;
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
#define ID_IMPORTANT -3
|
#define ID_IMPORTANT -3
|
||||||
#define ID_LABELS -4
|
#define ID_LABELS -4
|
||||||
|
|
||||||
#define MSG_SCORE_MAX 100
|
#define MSG_SCORE_MAX 100.0
|
||||||
#define MSG_SCORE_MIN 0
|
#define MSG_SCORE_MIN 0.0
|
||||||
|
|
||||||
#define ARGUMENTS_LIST_SEPARATOR "\n"
|
#define ARGUMENTS_LIST_SEPARATOR "\n"
|
||||||
#define IS_IN_ARRAY(offset, array) ((offset >= 0) && (offset < array.count()))
|
#define IS_IN_ARRAY(offset, array) ((offset >= 0) && (offset < array.count()))
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1229</width>
|
<width>1296</width>
|
||||||
<height>546</height>
|
<height>546</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -614,13 +614,14 @@ void MessagesView::adjustColumns() {
|
||||||
|
|
||||||
// Setup column resize strategies.
|
// Setup column resize strategies.
|
||||||
for (int i = 0; i < header()->count(); i++) {
|
for (int i = 0; i < header()->count(); i++) {
|
||||||
header()->setSectionResizeMode(i, QHeaderView::Interactive);
|
header()->setSectionResizeMode(i, QHeaderView::ResizeMode::Interactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
header()->setSectionResizeMode(MSG_DB_TITLE_INDEX, QHeaderView::Stretch);
|
header()->setSectionResizeMode(MSG_DB_TITLE_INDEX, QHeaderView::ResizeMode::Stretch);
|
||||||
header()->setSectionResizeMode(MSG_DB_READ_INDEX, QHeaderView::ResizeToContents);
|
header()->setSectionResizeMode(MSG_DB_READ_INDEX, QHeaderView::ResizeMode::ResizeToContents);
|
||||||
header()->setSectionResizeMode(MSG_DB_IMPORTANT_INDEX, QHeaderView::ResizeToContents);
|
header()->setSectionResizeMode(MSG_DB_IMPORTANT_INDEX, QHeaderView::ResizeMode::ResizeToContents);
|
||||||
header()->setSectionResizeMode(MSG_DB_HAS_ENCLOSURES, QHeaderView::ResizeToContents);
|
header()->setSectionResizeMode(MSG_DB_SCORE_INDEX, QHeaderView::ResizeMode::ResizeToContents);
|
||||||
|
header()->setSectionResizeMode(MSG_DB_HAS_ENCLOSURES, QHeaderView::ResizeMode::ResizeToContents);
|
||||||
|
|
||||||
// Hide columns.
|
// Hide columns.
|
||||||
hideColumn(MSG_DB_ID_INDEX);
|
hideColumn(MSG_DB_ID_INDEX);
|
||||||
|
|
Loading…
Add table
Reference in a new issue