Added read/unread state to channel service (copied from forum service).

Added new and missing tests of the RsItems.
Added new notifier on channel changes.
Reworked fill of channels in ChannelFeed. Now the channel tree is updated and not refilled.
Show unread message count in channels tree.
Fixed memory leak in context menu.
Show a new tray icon and action icon in MainWindow, when new channel messages are available.

Recompile of the GUI needed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3626 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-10-07 00:17:42 +00:00
parent df20d69b29
commit fc0ff38206
22 changed files with 1181 additions and 653 deletions

View file

@ -26,6 +26,7 @@
#include "FeedHolder.h"
#include "SubFileItem.h"
#include "gui/notifyqt.h"
#include <retroshare/rschannels.h>
@ -46,6 +47,8 @@ ChanMsgItem::ChanMsgItem(FeedHolder *parent, uint32_t feedId, std::string chanId
setAttribute ( Qt::WA_DeleteOnClose, true );
m_inUpdateItemStatic = false;
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
@ -55,13 +58,15 @@ ChanMsgItem::ChanMsgItem(FeedHolder *parent, uint32_t feedId, std::string chanId
connect( downloadButton, SIGNAL( clicked( void ) ), this, SLOT( download ( void ) ) );
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( play ( void ) ) );
connect( readButton, SIGNAL( toggled(bool) ), this, SLOT( readToggled(bool) ) );
connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
downloadButton->hide();
playButton->hide();
small();
updateItemStatic();
updateItem();
}
@ -81,12 +86,15 @@ void ChanMsgItem::updateItemStatic()
if (!rsChannels->getChannelMessage(mChanId, mMsgId, cmi))
return;
m_inUpdateItemStatic = true;
QString title;
ChannelInfo ci;
rsChannels->getChannelInfo(mChanId, ci);
if (!mIsHome)
{
ChannelInfo ci;
rsChannels->getChannelInfo(mChanId, ci);
title = "Channel Feed: ";
title += QString::fromStdWString(ci.channelName);
titleLabel->setText(title);
@ -97,6 +105,8 @@ void ChanMsgItem::updateItemStatic()
} else {
unsubscribeButton->setEnabled(false);
}
readButton->setVisible(false);
newLabel->setVisible(false);
}
else
{
@ -109,8 +119,32 @@ void ChanMsgItem::updateItemStatic()
unsubscribeButton->setEnabled(false);
clearButton->hide();
unsubscribeButton->hide();
if ((ci.channelFlags & RS_DISTRIB_SUBSCRIBED) || (ci.channelFlags & RS_DISTRIB_ADMIN)) {
readButton->setVisible(true);
uint32_t status = 0;
rsChannels->getMessageStatus(mChanId, mMsgId, status);
if ((status & CHANNEL_MSG_STATUS_READ) == 0 || (status & CHANNEL_MSG_STATUS_UNREAD_BY_USER)) {
readButton->setChecked(true);
readButton->setIcon(QIcon(":/images/message-state-unread.png"));
} else {
readButton->setChecked(false);
readButton->setIcon(QIcon(":/images/message-state-read.png"));
}
if (status & CHANNEL_MSG_STATUS_READ) {
newLabel->setVisible(false);
} else {
newLabel->setVisible(true);
}
} else {
readButton->setVisible(false);
newLabel->setVisible(false);
}
}
msgLabel->setText(QString::fromStdWString(cmi.msg));
QDateTime qtime;
@ -155,6 +189,8 @@ void ChanMsgItem::updateItemStatic()
label->setPixmap(thumbnail);
label->setStyleSheet("QLabel#label{border: 2px solid #D3D3D3;border-radius: 3px;}");
}
m_inUpdateItemStatic = false;
}
@ -311,3 +347,28 @@ void ChanMsgItem::play()
}
}
}
void ChanMsgItem::readToggled(bool checked)
{
if (m_inUpdateItemStatic) {
return;
}
/* set always as read ... */
uint32_t statusNew = CHANNEL_MSG_STATUS_READ;
if (checked) {
/* ... and as unread by user */
statusNew |= CHANNEL_MSG_STATUS_UNREAD_BY_USER;
} else {
/* ... and as read by user */
statusNew &= ~CHANNEL_MSG_STATUS_UNREAD_BY_USER;
}
rsChannels->setMessageStatus(mChanId, mMsgId, statusNew, CHANNEL_MSG_STATUS_READ | CHANNEL_MSG_STATUS_UNREAD_BY_USER);
}
void ChanMsgItem::channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status)
{
if (channelId.toStdString() == mChanId && msgId.toStdString() == mMsgId) {
updateItemStatic();
}
}

View file

@ -51,6 +51,9 @@ private slots:
void download();
void play();
void readToggled(bool checked);
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
void updateItem();
private:
@ -61,11 +64,10 @@ private:
std::string mMsgId;
bool mIsHome;
bool m_inUpdateItemStatic;
std::list<SubFileItem *> mFileItems;
};
#endif

View file

@ -87,7 +87,7 @@ border-radius: 10px;}</string>
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/thumb-default-video.png</pixmap>
<pixmap>:/images/thumb-default-video.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
@ -114,7 +114,7 @@ border-radius: 10px;}</string>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="7">
<item row="0" column="0" colspan="8">
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
@ -139,7 +139,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="7" colspan="3">
<item row="0" column="8" colspan="3">
<widget class="QLabel" name="datetimelabel">
<property name="font">
<font>
@ -156,7 +156,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="0" colspan="10">
<item row="1" column="0" colspan="11">
<widget class="QLabel" name="subjectLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
@ -182,7 +182,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="6" colspan="2">
<item row="2" column="7" colspan="2">
<widget class="QPushButton" name="unsubscribeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -197,12 +197,12 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/mail_delete.png</normaloff>:/images/mail_delete.png</iconset>
</property>
</widget>
</item>
<item row="2" column="8">
<item row="2" column="9">
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -217,12 +217,12 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
<item row="2" column="9">
<item row="2" column="10">
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -240,7 +240,7 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
@ -248,33 +248,33 @@ p, li { white-space: pre-wrap; }
<item row="2" column="1">
<widget class="QLabel" name="filelabel">
<property name="text">
<string notr="true">TextLabel</string>
<string notr="true">fileLabel</string>
</property>
</widget>
</item>
<item row="2" column="3">
<item row="2" column="4">
<widget class="QPushButton" name="downloadButton">
<property name="text">
<string>Download</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/download16.png</normaloff>:/images/download16.png</iconset>
</property>
</widget>
</item>
<item row="2" column="4">
<item row="2" column="5">
<widget class="QPushButton" name="playButton">
<property name="text">
<string>Play</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/player_play.png</normaloff>:/images/player_play.png</iconset>
</property>
</widget>
</item>
<item row="2" column="5">
<item row="2" column="6">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -290,6 +290,30 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="readButton">
<property name="icon">
<iconset>
<normaloff>:/images/message-state-unread.png</normaloff>:/images/message-state-unread.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="newLabel">
<property name="text">
<string>New</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -349,15 +373,6 @@ border-radius: 10px;}</string>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources>
<resources/>
<connections/>
</ui>