2018-11-14 15:14:40 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* retroshare-gui/src/gui/gxs/GxsCommentContainer.cpp *
|
|
|
|
* *
|
|
|
|
* Copyright 2012-2012 by Robert Fernie <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
#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
|
|
|
}
|
|
|
|
|
2017-05-18 16:31:52 -04:00
|
|
|
void GxsCommentContainer::commentLoad(const RsGxsGroupId &grpId, const std::set<RsGxsMessageId>& msg_versions,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);
|
|
|
|
|
2017-05-18 16:31:52 -04:00
|
|
|
commentDialog->commentLoad(grpId, msg_versions, msgId);
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
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
|
|
|
}
|