2013-03-11 16:53:15 -04:00
|
|
|
/*
|
|
|
|
* Retroshare Comment Dialog
|
|
|
|
*
|
|
|
|
* 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/GxsCommentDialog.h"
|
2014-05-07 20:00:21 -04:00
|
|
|
#include "ui_GxsCommentDialog.h"
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
GxsCommentDialog::GxsCommentDialog(QWidget *parent, RsTokenService *token_service, RsGxsCommentService *comment_service)
|
2014-05-07 20:00:21 -04:00
|
|
|
: QWidget(parent), ui(new Ui::GxsCommentDialog)
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
2014-05-07 20:00:21 -04:00
|
|
|
/* Invoke the Qt Designer generated QObject setup routine */
|
|
|
|
ui->setupUi(this);
|
2013-03-11 16:53:15 -04:00
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
//ui->postFrame->setVisible(false);
|
|
|
|
|
|
|
|
ui->treeWidget->setup(token_service, comment_service);
|
2013-03-12 20:33:14 -04:00
|
|
|
|
|
|
|
/* fill in the available OwnIds for signing */
|
2014-05-07 20:00:21 -04:00
|
|
|
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
|
2013-03-12 20:33:14 -04:00
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
connect(ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
|
|
|
|
connect(ui->idChooser, SIGNAL(currentIndexChanged( int )), this, SLOT(voterSelectionChanged( int )));
|
2015-05-09 05:28:38 -04:00
|
|
|
connect(ui->idChooser, SIGNAL(idsLoaded()), this, SLOT(idChooserReady()));
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
GxsCommentDialog::~GxsCommentDialog()
|
|
|
|
{
|
|
|
|
delete(ui);
|
|
|
|
}
|
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId)
|
|
|
|
{
|
2013-03-12 20:33:14 -04:00
|
|
|
std::cerr << "GxsCommentDialog::commentLoad(" << grpId << ", " << msgId << ")";
|
2013-03-11 16:53:15 -04:00
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
mGrpId = grpId;
|
|
|
|
mMsgId = msgId;
|
|
|
|
|
2013-03-12 20:33:14 -04:00
|
|
|
RsGxsGrpMsgIdPair threadId;
|
2013-03-11 16:53:15 -04:00
|
|
|
|
2013-03-12 20:33:14 -04:00
|
|
|
threadId.first = grpId;
|
|
|
|
threadId.second = msgId;
|
2013-03-11 16:53:15 -04:00
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
ui->treeWidget->requestComments(threadId);
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
2013-03-12 20:33:14 -04:00
|
|
|
void GxsCommentDialog::refresh()
|
|
|
|
{
|
|
|
|
std::cerr << "GxsCommentDialog::refresh()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
commentLoad(mGrpId, mMsgId);
|
|
|
|
}
|
|
|
|
|
2015-05-09 05:28:38 -04:00
|
|
|
void GxsCommentDialog::idChooserReady()
|
|
|
|
{
|
|
|
|
voterSelectionChanged(0);
|
|
|
|
}
|
|
|
|
|
2013-03-12 20:33:14 -04:00
|
|
|
void GxsCommentDialog::voterSelectionChanged( int index )
|
|
|
|
{
|
|
|
|
std::cerr << "GxsCommentDialog::voterSelectionChanged(" << index << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
RsGxsId voterId;
|
2014-07-06 07:19:58 -04:00
|
|
|
switch (ui->idChooser->getChosenId(voterId)) {
|
|
|
|
case GxsIdChooser::KnowId:
|
|
|
|
case GxsIdChooser::UnKnowId:
|
2013-03-12 20:33:14 -04:00
|
|
|
std::cerr << "GxsCommentDialog::voterSelectionChanged() => " << voterId;
|
|
|
|
std::cerr << std::endl;
|
2014-05-07 20:00:21 -04:00
|
|
|
ui->treeWidget->setVoteId(voterId);
|
2014-07-06 07:19:58 -04:00
|
|
|
|
|
|
|
break;
|
|
|
|
case GxsIdChooser::NoId:
|
|
|
|
case GxsIdChooser::None:
|
|
|
|
default:
|
2013-03-12 20:33:14 -04:00
|
|
|
std::cerr << "GxsCommentDialog::voterSelectionChanged() ERROR nothing selected";
|
|
|
|
std::cerr << std::endl;
|
2014-07-06 07:19:58 -04:00
|
|
|
}//switch (ui->idChooser->getChosenId(voterId))
|
2013-03-12 20:33:14 -04:00
|
|
|
}
|
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
void GxsCommentDialog::setCommentHeader(QWidget *header)
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
2013-03-15 17:02:43 -04:00
|
|
|
if (!header)
|
|
|
|
{
|
|
|
|
std::cerr << "GxsCommentDialog::setCommentHeader() NULL header!";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cerr << "GxsCommentDialog::setCommentHeader() Adding header to ui,postFrame";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
//header->setParent(ui->postFrame);
|
|
|
|
//ui->postFrame->setVisible(true);
|
2013-03-15 17:02:43 -04:00
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
QLayout *alayout = ui->postFrame->layout();
|
2013-03-15 17:02:43 -04:00
|
|
|
alayout->addWidget(header);
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
#if 0
|
2014-05-07 20:00:21 -04:00
|
|
|
ui->postFrame->setVisible(true);
|
2013-03-12 20:33:14 -04:00
|
|
|
|
|
|
|
QDateTime qtime;
|
|
|
|
qtime.setTime_t(mCurrentPost.mMeta.mPublishTs);
|
|
|
|
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
|
2014-05-07 20:00:21 -04:00
|
|
|
ui->dateLabel->setText(timestamp);
|
|
|
|
ui->fromLabel->setText(QString::fromUtf8(mCurrentPost.mMeta.mAuthorId.c_str()));
|
|
|
|
ui->titleLabel->setText("<a href=" + QString::fromStdString(mCurrentPost.mLink) +
|
2013-03-12 20:33:14 -04:00
|
|
|
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
|
|
|
|
QString::fromStdString(mCurrentPost.mMeta.mMsgName) + "</span></a>");
|
2014-05-07 20:00:21 -04:00
|
|
|
ui->siteLabel->setText("<a href=" + QString::fromStdString(mCurrentPost.mLink) +
|
2013-03-12 20:33:14 -04:00
|
|
|
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
|
|
|
|
QString::fromStdString(mCurrentPost.mLink) + "</span></a>");
|
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
ui->scoreLabel->setText(QString("0"));
|
2013-03-12 20:33:14 -04:00
|
|
|
|
2014-05-07 20:00:21 -04:00
|
|
|
ui->notesBrowser->setPlainText(QString::fromStdString(mCurrentPost.mNotes));
|
2013-03-11 16:53:15 -04:00
|
|
|
#endif
|
|
|
|
}
|