ChannelFeed:

- Sort the ChanMsgItems of the channel by date

ChanMsgItem:
- Fixed adding all files (SubFileItem) again by pressing the unsubscribe button (only in Friend Storm)
- Enable unsubscribe button only when channel is subscribed (only in Friend Storm)
- Fixed adding files with umlauts (utf8) on Windows
- Enabled Download and Play button in ChanMsgItem, when they are enabled in the SubFileItems

ftServer:
- Added the method alreadyHaveFile for use in the GUI - recompile of GUI needed

SubFileItem:
- Added state strings like LOCAL, REMOTE, ERROR, ... for translating


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3614 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-10-05 20:39:14 +00:00
parent 3c29434007
commit d31cef0f11
14 changed files with 290 additions and 120 deletions

View file

@ -52,6 +52,8 @@ ChanMsgItem::ChanMsgItem(FeedHolder *parent, uint32_t feedId, std::string chanId
/* specific */
connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) );
connect( downloadButton, SIGNAL( clicked( void ) ), this, SLOT( download ( void ) ) );
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( play ( void ) ) );
downloadButton->hide();
playButton->hide();
@ -89,12 +91,24 @@ void ChanMsgItem::updateItemStatic()
title += QString::fromStdWString(ci.channelName);
titleLabel->setText(title);
subjectLabel->setText(QString::fromStdWString(cmi.subject));
if ((ci.channelFlags & RS_DISTRIB_SUBSCRIBED) || (ci.channelFlags & RS_DISTRIB_ADMIN)) {
unsubscribeButton->setEnabled(true);
} else {
unsubscribeButton->setEnabled(false);
}
}
else
{
/* subject */
titleLabel->setText(QString::fromStdWString(cmi.subject));
subjectLabel->setText(QString::fromStdWString(cmi.msg));
/* disable buttons: deletion facility not enabled with cache services yet */
clearButton->setEnabled(false);
unsubscribeButton->setEnabled(false);
clearButton->hide();
unsubscribeButton->hide();
}
msgLabel->setText(QString::fromStdWString(cmi.msg));
@ -111,6 +125,15 @@ void ChanMsgItem::updateItemStatic()
}
if (mFileItems.empty() == false) {
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
delete(*it);
}
mFileItems.clear();
}
std::list<FileInfo>::iterator it;
for(it = cmi.files.begin(); it != cmi.files.end(); it++)
{
@ -132,17 +155,6 @@ void ChanMsgItem::updateItemStatic()
label->setPixmap(thumbnail);
label->setStyleSheet("QLabel#label{border: 2px solid #D3D3D3;border-radius: 3px;}");
}
if (mIsHome)
{
/* disable buttons: deletion facility not enabled with cache services yet */
clearButton->setEnabled(false);
unsubscribeButton->setEnabled(false);
clearButton->hide();
unsubscribeButton->hide();
}
}
@ -155,22 +167,68 @@ void ChanMsgItem::updateItem()
#endif
int msec_rate = 10000;
int downloadCount = 0;
int downloadStartable = 0;
int playCount = 0;
int playStartable = 0;
bool startable;
bool loopAgain = false;
/* Very slow Tick to check when all files are downloaded */
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
if (!(*it)->done())
SubFileItem *item = *it;
if (item->isDownloadable(startable)) {
downloadCount++;
if (startable) {
downloadStartable++;
}
}
if (item->isPlayable(startable)) {
playCount++;
if (startable) {
playStartable++;
}
}
if (!item->done())
{
/* loop again */
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
return;
loopAgain = true;
}
}
if (downloadCount) {
downloadButton->show();
if (downloadStartable) {
downloadButton->setEnabled(true);
} else {
downloadButton->setEnabled(false);
}
} else {
downloadButton->hide();
}
if (playCount) {
/* one file is playable */
playButton->show();
if (playStartable == 1) {
playButton->setEnabled(true);
} else {
playButton->setEnabled(false);
}
} else {
playButton->hide();
}
if (loopAgain) {
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
}
}
void ChanMsgItem::small()
{
expandFrame->hide();
@ -182,17 +240,16 @@ void ChanMsgItem::toggle()
{
expandFrame->show();
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
expandButton->setToolTip(tr("Hide"));
expandButton->setToolTip(tr("Hide"));
}
else
{
expandFrame->hide();
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip(tr("Expand"));
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip(tr("Expand"));
}
}
void ChanMsgItem::removeItem()
{
#ifdef DEBUG_ITEM
@ -220,10 +277,10 @@ void ChanMsgItem::gotoHome()
void ChanMsgItem::unsubscribeChannel()
{
#ifdef DEBUG_ITEM
std::cerr << "ChanMsgItem::unsubscribeChannel()";
std::cerr << std::endl;
#endif
#ifdef DEBUG_ITEM
std::cerr << "ChanMsgItem::unsubscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels)
{
@ -232,3 +289,25 @@ void ChanMsgItem::unsubscribeChannel()
updateItemStatic();
}
void ChanMsgItem::download()
{
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
(*it)->download();
}
updateItem();
}
void ChanMsgItem::play()
{
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
bool startable;
if ((*it)->isPlayable(startable) && startable) {
(*it)->play();
}
}
}

