Cleanup of GxsChannels GUI.

- disabled last references to old channels system.
 - switched on contextMenu.
 - removed FillThread.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6230 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2013-03-16 12:28:14 +00:00
parent 5dac882572
commit 0c604d08d9
3 changed files with 121 additions and 136 deletions

View File

@ -36,8 +36,6 @@
#include "util/HandleRichText.h" #include "util/HandleRichText.h"
#include "util/DateTime.h" #include "util/DateTime.h"
#include <retroshare/rschannels.h>
/**** /****
* #define DEBUG_ITEM 1 * #define DEBUG_ITEM 1
****/ ****/
@ -215,9 +213,9 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
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);
#endif
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))
{ {
@ -229,7 +227,6 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
readButton->setChecked(false); readButton->setChecked(false);
readButton->setIcon(QIcon(":/images/message-state-read.png")); readButton->setIcon(QIcon(":/images/message-state-read.png"));
} }
#endif
bool newState; bool newState;
QColor color; QColor color;

View File

@ -31,8 +31,7 @@
#include "GxsChannelDialog.h" #include "GxsChannelDialog.h"
//#include "../feeds/ChanMsgItem.h" #include "gui/feeds/GxsChannelPostItem.h"
#include "../feeds/GxsChannelPostItem.h"
#include "../common/PopularityDefs.h" #include "../common/PopularityDefs.h"
#include "../settings/rsharesettings.h" #include "../settings/rsharesettings.h"
@ -104,8 +103,6 @@ GxsChannelDialog::GxsChannelDialog(QWidget *parent)
ui.progressLabel->hide(); ui.progressLabel->hide();
ui.progressBar->hide(); ui.progressBar->hide();
fillThread = NULL;
//added from ahead //added from ahead
//updateChannelList(); //updateChannelList();
forceUpdateDisplay(); forceUpdateDisplay();
@ -120,12 +117,6 @@ GxsChannelDialog::GxsChannelDialog(QWidget *parent)
GxsChannelDialog::~GxsChannelDialog() GxsChannelDialog::~GxsChannelDialog()
{ {
if (fillThread) {
fillThread->stop();
delete(fillThread);
fillThread = NULL;
}
// save settings // save settings
processSettings(false); processSettings(false);
} }
@ -167,6 +158,95 @@ void GxsChannelDialog::processSettings(bool load)
void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ ) 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; ChannelInfo ci;
if (!rsChannels->getChannelInfo(mChannelId, ci)) { if (!rsChannels->getChannelInfo(mChannelId, ci)) {
return; return;
@ -239,6 +319,9 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ )
#endif #endif
contextMnu.exec(QCursor::pos()); contextMnu.exec(QCursor::pos());
#endif
} }
void GxsChannelDialog::createChannel() void GxsChannelDialog::createChannel()
@ -329,12 +412,8 @@ void GxsChannelDialog::selectChannel(const QString &id)
{ {
mChannelId = id.toStdString(); mChannelId = id.toStdString();
#if 0 bool autoDl = rsGxsChannels->getChannelAutoDownload(mChannelId);
bool autoDl = false;
rsChannels->channelGetAutoDl(mChannelId, autoDl);
setAutoDownloadButton(autoDl); setAutoDownloadButton(autoDl);
#endif
requestPosts(mChannelId); requestPosts(mChannelId);
//updateChannelMsgs(); //updateChannelMsgs();
@ -440,6 +519,8 @@ void GxsChannelDialog::channelMsgReadSatusChanged(const QString& channelId, cons
void GxsChannelDialog::updateMessageSummaryList(const std::string &channelId) void GxsChannelDialog::updateMessageSummaryList(const std::string &channelId)
{ {
#if 0
QTreeWidgetItem *items[2] = { ownChannels, subcribedChannels }; QTreeWidgetItem *items[2] = { ownChannels, subcribedChannels };
for (int item = 0; item < 2; item++) { for (int item = 0; item < 2; item++) {
@ -467,12 +548,16 @@ void GxsChannelDialog::updateMessageSummaryList(const std::string &channelId)
} }
} }
} }
#endif
} }
#if 0
static bool sortChannelMsgSummary(const ChannelMsgSummary &msg1, const ChannelMsgSummary &msg2) static bool sortChannelMsgSummary(const ChannelMsgSummary &msg1, const ChannelMsgSummary &msg2)
{ {
return (msg1.ts > msg2.ts); return (msg1.ts > msg2.ts);
} }
#endif
#if 0 #if 0
void GxsChannelDialog::updateChannelMsgs() void GxsChannelDialog::updateChannelMsgs()
@ -711,28 +796,22 @@ void GxsChannelDialog::setAllAsReadClicked()
void GxsChannelDialog::toggleAutoDownload() void GxsChannelDialog::toggleAutoDownload()
{ {
#if 0
if(mChannelId.empty()) if(mChannelId.empty())
return; return;
bool autoDl = true; bool autoDl = true;
if(rsChannels->channelGetAutoDl(mChannelId, autoDl)){
// if auto dl is set true, then set false autoDl = rsGxsChannels->getChannelAutoDownload(mChannelId);
if(autoDl){ if (rsGxsChannels->setChannelAutoDownload(mChannelId, !autoDl))
rsChannels->channelSetAutoDl(mChannelId, false); {
}else{
rsChannels->channelSetAutoDl(mChannelId, true);
}
setAutoDownloadButton(!autoDl); setAutoDownloadButton(!autoDl);
} }
else{ else
std::cerr << "Auto Download failed to set" {
<< std::endl; std::cerr << "GxsChannelDialog::toggleAutoDownload() Auto Download failed to set";
std::cerr << std::endl;
} }
#endif
} }
bool GxsChannelDialog::navigate(const std::string& channelId, const std::string& msgId) bool GxsChannelDialog::navigate(const std::string& channelId, const std::string& msgId)
@ -776,75 +855,17 @@ bool GxsChannelDialog::navigate(const std::string& channelId, const std::string&
void GxsChannelDialog::setAutoDownloadButton(bool autoDl) void GxsChannelDialog::setAutoDownloadButton(bool autoDl)
{ {
#if 0
if (autoDl) { if (autoDl) {
actionEnable_Auto_Download->setText(tr("Disable Auto-Download")); ui.actionEnable_Auto_Download->setText(tr("Disable Auto-Download"));
}else{ }else{
actionEnable_Auto_Download->setText(tr("Enable Auto-Download")); ui.actionEnable_Auto_Download->setText(tr("Enable Auto-Download"));
} }
#endif
}
// ForumsFillThread
GxsChannelFillThread::GxsChannelFillThread(GxsChannelDialog *parent, const std::string &channelId)
: QThread(parent)
{
stopped = false;
this->channelId = channelId;
}
GxsChannelFillThread::~GxsChannelFillThread()
{
#ifdef CHAN_DEBUG
std::cerr << "GxsChannelFillThread::~GxsChannelFillThread" << std::endl;
#endif
}
void GxsChannelFillThread::stop()
{
disconnect();
stopped = true;
QApplication::processEvents();
wait();
}
void GxsChannelFillThread::run()
{
#ifdef CHAN_DEBUG
std::cerr << "GxsChannelFillThread::run()" << std::endl;
#endif
std::list<ChannelMsgSummary> msgs;
std::list<ChannelMsgSummary>::iterator it;
rsChannels->getChannelMsgList(channelId, msgs);
msgs.sort(sortChannelMsgSummary);
int count = msgs.size();
int pos = 0;
for (it = msgs.begin(); it != msgs.end(); it++) {
if (stopped) {
break;
}
emit addMsg(QString::fromStdString(channelId), QString::fromStdString(it->msgId), ++pos, count);
}
#ifdef CHAN_DEBUG
std::cerr << "GxsChannelFillThread::run() stopped: " << (wasStopped() ? "yes" : "no") << std::endl;
#endif
} }
/********************************************************************************************** /**********************************************************************************************
* New Stuff here. * New Stuff here.
*
*
*
*************/ *************/
/*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/
@ -1029,42 +1050,36 @@ void GxsChannelDialog::insertChannelDetails(const RsGxsChannelGroup &group)
mChannelPostItems.clear(); mChannelPostItems.clear();
/* IMAGE - TODO. */ /* IMAGE */
#if 0
QPixmap chanImage; QPixmap chanImage;
if (ci.pngImageLen != 0) { if (group.mImage.mData != NULL) {
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG"); chanImage.loadFromData(group.mImage.mData, group.mImage.mSize, "PNG");
} else { } else {
chanImage = QPixmap(CHAN_DEFAULT_IMAGE); chanImage = QPixmap(CHAN_DEFAULT_IMAGE);
} }
logoLabel->setPixmap(chanImage); ui.logoLabel->setPixmap(chanImage);
logoLabel->setEnabled(true); ui.logoLabel->setEnabled(true);
#endif
/* set Channel name */ /* set Channel name */
ui.nameLabel->setText(QString::fromUtf8(group.mMeta.mGroupName.c_str())); ui.nameLabel->setText(QString::fromUtf8(group.mMeta.mGroupName.c_str()));
#if 0 if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)
if (group.mMeta.channelFlags & RS_DISTRIB_PUBLISH)
{ {
postButton->setEnabled(true); ui.postButton->setEnabled(true);
} }
else else
{ {
postButton->setEnabled(false); ui.postButton->setEnabled(false);
} }
if (!(ci.channelFlags & RS_DISTRIB_ADMIN) && if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)
(ci.channelFlags & RS_DISTRIB_SUBSCRIBED))
{ {
actionEnable_Auto_Download->setEnabled(true); ui.actionEnable_Auto_Download->setEnabled(true);
} }
else else
{ {
actionEnable_Auto_Download->setEnabled(false); ui.actionEnable_Auto_Download->setEnabled(false);
} }
#endif
} }

