diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 0b7ba26ab..15afcae9d 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -515,17 +515,20 @@ DEPENDPATH += gui/unfinished \ HEADERS += gui/unfinished/blogs/BlogsDialog.h \ gui/unfinished/blogs/CreateBlog.h \ gui/unfinished/blogs/CreateBlogMsg.h \ - gui/unfinished/blogs/BlogsMsgItem.h + gui/unfinished/blogs/BlogsMsgItem.h \ + gui/unfinished/blogs/BlogDetails.h FORMS += gui/unfinished/blogs/BlogsDialog.ui \ gui/unfinished/blogs/CreateBlog.ui \ gui/unfinished/blogs/CreateBlogMsg.ui \ - gui/unfinished/blogs/BlogsMsgItem.ui + gui/unfinished/blogs/BlogsMsgItem.ui \ + gui/unfinished/blogs/BlogDetails.ui SOURCES += gui/unfinished/blogs/BlogsDialog.cpp \ gui/unfinished/blogs/CreateBlog.cpp \ gui/unfinished/blogs/CreateBlogMsg.cpp \ - gui/unfinished/blogs/BlogsMsgItem.cpp + gui/unfinished/blogs/BlogsMsgItem.cpp \ + gui/unfinished/blogs/BlogDetails.cpp DEFINES *= BLOGS } diff --git a/retroshare-gui/src/gui/unfinished/blogs/BlogDetails.cpp b/retroshare-gui/src/gui/unfinished/blogs/BlogDetails.cpp new file mode 100644 index 000000000..ecb6fa4e7 --- /dev/null +++ b/retroshare-gui/src/gui/unfinished/blogs/BlogDetails.cpp @@ -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 +#include + +#include +#include +#include +#include + + +/** 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 channelList; + std::list::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(); + +} + + + diff --git a/retroshare-gui/src/gui/unfinished/blogs/BlogDetails.h b/retroshare-gui/src/gui/unfinished/blogs/BlogDetails.h new file mode 100644 index 000000000..f0e654d8c --- /dev/null +++ b/retroshare-gui/src/gui/unfinished/blogs/BlogDetails.h @@ -0,0 +1,68 @@ +/**************************************************************** + * 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. + ****************************************************************/ + +#ifndef _BLOGDETAILS_H +#define _BLOGDETAILS_H + +#include + +#include "ui_BlogDetails.h" + +class BlogDetails : public QDialog +{ + Q_OBJECT + + public: + + /** Default constructor */ + BlogDetails(QWidget *parent = 0, Qt::WFlags flags = 0); + /** Default destructor */ + + void showDetails(std::string mChannelId); + +signals: + void configChanged() ; + +public slots: + /** Overloaded QWidget.show */ + void show(); + +protected: + void closeEvent (QCloseEvent * event); + +private slots: + + void closeinfodlg(); + void applyDialog(); + + +private: + + void loadBlog(); + + std::string bId; + /** Qt Designer generated object */ + Ui::BlogDetails ui; + +}; + +#endif + diff --git a/retroshare-gui/src/gui/unfinished/blogs/BlogDetails.ui b/retroshare-gui/src/gui/unfinished/blogs/BlogDetails.ui new file mode 100644 index 000000000..d52d49392 --- /dev/null +++ b/retroshare-gui/src/gui/unfinished/blogs/BlogDetails.ui @@ -0,0 +1,151 @@ + + + BlogDetails + + + + 0 + 0 + 436 + 355 + + + + Blog Details + + + + :/images/rstray3.png:/images/rstray3.png + + + + + + 0 + + + + + :/images/info16.png:/images/info16.png + + + Blogl Details + + + + + + Blog Info + + + + + + Blog Name + + + + + + + + + + Popularity + + + + + + + true + + + + + + + Last Post + + + + + + + true + + + + + + + Blog ID + + + + + + + + + + Blog Description + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 311 + 20 + + + + + + + + Cancel + + + + + + + OK + + + false + + + true + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/unfinished/blogs/BlogsDialog.cpp b/retroshare-gui/src/gui/unfinished/blogs/BlogsDialog.cpp index a2f4f761c..6b55e07c4 100644 --- a/retroshare-gui/src/gui/unfinished/blogs/BlogsDialog.cpp +++ b/retroshare-gui/src/gui/unfinished/blogs/BlogsDialog.cpp @@ -37,6 +37,7 @@ #include "BlogsMsgItem.h" #include "CreateBlog.h" #include "CreateBlogMsg.h" +#include "BlogDetails.h" #include "gui/ChanGroupDelegate.h" #include "gui/GeneralMsgDialog.h" @@ -54,7 +55,6 @@ BlogsDialog::BlogsDialog(QWidget *parent) connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeBlog ( void ) ) ); connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeBlog ( void ) ) ); - mBlogId = ""; mPeerId = rsPeers->getOwnId(); // add your id @@ -122,11 +122,39 @@ void BlogsDialog::blogListCustomPopupMenu( QPoint point ) QMenu contextMnu( this ); QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier ); + QAction *subscribeblogAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Blog" ), this ); + connect( subscribeblogAct , SIGNAL( triggered() ), this, SLOT( subscribeBlog() ) ); + + QAction *unsubscribeblogAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Blog" ), this ); + connect( unsubscribeblogAct , SIGNAL( triggered() ), this, SLOT( unsubscribeBlog() ) ); + QAction *blogdetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Blog Details" ), this ); connect( blogdetailsAct , SIGNAL( triggered() ), this, SLOT( showBlogDetails() ) ); - + contextMnu.clear(); - contextMnu.addAction( blogdetailsAct ); + + BlogInfo bi; + if (!rsBlogs->getBlogInfo(mBlogId, bi)) + { + return; + } + + if (bi.blogFlags & RS_DISTRIB_PUBLISH) + { + contextMnu.addAction( blogdetailsAct ); + } + else if (bi.blogFlags & RS_DISTRIB_SUBSCRIBED) + { + contextMnu.addAction( unsubscribeblogAct ); + contextMnu.addSeparator(); + contextMnu.addAction( blogdetailsAct );; + } + else + { + contextMnu.addAction( subscribeblogAct ); + contextMnu.addSeparator(); + contextMnu.addAction( blogdetailsAct ); + } contextMnu.exec( mevent->globalPos() ); @@ -181,7 +209,6 @@ void BlogsDialog::openMsg(uint32_t type, std::string grpId, std::string inReplyT return; } - void BlogsDialog::createMsg() { if (mBlogId == "") @@ -195,9 +222,9 @@ void BlogsDialog::createMsg() return; } -void BlogsDialog::selectBlog( std::string cId) +void BlogsDialog::selectBlog( std::string bId) { - mBlogId = cId; + mBlogId = bId; updateBlogMsgs(); } @@ -235,7 +262,6 @@ void BlogsDialog::checkUpdate() } } - void BlogsDialog::updateBlogList() { @@ -341,12 +367,12 @@ void BlogsDialog::updateBlogListOwn(std::list &ids) QStandardItem *item1 = new QStandardItem(); QStandardItem *item2 = new QStandardItem(); - BlogInfo ci; - if (rsBlogs && rsBlogs->getBlogInfo(*iit, ci)) { - item1->setData(QVariant(QString::fromStdWString(ci.blogName)), Qt::DisplayRole); - item2->setData(QVariant(QString::fromStdString(ci.blogId)), Qt::DisplayRole); + BlogInfo bi; + if (rsBlogs && rsBlogs->getBlogInfo(*iit, bi)) { + item1->setData(QVariant(QString::fromStdWString(bi.blogName)), Qt::DisplayRole); + item2->setData(QVariant(QString::fromStdString(bi.blogId)), Qt::DisplayRole); item1->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3" - ).arg(QString::number(ci.pop)).arg(9999).arg(9999)); + ).arg(QString::number(bi.pop)).arg(9999).arg(9999)); } else { item1->setData(QVariant(QString("Unknown Blog")), Qt::DisplayRole); item2->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole); @@ -375,12 +401,12 @@ void BlogsDialog::updateBlogListSub(std::list &ids) QStandardItem *item1 = new QStandardItem(); QStandardItem *item2 = new QStandardItem(); - BlogInfo ci; - if (rsBlogs && rsBlogs->getBlogInfo(*iit, ci)) { - item1->setData(QVariant(QString::fromStdWString(ci.blogName)), Qt::DisplayRole); - item2->setData(QVariant(QString::fromStdString(ci.blogId)), Qt::DisplayRole); + BlogInfo bi; + if (rsBlogs && rsBlogs->getBlogInfo(*iit, bi)) { + item1->setData(QVariant(QString::fromStdWString(bi.blogName)), Qt::DisplayRole); + item2->setData(QVariant(QString::fromStdString(bi.blogId)), Qt::DisplayRole); item1->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3" - ).arg(QString::number(ci.pop)).arg(9999).arg(9999)); + ).arg(QString::number(bi.pop)).arg(9999).arg(9999)); } else { item1->setData(QVariant(QString("Unknown Blog")), Qt::DisplayRole); item2->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole); @@ -410,12 +436,12 @@ void BlogsDialog::updateBlogListPop(std::list &ids) QStandardItem *item1 = new QStandardItem(); QStandardItem *item2 = new QStandardItem(); - BlogInfo ci; - if (rsBlogs && rsBlogs->getBlogInfo(*iit, ci)) { - item1->setData(QVariant(QString::fromStdWString(ci.blogName)), Qt::DisplayRole); - item2->setData(QVariant(QString::fromStdString(ci.blogId)), Qt::DisplayRole); + BlogInfo bi; + if (rsBlogs && rsBlogs->getBlogInfo(*iit, bi)) { + item1->setData(QVariant(QString::fromStdWString(bi.blogName)), Qt::DisplayRole); + item2->setData(QVariant(QString::fromStdString(bi.blogId)), Qt::DisplayRole); item1->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3" - ).arg(QString::number(ci.pop)).arg(9999).arg(9999)); + ).arg(QString::number(bi.pop)).arg(9999).arg(9999)); } else { item1->setData(QVariant(QString("Unknown Blog")), Qt::DisplayRole); item2->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole); @@ -444,12 +470,12 @@ void BlogsDialog::updateBlogListOther(std::list &ids) QStandardItem *item1 = new QStandardItem(); QStandardItem *item2 = new QStandardItem(); - BlogInfo ci; - if (rsBlogs && rsBlogs->getBlogInfo(*iit, ci)) { - item1->setData(QVariant(QString::fromStdWString(ci.blogName)), Qt::DisplayRole); - item2->setData(QVariant(QString::fromStdString(ci.blogId)), Qt::DisplayRole); + BlogInfo bi; + if (rsBlogs && rsBlogs->getBlogInfo(*iit, bi)) { + item1->setData(QVariant(QString::fromStdWString(bi.blogName)), Qt::DisplayRole); + item2->setData(QVariant(QString::fromStdString(bi.blogId)), Qt::DisplayRole); item1->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3" - ).arg(QString::number(ci.pop)).arg(9999).arg(9999)); + ).arg(QString::number(bi.pop)).arg(9999).arg(9999)); } else { item1->setData(QVariant(QString("Unknown Blog")), Qt::DisplayRole); item2->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole); @@ -467,8 +493,8 @@ void BlogsDialog::updateBlogMsgs() if (!rsBlogs) return; - BlogInfo ci; - if (!rsBlogs->getBlogInfo(mBlogId, ci)) + BlogInfo bi; + if (!rsBlogs->getBlogInfo(mBlogId, bi)) { postButton->setEnabled(false); subscribeButton->setEnabled(false); @@ -485,11 +511,11 @@ void BlogsDialog::updateBlogMsgs() "color:white;\">%1"); /* set Blog name */ - QString bname = QString::fromStdWString(ci.blogName); + QString bname = QString::fromStdWString(bi.blogName); nameLabel->setText(blogStr.arg(bname)); /* do buttons */ - if (ci.blogFlags & RS_DISTRIB_SUBSCRIBED) + if (bi.blogFlags & RS_DISTRIB_SUBSCRIBED) { subscribeButton->setEnabled(false); unsubscribeButton->setEnabled(true); @@ -500,7 +526,7 @@ void BlogsDialog::updateBlogMsgs() unsubscribeButton->setEnabled(false); } - if (ci.blogFlags & RS_DISTRIB_PUBLISH) + if (bi.blogFlags & RS_DISTRIB_PUBLISH) { postButton->setEnabled(true); } @@ -531,7 +557,6 @@ void BlogsDialog::updateBlogMsgs() } } - void BlogsDialog::unsubscribeBlog() { #ifdef BLOG_DEBUG @@ -545,7 +570,6 @@ void BlogsDialog::unsubscribeBlog() updateBlogMsgs(); } - void BlogsDialog::subscribeBlog() { #ifdef BLOG_DEBUG @@ -559,7 +583,6 @@ void BlogsDialog::subscribeBlog() updateBlogMsgs(); } - void BlogsDialog::toggleSelection(const QModelIndex &index) { QItemSelectionModel *selectionModel = treeView->selectionModel(); @@ -577,9 +600,9 @@ void BlogsDialog::showBlogDetails() if (!rsBlogs) return; - //static BlogDetails *blogui = new BlogDetails(); + static BlogDetails *blogui = new BlogDetails(); - //blogui->showDetails(mBlogId); - //blogui->show(); + blogui->showDetails(mBlogId); + blogui->show(); } diff --git a/retroshare-gui/src/gui/unfinished/blogs/BlogsDialog.h b/retroshare-gui/src/gui/unfinished/blogs/BlogsDialog.h index fa788f55f..283b69af7 100644 --- a/retroshare-gui/src/gui/unfinished/blogs/BlogsDialog.h +++ b/retroshare-gui/src/gui/unfinished/blogs/BlogsDialog.h @@ -87,7 +87,7 @@ private: QStandardItemModel *model; - std::string mBlogId; /* current Channel */ + std::string mBlogId; /* current Blog */ std::string mPeerId; /* Layout Pointers */