improved naming of publish/admin rights in GroupTreeWidget

This commit is contained in:
csoler 2016-06-16 22:23:27 -04:00
parent 8d54603b02
commit b9ba51f2ba
6 changed files with 110 additions and 108 deletions

View File

@ -102,6 +102,7 @@ namespace GXS_SERV {
// GENERIC GXS MACROS
#define IS_MSG_NEW(status) (status & GXS_SERV::GXS_MSG_STATUS_GUI_NEW)
#define IS_MSG_UNREAD(status) (status & GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD)
#define IS_MSG_UNPROCESSED(status) (status & GXS_SERV::GXS_MSG_STATUS_UNPROCESSED)
#define IS_GROUP_PGP_AUTHED(signFlags) (signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG)
#define IS_GROUP_MESSAGE_TRACKING(signFlags) (signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES)
@ -111,7 +112,4 @@ namespace GXS_SERV {
#define IS_GROUP_SUBSCRIBED(subscribeFlags) (subscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)
#define IS_GROUP_NOT_SUBSCRIBED(subscribeFlags) (subscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_NOT_SUBSCRIBED)
#define IS_MSG_UNPROCESSED(status) (status & GXS_SERV::GXS_MSG_STATUS_UNPROCESSED)
#endif // RSGXSFLAGS_H

View File

@ -334,112 +334,114 @@ QString GroupTreeWidget::itemIdAt(QPoint &point)
void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<GroupItemInfo> &itemList)
{
if (categoryItem == NULL) {
return;
}
QString filterText = ui->filterLineEdit->text();
/* Iterate all items */
QList<GroupItemInfo>::const_iterator it;
for (it = itemList.begin(); it != itemList.end(); ++it) {
const GroupItemInfo &itemInfo = *it;
QTreeWidgetItem *item = NULL;
/* Search exisiting item */
int childCount = categoryItem->childCount();
for (int child = 0; child < childCount; ++child) {
QTreeWidgetItem *childItem = categoryItem->child(child);
if (childItem->data(COLUMN_DATA, ROLE_ID).toString() == itemInfo.id) {
/* Found child */
item = childItem;
break;
}
}
if (item == NULL) {
item = new RSTreeWidgetItem(compareRole);
item->setData(COLUMN_DATA, ROLE_ID, itemInfo.id);
categoryItem->addChild(item);
}
item->setText(COLUMN_NAME, itemInfo.name);
item->setData(COLUMN_DATA, ROLE_NAME, itemInfo.name);
item->setData(COLUMN_DATA, ROLE_DESCRIPTION, itemInfo.description);
/* Set last post */
qlonglong lastPost = itemInfo.lastpost.toTime_t();
item->setData(COLUMN_DATA, ROLE_LASTPOST, -lastPost); // negative for correct sorting
/* Set visible posts */
item->setData(COLUMN_DATA, ROLE_POSTS, -itemInfo.max_visible_posts);// negative for correct sorting
/* Set icon */
if (ui->treeWidget->itemWidget(item, COLUMN_NAME)) {
/* Item is waiting, save icon in role */
item->setData(COLUMN_DATA, ROLE_SAVED_ICON, itemInfo.icon);
} else {
item->setIcon(COLUMN_NAME, itemInfo.icon);
}
/* Set popularity */
QString tooltip = PopularityDefs::tooltip(itemInfo.popularity);
item->setIcon(COLUMN_POPULARITY, PopularityDefs::icon(itemInfo.popularity));
item->setData(COLUMN_DATA, ROLE_POPULARITY, -itemInfo.popularity); // negative for correct sorting
/* Set tooltip */
if (itemInfo.privatekey) {
tooltip += "\n" + tr("You have admin rights");
}
if(!IS_GROUP_SUBSCRIBED(itemInfo.subscribeFlags))
{
tooltip += "\n" + QString::number(itemInfo.max_visible_posts) + " messages available" ;
tooltip += "\n" + tr("Subscribe to download and read messages") ;
if (categoryItem == NULL) {
return;
}
item->setToolTip(COLUMN_NAME, tooltip);
item->setToolTip(COLUMN_POPULARITY, tooltip);
QString filterText = ui->filterLineEdit->text();
item->setData(COLUMN_DATA, ROLE_SUBSCRIBE_FLAGS, itemInfo.subscribeFlags);
/* Iterate all items */
QList<GroupItemInfo>::const_iterator it;
for (it = itemList.begin(); it != itemList.end(); ++it) {
const GroupItemInfo &itemInfo = *it;
/* Set color */
QBrush brush;
if (itemInfo.privatekey) {
brush = QBrush(textColorPrivateKey());
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_PRIVATEKEY);
} else {
brush = ui->treeWidget->palette().color(QPalette::Text);
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_STANDARD);
}
item->setForeground(COLUMN_NAME, brush);
QTreeWidgetItem *item = NULL;
/* Calculate score */
calculateScore(item, filterText);
}
/* Search exisiting item */
int childCount = categoryItem->childCount();
for (int child = 0; child < childCount; ++child) {
QTreeWidgetItem *childItem = categoryItem->child(child);
if (childItem->data(COLUMN_DATA, ROLE_ID).toString() == itemInfo.id) {
/* Found child */
item = childItem;
break;
}
}
/* Remove all items not in list */
int child = 0;
int childCount = categoryItem->childCount();
while (child < childCount) {
QString id = categoryItem->child(child)->data(COLUMN_DATA, ROLE_ID).toString();
if (item == NULL) {
item = new RSTreeWidgetItem(compareRole);
item->setData(COLUMN_DATA, ROLE_ID, itemInfo.id);
categoryItem->addChild(item);
}
for (it = itemList.begin(); it != itemList.end(); ++it) {
if (it->id == id) {
break;
}
}
item->setText(COLUMN_NAME, itemInfo.name);
item->setData(COLUMN_DATA, ROLE_NAME, itemInfo.name);
item->setData(COLUMN_DATA, ROLE_DESCRIPTION, itemInfo.description);
if (it == itemList.end()) {
delete(categoryItem->takeChild(child));
childCount = categoryItem->childCount();
} else {
++child;
}
}
/* Set last post */
qlonglong lastPost = itemInfo.lastpost.toTime_t();
item->setData(COLUMN_DATA, ROLE_LASTPOST, -lastPost); // negative for correct sorting
resort(categoryItem);
/* Set visible posts */
item->setData(COLUMN_DATA, ROLE_POSTS, -itemInfo.max_visible_posts);// negative for correct sorting
/* Set icon */
if (ui->treeWidget->itemWidget(item, COLUMN_NAME)) {
/* Item is waiting, save icon in role */
item->setData(COLUMN_DATA, ROLE_SAVED_ICON, itemInfo.icon);
} else {
item->setIcon(COLUMN_NAME, itemInfo.icon);
}
/* Set popularity */
QString tooltip = PopularityDefs::tooltip(itemInfo.popularity);
item->setIcon(COLUMN_POPULARITY, PopularityDefs::icon(itemInfo.popularity));
item->setData(COLUMN_DATA, ROLE_POPULARITY, -itemInfo.popularity); // negative for correct sorting
/* Set tooltip */
if (itemInfo.adminKey)
tooltip += "\n" + tr("You are admin (modify names and description using Edit menu)");
else if (itemInfo.publishKey)
tooltip += "\n" + tr("You have been granted as publisher (you can post here!)");
if(!IS_GROUP_SUBSCRIBED(itemInfo.subscribeFlags))
{
tooltip += "\n" + QString::number(itemInfo.max_visible_posts) + " messages available" ;
tooltip += "\n" + tr("Subscribe to download and read messages") ;
}
item->setToolTip(COLUMN_NAME, tooltip);
item->setToolTip(COLUMN_POPULARITY, tooltip);
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);
} else {
brush = ui->treeWidget->palette().color(QPalette::Text);
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_STANDARD);
}
item->setForeground(COLUMN_NAME, brush);
/* Calculate score */
calculateScore(item, filterText);
}
/* Remove all items not in list */
int child = 0;
int childCount = categoryItem->childCount();
while (child < childCount) {
QString id = categoryItem->child(child)->data(COLUMN_DATA, ROLE_ID).toString();
for (it = itemList.begin(); it != itemList.end(); ++it) {
if (it->id == id) {
break;
}
}
if (it == itemList.end()) {
delete(categoryItem->takeChild(child));
childCount = categoryItem->childCount();
} else {
++child;
}
}
resort(categoryItem);
}
void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount)

