Exemplo n.º 1
0
void ChannelFeed::copyChannelLink()
{
    if (mChannelId.empty()) {
        return;
    }

    ChannelInfo ci;
    if (rsChannels->getChannelInfo(mChannelId, ci)) {
        RetroShareLink link;
        if (link.createChannel(ci.channelId, "")) {
            QList<RetroShareLink> urls;
            urls.push_back(link);
            RSLinkClipboard::copyLinks(urls);
        }
    }
}
Exemplo n.º 2
0
void ChanNewItem::updateItemStatic()
{
	if (!rsChannels)
		return;


	/* fill in */
#ifdef DEBUG_ITEM
	std::cerr << "ChanNewItem::updateItemStatic()";
	std::cerr << std::endl;
#endif

	ChannelInfo ci;
	if (rsChannels->getChannelInfo(mChanId, ci))
	{
		RetroShareLink link;
		link.createChannel(ci.channelId, "");
		nameLabel->setText(link.toHtml());

		descLabel->setText(QString::fromStdWString(ci.channelDesc));
		
		if(ci.pngImageLen != 0){

    QPixmap chanImage;
    chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
    logo_label->setPixmap(QPixmap(chanImage));
    }else{
    QPixmap defaulImage(CHAN_DEFAULT_IMAGE);
    logo_label->setPixmap(QPixmap(defaulImage));
    }

		if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
		{
			subscribeButton->setEnabled(false);
			//postButton->setEnabled(true);
		}
		else
		{
			subscribeButton->setEnabled(true);
			//postButton->setEnabled(false);
		}
			

		/* should also check the other flags */
	}
	else
	{
		nameLabel->setText(tr("Unknown Channel"));
		titleLabel->setText("Channel ???");
		descLabel->setText("");
	}

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

	if (mIsHome)
	{
		/* disable buttons */
		clearButton->setEnabled(false);
	}
}
Exemplo n.º 3
0
void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
{
	/* fill in */
#ifdef DEBUG_ITEM
	std::cerr << "GxsChannelPostItem::loadPost()";
	std::cerr << std::endl;
#endif

	m_inUpdateItemStatic = true;

	mPost = post;

	QString title;

	if (!mIsHome)
	{
		title = tr("Channel Feed") + ": ";
		RetroShareLink link;
		link.createChannel(post.mMeta.mGroupId, "");
		title += link.toHtml();
		titleLabel->setText(title);
		RetroShareLink msgLink;
		msgLink.createChannel(post.mMeta.mGroupId, post.mMeta.mMsgId);
		subjectLabel->setText(msgLink.toHtml());

		if (IS_GROUP_SUBSCRIBED(mSubscribeFlags) || IS_GROUP_ADMIN(mSubscribeFlags))
		{
			unsubscribeButton->setEnabled(true);
		}
		else 
		{
			unsubscribeButton->setEnabled(false);
		}
		readButton->hide();
		//newLabel->hide();
		copyLinkButton->hide();
	}
	else
	{
		/* subject */
		titleLabel->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str()));
		subjectLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));

		/* disable buttons: deletion facility not enabled with cache services yet */
		clearButton->setEnabled(false);
		unsubscribeButton->setEnabled(false);
		clearButton->hide();
		readAndClearButton->hide();
		unsubscribeButton->hide();
		copyLinkButton->show();

		if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags))
		{

			readButton->setVisible(true);
#if 0
			uint32_t status = 0;
			rsChannels->getMessageStatus(mChanId, mMsgId, status);
#endif

			if (IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus))
			{
				readButton->setChecked(true);
				readButton->setIcon(QIcon(":/images/message-state-unread.png"));
			} 
			else 
			{
				readButton->setChecked(false);
				readButton->setIcon(QIcon(":/images/message-state-read.png"));
			}

			bool newState;
			QColor color;
			if (!IS_MSG_UNREAD(post.mMeta.mMsgStatus))
			{
				//newLabel->setVisible(false);
				newState = false;
				color = COLOR_NORMAL;
			} 
			else 
			{
				//newLabel->setVisible(true);
				newState = true;
				color = COLOR_NEW;
			}

			/* unpolish widget to clear the stylesheet's palette cache */
			frame->style()->unpolish(frame);

			QPalette palette = frame->palette();
			palette.setColor(frame->backgroundRole(), color);
			frame->setPalette(palette);

			frame->setProperty("new", newState);
			Rshare::refreshStyleSheet(frame, false);
		} 
		else 
		{
			readButton->setVisible(false);
			//newLabel->setVisible(false);
		}
	}

	msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
	msgFrame->setVisible(!post.mMsg.empty());

	datetimelabel->setText(DateTime::formatLongDateTime(post.mMeta.mPublishTs));

	filelabel->setText(QString("(%1 %2) %3").arg(post.mCount).arg(tr("Files")).arg(misc::friendlyUnit(post.mSize)));

	if (mFileItems.empty() == false) {
		std::list<SubFileItem *>::iterator it;
		for(it = mFileItems.begin(); it != mFileItems.end(); it++)
		{
			delete(*it);
		}
		mFileItems.clear();
	}

	std::list<RsGxsFile>::const_iterator it;
	for(it = post.mFiles.begin(); it != post.mFiles.end(); it++)
	{
		/* add file */
		std::string path;
		SubFileItem *fi = new SubFileItem(it->mHash, it->mName, path, it->mSize,
				SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, "");
		mFileItems.push_back(fi);
		
		/* check if the file is a media file */
		if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->mName.c_str())).suffix())) 
		  fi->mediatype();


		QLayout *layout = expandFrame->layout();
		layout->addWidget(fi);
	}

	if(post.mThumbnail.mData != NULL)
	{
		QPixmap thumbnail;
		thumbnail.loadFromData(post.mThumbnail.mData, post.mThumbnail.mSize, "PNG");
		// Wiping data - as its been passed to thumbnail.
		logoLabel->setPixmap(thumbnail);
	}

	m_inUpdateItemStatic = false;
}