Added subscribe flags to GroupTreeWidget.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5906 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-11-28 12:31:14 +00:00
parent 25de47c6f9
commit ef9ebf4cf3
4 changed files with 32 additions and 31 deletions

View File

@ -133,27 +133,17 @@ void GxsForumsDialog::processSettings(bool bLoad)
Settings->endGroup();
}
int GxsForumsDialog::subscribeFlags(const std::string &forumId)
{
QMap<std::string, int>::const_iterator it = mSubscribeFlags.find(mForumId);
if (it != mSubscribeFlags.end()) {
return it.value();
}
return 0;
}
void GxsForumsDialog::forumListCustomPopupMenu(QPoint /*point*/)
{
int flags = subscribeFlags(mForumId);
int subscribeFlags = ui.forumTreeWidget->subscribeFlags(QString::fromStdString(mForumId));
QMenu contextMnu(this);
QAction *action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe to Forum"), this, SLOT(subscribeToForum()));
action->setDisabled (mForumId.empty() || IS_GROUP_SUBSCRIBED(flags));
action->setDisabled (mForumId.empty() || IS_GROUP_SUBSCRIBED(subscribeFlags));
action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe to Forum"), this, SLOT(unsubscribeToForum()));
action->setEnabled (!mForumId.empty() && IS_GROUP_SUBSCRIBED(flags));
action->setEnabled (!mForumId.empty() && IS_GROUP_SUBSCRIBED(subscribeFlags));
contextMnu.addSeparator();
@ -163,16 +153,16 @@ void GxsForumsDialog::forumListCustomPopupMenu(QPoint /*point*/)
action->setEnabled (!mForumId.empty ());
action = contextMnu.addAction(QIcon(":/images/settings16.png"), tr("Edit Forum Details"), this, SLOT(editForumDetails()));
action->setEnabled (!mForumId.empty () && IS_GROUP_ADMIN(flags));
action->setEnabled (!mForumId.empty () && IS_GROUP_ADMIN(subscribeFlags));
QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Forum"), &contextMnu);
connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) );
shareKeyAct->setEnabled(!mForumId.empty() && IS_GROUP_ADMIN(flags));
shareKeyAct->setEnabled(!mForumId.empty() && IS_GROUP_ADMIN(subscribeFlags));
contextMnu.addAction( shareKeyAct);
QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Forum" ), &contextMnu);
connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreForumKeys() ) );
restoreKeysAct->setEnabled(!mForumId.empty() && !IS_GROUP_ADMIN(flags));
restoreKeysAct->setEnabled(!mForumId.empty() && !IS_GROUP_ADMIN(subscribeFlags));
contextMnu.addAction( restoreKeysAct);
action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyForumLink()));
@ -181,10 +171,10 @@ void GxsForumsDialog::forumListCustomPopupMenu(QPoint /*point*/)
contextMnu.addSeparator();
action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsReadAll()));
action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(flags));
action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags));
action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnreadAll()));
action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(flags));
action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags));
#ifdef DEBUG_FORUMS
contextMnu.addSeparator();
@ -256,6 +246,7 @@ void GxsForumsDialog::forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo,
//groupItemInfo.description = QString::fromUtf8(forumInfo.forumDesc);
groupItemInfo.popularity = forumInfo.mPop;
groupItemInfo.lastpost = QDateTime::fromTime_t(forumInfo.mLastPost);
groupItemInfo.subscribeFlags = forumInfo.mSubscribeFlags;
#if TOGXS
if (forumInfo.mGroupFlags & RS_DISTRIB_AUTHEN_REQ) {
@ -285,8 +276,6 @@ void GxsForumsDialog::forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo,
/***** INSERT FORUM LISTS *****/
void GxsForumsDialog::insertForumsData(const std::list<RsGroupMetaData> &forumList)
{
mSubscribeFlags.clear();
std::list<RsGroupMetaData>::const_iterator it;
QList<GroupItemInfo> adminList;
@ -299,9 +288,6 @@ void GxsForumsDialog::insertForumsData(const std::list<RsGroupMetaData> &forumLi
/* sort it into Publish (Own), Subscribed, Popular and Other */
uint32_t flags = it->mSubscribeFlags;
/* store for later use with poll */
mSubscribeFlags[it->mGroupId] = flags;
GroupItemInfo groupItemInfo;
forumInfoToGroupItemInfo(*it, groupItemInfo);

View File

@ -86,7 +86,6 @@ private slots:
private:
void insertForums();
int subscribeFlags(const std::string &forumId);
void updateMessageSummaryList(std::string forumId);
// void forumInfoToGroupItemInfo(const ForumInfo &forumInfo, GroupItemInfo &groupItemInfo);
@ -106,7 +105,6 @@ private:
// void loadGroupSummary_CurrentForum(const uint32_t &token);
std::string mForumId;
QMap<std::string, int> mSubscribeFlags;
TokenQueue *mForumQueue;
QTreeWidgetItem *yourForums;

View File

@ -43,6 +43,7 @@
#define ROLE_POPULARITY Qt::UserRole + 3
#define ROLE_LASTPOST Qt::UserRole + 4
#define ROLE_SEARCH_SCORE Qt::UserRole + 5
#define ROLE_SUBSCRIBE_FLAGS Qt::UserRole + 6
#define COMBO_NAME_INDEX 0
#define COMBO_DESC_INDEX 1
@ -299,6 +300,8 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
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.privatekey) {
@ -390,6 +393,16 @@ QTreeWidgetItem *GroupTreeWidget::activateId(const QString &id, bool focus)
return item;
}
int GroupTreeWidget::subscribeFlags(const QString &id)
{
QTreeWidgetItem *item = getItemFromId(id);
if (item == NULL) {
return 0;
}
return item->data(COLUMN_DATA, ROLE_SUBSCRIBE_FLAGS).toInt();
}
void GroupTreeWidget::calculateScore(QTreeWidgetItem *item, const QString &filterText)
{
if (item) {

View File

@ -42,6 +42,7 @@ public:
{
popularity = 0;
privatekey = false;
subscribeFlags = 0;
}
public:
@ -52,6 +53,7 @@ public:
QDateTime lastpost;
QIcon icon;
bool privatekey;
int subscribeFlags;
};
class GroupTreeWidget : public QWidget
@ -79,6 +81,8 @@ public:
QTreeWidgetItem *getItemFromId(const QString &id);
QTreeWidgetItem *activateId(const QString &id, bool focus);
int subscribeFlags(const QString &id);
signals:
void treeCustomContextMenuRequested(const QPoint &pos);
void treeCurrentItemChanged(const QString &id);