View File

@ -22,7 +22,6 @@
#ifndef _GXS_CHANNEL_DIALOG_H #ifndef _GXS_CHANNEL_DIALOG_H
#define _GXS_CHANNEL_DIALOG_H #define _GXS_CHANNEL_DIALOG_H
#include <retroshare/rschannels.h>
#include <retroshare/rsgxschannels.h> #include <retroshare/rsgxschannels.h>
#include <QStandardItemModel> #include <QStandardItemModel>
@ -42,7 +41,6 @@
//class ChanMsgItem; //class ChanMsgItem;
class GxsChannelPostItem; class GxsChannelPostItem;
class QTreeWidgetItem; class QTreeWidgetItem;
class GxsChannelFillThread;
class GxsChannelDialog : public RsAutoUpdatePage, public TokenResponse, public GxsServiceDialog, class GxsChannelDialog : public RsAutoUpdatePage, public TokenResponse, public GxsServiceDialog,
public FeedHolder public FeedHolder
@ -150,33 +148,8 @@ private:
QTreeWidgetItem *popularChannels; QTreeWidgetItem *popularChannels;
QTreeWidgetItem *otherChannels; QTreeWidgetItem *otherChannels;
GxsChannelFillThread *fillThread;
/* UI - from Designer */ /* UI - from Designer */
Ui::GxsChannelDialog ui; Ui::GxsChannelDialog ui;
}; };
class GxsChannelFillThread : public QThread
{
Q_OBJECT
public:
GxsChannelFillThread(GxsChannelDialog *parent, const std::string &channelId);
~GxsChannelFillThread();
void run();
void stop();
bool wasStopped() { return stopped; }
signals:
void addMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
public:
std::string channelId;
private:
volatile bool stopped;
};
#endif #endif