2013-03-11 16:53:15 -04:00
|
|
|
/*
|
2013-03-15 17:02:43 -04:00
|
|
|
* Retroshare Comment Container
|
2013-03-11 16:53:15 -04:00
|
|
|
*
|
|
|
|
* Copyright 2012-2012 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2.1 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gui/gxs/GxsCommentContainer.h"
|
|
|
|
#include "gui/gxs/GxsCommentDialog.h"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
#define MAX_COMMENT_TITLE 32
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
/****************************************************************
|
2013-07-15 14:39:39 -04:00
|
|
|
* GxsCommentContainer
|
2013-03-11 16:53:15 -04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
GxsCommentContainer::GxsCommentContainer(QWidget *parent)
|
|
|
|
: MainPage(parent)
|
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
2013-03-12 20:33:14 -04:00
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
connect(ui.tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int)));
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GxsCommentContainer::setup()
|
|
|
|
{
|
|
|
|
mServiceDialog = createServiceDialog();
|
2013-07-15 14:39:39 -04:00
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
QString name = getServiceName();
|
2013-07-15 14:39:39 -04:00
|
|
|
ui.titleBarLabel->setText(name);
|
|
|
|
ui.titleBarPixmap->setPixmap(getServicePixmap());
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
QWidget *widget = dynamic_cast<QWidget *>(mServiceDialog);
|
2013-07-15 14:39:39 -04:00
|
|
|
int index = ui.tabWidget->addTab(widget, name);
|
|
|
|
ui.tabWidget->hideCloseButton(index);
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
void GxsCommentContainer::commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title)
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
2013-03-15 17:02:43 -04:00
|
|
|
QString comments = title;
|
|
|
|
if (title.length() > MAX_COMMENT_TITLE)
|
|
|
|
{
|
|
|
|
comments.truncate(MAX_COMMENT_TITLE - 3);
|
|
|
|
comments += "...";
|
|
|
|
}
|
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
GxsCommentDialog *commentDialog = new GxsCommentDialog(this, getTokenService(), getCommentService());
|
2013-03-11 16:53:15 -04:00
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
QWidget *commentHeader = createHeaderWidget(grpId, msgId);
|
2013-03-11 16:53:15 -04:00
|
|
|
commentDialog->setCommentHeader(commentHeader);
|
|
|
|
|
|
|
|
commentDialog->commentLoad(grpId, msgId);
|
|
|
|
|
|
|
|
ui.tabWidget->addTab(commentDialog, comments);
|
|
|
|
}
|
|
|
|
|
2013-03-12 20:33:14 -04:00
|
|
|
void GxsCommentContainer::tabCloseRequested(int index)
|
|
|
|
{
|
|
|
|
std::cerr << "GxsCommentContainer::tabCloseRequested(" << index << ")";
|
2013-03-15 17:02:43 -04:00
|
|
|
std::cerr << std::endl;
|
2013-07-15 14:39:39 -04:00
|
|
|
|
2013-03-12 20:33:14 -04:00
|
|
|
if (index != 0)
|
|
|
|
{
|
|
|
|
QWidget *comments = ui.tabWidget->widget(index);
|
|
|
|
ui.tabWidget->removeTab(index);
|
|
|
|
delete comments;
|
|
|
|
}
|
2013-03-15 17:02:43 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cerr << "GxsCommentContainer::tabCloseRequested() Not closing First Tab";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
2013-03-12 20:33:14 -04:00
|
|
|
}
|