mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fix RSElidedItemDelegate to use StyleSheet as default but defined colors
if they are. If none, use Base Delegate.
This commit is contained in:
parent
4f25ab3fe8
commit
384ae46706
@ -452,7 +452,7 @@ void FeedReaderDialog::calculateFeedItem(QTreeWidgetItem *item, uint32_t &unread
|
||||
font.setBold(unreadCountItem != 0);
|
||||
item->setFont(i, font);
|
||||
|
||||
item->setTextColor(COLUMN_FEED_NAME, deactivated ? colorDeactivated : colorActivated);
|
||||
item->setData(COLUMN_FEED_NAME, Qt::ForegroundRole, deactivated ? colorDeactivated : colorActivated);
|
||||
}
|
||||
|
||||
QIcon icon = item->data(COLUMN_FEED_DATA, ROLE_FEED_ICON).value<QIcon>();
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "chat/ChatTabWidget.h"
|
||||
#include "chat/CreateLobbyDialog.h"
|
||||
#include "common/RSTreeWidgetItem.h"
|
||||
#include "common/RSElidedItemDelegate.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/gxs/GxsIdDetails.h"
|
||||
#include "gui/Identity/IdEditDialog.h"
|
||||
@ -157,6 +158,7 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
|
||||
ui.lobbyTreeWidget->setColumnHidden(COLUMN_USER_COUNT,true) ;
|
||||
ui.lobbyTreeWidget->setColumnHidden(COLUMN_TOPIC,true) ;
|
||||
ui.lobbyTreeWidget->setSortingEnabled(true) ;
|
||||
ui.lobbyTreeWidget->setItemDelegateForColumn(COLUMN_NAME, new RSElidedItemDelegate());
|
||||
|
||||
float fact = QFontMetricsF(font()).height()/14.0f;
|
||||
|
||||
@ -386,6 +388,8 @@ static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobby
|
||||
item->setData(COLUMN_DATA, ROLE_FLAGS, lobby_flags.toUInt32());
|
||||
item->setData(COLUMN_DATA, ROLE_AUTOSUBSCRIBE, autoSubscribe);
|
||||
|
||||
//TODO (Phenom): Add qproperty for these text colors in stylesheets
|
||||
// As palette is not updated by stylesheet
|
||||
QColor color = treeWidget->palette().color(QPalette::Active, QPalette::Text);
|
||||
|
||||
if (!subscribed) {
|
||||
@ -395,7 +399,7 @@ static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobby
|
||||
}
|
||||
|
||||
for (int column = 0; column < COLUMN_COUNT; ++column) {
|
||||
item->setTextColor(column, color);
|
||||
item->setData(column, Qt::ForegroundRole, color);
|
||||
}
|
||||
QString tooltipstr = QObject::tr("Subject:")+" "+item->text(COLUMN_TOPIC)+"\n"
|
||||
+QObject::tr("Participants:")+" "+QString::number(count)+"\n"
|
||||
@ -407,7 +411,7 @@ static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobby
|
||||
tooltipstr += QObject::tr("\nSecurity: no anonymous IDs") ;
|
||||
QColor foreground = QColor(0, 128, 0); // green
|
||||
for (int column = 0; column < COLUMN_COUNT; ++column)
|
||||
item->setTextColor(column, foreground);
|
||||
item->setData(column, Qt::ForegroundRole, foreground);
|
||||
}
|
||||
item->setToolTip(0,tooltipstr) ;
|
||||
}
|
||||
|
@ -415,9 +415,8 @@ void SearchDialog::download()
|
||||
std::cout << *it << "-" << std::endl;
|
||||
|
||||
QColor foreground = textColorDownloading();
|
||||
QBrush brush(foreground);
|
||||
for (int i = 0; i < item->columnCount(); ++i)
|
||||
item->setForeground(i, brush);
|
||||
item->setData(i, Qt::ForegroundRole, foreground );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1269,10 +1268,9 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s
|
||||
foreground = textColorHighSources();
|
||||
}
|
||||
|
||||
QBrush brush(foreground);
|
||||
for (int i = 0; i < item->columnCount(); ++i)
|
||||
{
|
||||
item->setForeground(i, brush);
|
||||
item->setData(i, Qt::ForegroundRole, foreground);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1355,10 +1353,9 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s
|
||||
}
|
||||
|
||||
if (setForeground) {
|
||||
QBrush brush(foreground);
|
||||
for (int i = 0; i < item->columnCount(); ++i)
|
||||
{
|
||||
item->setForeground(i, brush);
|
||||
item->setData(i, Qt::ForegroundRole, foreground);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1369,23 +1369,24 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
|
||||
item->setData(RSID_COL_NICKNAME, Qt::UserRole, QString::fromStdString(data.mMeta.mGroupId.toStdString()));
|
||||
item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId.toStdString()));
|
||||
|
||||
if(isBanned)
|
||||
{
|
||||
item->setForeground(RSID_COL_NICKNAME,QBrush(Qt::red));
|
||||
item->setForeground(RSID_COL_KEYID,QBrush(Qt::red));
|
||||
item->setForeground(RSID_COL_IDTYPE,QBrush(Qt::red));
|
||||
item->setForeground(RSID_COL_VOTES,QBrush(Qt::red));
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setForeground(RSID_COL_NICKNAME,QBrush(Qt::black));
|
||||
item->setForeground(RSID_COL_KEYID,QBrush(Qt::black));
|
||||
item->setForeground(RSID_COL_IDTYPE,QBrush(Qt::black));
|
||||
item->setForeground(RSID_COL_VOTES,QBrush(Qt::black));
|
||||
}
|
||||
if(isBanned)
|
||||
{
|
||||
//TODO (Phenom): Add qproperty for these text colors in stylesheets
|
||||
item->setData(RSID_COL_NICKNAME, Qt::ForegroundRole, QColor(Qt::red));
|
||||
item->setData(RSID_COL_KEYID , Qt::ForegroundRole, QColor(Qt::red));
|
||||
item->setData(RSID_COL_IDTYPE , Qt::ForegroundRole, QColor(Qt::red));
|
||||
item->setData(RSID_COL_VOTES , Qt::ForegroundRole, QColor(Qt::red));
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setData(RSID_COL_NICKNAME, Qt::ForegroundRole, QVariant());
|
||||
item->setData(RSID_COL_KEYID , Qt::ForegroundRole, QVariant());
|
||||
item->setData(RSID_COL_IDTYPE , Qt::ForegroundRole, QVariant());
|
||||
item->setData(RSID_COL_VOTES , Qt::ForegroundRole, QVariant());
|
||||
}
|
||||
|
||||
item->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ;
|
||||
item->setTextAlignment(RSID_COL_VOTES, Qt::AlignRight | Qt::AlignVCenter);
|
||||
item->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ;
|
||||
item->setTextAlignment(RSID_COL_VOTES, Qt::AlignRight | Qt::AlignVCenter);
|
||||
item->setData(
|
||||
RSID_COL_VOTES,Qt::DecorationRole,
|
||||
static_cast<uint32_t>(idd.mReputation.mOverallReputationLevel));
|
||||
@ -1404,14 +1405,15 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
|
||||
|
||||
QString tooltip = tr("This identity is owned by you");
|
||||
|
||||
if(idd.mFlags & RS_IDENTITY_FLAGS_IS_DEPRECATED)
|
||||
{
|
||||
item->setForeground(RSID_COL_NICKNAME,QBrush(Qt::red));
|
||||
item->setForeground(RSID_COL_KEYID,QBrush(Qt::red));
|
||||
item->setForeground(RSID_COL_IDTYPE,QBrush(Qt::red));
|
||||
if(idd.mFlags & RS_IDENTITY_FLAGS_IS_DEPRECATED)
|
||||
{
|
||||
//TODO (Phenom): Add qproperty for these text colors in stylesheets
|
||||
item->setData(RSID_COL_NICKNAME, Qt::ForegroundRole, QColor(Qt::red));
|
||||
item->setData(RSID_COL_KEYID , Qt::ForegroundRole, QColor(Qt::red));
|
||||
item->setData(RSID_COL_IDTYPE , Qt::ForegroundRole, QColor(Qt::red));
|
||||
|
||||
tooltip += tr("\nThis identity has a unsecure fingerprint (It's probably quite old).\nYou should get rid of it now and use a new one.\nThese identities will soon be not supported anymore.") ;
|
||||
}
|
||||
tooltip += tr("\nThis identity has a unsecure fingerprint (It's probably quite old).\nYou should get rid of it now and use a new one.\nThese identities will soon be not supported anymore.") ;
|
||||
}
|
||||
|
||||
item->setToolTip(RSID_COL_NICKNAME, tooltip) ;
|
||||
item->setToolTip(RSID_COL_KEYID, tooltip) ;
|
||||
|
@ -250,21 +250,23 @@ void ShareManager::load()
|
||||
|
||||
listWidget->item(row,COLUMN_GROUPS)->setText(getGroupString(mDirInfos[row].parent_groups));
|
||||
|
||||
QFont font = listWidget->item(row,COLUMN_GROUPS)->font();
|
||||
font.setBold(mDirInfos[row].shareflags & DIR_FLAGS_BROWSABLE) ;
|
||||
listWidget->item(row,COLUMN_GROUPS)->setTextColor( (mDirInfos[row].shareflags & DIR_FLAGS_BROWSABLE)? (Qt::black):(Qt::lightGray)) ;
|
||||
listWidget->item(row,COLUMN_GROUPS)->setFont(font);
|
||||
//TODO (Phenom): Add qproperty for these text colors in stylesheets
|
||||
// As palette is not updated by stylesheet
|
||||
QFont font = listWidget->item(row,COLUMN_GROUPS)->font();
|
||||
font.setBold(mDirInfos[row].shareflags & DIR_FLAGS_BROWSABLE) ;
|
||||
listWidget->item(row,COLUMN_GROUPS)->setData(Qt::ForegroundRole, QColor((mDirInfos[row].shareflags & DIR_FLAGS_BROWSABLE) ? (Qt::black):(Qt::lightGray)) );
|
||||
listWidget->item(row,COLUMN_GROUPS)->setFont(font);
|
||||
|
||||
if(QDir(QString::fromUtf8(mDirInfos[row].filename.c_str())).exists())
|
||||
{
|
||||
listWidget->item(row,COLUMN_PATH)->setTextColor(Qt::black);
|
||||
if(QDir(QString::fromUtf8(mDirInfos[row].filename.c_str())).exists())
|
||||
{
|
||||
listWidget->item(row,COLUMN_PATH)->setData(Qt::ForegroundRole, QColor(Qt::black));
|
||||
listWidget->item(row,COLUMN_PATH)->setToolTip(tr("Double click to change shared directory path")) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
listWidget->item(row,COLUMN_PATH)->setTextColor(Qt::lightGray);
|
||||
}
|
||||
else
|
||||
{
|
||||
listWidget->item(row,COLUMN_PATH)->setData(Qt::ForegroundRole, QColor(Qt::lightGray));
|
||||
listWidget->item(row,COLUMN_PATH)->setToolTip(tr("Directory does not exist! Double click to change shared directory path")) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
listWidget->setColumnWidth(COLUMN_SHARE_FLAGS,132 * QFontMetricsF(font()).height()/14.0) ;
|
||||
|
@ -614,10 +614,12 @@ void ChatLobbyDialog::updateParticipantsList()
|
||||
else
|
||||
widgetitem = dynamic_cast<GxsIdRSTreeWidgetItem*>(qlFoundParticipants.at(0));
|
||||
|
||||
//TODO (Phenom): Add qproperty for these text colors in stylesheets
|
||||
// As palette is not updated by stylesheet
|
||||
if (isParticipantMuted(it2->first)) {
|
||||
widgetitem->setTextColor(COLUMN_NAME,QColor(255,0,0));
|
||||
widgetitem->setData(COLUMN_NAME, Qt::ForegroundRole, QColor(255,0,0));
|
||||
} else {
|
||||
widgetitem->setTextColor(COLUMN_NAME,ui.participantsList->palette().color(QPalette::Active, QPalette::Text));
|
||||
widgetitem->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant());
|
||||
}
|
||||
|
||||
time_t tLastAct=widgetitem->text(COLUMN_ACTIVITY).toInt();
|
||||
|
@ -239,7 +239,10 @@ bool ElidedLabel::paintElidedLine( QPainter* painter, QString plainText
|
||||
*rectElision = mRectElision;
|
||||
|
||||
if(drawRoundedRect)
|
||||
if (painter) painter->drawRoundedRect(mRectElision, 2 , 2);
|
||||
if (painter) {
|
||||
painter->setBrush(QBrush(Qt::transparent));
|
||||
painter->drawRoundedRect(mRectElision, 2 , 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (painter) painter->restore();
|
||||
|
@ -717,7 +717,7 @@ void FriendList::insertPeers()
|
||||
groupItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||
groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter);
|
||||
groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP24));
|
||||
groupItem->setForeground(COLUMN_NAME, QBrush(textColorGroup()));
|
||||
groupItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorGroup());
|
||||
|
||||
/* used to find back the item */
|
||||
QString strID = QString::fromStdString(groupInfo->id.toStdString());
|
||||
@ -1110,8 +1110,8 @@ void FriendList::insertPeers()
|
||||
for (int i = 0; i < columnCount; ++i) {
|
||||
sslItem->setData(i, ROLE_SORT_STATE, peerState);
|
||||
|
||||
sslItem->setTextColor(i, sslColor);
|
||||
sslItem->setFont(i, sslFont);
|
||||
sslItem->setData(i, Qt::ForegroundRole, sslColor);
|
||||
sslItem->setData(i, Qt::FontRole, sslFont);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1222,8 +1222,8 @@ void FriendList::insertPeers()
|
||||
for (int i = 0; i < columnCount; ++i) {
|
||||
gpgItem->setData(i, ROLE_SORT_STATE, bestPeerState);
|
||||
|
||||
gpgItem->setTextColor(i, gpgColor);
|
||||
gpgItem->setFont(i, gpgFont);
|
||||
gpgItem->setData(i, Qt::ForegroundRole, gpgColor);
|
||||
gpgItem->setData(i, Qt::FontRole, gpgFont);
|
||||
}
|
||||
|
||||
if (openPeers.find(gpgId) != openPeers.end()) {
|
||||
|
@ -215,7 +215,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons
|
||||
}
|
||||
|
||||
if (state != (int) RS_STATUS_OFFLINE) {
|
||||
item->setTextColor(COLUMN_NAME, textColorOnline);
|
||||
item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline);
|
||||
}
|
||||
|
||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
|
||||
@ -434,7 +434,7 @@ void FriendSelectionWidget::secured_fillList()
|
||||
}
|
||||
|
||||
if (state != (int) RS_STATUS_OFFLINE) {
|
||||
gpgItem->setTextColor(COLUMN_NAME, textColorOnline());
|
||||
gpgItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
|
||||
}
|
||||
|
||||
gpgItem->setFlags(Qt::ItemIsUserCheckable | gpgItem->flags());
|
||||
@ -571,7 +571,7 @@ void FriendSelectionWidget::secured_fillList()
|
||||
QString name = QString::fromUtf8(detail.mNickname.c_str());
|
||||
gxsItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString( (*gxsIt).toStdString() )+")");
|
||||
|
||||
//gxsItem->setTextColor(COLUMN_NAME, textColorOnline());
|
||||
//gxsItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
|
||||
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
|
||||
gxsItem->setIcon(COLUMN_NAME, identicon);
|
||||
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
|
||||
@ -625,7 +625,7 @@ void FriendSelectionWidget::secured_fillList()
|
||||
QString name = QString::fromUtf8(detail.mNickname.c_str());
|
||||
gxsItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString( (*gxsIt).toStdString() )+")");
|
||||
|
||||
//gxsItem->setTextColor(COLUMN_NAME, textColorOnline());
|
||||
//gxsItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
|
||||
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
|
||||
gxsItem->setIcon(COLUMN_NAME, identicon);
|
||||
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
|
||||
@ -746,14 +746,12 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
|
||||
case IDTYPE_GPG:
|
||||
{
|
||||
if (item->data(COLUMN_DATA, ROLE_ID).toString() == gpgId) {
|
||||
QColor color;
|
||||
if (status != (int) RS_STATUS_OFFLINE) {
|
||||
color = textColorOnline();
|
||||
item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
|
||||
} else {
|
||||
color = ui->friendList->palette().color(QPalette::Text);
|
||||
item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant());
|
||||
}
|
||||
|
||||
item->setTextColor(COLUMN_NAME, color);
|
||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(gpgStatus)));
|
||||
|
||||
item->setData(COLUMN_NAME, ROLE_SORT_STATE, gpgStatus);
|
||||
@ -765,14 +763,12 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
|
||||
case IDTYPE_SSL:
|
||||
{
|
||||
if (item->data(COLUMN_DATA, ROLE_ID).toString() == peerId) {
|
||||
QColor color;
|
||||
if (status != (int) RS_STATUS_OFFLINE) {
|
||||
color = textColorOnline();
|
||||
item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
|
||||
} else {
|
||||
color = ui->friendList->palette().color(QPalette::Text);
|
||||
item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant());
|
||||
}
|
||||
|
||||
item->setTextColor(COLUMN_NAME, color);
|
||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(status)));
|
||||
|
||||
item->setData(COLUMN_NAME, ROLE_SORT_STATE, status);
|
||||
|
@ -287,9 +287,6 @@ void GroupTreeWidget::initDisplayMenu(QToolButton *toolButton)
|
||||
|
||||
void GroupTreeWidget::updateColors()
|
||||
{
|
||||
QBrush brush;
|
||||
QBrush standardBrush = ui->treeWidget->palette().color(QPalette::Text);
|
||||
|
||||
QTreeWidgetItemIterator itemIterator(ui->treeWidget);
|
||||
QTreeWidgetItem *item;
|
||||
while ((item = *itemIterator) != NULL) {
|
||||
@ -297,12 +294,11 @@ void GroupTreeWidget::updateColors()
|
||||
|
||||
int color = item->data(COLUMN_DATA, ROLE_COLOR).toInt();
|
||||
if (color >= 0) {
|
||||
brush = QBrush(mTextColor[color]);
|
||||
item->setData(COLUMN_NAME, Qt::TextColorRole, mTextColor[color]);
|
||||
} else {
|
||||
brush = standardBrush;
|
||||
item->setData(COLUMN_NAME, Qt::TextColorRole, QVariant());
|
||||
}
|
||||
|
||||
item->setForeground(COLUMN_NAME, brush);
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,7 +352,7 @@ QTreeWidgetItem *GroupTreeWidget::addCategoryItem(const QString &name, const QIc
|
||||
int S = QFontMetricsF(font).height();
|
||||
|
||||
item->setSizeHint(COLUMN_NAME, QSize(S*1.9, S*1.9));
|
||||
item->setForeground(COLUMN_NAME, QBrush(textColorCategory()));
|
||||
item->setData(COLUMN_NAME, Qt::TextColorRole, textColorCategory());
|
||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_CATEGORY);
|
||||
|
||||
item->setExpanded(expand);
|
||||
@ -513,15 +509,14 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
||||
item->setData(COLUMN_DATA, ROLE_SUBSCRIBE_FLAGS, itemInfo.subscribeFlags);
|
||||
|
||||
/* Set color */
|
||||
QBrush brush;
|
||||
if (itemInfo.publishKey) {
|
||||
brush = QBrush(textColorPrivateKey());
|
||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_PRIVATEKEY);
|
||||
item->setData(COLUMN_NAME, Qt::BackgroundRole, QBrush(textColorPrivateKey()));
|
||||
} else {
|
||||
brush = ui->treeWidget->palette().color(QPalette::Text);
|
||||
// Let StyleSheet color
|
||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_STANDARD);
|
||||
item->setData(COLUMN_NAME, Qt::BackgroundRole, QVariant());
|
||||
}
|
||||
item->setForeground(COLUMN_NAME, brush);
|
||||
|
||||
/* Calculate score */
|
||||
calculateScore(item, filterText);
|
||||
|
@ -36,6 +36,36 @@
|
||||
#include <cmath>
|
||||
#include <chrono>
|
||||
|
||||
//#define DEBUG_EID_PAINT 1
|
||||
|
||||
/* To test it you can make an empty.qss file with:
|
||||
QTreeView::item, QTreeWidget::item{
|
||||
color: #AB0000;
|
||||
background-color: #00DC00;
|
||||
}
|
||||
QTreeView::item:selected, QTreeWidget::item:selected{
|
||||
color: #00CD00;
|
||||
background-color: #0000BA;
|
||||
}
|
||||
QTreeView::item:hover, QTreeWidget::item:hover{
|
||||
color: #0000EF;
|
||||
background-color: #FEDCBA;
|
||||
}
|
||||
QQTreeView::item:selected:hover, TreeWidget::item:selected:hover{
|
||||
color: #ABCDEF;
|
||||
background-color: #FE0000;
|
||||
}
|
||||
|
||||
ForumsDialog, GxsForumThreadWidget
|
||||
{
|
||||
qproperty-textColorRead: darkgray;
|
||||
qproperty-textColorUnread: white;
|
||||
qproperty-textColorUnreadChildren: red;
|
||||
qproperty-textColorNotSubscribed: white;
|
||||
qproperty-textColorMissing: darkred;
|
||||
}
|
||||
*/
|
||||
|
||||
RSElidedItemDelegate::RSElidedItemDelegate(QObject *parent)
|
||||
: RSStyledItemDelegate(parent)
|
||||
, mOnlyPlainText(false), mPaintRoundedRect(true)
|
||||
@ -63,6 +93,18 @@ QSize RSElidedItemDelegate::sizeHint(const QStyleOptionViewItem &option, const Q
|
||||
return contSize;
|
||||
}
|
||||
|
||||
inline QColor getImagePixelColor(QImage img, int x, int y)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0)
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
// RsDbg() << " RSEID: Found Color " << img.pixelColor(x,y).name(QColor::HexArgb).toStdString() << " at " << x << "," << y << std::endl;
|
||||
#endif
|
||||
return img.pixelColor(x,y);
|
||||
#else
|
||||
return img.pixel(x,y);
|
||||
#endif
|
||||
}
|
||||
|
||||
void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
if(!index.isValid())
|
||||
@ -71,15 +113,16 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
return ;
|
||||
}
|
||||
painter->save();
|
||||
// To draw with default for debug purpose
|
||||
//QStyledItemDelegate::paint(painter, option, index);
|
||||
|
||||
QStyleOptionViewItem ownOption (option);
|
||||
initStyleOption(&ownOption, index);
|
||||
//Prefer use icon from option
|
||||
if (!option.icon.isNull())
|
||||
ownOption.icon = option.icon;
|
||||
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
RsDbg() << __PRETTY_FUNCTION__ << std::endl << " RSEID: Enter for item with text:" << ownOption.text.toStdString() << std::endl;
|
||||
#endif
|
||||
|
||||
const QWidget* widget = option.widget;
|
||||
QStyle* ownStyle = widget ? widget->style() : QApplication::style();
|
||||
|
||||
@ -89,28 +132,180 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
td.setHtml(ownOption.text);
|
||||
ownOption.text = td.toPlainText();
|
||||
}
|
||||
//Get Font as option.font is not accurate
|
||||
// Get Font as option.font is not accurate
|
||||
if (index.data(Qt::FontRole).type() == QVariant::Font) {
|
||||
QFont font = index.data(Qt::FontRole).value<QFont>();
|
||||
ownOption.font = font;
|
||||
ownOption.fontMetrics = QFontMetrics(font);
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
QFontInfo info(font);
|
||||
RsDbg() << " RSEID: Found font in model:" << info.family().toStdString() << std::endl;
|
||||
#endif
|
||||
}
|
||||
// Get Text color from model if one exists
|
||||
QColor textColor;
|
||||
if (index.data(Qt::TextColorRole).canConvert(QMetaType::QColor)) {
|
||||
textColor = QColor(index.data(Qt::TextColorRole).toString());//Needs to pass from string else loose RBG format.
|
||||
if (index.data(Qt::TextColorRole).isValid()) {
|
||||
//textColor = QColor(index.data(Qt::TextColorRole).toString());//Needs to pass from string else loose RBG format.
|
||||
textColor = index.data(Qt::TextColorRole).value<QColor>();
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
RsDbg() << " RSEID: Found text color in model:" << textColor.name().toStdString() << std::endl;
|
||||
#endif
|
||||
}
|
||||
if (index.data(Qt::BackgroundRole).canConvert(QMetaType::QBrush)) {
|
||||
QBrush brush(index.data(Qt::BackgroundRole).convert(QMetaType::QBrush));
|
||||
ownOption.backgroundBrush = brush;
|
||||
// Get Brush from model if one exists
|
||||
QBrush bgBrush;
|
||||
bgBrush.setColor(QColor());// To get color().spec()==QColor::Invalid)
|
||||
if (index.data(Qt::BackgroundRole).isValid()) {
|
||||
bgBrush = index.data(Qt::BackgroundRole).value<QBrush>();
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
RsDbg() << " RSEID: Found bg brush in model:" << bgBrush.color().name().toStdString() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//Code from: https://code.woboq.org/qt5/qtbase/src/widgets/styles/qcommonstyle.cpp.html#2271
|
||||
// If we get text and bg color from model, no need to retrieve it from base
|
||||
if ( (bgBrush.color().spec()==QColor::Invalid) || (textColor.spec()!=QColor::Invalid) )
|
||||
{
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
RsDbg() << " RSEID:"
|
||||
<< ((bgBrush.color().spec()==QColor::Invalid) ? " Brush not defined" : "")
|
||||
<< ((textColor.spec()==QColor::Invalid) ? " Text Color not defined" : "")
|
||||
<< " so get it from base image." << std::endl;
|
||||
#endif
|
||||
// QPalette is not updated by StyleSheet all occurs in internal class. (QRenderRule)
|
||||
// https://code.woboq.org/qt5/qtbase/src/widgets/styles/qstylesheetstyle.cpp.html#4138
|
||||
// void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p, const QWidget *w) const
|
||||
// case CE_ItemViewItem:
|
||||
// So we have to print it in Image to get colors by pixel
|
||||
QSize moSize=sizeHint(option,index);
|
||||
if (moSize.width() <= 20)
|
||||
moSize.setWidth(20);
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
RsDbg() << " RSEID: for item size = " << moSize.width() << "x" << moSize.height() << std::endl;
|
||||
#endif
|
||||
|
||||
QImage moImg(moSize,QImage::Format_ARGB32);
|
||||
QPainter moPnt;
|
||||
moPnt.begin(&moImg);
|
||||
moPnt.setCompositionMode (QPainter::CompositionMode_Source);
|
||||
moPnt.fillRect(moImg.rect(), Qt::transparent);
|
||||
moPnt.setCompositionMode (QPainter::CompositionMode_SourceOver);
|
||||
|
||||
QStyleOptionViewItem moOption (option);
|
||||
// Define option to get only what we want
|
||||
{
|
||||
moOption.rect = QRect(QPoint(0,0),moSize);
|
||||
moOption.state = ownOption.state;
|
||||
moOption.text = " ████████████████";//Add a blank char to get BackGround Color at top left
|
||||
// Remove unwanted info. Yes it can draw without that all public data ...
|
||||
moOption.backgroundBrush = QBrush();
|
||||
moOption.checkState = Qt::Unchecked;
|
||||
moOption.decorationAlignment = Qt::AlignLeft;
|
||||
moOption.decorationPosition = QStyleOptionViewItem::Left;
|
||||
moOption.decorationSize = QSize();
|
||||
moOption.displayAlignment = Qt::AlignLeft | Qt::AlignTop;
|
||||
moOption.features=0;
|
||||
moOption.font = QFont();
|
||||
moOption.icon = QIcon();
|
||||
moOption.index = QModelIndex();
|
||||
moOption.locale = QLocale();
|
||||
moOption.showDecorationSelected = false;
|
||||
moOption.textElideMode = Qt::ElideNone;
|
||||
moOption.viewItemPosition = QStyleOptionViewItem::Middle;
|
||||
//moOption.widget = nullptr; //Needed.
|
||||
|
||||
moOption.direction = Qt::LayoutDirectionAuto;
|
||||
moOption.fontMetrics = QFontMetrics(QFont());
|
||||
moOption.palette = QPalette();
|
||||
moOption.styleObject = nullptr;
|
||||
}
|
||||
QStyledItemDelegate::paint(&moPnt, moOption, QModelIndex());
|
||||
|
||||
//// But these lines doesn't works.
|
||||
{
|
||||
//QStyleOptionViewItem moOptionsState;
|
||||
//moOptionsState.initFrom(moOption.widget);
|
||||
//moOptionsState.rect = QRect(QPoint(0,0),moSize);
|
||||
//moOptionsState.state = QStyle::State_MouseOver | QStyle::State_Enabled | QStyle::State_Sibling;
|
||||
//moOptionsState.text = "████████";
|
||||
//moOptionsState.widget = option.widget;
|
||||
//QStyledItemDelegate::paint(&moPnt, moOptionsState, QModelIndex());
|
||||
}
|
||||
|
||||
moPnt.end();
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
// To save what it paint in application path
|
||||
moImg.save("image.png");
|
||||
#endif
|
||||
// Get Color in this rect.
|
||||
{
|
||||
QColor moColor;
|
||||
QColor moBGColor=getImagePixelColor(moImg,1,1); // BackGround may be paint.
|
||||
QColor moColorBorder;// To avoid Border pixel
|
||||
int moWidth = moImg.size().width(), moHeight = moImg.size().height();
|
||||
for (int x = 0; (x<moWidth) && (moColor.spec() == QColor::Invalid); x++)
|
||||
for (int y = 0; (y<moHeight) && (moColor.spec() == QColor::Invalid); y++)
|
||||
if (getImagePixelColor(moImg,x,y) != moBGColor)
|
||||
{
|
||||
if (getImagePixelColor(moImg,x,y) == moColorBorder)
|
||||
moColor = getImagePixelColor(moImg,x,y);
|
||||
else
|
||||
{
|
||||
if (moColorBorder.spec() == QColor::Invalid)
|
||||
{
|
||||
// First pixel border move inside
|
||||
x+=5;
|
||||
y+=5;
|
||||
}
|
||||
moColorBorder = getImagePixelColor(moImg,x,y);
|
||||
}
|
||||
}
|
||||
|
||||
// If not found color is same as BackGround.
|
||||
if (moColor.spec() == QColor::Invalid)
|
||||
moColor = moBGColor;
|
||||
|
||||
if (bgBrush.color().spec()==QColor::Invalid)
|
||||
{
|
||||
bgBrush = QBrush(moBGColor);
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
RsDbg() << " RSEID: bg brush setted to " << moBGColor.name(QColor::HexArgb).toStdString() << std::endl;
|
||||
#endif
|
||||
}
|
||||
if (textColor.spec()==QColor::Invalid)
|
||||
{
|
||||
textColor = moColor;
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
RsDbg() << " RSEID: text color setted to " << moColor.name(QColor::HexArgb).toStdString() << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
painter->setPen(textColor);
|
||||
painter->setBrush(bgBrush);
|
||||
ownOption.backgroundBrush = bgBrush;
|
||||
|
||||
// Code from: https://code.woboq.org/qt5/qtbase/src/widgets/styles/qcommonstyle.cpp.html#2271
|
||||
QRect checkRect = ownStyle->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &ownOption, widget);
|
||||
QRect iconRect = ownStyle->subElementRect(QStyle::SE_ItemViewItemDecoration, &ownOption, widget);
|
||||
QRect textRect = ownStyle->subElementRect(QStyle::SE_ItemViewItemText, &ownOption, widget);
|
||||
|
||||
// draw the background
|
||||
ownStyle->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, widget);
|
||||
// Draw the background
|
||||
if (bgBrush.color().alpha() == 0)
|
||||
// No BackGround Color found, use default delegate to draw it.
|
||||
ownStyle->proxy()->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, widget);// This prefer draw StyleSheet bg than item one.
|
||||
else
|
||||
painter->fillRect(ownOption.rect,bgBrush);
|
||||
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
{
|
||||
QStyleOptionViewItem tstOption = option;
|
||||
// Reduce rect to get this item bg color external and base internal
|
||||
tstOption.rect.adjust(3,3,-6,-6);
|
||||
// To draw with base for debug purpose
|
||||
QStyledItemDelegate::paint(painter, tstOption, index);
|
||||
}
|
||||
#endif
|
||||
|
||||
// draw the check mark
|
||||
if (ownOption.features & QStyleOptionViewItem::HasCheckIndicator) {
|
||||
QStyleOptionViewItem option(*&ownOption);
|
||||
@ -165,130 +360,31 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
qreal add = 120*(time/(duration*1000.0))*std::abs(sin(qDegreesToRadians(angle/2)));
|
||||
painter->setPen(QPen(QBrush(ownOption.palette.color(QPalette::Normal, QPalette::WindowText)),diag/10,Qt::DotLine,Qt::RoundCap));
|
||||
painter->drawEllipse( iconRect.x()+iconRect.width() /2 + (diag/4)*cos(qDegreesToRadians(angle ))
|
||||
, iconRect.y()+iconRect.height()/2 + (diag/4)*sin(qDegreesToRadians(angle )), 1, 1);
|
||||
, iconRect.y()+iconRect.height()/2 + (diag/4)*sin(qDegreesToRadians(angle )), 1, 1);
|
||||
painter->setPen(QPen(QBrush(ownOption.palette.color(QPalette::Normal, QPalette::Midlight)),diag/10,Qt::DotLine,Qt::RoundCap));
|
||||
painter->drawEllipse( iconRect.x()+iconRect.width() /2 + (diag/4)*cos(qDegreesToRadians(angle- add))
|
||||
, iconRect.y()+iconRect.height()/2 + (diag/4)*sin(qDegreesToRadians(angle- add)), 1, 1);
|
||||
, iconRect.y()+iconRect.height()/2 + (diag/4)*sin(qDegreesToRadians(angle- add)), 1, 1);
|
||||
painter->setPen(QPen(QBrush(ownOption.palette.color(QPalette::Normal, QPalette::Window)),diag/10,Qt::DotLine,Qt::RoundCap));
|
||||
painter->drawEllipse( iconRect.x()+iconRect.width() /2 + (diag/4)*cos(qDegreesToRadians(angle-2*add))
|
||||
, iconRect.y()+iconRect.height()/2 + (diag/4)*sin(qDegreesToRadians(angle-2*add)), 1, 1);
|
||||
, iconRect.y()+iconRect.height()/2 + (diag/4)*sin(qDegreesToRadians(angle-2*add)), 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// draw the text
|
||||
if (!ownOption.text.isEmpty()) {
|
||||
QPalette::ColorGroup cg = ownOption.state & QStyle::State_Enabled
|
||||
? QPalette::Normal : QPalette::Disabled;
|
||||
if (cg == QPalette::Normal && !(ownOption.state & QStyle::State_Active))
|
||||
cg = QPalette::Inactive;
|
||||
if (ownOption.state & QStyle::State_Selected) {
|
||||
painter->setPen(ownOption.palette.color(cg, QPalette::HighlightedText));
|
||||
} else {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0)
|
||||
if (ownOption.state & QStyle::State_MouseOver) {
|
||||
//TODO: Manage to get palette with HOVER css pseudoclass
|
||||
// For now this is hidden by Qt: https://code.woboq.org/qt5/qtbase/src/widgets/styles/qstylesheetstyle.cpp.html#6103
|
||||
// So we print default in image and get it's color...
|
||||
QSize moSize=sizeHint(option,index);
|
||||
QImage moImg(moSize,QImage::Format_ARGB32);
|
||||
QPainter moPnt;
|
||||
moPnt.begin(&moImg);
|
||||
moPnt.setPen(Qt::black);//Fill Image with Black
|
||||
moPnt.setBrush(Qt::black);
|
||||
moPnt.drawRect(moImg.rect());
|
||||
|
||||
QStyleOptionViewItem moOption (option);
|
||||
// Define option to get only what we want
|
||||
{
|
||||
moOption.rect = QRect(QPoint(0,0),moSize);
|
||||
moOption.state = QStyle::State_MouseOver | QStyle::State_Enabled | QStyle::State_Sibling;
|
||||
moOption.text = " ████████████████";//Add a blank char to get BackGround Color at top left
|
||||
// Remove unwanted info. Yes it can draw without that all public data ...
|
||||
moOption.backgroundBrush = QBrush();
|
||||
moOption.checkState = Qt::Unchecked;
|
||||
moOption.decorationAlignment = Qt::AlignLeft;
|
||||
moOption.decorationPosition = QStyleOptionViewItem::Left;
|
||||
moOption.decorationSize = QSize();
|
||||
moOption.displayAlignment = Qt::AlignLeft | Qt::AlignTop;
|
||||
moOption.features=0;
|
||||
moOption.font = QFont();
|
||||
moOption.icon = QIcon();
|
||||
moOption.index = QModelIndex();
|
||||
moOption.locale = QLocale();
|
||||
moOption.showDecorationSelected = false;
|
||||
moOption.textElideMode = Qt::ElideNone;
|
||||
moOption.viewItemPosition = QStyleOptionViewItem::Middle;
|
||||
//moOption.widget = nullptr; //Needed.
|
||||
|
||||
moOption.direction = Qt::LayoutDirectionAuto;
|
||||
moOption.fontMetrics = QFontMetrics(QFont());
|
||||
moOption.palette = QPalette();
|
||||
moOption.styleObject = nullptr;
|
||||
}
|
||||
QStyledItemDelegate::paint(&moPnt, moOption, QModelIndex());
|
||||
|
||||
//// But these lines doesn't works.
|
||||
{
|
||||
//QStyleOptionViewItem moOptionsState;
|
||||
//moOptionsState.initFrom(moOption.widget);
|
||||
//moOptionsState.rect = QRect(QPoint(0,0),moSize);
|
||||
//moOptionsState.state = QStyle::State_MouseOver | QStyle::State_Enabled | QStyle::State_Sibling;
|
||||
//moOptionsState.text = "████████";
|
||||
//moOptionsState.widget = option.widget;
|
||||
//QStyledItemDelegate::paint(&moPnt, moOptionsState, QModelIndex());
|
||||
}
|
||||
|
||||
moPnt.end();
|
||||
// To save what it paint
|
||||
//moImg.save("image.bmp");
|
||||
|
||||
// Get Color in this black rect.
|
||||
QColor moColor;
|
||||
QColor moBGColor=moImg.pixelColor(1,1); //BackGround may be paint.
|
||||
QColor moColorBorder;// To avoid Border pixel
|
||||
int moWidth = moImg.size().width(), moHeight = moImg.size().height();
|
||||
for (int x = 0; (x<moWidth) && (moColor.spec() == QColor::Invalid); x++)
|
||||
for (int y = 0; (y<moHeight) && (moColor.spec() == QColor::Invalid); y++)
|
||||
if (moImg.pixelColor(x,y) != moBGColor)
|
||||
{
|
||||
if (moImg.pixelColor(x,y) == moColorBorder)
|
||||
moColor = QColor(moImg.pixelColor(x,y).name());
|
||||
else
|
||||
{
|
||||
if (moColorBorder.spec() == QColor::Invalid)
|
||||
{
|
||||
// First pixel border move inside
|
||||
x+=5;
|
||||
y+=5;
|
||||
}
|
||||
moColorBorder = QColor(moImg.pixelColor(x,y).name());
|
||||
}
|
||||
}
|
||||
|
||||
// If not found color is same as BackGround.
|
||||
if (moColor.spec() == QColor::Invalid)
|
||||
moColor = moBGColor;
|
||||
|
||||
painter->setPen(moColor);
|
||||
}
|
||||
else
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
// To draw text near base one.
|
||||
ownOption.text = ownOption.text.prepend("__");
|
||||
#endif
|
||||
if (textColor.spec()==QColor::Invalid) {
|
||||
painter->setPen(ownOption.palette.color(cg, QPalette::Text));
|
||||
} else { //Only get color from index for unselected(as Qt does)
|
||||
painter->setPen(textColor);
|
||||
}
|
||||
}
|
||||
if (ownOption.state & QStyle::State_Editing) {
|
||||
painter->setPen(ownOption.palette.color(cg, QPalette::Text));
|
||||
painter->drawRect(textRect.adjusted(0, 0, -1, -1));
|
||||
}
|
||||
//d->viewItemDrawText(p, &ownOption, textRect);
|
||||
|
||||
QTextLayout textLayout(ownOption.text, painter->font());
|
||||
QTextOption to = textLayout.textOption();
|
||||
StyledElidedLabel::paintElidedLine(painter,ownOption.text,textRect,ownOption.font,ownOption.displayAlignment,to.wrapMode()&QTextOption::WordWrap,mPaintRoundedRect);
|
||||
}
|
||||
painter->restore();
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
RsDbg() << " RSEID: Finished" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RSElidedItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
|
||||
|
@ -537,8 +537,9 @@ bool RsCollectionDialog::addChild(QTreeWidgetItem* parent, const std::vector<Col
|
||||
|
||||
if (colFileInfo.filename_has_wrong_characters)
|
||||
{
|
||||
//TODO (Phenom): Add qproperty for these text colors in stylesheets
|
||||
wrong_chars = true ;
|
||||
item->setTextColor(COLUMN_FILE, QColor(255,80,120)) ;
|
||||
item->setData(COLUMN_FILE, Qt::ForegroundRole, QColor(255,80,120)) ;
|
||||
}
|
||||
|
||||
if (parentsFounds.empty()) {
|
||||
|
@ -451,7 +451,7 @@ void MessagesDialog::fillQuickView()
|
||||
text = TagDefs::name(tag->first, tag->second.first);
|
||||
|
||||
item = new QListWidgetItem (text, ui.quickViewWidget);
|
||||
item->setForeground(QBrush(QColor(tag->second.second)));
|
||||
item->setData(Qt::ForegroundRole, QColor(tag->second.second));
|
||||
item->setIcon(QIcon(":/images/foldermail.png"));
|
||||
item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_TAG);
|
||||
item->setData(ROLE_QUICKVIEW_ID, tag->first);
|
||||
@ -1262,7 +1262,7 @@ void MessagesDialog::updateMessageSummaryList()
|
||||
qf.setBold(true);
|
||||
item->setFont(qf);
|
||||
item->setIcon(QIcon(":/images/folder-inbox-new.png"));
|
||||
item->setForeground(QBrush(mTextColorInbox));
|
||||
item->setData(Qt::ForegroundRole, mTextColorInbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1272,7 +1272,7 @@ void MessagesDialog::updateMessageSummaryList()
|
||||
qf.setBold(false);
|
||||
item->setFont(qf);
|
||||
item->setIcon(QIcon(":/images/folder-inbox.png"));
|
||||
item->setForeground(QBrush(ui.messageTreeWidget->palette().color(QPalette::Text)));
|
||||
item->setData(Qt::ForegroundRole, QVariant());
|
||||
}
|
||||
|
||||
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
|
||||
|
@ -140,7 +140,7 @@ void MessagePage::fillTags()
|
||||
QString text = TagDefs::name(Tag->first, Tag->second.first);
|
||||
|
||||
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
|
||||
pItemWidget->setTextColor(QColor(Tag->second.second));
|
||||
pItemWidget->setData(Qt::ForegroundRole, QColor(Tag->second.second));
|
||||
pItemWidget->setData(Qt::UserRole, Tag->first);
|
||||
}
|
||||
}
|
||||
@ -155,7 +155,7 @@ void MessagePage::addTag()
|
||||
QString text = TagDefs::name(Tag->first, Tag->second.first);
|
||||
|
||||
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
|
||||
pItemWidget->setTextColor(QColor(Tag->second.second));
|
||||
pItemWidget->setData(Qt::ForegroundRole, QColor(Tag->second.second));
|
||||
pItemWidget->setData(Qt::UserRole, TagDlg.m_nId);
|
||||
|
||||
m_changedTagIds.push_back(TagDlg.m_nId);
|
||||
@ -186,7 +186,7 @@ void MessagePage::editTag()
|
||||
if (Tag->first >= RS_MSGTAGTYPE_USER) {
|
||||
pItemWidget->setText(QString::fromStdString(Tag->second.first));
|
||||
}
|
||||
pItemWidget->setTextColor(QColor(Tag->second.second));
|
||||
pItemWidget->setData(Qt::ForegroundRole, QColor(Tag->second.second));
|
||||
|
||||
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), TagDlg.m_nId) == m_changedTagIds.end()) {
|
||||
m_changedTagIds.push_back(TagDlg.m_nId);
|
||||
|
Loading…
Reference in New Issue
Block a user