View file

@ -48,6 +48,8 @@ private slots:
void toggle();
void unsubscribeChannel();
void download();
void play();
void updateItem();

View file

@ -111,11 +111,9 @@ void SubFileItem::Setup()
if (mMode == SFI_STATE_REMOTE)
{
FileInfo fi;
uint32_t hintflags = RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL
| RS_FILE_HINTS_SPEC_ONLY;
/* look up path */
if (rsFiles->FileDetails(mFileHash, hintflags, fi))
if (rsFiles->alreadyHaveFile(mFileHash, fi))
{
#ifdef DEBUG_ITEM
std::cerr << "SubFileItem::Setup() STATE=>Local Found File";
@ -131,8 +129,6 @@ void SubFileItem::Setup()
smaller();
updateItemStatic();
updateItem();
}
@ -154,7 +150,7 @@ void SubFileItem::updateItemStatic()
std::cerr << std::endl;
#endif
QString filename = QString::fromStdString(mFileName);
QString filename = QString::fromUtf8(mFileName.c_str());
mDivisor = 1;
if (mFileSize > 10000000) /* 10 Mb */
@ -214,7 +210,7 @@ void SubFileItem::updateItemStatic()
{
case SFI_STATE_ERROR:
progressBar->setRange(0, 100);
progressBar->setFormat("ERROR");
progressBar->setFormat(tr("ERROR"));
playButton->setEnabled(false);
downloadButton->setEnabled(false);
@ -222,12 +218,12 @@ void SubFileItem::updateItemStatic()
expandButton->setEnabled(false);
progressBar->setValue(0);
filename = "[ERROR] " + filename;
filename = "[" + tr("ERROR") + "] " + filename;
break;
case SFI_STATE_EXTRA:
filename = QString::fromStdString(mPath);
filename = QString::fromUtf8(mPath.c_str());
progressBar->setRange(0, 100);
progressBar->setFormat("HASHING");
@ -238,7 +234,7 @@ void SubFileItem::updateItemStatic()
expandButton->setEnabled(false);
progressBar->setValue(0);
filename = "[EXTRA] " + filename;
filename = "[" + tr("EXTRA") + "] " + filename;
break;
@ -249,7 +245,7 @@ void SubFileItem::updateItemStatic()
expandButton->setEnabled(false);
progressBar->setValue(0);
filename = "[REMOTE] " + filename;
filename = "[" + tr("REMOTE") + "] " + filename;
break;
@ -258,7 +254,7 @@ void SubFileItem::updateItemStatic()
downloadButton->setEnabled(false);
cancelButton->setEnabled(true);
expandButton->setEnabled(true);
filename = "[DOWNLOAD] " + filename;
filename = "[" + tr("DOWNLOAD") + "] " + filename;
break;
@ -269,7 +265,7 @@ void SubFileItem::updateItemStatic()
expandButton->setEnabled(false);
progressBar->setValue(mFileSize / mDivisor);
filename = "[LOCAL] " + filename;
filename = "[" + tr("LOCAL") + "] " + filename;
break;
@ -278,7 +274,7 @@ void SubFileItem::updateItemStatic()
downloadButton->setEnabled(false);
cancelButton->setEnabled(false);
expandButton->setEnabled(true);
filename = "[UPLOAD] " + filename;
filename = "[" + tr("UPLOAD") + "] " + filename;
break;
}
@ -341,6 +337,11 @@ void SubFileItem::updateItem()
std::cerr << std::endl;
#endif
/* ignore - dead file, or done */
if (mMode == SFI_STATE_ERROR) {
/* updateStatic once */
stateChanged = true;
}
}
else if (mMode == SFI_STATE_EXTRA)
{
@ -554,6 +555,8 @@ void SubFileItem::cancel()
{
rsFiles->FileCancel(mFileHash);
}
updateItem();
}
@ -617,6 +620,9 @@ void SubFileItem::download()
}
rsFiles->FileRequest(mFileName, mFileHash, mFileSize, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds);
downloadButton->setEnabled(false);
updateItem();
}
@ -653,3 +659,21 @@ void SubFileItem::save()
uint32_t SubFileItem::getState() {
return mMode;
}
bool SubFileItem::isDownloadable(bool &startable)
{
/* Check buttons. Not good, but it works. */
bool visible = downloadButton->isVisibleTo(this);
startable = visible && downloadButton->isEnabled();
return visible;
}
bool SubFileItem::isPlayable(bool &startable)
{
/* Check buttons. Not good, but it works. */
bool visible = playButton->isVisibleTo(this);
startable = visible && playButton->isEnabled();
return visible;
}

View file

@ -70,14 +70,17 @@ public:
bool ready();
uint32_t getState();
bool isDownloadable(bool &startable);
bool isPlayable(bool &startable);
public slots:
void download();
void play();
private slots:
void toggle();
void cancel();
void play();
void save();
void updateItem();