2008-06-20 08:43:23 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Robert Fernie
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2009-09-12 06:55:40 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2008-06-20 08:43:23 -04:00
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
2010-07-23 14:52:58 -04:00
|
|
|
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QStandardItemModel>
|
2010-10-17 10:43:49 -04:00
|
|
|
#include <QDateTime>
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
#include <iostream>
|
2008-11-02 10:20:42 -05:00
|
|
|
#include <algorithm>
|
2010-11-06 20:02:51 -04:00
|
|
|
#include <set>
|
|
|
|
#include <map>
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
#include "ChannelFeed.h"
|
2010-01-29 20:13:03 -05:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
#include "feeds/ChanMsgItem.h"
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
#include "channels/CreateChannel.h"
|
|
|
|
#include "channels/ChannelDetails.h"
|
|
|
|
#include "channels/CreateChannelMsg.h"
|
|
|
|
#include "channels/EditChanDetails.h"
|
|
|
|
#include "channels/ShareKey.h"
|
|
|
|
#include "notifyqt.h"
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
#include "ChanGroupDelegate.h"
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2010-05-14 09:06:58 -04:00
|
|
|
#define CHAN_DEFAULT_IMAGE ":/images/channels.png"
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
#define COLUMN_NAME 0
|
|
|
|
#define COLUMN_POPULARITY 1
|
|
|
|
#define COLUMN_COUNT 2
|
|
|
|
#define COLUMN_DATA COLUMN_NAME
|
|
|
|
|
|
|
|
#define ROLE_ID Qt::UserRole
|
|
|
|
#define ROLE_CHANNEL_TITLE Qt::UserRole + 1
|
2010-10-25 16:46:26 -04:00
|
|
|
#define ROLE_CHANNEL_SEARCH_SCORE Qt::UserRole + 2
|
2010-10-17 10:43:49 -04:00
|
|
|
#define ROLE_CHANNEL_TS Qt::UserRole + 3
|
2010-10-06 20:17:42 -04:00
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
|
|
|
|
#define COMBO_TITLE_INDEX 0
|
|
|
|
#define COMBO_DESC_INDEX 1
|
|
|
|
|
2010-11-06 20:02:51 -04:00
|
|
|
#define WARNING_LIMIT 3600*24*2
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
/****
|
|
|
|
* #define CHAN_DEBUG
|
|
|
|
***/
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
/** Constructor */
|
|
|
|
ChannelFeed::ChannelFeed(QWidget *parent)
|
2010-07-23 07:55:21 -04:00
|
|
|
: RsAutoUpdatePage(1000,parent)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
2010-10-06 20:17:42 -04:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
connect(actionCreate_Channel, SIGNAL(triggered()), this, SLOT(createChannel()));
|
|
|
|
connect(postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
|
|
|
|
connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeChannel ( void ) ) );
|
|
|
|
connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) );
|
|
|
|
connect(setAllAsReadButton, SIGNAL(clicked()), this, SLOT(setAllAsReadClicked()));
|
2010-10-17 10:43:49 -04:00
|
|
|
connect(resetButton, SIGNAL(clicked()), this, SLOT(finishSearching( void )));
|
2010-10-25 16:46:26 -04:00
|
|
|
connect( searchLine, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
2010-10-06 20:17:42 -04:00
|
|
|
|
|
|
|
connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
|
|
|
|
|
|
|
|
/*************** Setup Left Hand Side (List of Channels) ****************/
|
|
|
|
|
|
|
|
connect(treeView, SIGNAL(customContextMenuRequested( QPoint ) ), this, SLOT( channelListCustomPopupMenu( QPoint ) ) );
|
|
|
|
|
|
|
|
mChannelId.clear();
|
2010-10-11 18:39:47 -04:00
|
|
|
|
|
|
|
model = new QStandardItemModel(0, COLUMN_COUNT, this);
|
2010-10-06 20:17:42 -04:00
|
|
|
model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name"), Qt::DisplayRole);
|
|
|
|
model->setHeaderData(COLUMN_POPULARITY, Qt::Horizontal, tr("Popularity"), Qt::DisplayRole);
|
|
|
|
|
|
|
|
treeView->setModel(model);
|
|
|
|
|
|
|
|
treeView->setItemDelegate(new ChanGroupDelegate());
|
|
|
|
|
|
|
|
connect(treeView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(selectChannel(QModelIndex)));
|
|
|
|
|
|
|
|
/* Set header resize modes and initial section sizes TreeView*/
|
2010-06-26 18:28:04 -04:00
|
|
|
QHeaderView * _header = treeView->header () ;
|
2010-10-11 18:39:47 -04:00
|
|
|
_header->setResizeMode ( COLUMN_NAME, QHeaderView::Stretch);
|
|
|
|
_header->setResizeMode ( COLUMN_POPULARITY, QHeaderView::Fixed);
|
|
|
|
_header->resizeSection ( COLUMN_POPULARITY, 25 );
|
2010-06-26 18:28:04 -04:00
|
|
|
|
|
|
|
// set ChannelList Font
|
2010-10-06 20:17:42 -04:00
|
|
|
itemFont = QFont("ARIAL", 10);
|
|
|
|
itemFont.setBold(true);
|
|
|
|
|
|
|
|
QStandardItem *ownChannels = new QStandardItem(tr("Own Channels"));
|
2010-06-26 18:28:04 -04:00
|
|
|
ownChannels->setFont(itemFont);
|
|
|
|
ownChannels->setForeground(QBrush(QColor(79, 79, 79)));
|
2009-09-12 06:55:40 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
QStandardItem *subcribedChannels = new QStandardItem(tr("Subscribed Channels"));
|
2010-06-26 18:28:04 -04:00
|
|
|
subcribedChannels->setFont(itemFont);
|
|
|
|
subcribedChannels->setForeground(QBrush(QColor(79, 79, 79)));
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
QStandardItem *popularChannels = new QStandardItem(tr("Popular Channels"));
|
2010-06-26 18:28:04 -04:00
|
|
|
popularChannels->setFont(itemFont);
|
|
|
|
popularChannels->setForeground(QBrush(QColor(79, 79, 79)));
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
QStandardItem *otherChannels = new QStandardItem(tr("Other Channels"));
|
2010-06-26 18:28:04 -04:00
|
|
|
otherChannels->setFont(itemFont);
|
|
|
|
otherChannels->setForeground(QBrush(QColor(79, 79, 79)));
|
2009-09-12 06:55:40 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
model->appendRow(ownChannels);
|
|
|
|
model->appendRow(subcribedChannels);
|
|
|
|
model->appendRow(popularChannels);
|
|
|
|
model->appendRow(otherChannels);
|
2009-09-12 06:55:40 -04:00
|
|
|
|
2010-09-15 12:06:31 -04:00
|
|
|
treeView->expand(ownChannels->index());
|
|
|
|
treeView->expand(subcribedChannels->index());
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
//added from ahead
|
|
|
|
updateChannelList();
|
2009-09-13 12:33:59 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
mChannelFont = QFont("MS SANS SERIF", 22);
|
|
|
|
nameLabel->setFont(mChannelFont);
|
|
|
|
nameLabel->setMinimumWidth(20);
|
|
|
|
|
2010-06-26 18:28:04 -04:00
|
|
|
// Setup Channel Menu:
|
|
|
|
QMenu *channelmenu = new QMenu();
|
|
|
|
channelmenu->addAction(actionCreate_Channel);
|
|
|
|
channelmenu->addSeparator();
|
|
|
|
channelpushButton->setMenu(channelmenu);
|
2010-10-17 10:43:49 -04:00
|
|
|
resetButton->setVisible(false);
|
2009-09-15 20:01:09 -04:00
|
|
|
|
2010-09-13 11:11:20 -04:00
|
|
|
updateChannelMsgs();
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
2010-01-19 19:29:40 -05:00
|
|
|
void ChannelFeed::channelListCustomPopupMenu( QPoint point )
|
|
|
|
{
|
2010-10-06 20:17:42 -04:00
|
|
|
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 *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_PUBLISH) && (ci.channelFlags & RS_DISTRIB_ADMIN)) {
|
2010-06-26 18:28:04 -04:00
|
|
|
contextMnu.addAction( postchannelAct );
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction( editChannelDetailAct);
|
|
|
|
contextMnu.addAction( shareKeyAct );
|
2010-09-24 11:20:35 -04:00
|
|
|
contextMnu.addAction( channeldetailsAct );
|
2010-10-06 20:17:42 -04:00
|
|
|
}
|
2010-11-06 20:02:51 -04:00
|
|
|
else if ((ci.channelFlags & RS_DISTRIB_PUBLISH) && (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) {
|
2010-02-28 16:59:39 -05:00
|
|
|
contextMnu.addAction( postchannelAct );
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction( channeldetailsAct );
|
2010-06-19 12:38:13 -04:00
|
|
|
contextMnu.addAction( shareKeyAct );
|
2010-10-06 20:17:42 -04:00
|
|
|
} else if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED) {
|
2010-02-28 16:59:39 -05:00
|
|
|
contextMnu.addAction( unsubscribechannelAct );
|
|
|
|
contextMnu.addSeparator();
|
2010-05-19 18:43:07 -04:00
|
|
|
contextMnu.addAction( channeldetailsAct );
|
|
|
|
contextMnu.addAction( restoreKeysAct );
|
2010-10-06 20:17:42 -04:00
|
|
|
} else {
|
2010-02-28 16:59:39 -05:00
|
|
|
contextMnu.addAction( subscribechannelAct );
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction( channeldetailsAct );
|
2010-05-19 18:43:07 -04:00
|
|
|
contextMnu.addAction( restoreKeysAct );
|
2010-10-06 20:17:42 -04:00
|
|
|
}
|
2010-01-19 19:29:40 -05:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
contextMnu.exec(QCursor::pos());
|
2010-01-19 19:29:40 -05:00
|
|
|
}
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
void ChannelFeed::createChannel()
|
|
|
|
{
|
2010-05-04 20:05:36 -04:00
|
|
|
CreateChannel cf (this);
|
|
|
|
cf.exec();
|
2008-06-24 00:36:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::channelSelection()
|
|
|
|
{
|
|
|
|
/* which item was selected? */
|
|
|
|
|
|
|
|
|
|
|
|
/* update mChannelId */
|
|
|
|
|
|
|
|
updateChannelMsgs();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************************/
|
|
|
|
/*************************************************************************************/
|
|
|
|
/*************************************************************************************/
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
void ChannelFeed::deleteFeedItem(QWidget *item, uint32_t type)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::openChat(std::string peerId)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-06-04 18:52:01 -04:00
|
|
|
void ChannelFeed::editChannelDetail(){
|
|
|
|
|
|
|
|
EditChanDetails editUi(this, 0, mChannelId);
|
|
|
|
editUi.exec();
|
|
|
|
}
|
|
|
|
|
2010-06-19 12:38:13 -04:00
|
|
|
void ChannelFeed::shareKey()
|
|
|
|
{
|
|
|
|
ShareKey shareUi(this, 0, mChannelId);
|
|
|
|
shareUi.exec();
|
|
|
|
}
|
|
|
|
|
2010-01-18 16:02:16 -05:00
|
|
|
void ChannelFeed::createMsg()
|
|
|
|
{
|
2010-10-06 20:17:42 -04:00
|
|
|
if (mChannelId.empty()) {
|
2010-01-18 16:02:16 -05:00
|
|
|
return;
|
2010-10-06 20:17:42 -04:00
|
|
|
}
|
2010-01-18 16:02:16 -05:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
CreateChannelMsg *msgDialog = new CreateChannelMsg(mChannelId);
|
|
|
|
msgDialog->show();
|
2010-05-04 20:05:36 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
/* window will destroy itself! */
|
2010-01-18 16:02:16 -05:00
|
|
|
}
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
void ChannelFeed::restoreChannelKeys()
|
2008-06-24 00:36:45 -04:00
|
|
|
{
|
2010-10-06 20:17:42 -04:00
|
|
|
rsChannels->channelRestoreKeys(mChannelId);
|
2008-06-24 00:36:45 -04:00
|
|
|
}
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
void ChannelFeed::selectChannel(QModelIndex index)
|
|
|
|
{
|
|
|
|
QStandardItem *itemData = NULL;
|
2010-05-19 18:43:07 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
if (index.isValid()) {
|
|
|
|
QStandardItem *item = model->itemFromIndex(index);
|
|
|
|
if (item && item->parent() != NULL) {
|
|
|
|
itemData = item->parent()->child(item->row(), COLUMN_DATA);
|
|
|
|
}
|
|
|
|
}
|
2010-05-19 18:43:07 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
if (itemData) {
|
|
|
|
mChannelId = itemData->data(ROLE_ID).toString().toStdString();
|
|
|
|
} else {
|
|
|
|
mChannelId.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
updateChannelMsgs();
|
2009-09-12 06:55:40 -04:00
|
|
|
}
|
|
|
|
|
2010-07-23 07:55:21 -04:00
|
|
|
void ChannelFeed::updateDisplay()
|
2008-06-24 00:36:45 -04:00
|
|
|
{
|
2010-10-06 20:17:42 -04:00
|
|
|
if (!rsChannels) {
|
|
|
|
return;
|
|
|
|
}
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
std::list<std::string> chanIds;
|
|
|
|
std::list<std::string>::iterator it;
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
if (rsChannels->channelsChanged(chanIds)) {
|
|
|
|
/* update channel list */
|
|
|
|
updateChannelList();
|
|
|
|
|
|
|
|
it = std::find(chanIds.begin(), chanIds.end(), mChannelId);
|
|
|
|
if (it != chanIds.end()) {
|
|
|
|
updateChannelMsgs();
|
|
|
|
}
|
|
|
|
}
|
2008-06-24 00:36:45 -04:00
|
|
|
}
|
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
void ChannelFeed::filterRegExpChanged(){
|
2010-10-17 10:43:49 -04:00
|
|
|
|
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
if(searchLine->text().isEmpty()){
|
2010-10-17 10:43:49 -04:00
|
|
|
finishSearching();
|
2010-10-25 16:46:26 -04:00
|
|
|
return;
|
|
|
|
}
|
2010-10-17 10:43:49 -04:00
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
resetButton->setEnabled(true);
|
2010-10-17 10:43:49 -04:00
|
|
|
resetButton->setVisible(true);
|
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
// force display to be updated
|
|
|
|
updateChannelList();
|
2010-10-17 10:43:49 -04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::finishSearching(){
|
|
|
|
|
|
|
|
|
|
|
|
searchLine->clear();
|
|
|
|
resetButton->setVisible(false);
|
2010-10-25 16:46:26 -04:00
|
|
|
resetButton->setEnabled(false);
|
|
|
|
mChanSearchScore.clear();
|
|
|
|
updateChannelList();
|
2010-10-17 10:43:49 -04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
void ChannelFeed::updateChannelList()
|
2008-06-24 00:36:45 -04:00
|
|
|
{
|
2010-10-06 20:17:42 -04:00
|
|
|
if (!rsChannels) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::list<ChannelInfo> channelList;
|
|
|
|
std::list<ChannelInfo>::iterator it;
|
|
|
|
|
|
|
|
rsChannels->getChannelList(channelList);
|
|
|
|
|
|
|
|
/* get the ids for our lists */
|
|
|
|
std::list<ChannelInfo> adminList;
|
|
|
|
std::list<ChannelInfo> subList;
|
|
|
|
std::list<ChannelInfo> popList;
|
|
|
|
std::list<ChannelInfo> otherList;
|
|
|
|
std::multimap<uint32_t, ChannelInfo> popMap;
|
|
|
|
|
|
|
|
for(it = channelList.begin(); it != channelList.end(); it++) {
|
|
|
|
/* sort it into Publish (Own), Subscribed, Popular and Other */
|
|
|
|
uint32_t flags = it->channelFlags;
|
|
|
|
|
2010-11-06 20:02:51 -04:00
|
|
|
if ((flags & RS_DISTRIB_ADMIN) && (flags & RS_DISTRIB_PUBLISH) && (flags & RS_DISTRIB_SUBSCRIBED)) {
|
2010-10-06 20:17:42 -04:00
|
|
|
adminList.push_back(*it);
|
2010-11-06 20:02:51 -04:00
|
|
|
} else if ((flags & RS_DISTRIB_SUBSCRIBED) || ((flags & RS_DISTRIB_SUBSCRIBED) && (flags &RS_DISTRIB_PUBLISH)) ) {
|
2010-10-06 20:17:42 -04:00
|
|
|
subList.push_back(*it);
|
|
|
|
} else {
|
|
|
|
/* rate the others by popularity */
|
|
|
|
popMap.insert(std::make_pair(it->pop, *it));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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, ChannelInfo>::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);
|
|
|
|
}
|
|
|
|
}
|
2010-01-29 20:13:03 -05:00
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
// check if search filter is being used
|
|
|
|
if(! searchLine->text().isEmpty()){
|
|
|
|
|
|
|
|
filterChannelList(adminList);
|
|
|
|
filterChannelList(subList);
|
|
|
|
filterChannelList(popList);
|
|
|
|
filterChannelList(otherList);
|
|
|
|
}
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
/* now we have our lists ---> update entries */
|
2010-01-29 20:13:03 -05:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
fillChannelList(OWN, adminList);
|
|
|
|
fillChannelList(SUBSCRIBED, subList);
|
|
|
|
fillChannelList(POPULAR, popList);
|
|
|
|
fillChannelList(OTHER, otherList);
|
2010-05-14 12:33:35 -04:00
|
|
|
|
2010-11-06 20:02:51 -04:00
|
|
|
// place notices for channel with private keys available
|
|
|
|
highlightPrivateKeys(SUBSCRIBED);
|
|
|
|
highlightPrivateKeys(POPULAR);
|
|
|
|
highlightPrivateKeys(OTHER);
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
updateMessageSummaryList("");
|
2008-06-24 00:36:45 -04:00
|
|
|
}
|
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
|
|
|
|
void ChannelFeed::filterChannelList(std::list<ChannelInfo> &ci){
|
|
|
|
|
|
|
|
uint32_t score = 0;
|
|
|
|
QString scoreString;
|
|
|
|
mChanSearchScore.clear();
|
|
|
|
std::list<ChannelInfo>::iterator it = ci.begin();
|
|
|
|
|
|
|
|
// first find out which has given word in it
|
|
|
|
for(;it != ci.end(); it++){
|
|
|
|
|
|
|
|
if(sectionCombo->currentIndex() == COMBO_DESC_INDEX){
|
|
|
|
scoreString = QString::fromStdWString(it->channelDesc);
|
|
|
|
score = scoreString.count(searchLine->text(), Qt::CaseInsensitive);
|
|
|
|
mChanSearchScore.insert(std::pair<std::string, uint32_t>(it->channelId, score));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
scoreString = QString::fromStdWString(it->channelName);
|
|
|
|
score = scoreString.count(searchLine->text(), Qt::CaseInsensitive);
|
|
|
|
mChanSearchScore.insert(std::pair<std::string, uint32_t>(it->channelId, score));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(score == 0){
|
|
|
|
it = ci.erase(it);
|
|
|
|
it--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-11-06 20:02:51 -04:00
|
|
|
void ChannelFeed::highlightPrivateKeys(int group){
|
|
|
|
|
|
|
|
QStandardItem *groupItem = model->item(group);
|
|
|
|
QStandardItem *item = NULL;
|
|
|
|
std::list<std::string> keysAvailable;
|
|
|
|
std::list<std::string>::iterator it;
|
|
|
|
int rowCount = 0;
|
|
|
|
QBrush brush;
|
|
|
|
|
|
|
|
brush.setColor(Qt::blue);
|
|
|
|
|
|
|
|
if((groupItem == NULL) || (rsChannels == NULL))
|
|
|
|
return;
|
|
|
|
|
|
|
|
rowCount = groupItem->rowCount();
|
|
|
|
rsChannels->getPubKeysAvailableGrpIds(keysAvailable);
|
|
|
|
|
|
|
|
|
|
|
|
for(it= keysAvailable.begin(); it != keysAvailable.end(); it++)
|
|
|
|
|
|
|
|
for (int row = 0; row < rowCount; row++) {
|
|
|
|
if (groupItem->child(row, COLUMN_DATA)->data(ROLE_ID).toString() == QString::fromStdString(*it)) {
|
|
|
|
/* found channel */
|
|
|
|
item = groupItem->child(row, COLUMN_NAME);
|
|
|
|
|
|
|
|
/* set title text to bold and colored blue */
|
|
|
|
QFont chanFont = item->font();
|
|
|
|
chanFont.setBold(true);
|
|
|
|
item->setFont(chanFont);
|
|
|
|
item->setForeground(brush);
|
|
|
|
item->setToolTip(item->toolTip() + QString("\nPrivate Key Available"));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::fillChannelList(int channelItem, std::list<ChannelInfo> &channelInfos){
|
2010-10-06 20:17:42 -04:00
|
|
|
std::list<ChannelInfo>::iterator iit;
|
2010-01-29 20:13:03 -05:00
|
|
|
|
|
|
|
/* remove rows with groups before adding new ones */
|
2010-10-06 20:17:42 -04:00
|
|
|
QStandardItem *groupItem = model->item(channelItem);
|
|
|
|
if (groupItem == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2010-01-29 20:13:03 -05:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
/* iterate all channels */
|
|
|
|
for (iit = channelInfos.begin(); iit != channelInfos.end(); iit++) {
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef CHAN_DEBUG
|
2010-10-06 20:17:42 -04:00
|
|
|
std::cerr << "ChannelFeed::fillChannelList(): " << channelItem << " - " << iit->channelId << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
ChannelInfo &ci = *iit;
|
|
|
|
QString channelId = QString::fromStdString(ci.channelId);
|
|
|
|
|
|
|
|
/* search exisiting channel item */
|
|
|
|
int row;
|
|
|
|
int rowCount = groupItem->rowCount();
|
|
|
|
for (row = 0; row < rowCount; row++) {
|
|
|
|
if (groupItem->child(row, COLUMN_DATA)->data(ROLE_ID).toString() == channelId) {
|
|
|
|
/* found channel */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
QStandardItem *chNameItem = NULL;
|
|
|
|
QStandardItem *chPopItem = NULL;
|
2010-10-06 20:17:42 -04:00
|
|
|
if (row < rowCount) {
|
|
|
|
chNameItem = groupItem->child(row, COLUMN_NAME);
|
|
|
|
chPopItem = groupItem->child(row, COLUMN_POPULARITY);
|
|
|
|
} else {
|
|
|
|
QList<QStandardItem*> channel;
|
2010-10-17 10:43:49 -04:00
|
|
|
chNameItem = new QChannelItem();
|
2010-10-06 20:17:42 -04:00
|
|
|
chPopItem = new QStandardItem();
|
2010-01-29 20:13:03 -05:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
channel.append(chNameItem);
|
|
|
|
channel.append(chPopItem);
|
|
|
|
groupItem->appendRow(channel);
|
|
|
|
|
|
|
|
groupItem->child(chNameItem->index().row(), COLUMN_DATA)->setData(channelId, ROLE_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
chNameItem->setText(QString::fromStdWString(ci.channelName));
|
|
|
|
groupItem->child(chNameItem->index().row(), COLUMN_DATA)->setData(QString::fromStdWString(ci.channelName), ROLE_CHANNEL_TITLE);
|
2010-10-17 10:43:49 -04:00
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
// important for arrangement of channels
|
|
|
|
groupItem->child(chNameItem->index().row(), COLUMN_DATA)->setData(((mChanSearchScore.find(channelId.toStdString()))->second),
|
|
|
|
ROLE_CHANNEL_SEARCH_SCORE);
|
2010-10-17 10:43:49 -04:00
|
|
|
groupItem->child(chNameItem->index().row(), COLUMN_DATA)->setData(QDateTime::fromTime_t(ci.lastPost), ROLE_CHANNEL_TS);
|
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
|
2010-11-06 20:02:51 -04:00
|
|
|
chNameItem->setToolTip(tr("Popularity: %1").arg(QString::number(ci.pop)));
|
2010-05-14 12:33:35 -04:00
|
|
|
|
|
|
|
QPixmap chanImage;
|
2010-10-06 20:17:42 -04:00
|
|
|
if (ci.pngImageLen != 0) {
|
|
|
|
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
|
|
|
|
} else {
|
|
|
|
chanImage = QPixmap(CHAN_DEFAULT_IMAGE);
|
|
|
|
}
|
|
|
|
chNameItem->setIcon(QIcon(chanImage));
|
|
|
|
|
|
|
|
/* set Popularity icon */
|
|
|
|
int popcount = ci.pop;
|
|
|
|
if (popcount == 0) {
|
|
|
|
chPopItem->setIcon(QIcon(":/images/hot_0.png"));
|
|
|
|
} else if (popcount < 2) {
|
|
|
|
chPopItem->setIcon(QIcon(":/images/hot_1.png"));
|
|
|
|
} else if (popcount < 4) {
|
|
|
|
chPopItem->setIcon(QIcon(":/images/hot_2.png"));
|
|
|
|
} else if (popcount < 8) {
|
|
|
|
chPopItem->setIcon(QIcon(":/images/hot_3.png"));
|
|
|
|
} else if (popcount < 16) {
|
|
|
|
chPopItem->setIcon(QIcon(":/images/hot_4.png"));
|
|
|
|
} else {
|
|
|
|
chPopItem->setIcon(QIcon(":/images/hot_5.png"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove all items not in list */
|
|
|
|
int row = 0;
|
|
|
|
int rowCount = groupItem->rowCount();
|
|
|
|
while (row < rowCount) {
|
|
|
|
std::string channelId = groupItem->child(row, COLUMN_DATA)->data(ROLE_ID).toString().toStdString();
|
|
|
|
|
|
|
|
for (iit = channelInfos.begin(); iit != channelInfos.end(); iit++) {
|
|
|
|
if (iit->channelId == channelId) {
|
|
|
|
break;
|
|
|
|
}
|
2010-05-14 12:33:35 -04:00
|
|
|
}
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
if (iit == channelInfos.end()) {
|
|
|
|
groupItem->removeRow(row);
|
|
|
|
rowCount = groupItem->rowCount();
|
|
|
|
} else {
|
|
|
|
row++;
|
|
|
|
}
|
|
|
|
}
|
2010-10-17 10:43:49 -04:00
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
model->item(channelItem)->sortChildren(COLUMN_NAME, Qt::DescendingOrder);
|
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
}
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
void ChannelFeed::channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status)
|
2008-06-24 00:36:45 -04:00
|
|
|
{
|
2010-10-06 20:17:42 -04:00
|
|
|
updateMessageSummaryList(channelId.toStdString());
|
|
|
|
}
|
2010-01-29 20:13:03 -05:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
void ChannelFeed::updateMessageSummaryList(const std::string &channelId)
|
|
|
|
{
|
|
|
|
int channelItems[2] = { OWN, SUBSCRIBED };
|
2010-01-29 20:13:03 -05:00
|
|
|
|
2010-11-06 20:02:51 -04:00
|
|
|
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
for (int channelItem = 0; channelItem < 2; channelItem++) {
|
2010-10-07 15:31:37 -04:00
|
|
|
QStandardItem *groupItem = model->item(channelItems[channelItem]);
|
2010-10-06 20:17:42 -04:00
|
|
|
if (groupItem == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int row;
|
|
|
|
int rowCount = groupItem->rowCount();
|
|
|
|
for (row = 0; row < rowCount; row++) {
|
|
|
|
std::string rowChannelId = groupItem->child(row, COLUMN_DATA)->data(ROLE_ID).toString().toStdString();
|
|
|
|
if (rowChannelId.empty()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (channelId.empty() || rowChannelId == channelId) {
|
|
|
|
/* calculate unread messages */
|
|
|
|
unsigned int newMessageCount = 0;
|
|
|
|
unsigned int unreadMessageCount = 0;
|
|
|
|
rsChannels->getMessageCount(rowChannelId, newMessageCount, unreadMessageCount);
|
|
|
|
|
|
|
|
QStandardItem *item = groupItem->child(row, COLUMN_NAME);
|
|
|
|
|
|
|
|
QString title = item->data(ROLE_CHANNEL_TITLE).toString();
|
|
|
|
QFont font = item->font();
|
|
|
|
|
|
|
|
if (unreadMessageCount) {
|
|
|
|
title += " (" + QString::number(unreadMessageCount) + ")";
|
|
|
|
font.setBold(true);
|
|
|
|
} else {
|
|
|
|
font.setBold(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
item->setText(title);
|
|
|
|
item->setFont(font);
|
|
|
|
|
|
|
|
if (channelId.empty() == false) {
|
|
|
|
/* calculate only this channel */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-06-24 00:36:45 -04:00
|
|
|
}
|
|
|
|
|
2010-10-05 16:39:14 -04:00
|
|
|
static bool sortChannelMsgSummary(const ChannelMsgSummary &msg1, const ChannelMsgSummary &msg2)
|
|
|
|
{
|
2010-10-07 15:31:37 -04:00
|
|
|
return (msg1.ts > msg2.ts);
|
2010-10-05 16:39:14 -04:00
|
|
|
}
|
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
void ChannelFeed::updateChannelMsgs()
|
|
|
|
{
|
2010-10-06 20:17:42 -04:00
|
|
|
if (!rsChannels) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-10-07 15:31:37 -04:00
|
|
|
/* replace all the messages with new ones */
|
|
|
|
std::list<ChanMsgItem *>::iterator mit;
|
|
|
|
for (mit = mChanMsgItems.begin(); mit != mChanMsgItems.end(); mit++) {
|
|
|
|
delete (*mit);
|
|
|
|
}
|
|
|
|
mChanMsgItems.clear();
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
ChannelInfo ci;
|
|
|
|
if (!rsChannels->getChannelInfo(mChannelId, ci)) {
|
|
|
|
postButton->setEnabled(false);
|
|
|
|
subscribeButton->setEnabled(false);
|
|
|
|
unsubscribeButton->setEnabled(false);
|
|
|
|
setAllAsReadButton->setEnabled(false);
|
|
|
|
nameLabel->setText(tr("No Channel Selected"));
|
|
|
|
iconLabel->setPixmap(QPixmap(":/images/channels.png"));
|
|
|
|
iconLabel->setEnabled(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ci.pngImageLen != 0) {
|
|
|
|
QPixmap chanImage;
|
|
|
|
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
|
|
|
|
iconLabel->setPixmap(chanImage);
|
|
|
|
iconLabel->setStyleSheet("QLabel{border: 3px solid white;}");
|
|
|
|
} else {
|
|
|
|
QPixmap defaulImage(CHAN_DEFAULT_IMAGE);
|
|
|
|
iconLabel->setPixmap(defaulImage);
|
|
|
|
iconLabel->setStyleSheet("QLabel{border: 2px solid white;border-radius: 10px;}");
|
|
|
|
}
|
|
|
|
iconLabel->setEnabled(true);
|
|
|
|
|
|
|
|
/* set textcolor for Channel name */
|
|
|
|
QString channelStr("<span style=\"font-size:22pt; font-weight:500;"
|
|
|
|
"color:#4F4F4F;\">%1</span>");
|
|
|
|
|
|
|
|
/* set Channel name */
|
|
|
|
QString cname = QString::fromStdWString(ci.channelName);
|
|
|
|
nameLabel->setText(channelStr.arg(cname));
|
|
|
|
|
|
|
|
/* do buttons */
|
|
|
|
if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED) {
|
|
|
|
subscribeButton->setEnabled(false);
|
|
|
|
unsubscribeButton->setEnabled(true);
|
|
|
|
setAllAsReadButton->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
subscribeButton->setEnabled(true);
|
|
|
|
unsubscribeButton->setEnabled(false);
|
|
|
|
setAllAsReadButton->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ci.channelFlags & RS_DISTRIB_PUBLISH) {
|
|
|
|
postButton->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
postButton->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::list<ChannelMsgSummary> msgs;
|
|
|
|
std::list<ChannelMsgSummary>::iterator it;
|
|
|
|
rsChannels->getChannelMsgList(mChannelId, msgs);
|
|
|
|
|
|
|
|
msgs.sort(sortChannelMsgSummary);
|
|
|
|
|
2010-11-06 20:02:51 -04:00
|
|
|
/* set get warning list for channel */
|
|
|
|
std::map<std::string, uint32_t> warningList;
|
|
|
|
std::map<std::string, uint32_t>::iterator msgId_it;
|
|
|
|
|
|
|
|
rsChannels->getCleanUpList(warningList, mChannelId, WARNING_LIMIT);
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
for(it = msgs.begin(); it != msgs.end(); it++) {
|
|
|
|
ChanMsgItem *cmi = new ChanMsgItem(this, 0, mChannelId, it->msgId, true);
|
|
|
|
|
2010-11-06 20:02:51 -04:00
|
|
|
msgId_it = warningList.find(it->msgId);
|
|
|
|
if(msgId_it != warningList.end())
|
|
|
|
cmi->setFileCleanUpWarning(msgId_it->second);
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
mChanMsgItems.push_back(cmi);
|
|
|
|
verticalLayout_2->addWidget(cmi);
|
|
|
|
}
|
2008-06-24 00:36:45 -04:00
|
|
|
}
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-04 10:41:24 -04:00
|
|
|
void ChannelFeed::unsubscribeChannel()
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef CHAN_DEBUG
|
2010-10-06 20:17:42 -04:00
|
|
|
std::cerr << "ChannelFeed::unsubscribeChannel()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-04 10:41:24 -04:00
|
|
|
#endif
|
2010-10-06 20:17:42 -04:00
|
|
|
|
|
|
|
if (rsChannels) {
|
|
|
|
rsChannels->channelSubscribe(mChannelId, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
updateChannelMsgs();
|
2008-07-04 10:41:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChannelFeed::subscribeChannel()
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef CHAN_DEBUG
|
2010-10-06 20:17:42 -04:00
|
|
|
std::cerr << "ChannelFeed::subscribeChannel()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-04 10:41:24 -04:00
|
|
|
#endif
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
if (rsChannels) {
|
|
|
|
rsChannels->channelSubscribe(mChannelId, true);
|
|
|
|
}
|
2008-07-04 10:41:24 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
updateChannelMsgs();
|
2009-09-12 06:55:40 -04:00
|
|
|
}
|
2010-01-04 20:49:58 -05:00
|
|
|
|
2010-01-19 19:29:40 -05:00
|
|
|
void ChannelFeed::showChannelDetails()
|
|
|
|
{
|
2010-10-06 20:17:42 -04:00
|
|
|
if (mChannelId.empty()) {
|
2010-01-19 19:29:40 -05:00
|
|
|
return;
|
2010-10-06 20:17:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!rsChannels) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ChannelDetails channelui (this);
|
|
|
|
|
|
|
|
channelui.showDetails(mChannelId);
|
|
|
|
channelui.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelFeed::setAllAsReadClicked()
|
|
|
|
{
|
|
|
|
if (mChannelId.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
2010-01-19 19:29:40 -05:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
if (!rsChannels) {
|
|
|
|
return;
|
|
|
|
}
|
2010-01-19 19:29:40 -05:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
ChannelInfo ci;
|
|
|
|
if (rsChannels->getChannelInfo(mChannelId, ci) == false) {
|
|
|
|
return;
|
|
|
|
}
|
2010-01-19 19:29:40 -05:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED) {
|
|
|
|
std::list<ChannelMsgSummary> msgs;
|
|
|
|
std::list<ChannelMsgSummary>::iterator it;
|
|
|
|
|
|
|
|
rsChannels->getChannelMsgList(mChannelId, msgs);
|
|
|
|
|
|
|
|
for(it = msgs.begin(); it != msgs.end(); it++) {
|
|
|
|
rsChannels->setMessageStatus(mChannelId, it->msgId, CHANNEL_MSG_STATUS_READ, CHANNEL_MSG_STATUS_READ | CHANNEL_MSG_STATUS_UNREAD_BY_USER);
|
|
|
|
}
|
|
|
|
}
|
2010-01-19 19:29:40 -05:00
|
|
|
}
|
2010-10-17 10:43:49 -04:00
|
|
|
|
|
|
|
QChannelItem::QChannelItem()
|
|
|
|
: QStandardItem(){
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QChannelItem::~QChannelItem(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QChannelItem::operator<(const QStandardItem& other) const {
|
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
uint32_t otherCount = 0, thisCount = 0;
|
2010-10-17 10:43:49 -04:00
|
|
|
uint otherChanTs = other.data(ROLE_CHANNEL_TS).toDateTime().toTime_t();
|
|
|
|
uint thisChanTs = this->data(ROLE_CHANNEL_TS).toDateTime().toTime_t();
|
|
|
|
|
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
otherCount = other.data(ROLE_CHANNEL_SEARCH_SCORE).toUInt();
|
|
|
|
thisCount = this->data(ROLE_CHANNEL_SEARCH_SCORE).toUInt();
|
|
|
|
|
2010-10-17 10:43:49 -04:00
|
|
|
// if counts are equal then determine by who has the most recent post
|
|
|
|
if(otherCount == thisCount){
|
2010-10-25 16:46:26 -04:00
|
|
|
if(thisChanTs < otherChanTs)
|
2010-10-17 10:43:49 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// choose the item where the string occurs the most
|
|
|
|
if(thisCount < otherCount)
|
|
|
|
return true;
|
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
if(thisChanTs < otherChanTs)
|
|
|
|
return true;
|
2010-10-17 10:43:49 -04:00
|
|
|
|
2010-10-25 16:46:26 -04:00
|
|
|
return false;
|
2010-10-17 10:43:49 -04:00
|
|
|
}
|
|
|
|
|