mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fix Friend List Status
This commit is contained in:
parent
cb90c70beb
commit
6b519838b1
@ -48,11 +48,7 @@ const uint32_t RS_STATUS_COUNT = 0x0005; // count of status
|
|||||||
class StatusInfo
|
class StatusInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StatusInfo()
|
StatusInfo() : status(RS_STATUS_OFFLINE), time_stamp(0) {}
|
||||||
{
|
|
||||||
status = 0;
|
|
||||||
time_stamp = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RsPeerId id;
|
RsPeerId id;
|
||||||
|
@ -406,14 +406,14 @@ QVariant RsFriendListModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
QVariant RsFriendListModel::textColorRole(const EntryIndex& fmpe,int column) const
|
QVariant RsFriendListModel::textColorRole(const EntryIndex& fmpe,int column) const
|
||||||
{
|
{
|
||||||
switch(fmpe.type)
|
switch(fmpe.type)
|
||||||
{
|
{
|
||||||
case ENTRY_TYPE_GROUP: return QVariant(QBrush(mTextColorGroup));
|
case ENTRY_TYPE_GROUP: return QVariant(QBrush(mTextColorGroup));
|
||||||
case ENTRY_TYPE_PROFILE:
|
case ENTRY_TYPE_PROFILE:
|
||||||
case ENTRY_TYPE_NODE: return QVariant(QBrush(mTextColorStatus[ onlineRole(fmpe,column).toBool() ?RS_STATUS_ONLINE:RS_STATUS_OFFLINE]));
|
case ENTRY_TYPE_NODE: return QVariant(QBrush(mTextColorStatus[onlineRole(fmpe,column).toInt()]));
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsFriendListModel::statusRole(const EntryIndex& /*fmpe*/,int /*column*/) const
|
QVariant RsFriendListModel::statusRole(const EntryIndex& /*fmpe*/,int /*column*/) const
|
||||||
@ -545,47 +545,51 @@ QVariant RsFriendListModel::sortRole(const EntryIndex& entry,int column) const
|
|||||||
|
|
||||||
QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const
|
QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const
|
||||||
{
|
{
|
||||||
switch(e.type)
|
switch(e.type)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ENTRY_TYPE_GROUP:
|
case ENTRY_TYPE_GROUP:
|
||||||
{
|
|
||||||
const HierarchicalGroupInformation& g(mGroups[e.group_index]);
|
|
||||||
|
|
||||||
for(uint32_t j=0;j<g.child_profile_indices.size();++j)
|
|
||||||
{
|
{
|
||||||
const HierarchicalProfileInformation& prof = mProfiles[g.child_profile_indices[j]];
|
const HierarchicalGroupInformation& g(mGroups[e.group_index]);
|
||||||
|
|
||||||
for(uint32_t i=0;i<prof.child_node_indices.size();++i)
|
for(uint32_t j=0;j<g.child_profile_indices.size();++j)
|
||||||
if(mLocations[prof.child_node_indices[i]].node_info.state & RS_PEER_STATE_CONNECTED)
|
{
|
||||||
return QVariant(true);
|
const HierarchicalProfileInformation& prof = mProfiles[g.child_profile_indices[j]];
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<prof.child_node_indices.size();++i)
|
||||||
|
if(mLocations[prof.child_node_indices[i]].node_info.state & RS_PEER_STATE_CONNECTED)
|
||||||
|
return QVariant(RS_STATUS_ONLINE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return QVariant(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
case ENTRY_TYPE_PROFILE:
|
case ENTRY_TYPE_PROFILE:
|
||||||
{
|
{
|
||||||
const HierarchicalProfileInformation *prof = getProfileInfo(e);
|
const HierarchicalProfileInformation *prof = getProfileInfo(e);
|
||||||
|
|
||||||
if(!prof)
|
if(prof)
|
||||||
return QVariant();
|
{
|
||||||
|
for(uint32_t i=0;i<prof->child_node_indices.size();++i)
|
||||||
|
if(mLocations[prof->child_node_indices[i]].node_info.state & RS_PEER_STATE_CONNECTED)
|
||||||
|
return QVariant(RS_STATUS_ONLINE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
for(uint32_t i=0;i<prof->child_node_indices.size();++i)
|
case ENTRY_TYPE_NODE:
|
||||||
if(mLocations[prof->child_node_indices[i]].node_info.state & RS_PEER_STATE_CONNECTED)
|
{
|
||||||
return QVariant(true);
|
const HierarchicalNodeInformation *node = getNodeInfo(e);
|
||||||
|
|
||||||
return QVariant();
|
if(node)
|
||||||
}
|
{
|
||||||
break;
|
StatusInfo status;
|
||||||
|
rsStatus->getStatus(node->node_info.id, status);
|
||||||
|
|
||||||
case ENTRY_TYPE_NODE:
|
return QVariant(status.status);
|
||||||
const HierarchicalNodeInformation *node = getNodeInfo(e);
|
}
|
||||||
|
}
|
||||||
if(!node)
|
|
||||||
return QVariant();
|
|
||||||
|
|
||||||
return QVariant(bool(node->node_info.state & RS_PEER_STATE_CONNECTED));
|
|
||||||
}
|
}
|
||||||
|
return QVariant(RS_STATUS_OFFLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsFriendListModel::fontRole(const EntryIndex& e, int col) const
|
QVariant RsFriendListModel::fontRole(const EntryIndex& e, int col) const
|
||||||
@ -594,17 +598,23 @@ QVariant RsFriendListModel::fontRole(const EntryIndex& e, int col) const
|
|||||||
std::cerr << " font role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": " << std::endl;
|
std::cerr << " font role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool b = onlineRole(e,col).toBool();
|
int status = onlineRole(e,col).toInt();
|
||||||
|
|
||||||
if(b)
|
switch (status)
|
||||||
{
|
{
|
||||||
QFont font ;
|
case RS_STATUS_AWAY:
|
||||||
font.setBold(b);
|
case RS_STATUS_BUSY:
|
||||||
|
case RS_STATUS_ONLINE:
|
||||||
|
case RS_STATUS_INACTIVE:
|
||||||
|
{
|
||||||
|
QFont font ;
|
||||||
|
font.setBold(true);
|
||||||
|
|
||||||
return QVariant(font);
|
return QVariant(font);
|
||||||
}
|
}
|
||||||
else
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AutoEndel
|
class AutoEndel
|
||||||
@ -617,7 +627,6 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
|
|||||||
{
|
{
|
||||||
#ifdef DEBUG_MODEL_INDEX
|
#ifdef DEBUG_MODEL_INDEX
|
||||||
std::cerr << " Display role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": ";
|
std::cerr << " Display role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": ";
|
||||||
AutoEndel x;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch(e.type)
|
switch(e.type)
|
||||||
@ -651,7 +660,7 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
|
|||||||
else
|
else
|
||||||
return QVariant(QString::fromUtf8(group->group_info.name.c_str()));
|
return QVariant(QString::fromUtf8(group->group_info.name.c_str()));
|
||||||
|
|
||||||
case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(group->group_info.id.toStdString()));
|
//case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(group->group_info.id.toStdString()));
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -724,8 +733,15 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
|
|||||||
{
|
{
|
||||||
std::string css = rsMsgs->getCustomStateString(node->node_info.id);
|
std::string css = rsMsgs->getCustomStateString(node->node_info.id);
|
||||||
|
|
||||||
if(!css.empty() && mDisplayStatusString)
|
if (mDisplayStatusString)
|
||||||
return QVariant(QString::fromUtf8(node->node_info.location.c_str())+"\n"+QString::fromUtf8(css.c_str()));
|
if(!css.empty())
|
||||||
|
return QVariant(QString::fromUtf8(node->node_info.location.c_str())+"\n"
|
||||||
|
+ QString::fromUtf8(css.c_str()));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QVariant(QString::fromUtf8(node->node_info.location.c_str())+"\n"
|
||||||
|
+ "(" + StatusDefs::name(onlineRole(e,col).toInt()) + ")");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return QVariant(QString::fromUtf8(node->node_info.location.c_str()));
|
return QVariant(QString::fromUtf8(node->node_info.location.c_str()));
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "gui/chat/ChatDialog.h"
|
#include "gui/chat/ChatDialog.h"
|
||||||
#include "gui/common/AvatarDefs.h"
|
#include "gui/common/AvatarDefs.h"
|
||||||
#include "gui/common/FilesDefs.h"
|
#include "gui/common/FilesDefs.h"
|
||||||
|
#include "gui/common/RSElidedItemDelegate.h"
|
||||||
|
|
||||||
#include "gui/connect/ConfCertDialog.h"
|
#include "gui/connect/ConfCertDialog.h"
|
||||||
#include "gui/connect/PGPKeyDialog.h"
|
#include "gui/connect/PGPKeyDialog.h"
|
||||||
@ -106,44 +107,45 @@ Q_DECLARE_METATYPE(ElidedLabel*)
|
|||||||
class FriendListSortFilterProxyModel: public QSortFilterProxyModel
|
class FriendListSortFilterProxyModel: public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FriendListSortFilterProxyModel(const QHeaderView *header,QObject *parent = NULL): QSortFilterProxyModel(parent),
|
explicit FriendListSortFilterProxyModel(const QHeaderView *header,QObject *parent = NULL)
|
||||||
m_header(header),
|
: QSortFilterProxyModel(parent)
|
||||||
m_sortingEnabled(false),
|
, m_header(header)
|
||||||
m_showOfflineNodes(true) {}
|
, m_sortingEnabled(false), m_sortByState(false)
|
||||||
|
, m_showOfflineNodes(true) {}
|
||||||
|
|
||||||
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
|
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
|
||||||
{
|
{
|
||||||
bool is_group_1 = left.data(RsFriendListModel::TypeRole).toUInt() == (uint)RsFriendListModel::ENTRY_TYPE_GROUP;
|
bool is_group_1 = left.data(RsFriendListModel::TypeRole).toUInt() == (uint)RsFriendListModel::ENTRY_TYPE_GROUP;
|
||||||
bool is_group_2 = right.data(RsFriendListModel::TypeRole).toUInt() == (uint)RsFriendListModel::ENTRY_TYPE_GROUP;
|
bool is_group_2 = right.data(RsFriendListModel::TypeRole).toUInt() == (uint)RsFriendListModel::ENTRY_TYPE_GROUP;
|
||||||
|
|
||||||
if(is_group_1 ^ is_group_2) // if the two are different, put the group first.
|
if(is_group_1 ^ is_group_2) // if the two are different, put the group first.
|
||||||
return is_group_1 ;
|
return is_group_1 ;
|
||||||
|
|
||||||
bool online1 = left .data(RsFriendListModel::OnlineRole).toBool();
|
bool online1 = (left .data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE);
|
||||||
bool online2 = right.data(RsFriendListModel::OnlineRole).toBool();
|
bool online2 = (right.data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE);
|
||||||
|
|
||||||
if(online1 != online2 && m_sortByState)
|
if(online1 != online2 && m_sortByState)
|
||||||
return (m_header->sortIndicatorOrder()==Qt::AscendingOrder)?online1:online2 ; // always put online nodes first
|
return (m_header->sortIndicatorOrder()==Qt::AscendingOrder)?online1:online2 ; // always put online nodes first
|
||||||
|
|
||||||
return left.data(RsFriendListModel::SortRole) < right.data(RsFriendListModel::SortRole) ;
|
return left.data(RsFriendListModel::SortRole) < right.data(RsFriendListModel::SortRole) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
|
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
|
||||||
{
|
{
|
||||||
// do not show empty groups
|
// do not show empty groups
|
||||||
|
|
||||||
QModelIndex index = sourceModel()->index(source_row,0,source_parent);
|
QModelIndex index = sourceModel()->index(source_row,0,source_parent);
|
||||||
|
|
||||||
if(index.data(RsFriendListModel::TypeRole) == RsFriendListModel::ENTRY_TYPE_GROUP) // always show groups, so we can delete them even when empty
|
if(index.data(RsFriendListModel::TypeRole) == RsFriendListModel::ENTRY_TYPE_GROUP) // always show groups, so we can delete them even when empty
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Filter offline friends
|
// Filter offline friends
|
||||||
|
|
||||||
if(!m_showOfflineNodes && !index.data(RsFriendListModel::OnlineRole).toBool())
|
if(!m_showOfflineNodes && (index.data(RsFriendListModel::OnlineRole).toInt() == RS_STATUS_OFFLINE))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return index.data(RsFriendListModel::FilterRole).toString() == RsFriendListModel::FilterString ;
|
return index.data(RsFriendListModel::FilterRole).toString() == RsFriendListModel::FilterString ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override
|
void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override
|
||||||
{
|
{
|
||||||
@ -187,7 +189,9 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par
|
|||||||
mProxyModel->setFilterRole(RsFriendListModel::FilterRole);
|
mProxyModel->setFilterRole(RsFriendListModel::FilterRole);
|
||||||
mProxyModel->setFilterRegExp(QRegExp(RsFriendListModel::FilterString));
|
mProxyModel->setFilterRegExp(QRegExp(RsFriendListModel::FilterString));
|
||||||
|
|
||||||
ui->peerTreeWidget->setModel(mProxyModel);
|
ui->peerTreeWidget->setModel(mProxyModel);
|
||||||
|
ui->peerTreeWidget->setItemDelegate(new RSElidedItemDelegate());
|
||||||
|
ui->peerTreeWidget->setWordWrap(false);
|
||||||
|
|
||||||
/* Add filter actions */
|
/* Add filter actions */
|
||||||
QString headerText = mModel->headerData(RsFriendListModel::COLUMN_THREAD_NAME,Qt::Horizontal,Qt::DisplayRole).toString();
|
QString headerText = mModel->headerData(RsFriendListModel::COLUMN_THREAD_NAME,Qt::Horizontal,Qt::DisplayRole).toString();
|
||||||
@ -1255,7 +1259,7 @@ bool NewFriendList::exportFriendlist(QString &fileName)
|
|||||||
|
|
||||||
QDomElement pgpIDs = doc.createElement("pgpIDs");
|
QDomElement pgpIDs = doc.createElement("pgpIDs");
|
||||||
RsPeerDetails detailPGP;
|
RsPeerDetails detailPGP;
|
||||||
for(std::list<RsPgpId>::iterator list_iter = gpg_ids.begin(); list_iter != gpg_ids.end(); list_iter++) {
|
for(std::list<RsPgpId>::iterator list_iter = gpg_ids.begin(); list_iter != gpg_ids.end(); ++list_iter) {
|
||||||
rsPeers->getGPGDetails(*list_iter, detailPGP);
|
rsPeers->getGPGDetails(*list_iter, detailPGP);
|
||||||
QDomElement pgpID = doc.createElement("pgpID");
|
QDomElement pgpID = doc.createElement("pgpID");
|
||||||
// these values aren't used and just stored for better human readability
|
// these values aren't used and just stored for better human readability
|
||||||
@ -1264,9 +1268,9 @@ bool NewFriendList::exportFriendlist(QString &fileName)
|
|||||||
|
|
||||||
std::list<RsPeerId> ssl_ids;
|
std::list<RsPeerId> ssl_ids;
|
||||||
rsPeers->getAssociatedSSLIds(*list_iter, ssl_ids);
|
rsPeers->getAssociatedSSLIds(*list_iter, ssl_ids);
|
||||||
for(std::list<RsPeerId>::iterator list_iter = ssl_ids.begin(); list_iter != ssl_ids.end(); list_iter++) {
|
for(std::list<RsPeerId>::iterator list_iter2 = ssl_ids.begin(); list_iter2 != ssl_ids.end(); ++list_iter2) {
|
||||||
RsPeerDetails detailSSL;
|
RsPeerDetails detailSSL;
|
||||||
if (!rsPeers->getPeerDetails(*list_iter, detailSSL))
|
if (!rsPeers->getPeerDetails(*list_iter2, detailSSL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::string certificate = rsPeers->GetRetroshareInvite(detailSSL.id, RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::DNS | RetroshareInviteFlags::RADIX_FORMAT);
|
std::string certificate = rsPeers->GetRetroshareInvite(detailSSL.id, RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::DNS | RetroshareInviteFlags::RADIX_FORMAT);
|
||||||
@ -1291,7 +1295,7 @@ bool NewFriendList::exportFriendlist(QString &fileName)
|
|||||||
root.appendChild(pgpIDs);
|
root.appendChild(pgpIDs);
|
||||||
|
|
||||||
QDomElement groups = doc.createElement("groups");
|
QDomElement groups = doc.createElement("groups");
|
||||||
for(std::list<RsGroupInfo>::iterator list_iter = group_info_list.begin(); list_iter != group_info_list.end(); list_iter++) {
|
for(std::list<RsGroupInfo>::iterator list_iter = group_info_list.begin(); list_iter != group_info_list.end(); ++list_iter) {
|
||||||
RsGroupInfo group_info = *list_iter;
|
RsGroupInfo group_info = *list_iter;
|
||||||
|
|
||||||
//skip groups without peers
|
//skip groups without peers
|
||||||
@ -1303,7 +1307,7 @@ bool NewFriendList::exportFriendlist(QString &fileName)
|
|||||||
group.setAttribute("name", QString::fromUtf8(group_info.name.c_str()));
|
group.setAttribute("name", QString::fromUtf8(group_info.name.c_str()));
|
||||||
group.setAttribute("flag", group_info.flag);
|
group.setAttribute("flag", group_info.flag);
|
||||||
|
|
||||||
for(std::set<RsPgpId>::iterator i = group_info.peerIds.begin(); i != group_info.peerIds.end(); i++) {
|
for(std::set<RsPgpId>::iterator i = group_info.peerIds.begin(); i != group_info.peerIds.end(); ++i) {
|
||||||
QDomElement pgpID = doc.createElement("pgpID");
|
QDomElement pgpID = doc.createElement("pgpID");
|
||||||
std::string pid = i->toStdString();
|
std::string pid = i->toStdString();
|
||||||
pgpID.setAttribute("id", QString::fromStdString(pid));
|
pgpID.setAttribute("id", QString::fromStdString(pid));
|
||||||
@ -1344,6 +1348,9 @@ static void showXMLParsingError()
|
|||||||
*/
|
*/
|
||||||
bool NewFriendList::importFriendlist(QString &fileName, bool &errorPeers, bool &errorGroups)
|
bool NewFriendList::importFriendlist(QString &fileName, bool &errorPeers, bool &errorGroups)
|
||||||
{
|
{
|
||||||
|
errorPeers = false;
|
||||||
|
errorGroups = false;
|
||||||
|
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
// load from file
|
// load from file
|
||||||
{
|
{
|
||||||
@ -1375,10 +1382,6 @@ bool NewFriendList::importFriendlist(QString &fileName, bool &errorPeers, bool &
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
errorPeers = false;
|
|
||||||
errorGroups = false;
|
|
||||||
|
|
||||||
std::string error_string;
|
|
||||||
RsPeerDetails rsPeerDetails;
|
RsPeerDetails rsPeerDetails;
|
||||||
RsPeerId rsPeerID;
|
RsPeerId rsPeerID;
|
||||||
RsPgpId rsPgpID;
|
RsPgpId rsPgpID;
|
||||||
|
@ -309,21 +309,21 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
|
|
||||||
// draw the check mark
|
// draw the check mark
|
||||||
if (ownOption.features & QStyleOptionViewItem::HasCheckIndicator) {
|
if (ownOption.features & QStyleOptionViewItem::HasCheckIndicator) {
|
||||||
QStyleOptionViewItem option(*&ownOption);
|
QStyleOptionViewItem cmOption(*&ownOption);
|
||||||
option.rect = checkRect;
|
cmOption.rect = checkRect;
|
||||||
option.state = option.state & ~QStyle::State_HasFocus;
|
cmOption.state = cmOption.state & ~QStyle::State_HasFocus;
|
||||||
switch (ownOption.checkState) {
|
switch (ownOption.checkState) {
|
||||||
case Qt::Unchecked:
|
case Qt::Unchecked:
|
||||||
option.state |= QStyle::State_Off;
|
cmOption.state |= QStyle::State_Off;
|
||||||
break;
|
break;
|
||||||
case Qt::PartiallyChecked:
|
case Qt::PartiallyChecked:
|
||||||
option.state |= QStyle::State_NoChange;
|
cmOption.state |= QStyle::State_NoChange;
|
||||||
break;
|
break;
|
||||||
case Qt::Checked:
|
case Qt::Checked:
|
||||||
option.state |= QStyle::State_On;
|
cmOption.state |= QStyle::State_On;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ownStyle->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck, &option, painter, widget);
|
ownStyle->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck, &cmOption, painter, widget);
|
||||||
}
|
}
|
||||||
// draw the icon
|
// draw the icon
|
||||||
{
|
{
|
||||||
@ -340,7 +340,7 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
mode = QIcon::Disabled;
|
mode = QIcon::Disabled;
|
||||||
else if (ownOption.state & QStyle::State_Selected)
|
else if (ownOption.state & QStyle::State_Selected)
|
||||||
mode = QIcon::Selected;
|
mode = QIcon::Selected;
|
||||||
QIcon::State state = ownOption.state & QStyle::State_Open ? QIcon::On : QIcon::Off;
|
QIcon::State state = (ownOption.state & QStyle::State_Open) ? QIcon::On : QIcon::Off;
|
||||||
ownOption.icon.paint(painter, iconRect, ownOption.decorationAlignment, mode, state);
|
ownOption.icon.paint(painter, iconRect, ownOption.decorationAlignment, mode, state);
|
||||||
}
|
}
|
||||||
// Then overlay with waiting
|
// Then overlay with waiting
|
||||||
@ -380,11 +380,12 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
|
|
||||||
QTextLayout textLayout(ownOption.text, painter->font());
|
QTextLayout textLayout(ownOption.text, painter->font());
|
||||||
QTextOption to = textLayout.textOption();
|
QTextOption to = textLayout.textOption();
|
||||||
|
to.setWrapMode((ownOption.features & QStyleOptionViewItem::WrapText) ? QTextOption::WordWrap : QTextOption::NoWrap);
|
||||||
const int textHMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
|
const int textHMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
|
||||||
const int textVMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameVMargin, nullptr, widget) + 1;
|
const int textVMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameVMargin, nullptr, widget) + 1;
|
||||||
textRect = textRect.adjusted(textHMargin, textVMargin, -textHMargin, -textVMargin); // remove width padding
|
textRect = textRect.adjusted(textHMargin, textVMargin, -textHMargin, -textVMargin); // remove width padding
|
||||||
|
|
||||||
StyledElidedLabel::paintElidedLine(painter,ownOption.text,textRect,ownOption.font,ownOption.displayAlignment,to.wrapMode()&QTextOption::WordWrap,mPaintRoundedRect);
|
StyledElidedLabel::paintElidedLine(painter,ownOption.text,textRect,ownOption.font,ownOption.displayAlignment,to.wrapMode(),mPaintRoundedRect);
|
||||||
}
|
}
|
||||||
painter->restore();
|
painter->restore();
|
||||||
#ifdef DEBUG_EID_PAINT
|
#ifdef DEBUG_EID_PAINT
|
||||||
@ -400,6 +401,7 @@ bool RSElidedItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
|||||||
if (ev->buttons()==Qt::LeftButton) {
|
if (ev->buttons()==Qt::LeftButton) {
|
||||||
#ifdef DEBUG_EID_PAINT
|
#ifdef DEBUG_EID_PAINT
|
||||||
QVariant var = index.data();
|
QVariant var = index.data();
|
||||||
|
Q_UNUSED(var);
|
||||||
#endif
|
#endif
|
||||||
if (index.data().type() == QVariant::String) {
|
if (index.data().type() == QVariant::String) {
|
||||||
QString text = index.data().toString();
|
QString text = index.data().toString();
|
||||||
@ -430,10 +432,11 @@ bool RSElidedItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
|||||||
|
|
||||||
QTextLayout textLayout(text, ownOption.font);
|
QTextLayout textLayout(text, ownOption.font);
|
||||||
QTextOption to = textLayout.textOption();
|
QTextOption to = textLayout.textOption();
|
||||||
|
to.setWrapMode((ownOption.features & QStyleOptionViewItem::WrapText) ? QTextOption::WordWrap : QTextOption::NoWrap);
|
||||||
|
|
||||||
//Update RSElidedItemDelegate as only one delegate for all items
|
//Update RSElidedItemDelegate as only one delegate for all items
|
||||||
QRect rectElision;
|
QRect rectElision;
|
||||||
bool elided = StyledElidedLabel::paintElidedLine(nullptr,text,textRect,ownOption.font,ownOption.displayAlignment,to.wrapMode()&QTextOption::WordWrap,true,&rectElision);
|
bool elided = StyledElidedLabel::paintElidedLine(nullptr,text,textRect,ownOption.font,ownOption.displayAlignment,to.wrapMode(),true,&rectElision);
|
||||||
if (elided && (rectElision.contains(ev->pos()))){
|
if (elided && (rectElision.contains(ev->pos()))){
|
||||||
QToolTip::showText(ev->globalPos(),QString("<FONT>") + text + QString("</FONT>"));
|
QToolTip::showText(ev->globalPos(),QString("<FONT>") + text + QString("</FONT>"));
|
||||||
return true; // eat event
|
return true; // eat event
|
||||||
|
@ -25,11 +25,11 @@ FriendSelectionWidget
|
|||||||
|
|
||||||
NewFriendList
|
NewFriendList
|
||||||
{
|
{
|
||||||
qproperty-textColorStatusOffline: white;
|
qproperty-textColorStatusAway: #4040A0;
|
||||||
qproperty-textColorStatusAway: gray;
|
qproperty-textColorStatusBusy: #A04040;
|
||||||
qproperty-textColorStatusBusy: gray;
|
qproperty-textColorStatusOnline: #40A040;
|
||||||
qproperty-textColorStatusOnline: lightBlue;
|
qproperty-textColorStatusInactive: #A0A040;
|
||||||
qproperty-textColorStatusInactive: gray;
|
qproperty-textColorStatusOffline: gray;
|
||||||
qproperty-textColorGroup: rgb(123, 123, 123);
|
qproperty-textColorGroup: rgb(123, 123, 123);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1945,11 +1945,12 @@ PlotWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NewFriendList {
|
NewFriendList {
|
||||||
qproperty-textColorStatusAway: lightgray;
|
qproperty-textColorStatusAway: #4040A0;
|
||||||
qproperty-textColorStatusBusy: lightgray;
|
qproperty-textColorStatusBusy: #A04040;
|
||||||
qproperty-textColorStatusOnline: green;
|
qproperty-textColorStatusOnline: #40A040;
|
||||||
qproperty-textColorStatusInactive: lightgray;
|
qproperty-textColorStatusInactive: #A0A040;
|
||||||
qproperty-textColorStatusOffline: gray;
|
qproperty-textColorStatusOffline: gray;
|
||||||
|
qproperty-textColorGroup: rgb(123, 123, 123);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkDialog {
|
NetworkDialog {
|
||||||
|
@ -849,11 +849,12 @@ QDockWidget::close-button:pressed, QDockWidget::float-button:pressed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NewFriendList {
|
NewFriendList {
|
||||||
qproperty-textColorStatusAway: lightgray;
|
qproperty-textColorStatusAway: #4040A0;
|
||||||
qproperty-textColorStatusBusy: lightgray;
|
qproperty-textColorStatusBusy: #A04040;
|
||||||
qproperty-textColorStatusOnline: green;
|
qproperty-textColorStatusOnline: #40A040;
|
||||||
qproperty-textColorStatusInactive: lightgray;
|
qproperty-textColorStatusInactive: #A0A040;
|
||||||
qproperty-textColorStatusOffline: gray;
|
qproperty-textColorStatusOffline: gray;
|
||||||
|
qproperty-textColorGroup: rgb(123, 123, 123);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeView, QListView
|
QTreeView, QListView
|
||||||
|
Loading…
Reference in New Issue
Block a user