2010-01-19 19:29:40 -05:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 RetroShare Team
|
|
|
|
*
|
|
|
|
* 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 "ChannelDetails.h"
|
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsiface.h>
|
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
#include <retroshare/rsdisc.h>
|
|
|
|
#include <retroshare/rschannels.h>
|
2010-01-19 19:29:40 -05:00
|
|
|
|
|
|
|
#include <QTime>
|
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <list>
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
/* Define the format used for displaying the date and time */
|
|
|
|
#define DATETIME_FMT "MMM dd hh:mm:ss"
|
|
|
|
|
|
|
|
/** Default constructor */
|
|
|
|
ChannelDetails::ChannelDetails(QWidget *parent, Qt::WFlags flags)
|
|
|
|
: QDialog(parent, flags)
|
|
|
|
{
|
|
|
|
/* Invoke Qt Designer generated QObject setup routine */
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
|
|
|
|
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg()));
|
|
|
|
|
|
|
|
ui.applyButton->setToolTip(tr("Close"));
|
|
|
|
|
|
|
|
ui.nameline ->setReadOnly(true);
|
|
|
|
ui.popline ->setReadOnly(true);
|
|
|
|
ui.postline ->setReadOnly(true);
|
|
|
|
ui.IDline ->setReadOnly(true);
|
|
|
|
ui.DescriptiontextEdit ->setReadOnly(true);
|
|
|
|
|
2010-09-24 10:51:00 -04:00
|
|
|
ui.typeEncrypted->setEnabled(false);
|
|
|
|
ui.typePrivate->setEnabled(false);
|
|
|
|
|
2010-01-19 19:29:40 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Overloads the default show() slot so we can set opacity*/
|
|
|
|
|
|
|
|
void
|
|
|
|
ChannelDetails::show()
|
|
|
|
{
|
|
|
|
//loadSettings();
|
|
|
|
if(!this->isVisible()) {
|
|
|
|
QDialog::show();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelDetails::closeEvent (QCloseEvent * event)
|
|
|
|
{
|
|
|
|
QWidget::closeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelDetails::closeinfodlg()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelDetails::showDetails(std::string mChannelId)
|
|
|
|
{
|
|
|
|
cId = mChannelId;
|
|
|
|
loadChannel();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelDetails::loadChannel()
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!rsChannels)
|
|
|
|
{
|
|
|
|
return;
|
2010-09-24 10:51:00 -04:00
|
|
|
}
|
|
|
|
uint32_t flags = 0;
|
2010-01-19 19:29:40 -05:00
|
|
|
|
|
|
|
ChannelInfo ci;
|
|
|
|
rsChannels->getChannelInfo(cId, ci);
|
2010-10-17 10:43:49 -04:00
|
|
|
flags = ci.channelFlags;
|
2010-01-19 19:29:40 -05:00
|
|
|
|
|
|
|
// Set Channel Name
|
|
|
|
ui.nameline->setText(QString::fromStdWString(ci.channelName));
|
|
|
|
|
|
|
|
// Set Channel Popularity
|
|
|
|
{
|
|
|
|
std::ostringstream out;
|
2010-10-17 10:43:49 -04:00
|
|
|
out << ci.pop;
|
2010-01-19 19:29:40 -05:00
|
|
|
ui.popline -> setText(QString::fromStdString(out.str()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set Last Channel Post Date
|
2011-01-04 15:19:45 -05:00
|
|
|
if (ci.lastPost) {
|
2010-01-19 19:29:40 -05:00
|
|
|
QDateTime qtime;
|
2010-10-17 10:43:49 -04:00
|
|
|
qtime.setTime_t(ci.lastPost);
|
2010-01-19 19:29:40 -05:00
|
|
|
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
|
|
|
ui.postline -> setText(timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set Channel ID
|
|
|
|
ui.IDline->setText(QString::fromStdString(ci.channelId));
|
|
|
|
|
|
|
|
// Set Channel Description
|
|
|
|
ui.DescriptiontextEdit->setText(QString::fromStdWString(ci.channelDesc));
|
2010-09-24 10:51:00 -04:00
|
|
|
|
|
|
|
if (flags |= RS_DISTRIB_PRIVATE)
|
|
|
|
{
|
|
|
|
ui.typeEncrypted->setChecked(false);
|
|
|
|
ui.typePrivate->setChecked(true);
|
|
|
|
}
|
|
|
|
else if (flags |= RS_DISTRIB_ENCRYPTED)
|
|
|
|
{
|
|
|
|
ui.typeEncrypted->setChecked(true);
|
|
|
|
ui.typePrivate->setChecked(false);
|
|
|
|
}
|
2010-01-19 19:29:40 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelDetails::applyDialog()
|
|
|
|
{
|
|
|
|
|
|
|
|
/* reload now */
|
|
|
|
loadChannel();
|
|
|
|
|
|
|
|
/* close the Dialog after the Changes applied */
|
|
|
|
closeinfodlg();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|