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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
#include <QtGui>
|
|
|
|
|
|
|
|
#include "BlogMsgItem.h"
|
|
|
|
|
|
|
|
#include "FeedHolder.h"
|
|
|
|
#include "SubFileItem.h"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#define DEBUG_ITEM 1
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
BlogMsgItem::BlogMsgItem(FeedHolder *parent, uint32_t feedId, std::string peerId, std::string msgId, bool isHome)
|
|
|
|
:QWidget(NULL), mParent(parent), mFeedId(feedId),
|
|
|
|
mPeerId(peerId), mMsgId(msgId), mIsHome(isHome)
|
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
/* general ones */
|
|
|
|
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
|
|
|
|
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
|
2008-07-04 10:41:24 -04:00
|
|
|
//connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
/* specific ones */
|
|
|
|
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( playMedia ( void ) ) );
|
|
|
|
|
|
|
|
small();
|
|
|
|
updateItemStatic();
|
|
|
|
updateItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BlogMsgItem::updateItemStatic()
|
|
|
|
{
|
|
|
|
/* fill in */
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "BlogMsgItem::updateItemStatic()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
2008-07-06 12:03:16 -04:00
|
|
|
msgLabel->setText("What did you expect? \nThe Blogs will be up and running shortly!");
|
|
|
|
titleLabel->setText("Blog Feed: Jacki @ Friday");
|
|
|
|
subjectLabel->setText("Brand new exciting Blog stuff");
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
/* add Files */
|
|
|
|
int total = (int) (10.0 * (rand() / (RAND_MAX + 1.0)));
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < total; i++)
|
|
|
|
{
|
|
|
|
/* add file */
|
2008-07-06 12:03:16 -04:00
|
|
|
SubFileItem *fi = new SubFileItem("dummyHash", "dummy_File", 1283918, SFI_STATE_REMOTE, mPeerId);
|
2008-06-20 08:43:23 -04:00
|
|
|
mFileItems.push_back(fi);
|
|
|
|
|
|
|
|
QLayout *layout = expandFrame->layout();
|
|
|
|
layout->addWidget(fi);
|
|
|
|
}
|
|
|
|
|
|
|
|
playButton->setEnabled(false);
|
|
|
|
|
|
|
|
if (mIsHome)
|
|
|
|
{
|
|
|
|
/* disable buttons */
|
|
|
|
clearButton->setEnabled(false);
|
2008-07-04 10:41:24 -04:00
|
|
|
//gotoButton->setEnabled(false);
|
|
|
|
|
|
|
|
clearButton->hide();
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BlogMsgItem::updateItem()
|
|
|
|
{
|
|
|
|
/* fill in */
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "BlogMsgItem::updateItem()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
int msec_rate = 10000;
|
|
|
|
|
|
|
|
/* 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())
|
|
|
|
{
|
|
|
|
/* loop again */
|
|
|
|
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2008-07-04 10:41:24 -04:00
|
|
|
if (mFileItems.size() > 0)
|
|
|
|
{
|
|
|
|
playButton->setEnabled(true);
|
|
|
|
}
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BlogMsgItem::small()
|
|
|
|
{
|
|
|
|
expandFrame->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BlogMsgItem::toggle()
|
|
|
|
{
|
|
|
|
if (expandFrame->isHidden())
|
|
|
|
{
|
|
|
|
expandFrame->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
expandFrame->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BlogMsgItem::removeItem()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "BlogMsgItem::removeItem()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
hide();
|
|
|
|
if (mParent)
|
|
|
|
{
|
|
|
|
mParent->deleteFeedItem(this, mFeedId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BlogMsgItem::gotoHome()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "BlogMsgItem::gotoHome()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********** SPECIFIC FUNCTIOSN ***********************/
|
|
|
|
|
|
|
|
|
|
|
|
void BlogMsgItem::playMedia()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "BlogMsgItem::playMedia()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|