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 "ForumNewItem.h"
|
|
|
|
#include "FeedHolder.h"
|
2011-04-19 15:42:44 -04:00
|
|
|
#include "gui/MainWindow.h"
|
|
|
|
#include "gui/ForumsDialog.h"
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsforums.h>
|
2010-05-23 19:02:15 -04:00
|
|
|
#include "gui/forums/CreateForumMsg.h"
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
/****
|
|
|
|
* #define DEBUG_ITEM 1
|
|
|
|
****/
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
/** 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);
|
|
|
|
|
2010-05-04 20:05:36 -04:00
|
|
|
setAttribute ( Qt::WA_DeleteOnClose, true );
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
/* general ones */
|
|
|
|
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
|
|
|
|
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
|
2011-04-19 15:42:44 -04:00
|
|
|
connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
/* specific ones */
|
|
|
|
connect( subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeForum ( void ) ) );
|
|
|
|
// To Cheeky to post on a brand new forum....
|
2010-05-23 19:02:15 -04:00
|
|
|
connect( postButton, SIGNAL( clicked( void ) ), this, SLOT( postToForum ( void ) ) );
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
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));
|
|
|
|
|
2010-04-29 15:00:27 -04:00
|
|
|
if (fi.subscribeFlags & RS_DISTRIB_SUBSCRIBED)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
|
|
|
subscribeButton->setEnabled(false);
|
2010-05-23 19:02:15 -04:00
|
|
|
postButton->setEnabled(true);
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
subscribeButton->setEnabled(true);
|
2010-05-23 19:02:15 -04:00
|
|
|
postButton->setEnabled(false);
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 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);
|
2008-07-04 10:41:24 -04:00
|
|
|
//gotoButton->setEnabled(false);
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
2008-08-17 10:13:09 -04:00
|
|
|
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
|
|
|
expandButton->setToolTip("Hide");
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
expandFrame->hide();
|
2008-08-17 10:13:09 -04:00
|
|
|
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
|
|
|
|
expandButton->setToolTip("Expand");
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2011-04-19 15:42:44 -04:00
|
|
|
|
|
|
|
MainWindow::showWindow(MainWindow::Forums);
|
|
|
|
ForumsDialog *forumsDialog = dynamic_cast<ForumsDialog*>(MainWindow::getPage(MainWindow::Forums));
|
|
|
|
if (forumsDialog) {
|
|
|
|
forumsDialog->navigate(mForumId, "");
|
|
|
|
}
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********** 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)
|
|
|
|
{
|
2010-05-23 18:35:51 -04:00
|
|
|
//mParent->openMsg(FEEDHOLDER_MSG_FORUM, mForumId, "");
|
2010-05-23 19:02:15 -04:00
|
|
|
CreateForumMsg *cfm = new CreateForumMsg(mForumId, "");
|
|
|
|
cfm->show();
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|