Пример #1
0
void PostedGroupItem::fill()
{
	/* fill in */

#ifdef DEBUG_ITEM
	std::cerr << "PostedGroupItem::fill()";
	std::cerr << std::endl;
#endif

	// No link type at this moment
    RetroShareLink link;
    link.createGxsGroupLink(RetroShareLink::TYPE_POSTED, mGroup.mMeta.mGroupId, groupName());
    ui->nameLabel->setText(link.toHtml());
//	ui->nameLabel->setText(groupName());

	ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str()));

	//TODO - nice icon for subscribed group
	if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) {
		ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png"));
	} else {
		ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png"));
	}

	if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) {
		ui->subscribeButton->setEnabled(false);
	} else {
		ui->subscribeButton->setEnabled(true);
	}

//	if (mIsNew)
//	{
		ui->titleLabel->setText(tr("New Posted"));
//	}
//	else
//	{
//		ui->titleLabel->setText(tr("Updated Posted"));
//	}

	if (mIsHome)
	{
		/* disable buttons */
		ui->clearButton->setEnabled(false);
	}
}
Пример #2
0
void GxsChannelDialog::insertChannelData(const std::list<RsGroupMetaData> &channelList)
{
	std::list<RsGroupMetaData>::const_iterator it;

	QList<GroupItemInfo> adminList;
	QList<GroupItemInfo> subList;
	QList<GroupItemInfo> popList;
	QList<GroupItemInfo> otherList;
	std::multimap<uint32_t, GroupItemInfo> popMap;

	for(it = channelList.begin(); it != channelList.end(); it++) {
		/* sort it into Publish (Own), Subscribed, Popular and Other */
		uint32_t flags = it->mSubscribeFlags;

		GroupItemInfo groupItemInfo;
		channelInfoToGroupItemInfo(*it, groupItemInfo);

		if (IS_GROUP_SUBSCRIBED(flags)) 
		{
			if (IS_GROUP_ADMIN(flags) || IS_GROUP_PUBLISHER(flags))
			{
				adminList.push_back(groupItemInfo);
			}
			else
			{
				/* subscribed forum */
				subList.push_back(groupItemInfo);
			}
		} 
		else 
		{
			/* rate the others by popularity */
			popMap.insert(std::make_pair(it->mPop, groupItemInfo));
		}
	}

	/* iterate backwards through popMap - take the top 5 or 10% of list */
	uint32_t popCount = 5;
	if (popCount < popMap.size() / 10) 
	{
		popCount = popMap.size() / 10;
	}

	uint32_t i = 0;
	std::multimap<uint32_t, GroupItemInfo>::reverse_iterator rit;
	for (rit = popMap.rbegin(); rit != popMap.rend(); rit++) 
	{
		if (i < popCount) 
		{
			popList.push_back(rit->second);
			i++;
		} 
		else 
		{
			otherList.push_back(rit->second);
		}
	}

	/* now we have our lists ---> update entries */

	ui.treeWidget->fillGroupItems(ownChannels, adminList);
	ui.treeWidget->fillGroupItems(subcribedChannels, subList);
	ui.treeWidget->fillGroupItems(popularChannels, popList);
	ui.treeWidget->fillGroupItems(otherChannels, otherList);

	updateMessageSummaryList("");
}
Пример #3
0
void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ )
{
	if (mChannelId.empty()) 
	{
		return;
	}

	uint32_t subscribeFlags = ui.treeWidget->subscribeFlags(QString::fromStdString(mChannelId));

	QMenu contextMnu(this);

	bool isAdmin = IS_GROUP_ADMIN(subscribeFlags);
	bool isPublisher = IS_GROUP_PUBLISHER(subscribeFlags);
	bool isSubscribed = IS_GROUP_SUBSCRIBED(subscribeFlags);
	bool autoDownload = rsGxsChannels->getChannelAutoDownload(mChannelId);

	if (isPublisher)
	{
		QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), &contextMnu);
		connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) );
	  	contextMnu.addAction( postchannelAct );
		contextMnu.addSeparator();
	}

	if (isSubscribed)
	{
		QAction *setallasreadchannelAct = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Set all as read" ), &contextMnu);
		connect( setallasreadchannelAct , SIGNAL( triggered() ), this, SLOT( setAllAsReadClicked() ) );
		contextMnu.addAction( setallasreadchannelAct );

		contextMnu.addSeparator();

		QAction *autoAct = new QAction(QIcon(":/images/redled.png"), tr( "Disable Auto-Download" ), &contextMnu);
		QAction *noautoAct = new QAction(QIcon(":/images/start.png"),tr( "Enable Auto-Download" ), &contextMnu);
		connect( autoAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) );
		connect( noautoAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) );

		contextMnu.addAction( autoAct );
		contextMnu.addAction( noautoAct );

		autoAct->setEnabled(autoDownload);
		noautoAct->setEnabled(!autoDownload);

		QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), &contextMnu);
		connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) );
		contextMnu.addAction( unsubscribechannelAct );
	}
	else
	{
		QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), &contextMnu);
		connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) );
		contextMnu.addAction( subscribechannelAct );
	}

	if (isAdmin)
	{
		QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu);
		connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) );
		contextMnu.addAction( editChannelDetailAct);
	}
	else
	{
		QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu);
		connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) );
		contextMnu.addAction( channeldetailsAct );
	}

	if (isPublisher)
	{
		QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu);
		connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) );
		contextMnu.addAction( restoreKeysAct );
	}
	else
	{
		QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu);
		connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) );
		contextMnu.addAction( shareKeyAct );
	}

	contextMnu.addSeparator();
	QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink()));
	action->setEnabled(!mChannelId.empty());

	contextMnu.exec(QCursor::pos());

#if 0
	ChannelInfo ci;
	if (!rsChannels->getChannelInfo(mChannelId, ci)) {
		return;
	}

	QMenu contextMnu(this);

	QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), &contextMnu);
	connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) );

	QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), &contextMnu);
	connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) );

	QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), &contextMnu);
	connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) );

	QAction *setallasreadchannelAct = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Set all as read" ), &contextMnu);
	connect( setallasreadchannelAct , SIGNAL( triggered() ), this, SLOT( setAllAsReadClicked() ) );

	bool autoDl = false;
	rsChannels->channelGetAutoDl(mChannelId, autoDl);

	QAction *autochannelAct = autoDl? (new QAction(QIcon(":/images/redled.png"), tr( "Disable Auto-Download" ), &contextMnu))
			 									: (new QAction(QIcon(":/images/start.png"),tr( "Enable Auto-Download" ), &contextMnu)) ;

	connect( autochannelAct , SIGNAL( triggered() ), this, SLOT( toggleAutoDownload() ) );

	QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu);
	connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) );

	QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu);
	connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) );

	QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu);
	connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) );

	QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Channel"), &contextMnu);
	connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) );

	if((ci.channelFlags & RS_DISTRIB_ADMIN) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED))
		contextMnu.addAction( editChannelDetailAct);
	else
		contextMnu.addAction( channeldetailsAct );

	if((ci.channelFlags & RS_DISTRIB_PUBLISH) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) 
	{
		contextMnu.addAction( postchannelAct );
		contextMnu.addAction( shareKeyAct );
	}

	if(ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
	{
		contextMnu.addAction( unsubscribechannelAct );
		contextMnu.addAction( restoreKeysAct );
		contextMnu.addSeparator();
		contextMnu.addAction( autochannelAct );
		contextMnu.addAction( setallasreadchannelAct );
	}
	else
		contextMnu.addAction( subscribechannelAct );

	contextMnu.addSeparator();
	QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink()));
	action->setEnabled(!mChannelId.empty());

	contextMnu.exec(QCursor::pos());

#endif
}