mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-08 00:55:13 -04:00
* Addition of NewsFeed, ChannelFeed and BlogFeed.
* Added new GUI NewsFeed elements to display information (gui/feeds/*) * modifications to RS interfaces to support NewsFeeds. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@617 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9f024eaee7
commit
07451c5336
43 changed files with 6550 additions and 1303 deletions
206
retroshare-gui/src/gui/feeds/ForumNewItem.cpp
Normal file
206
retroshare-gui/src/gui/feeds/ForumNewItem.cpp
Normal file
|
@ -0,0 +1,206 @@
|
|||
/****************************************************************
|
||||
* 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 "ForumNewItem.h"
|
||||
#include "FeedHolder.h"
|
||||
|
||||
#include "rsiface/rsforums.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define DEBUG_ITEM 1
|
||||
|
||||
/** Constructor */
|
||||
ForumNewItem::ForumNewItem(FeedHolder *parent, uint32_t feedId, std::string forumId, bool isHome, bool isNew)
|
||||
:QWidget(NULL), mParent(parent), mFeedId(feedId),
|
||||
mForumId(forumId), mIsHome(isHome), mIsNew(isNew)
|
||||
{
|
||||
/* 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 ) ) );
|
||||
connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
|
||||
|
||||
/* specific ones */
|
||||
connect( subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeForum ( void ) ) );
|
||||
// To Cheeky to post on a brand new forum....
|
||||
//connect( postButton, SIGNAL( clicked( void ) ), this, SLOT( postToForum ( void ) ) );
|
||||
|
||||
small();
|
||||
updateItemStatic();
|
||||
updateItem();
|
||||
}
|
||||
|
||||
|
||||
void ForumNewItem::updateItemStatic()
|
||||
{
|
||||
if (!rsForums)
|
||||
return;
|
||||
|
||||
|
||||
/* fill in */
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "ForumNewItem::updateItemStatic()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
ForumInfo fi;
|
||||
if (rsForums->getForumInfo(mForumId, fi))
|
||||
{
|
||||
nameLabel->setText(QString::fromStdWString(fi.forumName));
|
||||
|
||||
descLabel->setText(QString::fromStdWString(fi.forumDesc));
|
||||
|
||||
if (fi.forumFlags & RS_DISTRIB_SUBSCRIBED)
|
||||
{
|
||||
subscribeButton->setEnabled(false);
|
||||
//postButton->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
subscribeButton->setEnabled(true);
|
||||
//postButton->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
/* should also check the other flags */
|
||||
}
|
||||
else
|
||||
{
|
||||
nameLabel->setText("Unknown Forum");
|
||||
titleLabel->setText("New Forum");
|
||||
descLabel->setText("");
|
||||
}
|
||||
|
||||
if (mIsNew)
|
||||
{
|
||||
titleLabel->setText("New Forum");
|
||||
}
|
||||
else
|
||||
{
|
||||
titleLabel->setText("Updated Forum");
|
||||
}
|
||||
|
||||
if (mIsHome)
|
||||
{
|
||||
/* disable buttons */
|
||||
clearButton->setEnabled(false);
|
||||
gotoButton->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ForumNewItem::updateItem()
|
||||
{
|
||||
/* fill in */
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "ForumNewItem::updateItem()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ForumNewItem::small()
|
||||
{
|
||||
expandFrame->hide();
|
||||
}
|
||||
|
||||
void ForumNewItem::toggle()
|
||||
{
|
||||
if (expandFrame->isHidden())
|
||||
{
|
||||
expandFrame->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
expandFrame->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ForumNewItem::removeItem()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "ForumNewItem::removeItem()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
hide();
|
||||
if (mParent)
|
||||
{
|
||||
mParent->deleteFeedItem(this, mFeedId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ForumNewItem::gotoHome()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "ForumNewItem::gotoHome()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*********** SPECIFIC FUNCTIOSN ***********************/
|
||||
|
||||
|
||||
void ForumNewItem::unsubscribeForum()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "ForumNewItem::unsubscribeForum()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
if (rsForums)
|
||||
{
|
||||
rsForums->forumSubscribe(mForumId, false);
|
||||
}
|
||||
updateItemStatic();
|
||||
}
|
||||
|
||||
|
||||
void ForumNewItem::subscribeForum()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "ForumNewItem::subscribeForum()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
if (rsForums)
|
||||
{
|
||||
rsForums->forumSubscribe(mForumId, true);
|
||||
}
|
||||
updateItemStatic();
|
||||
}
|
||||
|
||||
void ForumNewItem::postToForum()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "ForumNewItem::subscribeForum()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
if (mParent)
|
||||
{
|
||||
mParent->openMsg(FEEDHOLDER_MSG_FORUM, mForumId, "");
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue