Code maintenance

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7335 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-05-05 23:25:17 +00:00
parent 306c8fe431
commit 471f4357ba
4 changed files with 202 additions and 227 deletions

View File

@ -47,31 +47,27 @@
#define COLOR_NORMAL QColor(248, 248, 248) #define COLOR_NORMAL QColor(248, 248, 248)
#define COLOR_NEW QColor(220, 236, 253) #define COLOR_NEW QColor(220, 236, 253)
#define SELF_LOAD 1 #define SELF_LOAD 1
#define DATA_PROVIDED 2 #define DATA_PROVIDED 2
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome) :
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome) GxsFeedItem(parent, feedId, groupId, messageId, isHome, rsGxsChannels, true)
:GxsFeedItem(parent, feedId, groupId, messageId, isHome, rsGxsChannels, true)
{ {
mMode = SELF_LOAD; mMode = SELF_LOAD;
setup(); setup();
} }
/** Constructor */ /** Constructor */
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsChannelPost &post, uint32_t subFlags, bool isHome) GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsChannelPost &post, uint32_t subFlags, bool isHome) :
:GxsFeedItem(parent, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsChannels, false) GxsFeedItem(parent, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsChannels, false)
{ {
std::cerr << "GxsChannelPostItem::GxsChannelPostItem() Direct Load"; std::cerr << "GxsChannelPostItem::GxsChannelPostItem() Direct Load";
std::cerr << std::endl; std::cerr << std::endl;
mMode = DATA_PROVIDED; mMode = DATA_PROVIDED;
mGroupMeta.mSubscribeFlags = subFlags; mGroupMeta.mSubscribeFlags = subFlags;
m_inUpdateItemStatic = false; mInUpdateItemStatic = false;
setup(); setup();
@ -79,62 +75,65 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, cons
loadPost(post); loadPost(post);
} }
GxsChannelPostItem::~GxsChannelPostItem()
{
delete(ui);
}
void GxsChannelPostItem::setup() void GxsChannelPostItem::setup()
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
setupUi(this); ui = new Ui::GxsChannelPostItem;
ui->setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true ); setAttribute ( Qt::WA_DeleteOnClose, true );
m_inUpdateItemStatic = false; mInUpdateItemStatic = false;
/* general ones */ /* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) ); connect(ui->expandButton, SIGNAL(clicked(void)), this, SLOT(toggle(void)));
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) ); connect(ui->clearButton, SIGNAL(clicked(void)), this, SLOT(removeItem(void)));
/* specific */ /* specific */
connect(readAndClearButton, SIGNAL(clicked()), this, SLOT(readAndClearItem())); connect(ui->readAndClearButton, SIGNAL(clicked()), this, SLOT(readAndClearItem()));
connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) ); connect(ui->unsubscribeButton, SIGNAL(clicked(void)), this, SLOT(unsubscribeChannel(void)));
connect( downloadButton, SIGNAL( clicked( void ) ), this, SLOT( download ( void ) ) ); connect(ui->downloadButton, SIGNAL(clicked(void)), this, SLOT(download(void)));
// HACK FOR NOW. // HACK FOR NOW.
connect( commentButton, SIGNAL( clicked( void ) ), this, SLOT( loadComments ( void ) ) ); connect(ui->commentButton, SIGNAL(clicked(void)), this, SLOT(loadComments(void)));
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( play ( void ) ) ); connect(ui->playButton, SIGNAL(clicked(void)), this, SLOT( play(void)));
connect( copyLinkButton, SIGNAL( clicked( void ) ), this, SLOT( copyLink ( void ) ) ); connect(ui->copyLinkButton, SIGNAL(clicked(void)), this, SLOT(copyLink(void)));
connect( readButton, SIGNAL( toggled(bool) ), this, SLOT( readToggled(bool) ) ); connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool)));
connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection); //connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
//connect( voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote())); //connect(ui-> voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote()));
//connect( voteDownButton, SIGNAL(clicked()), this, SLOT( makeDownVote())); //connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT(makeDownVote()));
downloadButton->hide(); ui->downloadButton->hide();
playButton->hide(); ui->playButton->hide();
warn_image_label->hide(); ui->warn_image_label->hide();
warning_label->hide(); ui->warning_label->hide();
titleLabel->setMinimumWidth(100); ui->titleLabel->setMinimumWidth(100);
subjectLabel->setMinimumWidth(100); ui->subjectLabel->setMinimumWidth(100);
warning_label->setMinimumWidth(100); ui->warning_label->setMinimumWidth(100);
frame->setProperty("state", ""); ui->frame->setProperty("state", "");
QPalette palette = frame->palette(); QPalette palette = ui->frame->palette();
palette.setColor(frame->backgroundRole(), COLOR_NORMAL); palette.setColor(ui->frame->backgroundRole(), COLOR_NORMAL);
frame->setPalette(palette); ui->frame->setPalette(palette);
expandFrame->hide(); ui->expandFrame->hide();
} }
void GxsChannelPostItem::loadComments() void GxsChannelPostItem::loadComments()
{ {
QString title = QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); QString title = QString::fromUtf8(mPost.mMeta.mMsgName.c_str());
comments(title); comments(title);
} }
void GxsChannelPostItem::loadMessage(const uint32_t &token) void GxsChannelPostItem::loadMessage(const uint32_t &token)
{ {
std::cerr << "GxsChannelPostItem::loadMessage()"; std::cerr << "GxsChannelPostItem::loadMessage()";
@ -160,8 +159,6 @@ void GxsChannelPostItem::loadMessage(const uint32_t &token)
updateItem(); updateItem();
} }
void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post) void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
{ {
/* fill in */ /* fill in */
@ -170,7 +167,7 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
m_inUpdateItemStatic = true; mInUpdateItemStatic = true;
mPost = post; mPost = post;
@ -180,46 +177,45 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
{ {
title = tr("Channel Feed") + ": "; title = tr("Channel Feed") + ": ";
RetroShareLink link; RetroShareLink link;
link.createChannel(post.mMeta.mGroupId.toStdString(), ""); link.createChannel(post.mMeta.mGroupId.toStdString(), "");
title += link.toHtml(); title += link.toHtml();
titleLabel->setText(title); ui->titleLabel->setText(title);
RetroShareLink msgLink; RetroShareLink msgLink;
msgLink.createChannel(post.mMeta.mGroupId.toStdString(), post.mMeta.mMsgId.toStdString()); msgLink.createChannel(post.mMeta.mGroupId.toStdString(), post.mMeta.mMsgId.toStdString());
subjectLabel->setText(msgLink.toHtml()); ui->subjectLabel->setText(msgLink.toHtml());
if (IS_GROUP_SUBSCRIBED(mSubscribeFlags) || IS_GROUP_ADMIN(mSubscribeFlags)) if (IS_GROUP_SUBSCRIBED(mSubscribeFlags) || IS_GROUP_ADMIN(mSubscribeFlags))
{ {
unsubscribeButton->setEnabled(true); ui->unsubscribeButton->setEnabled(true);
} }
else else
{ {
unsubscribeButton->setEnabled(false); ui->unsubscribeButton->setEnabled(false);
} }
readButton->hide(); ui->readButton->hide();
//newLabel->hide(); //newLabel->hide();
copyLinkButton->hide(); ui->copyLinkButton->hide();
} }
else else
{ {
/* subject */ /* subject */
titleLabel->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str())); ui->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)); ui->subjectLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
//QString score = QString::number(post.mTopScore); //QString score = QString::number(post.mTopScore);
// scoreLabel->setText(score); // scoreLabel->setText(score);
/* disable buttons: deletion facility not enabled with cache services yet */ /* disable buttons: deletion facility not enabled with cache services yet */
clearButton->setEnabled(false); ui->clearButton->setEnabled(false);
unsubscribeButton->setEnabled(false); ui->unsubscribeButton->setEnabled(false);
clearButton->hide(); ui->clearButton->hide();
readAndClearButton->hide(); ui->readAndClearButton->hide();
unsubscribeButton->hide(); ui->unsubscribeButton->hide();
copyLinkButton->show(); ui->copyLinkButton->show();
if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags)) if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags))
{ {
ui->readButton->setVisible(true);
readButton->setVisible(true);
#if 0 #if 0
uint32_t status = 0; uint32_t status = 0;
rsChannels->getMessageStatus(mChanId, mMsgId, status); rsChannels->getMessageStatus(mChanId, mMsgId, status);
@ -227,13 +223,13 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
if (IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) if (IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus))
{ {
readButton->setChecked(true); ui->readButton->setChecked(true);
readButton->setIcon(QIcon(":/images/message-state-unread.png")); ui->readButton->setIcon(QIcon(":/images/message-state-unread.png"));
} }
else else
{ {
readButton->setChecked(false); ui->readButton->setChecked(false);
readButton->setIcon(QIcon(":/images/message-state-read.png")); ui->readButton->setIcon(QIcon(":/images/message-state-read.png"));
} }
bool newState; bool newState;
@ -252,26 +248,26 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
} }
/* unpolish widget to clear the stylesheet's palette cache */ /* unpolish widget to clear the stylesheet's palette cache */
frame->style()->unpolish(frame); ui->frame->style()->unpolish(ui->frame);
QPalette palette = frame->palette(); QPalette palette = ui->frame->palette();
palette.setColor(frame->backgroundRole(), color); palette.setColor(ui->frame->backgroundRole(), color);
frame->setPalette(palette); ui->frame->setPalette(palette);
frame->setProperty("new", newState); ui->frame->setProperty("new", newState);
Rshare::refreshStyleSheet(frame, false); Rshare::refreshStyleSheet(ui->frame, false);
} }
else else
{ {
readButton->setVisible(false); ui->readButton->setVisible(false);
//newLabel->setVisible(false); //ui->newLabel->setVisible(false);
} }
} }
// differences between Feed or Top of Comment. // differences between Feed or Top of Comment.
if (mParent) if (mParent)
{ {
commentButton->show(); ui->commentButton->show();
// THIS CODE IS doesn't compile - disabling until fixed. // THIS CODE IS doesn't compile - disabling until fixed.
#if 0 #if 0
@ -280,18 +276,18 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
QString commentText = QString::number(post.mComments); QString commentText = QString::number(post.mComments);
commentText += " "; commentText += " ";
commentText += tr("Comments"); commentText += tr("Comments");
commentButton->setText(commentText); ui->commentButton->setText(commentText);
} }
else else
{ {
commentButton->setText(tr("Comment")); ui->commentButton->setText(tr("Comment"));
} }
#endif #endif
} }
else else
{ {
commentButton->hide(); ui->commentButton->hide();
} }
// disable voting buttons - if they have already voted. // disable voting buttons - if they have already voted.
@ -301,12 +297,12 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
voteDownButton->setEnabled(false); voteDownButton->setEnabled(false);
}*/ }*/
msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); ui->msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
msgFrame->setVisible(!post.mMsg.empty()); ui->msgFrame->setVisible(!post.mMsg.empty());
datetimelabel->setText(DateTime::formatLongDateTime(post.mMeta.mPublishTs)); ui->datetimelabel->setText(DateTime::formatLongDateTime(post.mMeta.mPublishTs));
filelabel->setText(QString("(%1 %2) %3").arg(post.mCount).arg(tr("Files")).arg(misc::friendlyUnit(post.mSize))); ui->filelabel->setText(QString("(%1 %2) %3").arg(post.mCount).arg(tr("Files")).arg(misc::friendlyUnit(post.mSize)));
if (mFileItems.empty() == false) { if (mFileItems.empty() == false) {
std::list<SubFileItem *>::iterator it; std::list<SubFileItem *>::iterator it;
@ -329,8 +325,7 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->mName.c_str())).suffix())) if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->mName.c_str())).suffix()))
fi->mediatype(); fi->mediatype();
QLayout *layout = ui->expandFrame->layout();
QLayout *layout = expandFrame->layout();
layout->addWidget(fi); layout->addWidget(fi);
} }
@ -339,10 +334,10 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
QPixmap thumbnail; QPixmap thumbnail;
thumbnail.loadFromData(post.mThumbnail.mData, post.mThumbnail.mSize, "PNG"); thumbnail.loadFromData(post.mThumbnail.mData, post.mThumbnail.mSize, "PNG");
// Wiping data - as its been passed to thumbnail. // Wiping data - as its been passed to thumbnail.
logoLabel->setPixmap(thumbnail); ui->logoLabel->setPixmap(thumbnail);
} }
m_inUpdateItemStatic = false; mInUpdateItemStatic = false;
} }
void GxsChannelPostItem::setFileCleanUpWarning(uint32_t time_left) void GxsChannelPostItem::setFileCleanUpWarning(uint32_t time_left)
@ -350,22 +345,21 @@ void GxsChannelPostItem::setFileCleanUpWarning(uint32_t time_left)
int hours = (int)time_left/3600; int hours = (int)time_left/3600;
int minutes = (time_left - hours*3600)%60; int minutes = (time_left - hours*3600)%60;
warning_label->setText(tr("Warning! You have less than %1 hours and %2 minute before this file is deleted Consider saving it.").arg( ui->warning_label->setText(tr("Warning! You have less than %1 hours and %2 minute before this file is deleted Consider saving it.").arg(
QString::number(hours)).arg(QString::number(minutes))); QString::number(hours)).arg(QString::number(minutes)));
QFont warnFont = warning_label->font(); QFont warnFont = ui->warning_label->font();
warnFont.setBold(true); warnFont.setBold(true);
warning_label->setFont(warnFont); ui->warning_label->setFont(warnFont);
warn_image_label->setVisible(true);
warning_label->setVisible(true);
return;
ui->warn_image_label->setVisible(true);
ui->warning_label->setVisible(true);
} }
void GxsChannelPostItem::updateItem() void GxsChannelPostItem::updateItem()
{ {
/* fill in */ /* fill in */
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "GxsChannelPostItem::updateItem()"; std::cerr << "GxsChannelPostItem::updateItem()";
std::cerr << std::endl; std::cerr << std::endl;
@ -406,31 +400,31 @@ void GxsChannelPostItem::updateItem()
} }
if (downloadCount) { if (downloadCount) {
downloadButton->show(); ui->downloadButton->show();
if (downloadStartable) { if (downloadStartable) {
downloadButton->setEnabled(true); ui->downloadButton->setEnabled(true);
} else { } else {
downloadButton->setEnabled(false); ui->downloadButton->setEnabled(false);
} }
} else { } else {
downloadButton->hide(); ui->downloadButton->hide();
} }
if (playCount) { if (playCount) {
/* one file is playable */ /* one file is playable */
playButton->show(); ui->playButton->show();
if (playStartable == 1) { if (playStartable == 1) {
playButton->setEnabled(true); ui->playButton->setEnabled(true);
} else { } else {
playButton->setEnabled(false); ui->playButton->setEnabled(false);
} }
} else { } else {
playButton->hide(); ui->playButton->hide();
} }
if (loopAgain) { if (loopAgain) {
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) )); QTimer::singleShot( msec_rate, this, SLOT(updateItem(void)));
} }
// HACK TO DISPLAY COMMENT BUTTON FOR NOW. // HACK TO DISPLAY COMMENT BUTTON FOR NOW.
@ -445,19 +439,19 @@ void GxsChannelPostItem::toggle()
mParent->lockLayout(this, true); mParent->lockLayout(this, true);
} }
if (expandFrame->isHidden()) if (ui->expandFrame->isHidden())
{ {
expandFrame->show(); ui->expandFrame->show();
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png"))); ui->expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
expandButton->setToolTip(tr("Hide")); ui->expandButton->setToolTip(tr("Hide"));
readToggled(false); readToggled(false);
} }
else else
{ {
expandFrame->hide(); ui->expandFrame->hide();
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png"))); ui->expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip(tr("Expand")); ui->expandButton->setToolTip(tr("Expand"));
} }
if (mParent) if (mParent)
@ -515,9 +509,8 @@ void GxsChannelPostItem::play()
void GxsChannelPostItem::readToggled(bool checked) void GxsChannelPostItem::readToggled(bool checked)
{ {
#if 0 #if 0
if (m_inUpdateItemStatic) { if (mInUpdateItemStatic) {
return; return;
} }
@ -538,14 +531,11 @@ void GxsChannelPostItem::readToggled(bool checked)
if (!mIsHome) { if (!mIsHome) {
connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection); connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
} }
#endif #endif
} }
void GxsChannelPostItem::channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status) void GxsChannelPostItem::channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status)
{ {
#if 0 #if 0
if (channelId.toStdString() == mChanId && msgId.toStdString() == mMsgId) { if (channelId.toStdString() == mChanId && msgId.toStdString() == mMsgId) {
if (!mIsHome) { if (!mIsHome) {
@ -557,12 +547,10 @@ void GxsChannelPostItem::channelMsgReadSatusChanged(const QString& channelId, co
updateItemStatic(); updateItemStatic();
} }
#endif #endif
} }
void GxsChannelPostItem::copyLink() void GxsChannelPostItem::copyLink()
{ {
#if 0 #if 0
if (mChanId.empty() || mMsgId.empty()) { if (mChanId.empty() || mMsgId.empty()) {
return; return;
@ -578,7 +566,6 @@ void GxsChannelPostItem::copyLink()
} }
} }
#endif #endif
} }
void GxsChannelPostItem::makeDownVote() void GxsChannelPostItem::makeDownVote()
@ -587,8 +574,8 @@ void GxsChannelPostItem::makeDownVote()
msgId.first = mPost.mMeta.mGroupId; msgId.first = mPost.mMeta.mGroupId;
msgId.second = mPost.mMeta.mMsgId; msgId.second = mPost.mMeta.mMsgId;
voteUpButton->setEnabled(false); ui->voteUpButton->setEnabled(false);
voteDownButton->setEnabled(false); ui->voteDownButton->setEnabled(false);
emit vote(msgId, false); emit vote(msgId, false);
} }
@ -599,8 +586,8 @@ void GxsChannelPostItem::makeUpVote()
msgId.first = mPost.mMeta.mGroupId; msgId.first = mPost.mMeta.mGroupId;
msgId.second = mPost.mMeta.mMsgId; msgId.second = mPost.mMeta.mMsgId;
voteUpButton->setEnabled(false); ui->voteUpButton->setEnabled(false);
voteDownButton->setEnabled(false); ui->voteDownButton->setEnabled(false);
emit vote(msgId, true); emit vote(msgId, true);
} }