View File

@ -47,7 +47,7 @@ public:
GroupItemInfo()
{
popularity = 0;
privatekey = false;
publishKey = false;
subscribeFlags = 0;
max_visible_posts =0;
}
@ -59,7 +59,8 @@ public:
int popularity;
QDateTime lastpost;
QIcon icon;
bool privatekey;
bool publishKey;
bool adminKey;
quint32 subscribeFlags;
quint32 max_visible_posts ;
};

View File

@ -286,7 +286,7 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point)
action->setEnabled (!mGroupId.isNull() && isAdmin);
if (shareKeyType()) {
action = contextMnu.addAction(QIcon(IMAGE_SHARE), tr("Share admin permissions"), this, SLOT(shareKey()));
action = contextMnu.addAction(QIcon(IMAGE_SHARE), tr("Share publish permissions"), this, SLOT(sharePublishKey()));
action->setEnabled(!mGroupId.isNull() && isPublisher);
}
@ -429,7 +429,7 @@ void GxsGroupFrameDialog::markMsgAsUnread()
}
}
void GxsGroupFrameDialog::shareKey()
void GxsGroupFrameDialog::sharePublishKey()
{
if (mGroupId.isNull()) {
return;
@ -673,7 +673,8 @@ void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupI
groupItemInfo.popularity = groupInfo.mPop;
groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost);
groupItemInfo.subscribeFlags = groupInfo.mSubscribeFlags;
groupItemInfo.privatekey = IS_GROUP_PUBLISHER(groupInfo.mSubscribeFlags) ;
groupItemInfo.publishKey = IS_GROUP_PUBLISHER(groupInfo.mSubscribeFlags) ;
groupItemInfo.adminKey = IS_GROUP_ADMIN(groupInfo.mSubscribeFlags) ;
groupItemInfo.max_visible_posts = groupInfo.mVisibleMsgCount ;
#if TOGXS

View File

@ -122,7 +122,7 @@ private slots:
void markMsgAsRead();
void markMsgAsUnread();
void shareKey();
void sharePublishKey();
void loadComment(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title);

View File

@ -78,8 +78,8 @@ void GroupShareKey::setTyp()
return;
ui->headerFrame->setHeaderImage(QPixmap(":/images/channels.png"));
ui->headerFrame->setHeaderText(tr("Share channel admin permissions"));
ui->sharekeyinfo_label->setText(tr("You can allow your friends to publish in your channel and to modify the description. Or you can send the admin permissions to another Retroshare instance. Select the friends which you want to be allowed to publish in this channel. Note: it is not possible to revoke channel admin permissions."));
ui->headerFrame->setHeaderText(tr("Share channel publish permissions"));
ui->sharekeyinfo_label->setText(tr("You can allow your friends to publish in your channel, or send the publish permissions to another Retroshare instance of yours. Select the friends which you want to be allowed to publish in this channel. Note: it is currently not possible to revoke channel publish permissions."));
}
else if(mGrpType == FORUM_KEY_SHARE)
{