added BlogDetails to Blogs, added context menu actions for subscribe/unsubscribe

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2463 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-02-28 21:26:46 +00:00
parent 0a25b291f3
commit 323b96cc04
6 changed files with 433 additions and 42 deletions

View file

@ -0,0 +1,146 @@
/****************************************************************
* 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 "BlogDetails.h"
#include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsdisc.h"
#include "rsiface/rsblogs.h"
#include <QTime>
#include <QDateTime>
#include <sstream>
#include <list>
#include <iostream>
#include <string>
/** Default constructor */
BlogDetails::BlogDetails(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);
}
/** Overloads the default show() */
void
BlogDetails::show()
{
if(!this->isVisible()) {
QDialog::show();
}
}
void BlogDetails::closeEvent (QCloseEvent * event)
{
QWidget::closeEvent(event);
}
void BlogDetails::closeinfodlg()
{
close();
}
void BlogDetails::showDetails(std::string mBlogId)
{
bId = mBlogId;
loadBlog();
}
void BlogDetails::loadBlog()
{
if (!rsBlogs)
{
return;
}
std::list<BlogInfo> channelList;
std::list<BlogInfo>::iterator it;
BlogInfo bi;
rsBlogs->getBlogInfo(bId, bi);
rsBlogs->getBlogList(channelList);
for(it = channelList.begin(); it != channelList.end(); it++)
{
// Set Blog Name
ui.nameline->setText(QString::fromStdWString(bi.blogName));
// Set Blog Popularity
{
std::ostringstream out;
out << it->pop;
ui.popline -> setText(QString::fromStdString(out.str()));
}
// Set Last Blog Post Date
{
QDateTime qtime;
qtime.setTime_t(it->lastPost);
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
ui.postline -> setText(timestamp);
}
// Set Blog ID
ui.IDline->setText(QString::fromStdString(bi.blogId));
// Set Blog Description
ui.DescriptiontextEdit->setText(QString::fromStdWString(bi.blogDesc));
}
}
void BlogDetails::applyDialog()
{
/* reload now */
loadBlog();
/* close the Dialog after the Changes applied */
closeinfodlg();
}