View File

@ -29,24 +29,27 @@
#include "ui_GxsChannelPostItem.h" #include "ui_GxsChannelPostItem.h"
#include <stdint.h> #include <stdint.h>
namespace Ui {
class GxsChannelPostItem;
}
class FeedHolder; class FeedHolder;
class SubFileItem; class SubFileItem;
class GxsChannelPostItem : public GxsFeedItem, private Ui::GxsChannelPostItem class GxsChannelPostItem : public GxsFeedItem
{ {
Q_OBJECT Q_OBJECT
public: public:
/** Default Constructor */ /** Default Constructor */
GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome); GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome);
GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsChannelPost &post, uint32_t subscribeFlags, bool isHome); GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsChannelPost &post, uint32_t subscribeFlags, bool isHome);
virtual ~GxsChannelPostItem();
void setFileCleanUpWarning(uint32_t time_left); void setFileCleanUpWarning(uint32_t time_left);
//const std::string &msgId() { return mMsgId; }
protected: protected:
virtual void loadMessage(const uint32_t &token); virtual void loadMessage(const uint32_t &token);
private slots: private slots:
/* default stuff */ /* default stuff */
@ -73,14 +76,16 @@ private:
void setup(); void setup();
void loadPost(const RsGxsChannelPost &post); void loadPost(const RsGxsChannelPost &post);
bool m_inUpdateItemStatic; bool mInUpdateItemStatic;
uint32_t mMode; uint32_t mMode;
uint32_t mSubscribeFlags; uint32_t mSubscribeFlags;
RsGxsChannelPost mPost; RsGxsChannelPost mPost;
std::list<SubFileItem *> mFileItems; std::list<SubFileItem *> mFileItems;
/** Qt Designer generated object */
Ui::GxsChannelPostItem *ui;
}; };
#endif #endif

