auto download option:

ability to enable and disable channels auto dl added
added gui update to channel feed
msg download not enabled yet

cache opt:
added more enable cache opt #defines to disable cache opt code





git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4133 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2011-04-07 22:10:10 +00:00
parent 814c5d1619
commit 1bef23042f
4 changed files with 664 additions and 613 deletions

View File

@ -42,6 +42,8 @@
#include "notifyqt.h" #include "notifyqt.h"
#define CHAN_DEFAULT_IMAGE ":/images/channels.png" #define CHAN_DEFAULT_IMAGE ":/images/channels.png"
#define ENABLE_AUTO_DL "Enable Auto-Download"
#define DISABLE_AUTO_DL "Disable Auto-Download"
#define WARNING_LIMIT 3600*24*2 #define WARNING_LIMIT 3600*24*2
@ -61,6 +63,7 @@ ChannelFeed::ChannelFeed(QWidget *parent)
connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeChannel ( void ) ) ); connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeChannel ( void ) ) );
connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) ); connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) );
connect(setAllAsReadButton, SIGNAL(clicked()), this, SLOT(setAllAsReadClicked())); connect(setAllAsReadButton, SIGNAL(clicked()), this, SLOT(setAllAsReadClicked()));
connect(autoDownload, SIGNAL(clicked()), this, SLOT(toggleAutoDownload()));
connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int))); connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
@ -84,6 +87,7 @@ ChannelFeed::ChannelFeed(QWidget *parent)
popularChannels = treeWidget->addCategoryItem(tr("Popular Channels"), QIcon(), false); popularChannels = treeWidget->addCategoryItem(tr("Popular Channels"), QIcon(), false);
otherChannels = treeWidget->addCategoryItem(tr("Other Channels"), QIcon(), false); otherChannels = treeWidget->addCategoryItem(tr("Other Channels"), QIcon(), false);
//added from ahead //added from ahead
updateChannelList(); updateChannelList();
@ -238,6 +242,14 @@ void ChannelFeed::selectChannel(const QString &id)
{ {
mChannelId = id.toStdString(); mChannelId = id.toStdString();
bool autoDl = false;
rsChannels->channelGetAutoDl(mChannelId, autoDl);
if(autoDl)
autoDownload->setText(QString(DISABLE_AUTO_DL));
else
autoDownload->setText(QString(ENABLE_AUTO_DL));
updateChannelMsgs(); updateChannelMsgs();
} }
@ -450,14 +462,21 @@ void ChannelFeed::updateChannelMsgs()
subscribeButton->setEnabled(true); subscribeButton->setEnabled(true);
unsubscribeButton->setEnabled(false); unsubscribeButton->setEnabled(false);
setAllAsReadButton->setEnabled(false); setAllAsReadButton->setEnabled(false);
autoDownload->setEnabled(false);
} }
if (ci.channelFlags & RS_DISTRIB_PUBLISH) { if (ci.channelFlags & RS_DISTRIB_PUBLISH) {
postButton->setEnabled(true); postButton->setEnabled(true);
autoDownload->setEnabled(false);
} else { } else {
postButton->setEnabled(false); postButton->setEnabled(false);
} }
if(!(ci.channelFlags & RS_DISTRIB_PUBLISH) &&
(ci.channelFlags & RS_DISTRIB_SUBSCRIBED))
autoDownload->setEnabled(true);
std::list<ChannelMsgSummary> msgs; std::list<ChannelMsgSummary> msgs;
std::list<ChannelMsgSummary>::iterator it; std::list<ChannelMsgSummary>::iterator it;
rsChannels->getChannelMsgList(mChannelId, msgs); rsChannels->getChannelMsgList(mChannelId, msgs);
@ -482,7 +501,7 @@ void ChannelFeed::unsubscribeChannel()
#endif #endif
if (rsChannels) { if (rsChannels) {
rsChannels->channelSubscribe(mChannelId, false); rsChannels->channelSubscribe(mChannelId, false, false);
} }
updateChannelMsgs(); updateChannelMsgs();
@ -497,7 +516,7 @@ void ChannelFeed::subscribeChannel()
#endif #endif
if (rsChannels) { if (rsChannels) {
rsChannels->channelSubscribe(mChannelId, true); rsChannels->channelSubscribe(mChannelId, true, true);
} }
updateChannelMsgs(); updateChannelMsgs();
@ -545,3 +564,27 @@ void ChannelFeed::setAllAsReadClicked()
} }
} }
} }
void ChannelFeed::toggleAutoDownload(){
if(mChannelId.empty())
return;
bool autoDl = true;
if(rsChannels->channelGetAutoDl(mChannelId, autoDl)){
// if auto dl is set true, then set false
if(autoDl){
rsChannels->channelSetAutoDl(mChannelId, false);
autoDownload->setText(QString(ENABLE_AUTO_DL));
}else{
rsChannels->channelSetAutoDl(mChannelId, true);
autoDownload->setText(QString(DISABLE_AUTO_DL));
}
}
else{
std::cerr << "Auto Download failed to set"
<< std::endl;
}
}

View File

@ -61,6 +61,7 @@ private slots:
void subscribeChannel(); void subscribeChannel();
void unsubscribeChannel(); void unsubscribeChannel();
void setAllAsReadClicked(); void setAllAsReadClicked();
void toggleAutoDownload();
void createMsg(); void createMsg();

View File

@ -506,6 +506,13 @@ border-image: url(:/images/btn_26_pressed.png) 4;
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="5">
<widget class="QPushButton" name="autoDownload">
<property name="text">
<string>Enable Auto-download</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -542,8 +549,8 @@ border-image: url(:/images/btn_26_pressed.png) 4;
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>404</width> <width>407</width>
<height>331</height> <height>330</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">

View File

@ -188,7 +188,7 @@ void ChanNewItem::unsubscribeChannel()
#endif #endif
if (rsChannels) if (rsChannels)
{ {
rsChannels->channelSubscribe(mChanId, false); rsChannels->channelSubscribe(mChanId, false, false);
} }
updateItemStatic(); updateItemStatic();
} }
@ -202,7 +202,7 @@ void ChanNewItem::subscribeChannel()
#endif #endif
if (rsChannels) if (rsChannels)
{ {
rsChannels->channelSubscribe(mChanId, true); rsChannels->channelSubscribe(mChanId, true, true);
} }
updateItemStatic(); updateItemStatic();
} }