View File

@ -30,11 +30,8 @@
* #define DEBUG_ITEM 1 * #define DEBUG_ITEM 1
**/ **/
#define DEBUG_ITEM 1 #define GXSFEEDITEM_GROUPMETA 5
#define GXSFEEDITEM_MESSAGE 6
#define GXSFEEDITEM_GROUPMETA 5
#define GXSFEEDITEM_MESSAGE 6
void GxsFeedItem::removeItem() void GxsFeedItem::removeItem()
{ {
@ -60,14 +57,14 @@ void GxsFeedItem::removeItem()
void GxsFeedItem::comments(const QString &title) void GxsFeedItem::comments(const QString &title)
{ {
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "GxsFeedItem::comments()"; std::cerr << "GxsFeedItem::comments()";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
if (mParent) if (mParent)
{ {
mParent->openComments(mFeedId, mGroupId, mMessageId, title); mParent->openComments(mFeedId, mGroupId, mMessageId, title);
} }
} }
void GxsFeedItem::unsubscribe() void GxsFeedItem::unsubscribe()
@ -79,12 +76,11 @@ void GxsFeedItem::unsubscribe()
if (mGxsIface) if (mGxsIface)
{ {
uint32_t token; uint32_t token;
mGxsIface->subscribeToGroup(token, mGroupId, false); mGxsIface->subscribeToGroup(token, mGroupId, false);
} }
} }
void GxsFeedItem::subscribe() void GxsFeedItem::subscribe()
{ {
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
@ -94,19 +90,18 @@ void GxsFeedItem::subscribe()
if (mGxsIface) if (mGxsIface)
{ {
uint32_t token; uint32_t token;
mGxsIface->subscribeToGroup(token, mGroupId, true); mGxsIface->subscribeToGroup(token, mGroupId, true);
} }
} }
void GxsFeedItem::updateItemStatic() void GxsFeedItem::updateItemStatic()
{ {
std::cerr << "GxsFeedItem::updateItemStatic()"; std::cerr << "GxsFeedItem::updateItemStatic()";
std::cerr << std::endl; std::cerr << std::endl;
requestMessage();
}
requestMessage();
}
void GxsFeedItem::updateItem() void GxsFeedItem::updateItem()
{ {
@ -114,14 +109,13 @@ void GxsFeedItem::updateItem()
std::cerr << std::endl; std::cerr << std::endl;
} }
/***********************************************************/ /***********************************************************/
GxsFeedItem::GxsFeedItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, RsGxsIfaceHelper *iface, bool loadData) GxsFeedItem::GxsFeedItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, RsGxsIfaceHelper *iface, bool loadData) :
:QWidget(NULL) QWidget(NULL)
{ {
std::cerr << "GxsFeedItem::GxsFeedItem()"; std::cerr << "GxsFeedItem::GxsFeedItem()";
std::cerr << std::endl; std::cerr << std::endl;
/* this are just generally useful for all children */ /* this are just generally useful for all children */
mParent = parent; mParent = parent;
@ -144,11 +138,10 @@ GxsFeedItem::GxsFeedItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId
} }
} }
GxsFeedItem::~GxsFeedItem() GxsFeedItem::~GxsFeedItem()
{ {
std::cerr << "GxsFeedItem::~GxsFeedItem()"; std::cerr << "GxsFeedItem::~GxsFeedItem()";
std::cerr << std::endl; std::cerr << std::endl;
if (mLoadQueue) if (mLoadQueue)
{ {
@ -156,100 +149,94 @@ GxsFeedItem::~GxsFeedItem()
} }
} }
void GxsFeedItem::requestGroupMeta() void GxsFeedItem::requestGroupMeta()
{ {
std::cerr << "GxsFeedItem::requestGroup()"; std::cerr << "GxsFeedItem::requestGroup()";
std::cerr << std::endl; std::cerr << std::endl;
if (!mLoadQueue) if (!mLoadQueue)
{ {
return; return;
} }
std::list<RsGxsGroupId> ids; std::list<RsGxsGroupId> ids;
ids.push_back(mGroupId); ids.push_back(mGroupId);
RsTokReqOptions opts; RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
uint32_t token; uint32_t token;
mLoadQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, ids, GXSFEEDITEM_GROUPMETA); mLoadQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, ids, GXSFEEDITEM_GROUPMETA);
updateItemStatic(); updateItemStatic();
} }
void GxsFeedItem::requestMessage() void GxsFeedItem::requestMessage()
{ {
std::cerr << "GxsFeedItem::requestMessage()"; std::cerr << "GxsFeedItem::requestMessage()";
std::cerr << std::endl; std::cerr << std::endl;
if (!mLoadQueue) if (!mLoadQueue)
{ {
return; return;
} }
RsTokReqOptions opts; RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
GxsMsgReq msgIds; GxsMsgReq msgIds;
std::vector<RsGxsMessageId> &vect_msgIds = msgIds[mGroupId]; std::vector<RsGxsMessageId> &vect_msgIds = msgIds[mGroupId];
vect_msgIds.push_back(mMessageId); vect_msgIds.push_back(mMessageId);
uint32_t token; uint32_t token;
mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, GXSFEEDITEM_MESSAGE); mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, GXSFEEDITEM_MESSAGE);
} }
void GxsFeedItem::loadGroupMeta(const uint32_t &token) void GxsFeedItem::loadGroupMeta(const uint32_t &token)
{ {
std::cerr << "GxsFeedItem::loadGroupMeta()"; std::cerr << "GxsFeedItem::loadGroupMeta()";
std::cerr << std::endl; std::cerr << std::endl;
std::list<RsGroupMetaData> groupMeta; std::list<RsGroupMetaData> groupMeta;
if (!mGxsIface->getGroupSummary(token, groupMeta)) if (!mGxsIface->getGroupSummary(token, groupMeta))
{ {
std::cerr << "GxsFeedItem::loadGroupMeta() Error getting GroupMeta"; std::cerr << "GxsFeedItem::loadGroupMeta() Error getting GroupMeta";
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
if (groupMeta.size() == 1) if (groupMeta.size() == 1)
{ {
mGroupMeta = *groupMeta.begin(); mGroupMeta = *groupMeta.begin();
} }
else else
{ {
std::cerr << "GxsFeedItem::loadGroupMeta() ERROR Should be ONE GroupMeta"; std::cerr << "GxsFeedItem::loadGroupMeta() ERROR Should be ONE GroupMeta";
std::cerr << std::endl; std::cerr << std::endl;
} }
} }
void GxsFeedItem::loadRequest(const TokenQueue *queue, const TokenRequest &req) void GxsFeedItem::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{ {
std::cerr << "GxsFeedItem::loadRequest()"; std::cerr << "GxsFeedItem::loadRequest()";
std::cerr << std::endl; std::cerr << std::endl;
if (queue == mLoadQueue) if (queue == mLoadQueue)
{ {
switch(req.mUserType) switch(req.mUserType)
{ {
case GXSFEEDITEM_GROUPMETA: case GXSFEEDITEM_GROUPMETA:
loadGroupMeta(req.mToken); loadGroupMeta(req.mToken);
break; break;
case GXSFEEDITEM_MESSAGE: case GXSFEEDITEM_MESSAGE:
loadMessage(req.mToken); loadMessage(req.mToken);
break; break;
default: default:
std::cerr << "GxsFeedItem::loadRequest() ERROR: INVALID TYPE"; std::cerr << "GxsFeedItem::loadRequest() ERROR: INVALID TYPE";
std::cerr << std::endl; std::cerr << std::endl;
break; break;
} }
} }
} }

View File

@ -37,37 +37,34 @@ class GxsFeedItem : public QWidget, public TokenResponse
public: public:
/** Note parent can = NULL */ /** Note parent can = NULL */
GxsFeedItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, RsGxsIfaceHelper *iface, bool loadData); GxsFeedItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, RsGxsIfaceHelper *iface, bool loadData);
virtual ~GxsFeedItem(); virtual ~GxsFeedItem();
RsGxsGroupId groupId() { return mGroupId; } RsGxsGroupId groupId() { return mGroupId; }
RsGxsMessageId messageId() { return mMessageId; } RsGxsMessageId messageId() { return mMessageId; }
protected: protected:
// generic Fns - to be overloaded. // generic Fns - to be overloaded.
virtual void updateItemStatic(); virtual void updateItemStatic();
virtual void updateItem(); virtual void updateItem();
virtual void loadMessage(const uint32_t &token) = 0; virtual void loadMessage(const uint32_t &token) = 0;
void requestMessage(); void requestMessage();
virtual void loadGroupMeta(const uint32_t &token); virtual void loadGroupMeta(const uint32_t &token);
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
// general fns that can be implemented here. // general fns that can be implemented here.
protected slots:
protected slots:
void comments(const QString &title); void comments(const QString &title);
void subscribe(); void subscribe();
void unsubscribe(); void unsubscribe();
void removeItem(); void removeItem();
protected: protected:
FeedHolder *mParent; FeedHolder *mParent;
uint32_t mFeedId; uint32_t mFeedId;
bool mIsHome; bool mIsHome;
RsGxsGroupId mGroupId; RsGxsGroupId mGroupId;
RsGxsMessageId mMessageId; RsGxsMessageId mMessageId;
@ -75,7 +72,6 @@ protected:
RsGroupMetaData mGroupMeta; RsGroupMetaData mGroupMeta;
private: private:
void requestGroupMeta(); void requestGroupMeta();
RsGxsIfaceHelper *mGxsIface; RsGxsIfaceHelper *mGxsIface;