From 65b35e8c53a29d7f6ea6e2bfe0df7a682a8c5cfb Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 2 Jan 2010 15:47:07 +0000 Subject: [PATCH] Added Forum Details Dialog git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1961 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/RetroShare.pro | 3 + retroshare-gui/src/gui/ForumsDialog.cpp | 7 +- .../src/gui/forums/ForumDetails.cpp | 137 ++++++++++++++++ retroshare-gui/src/gui/forums/ForumDetails.h | 67 ++++++++ retroshare-gui/src/gui/forums/ForumDetails.ui | 151 ++++++++++++++++++ 5 files changed, 362 insertions(+), 3 deletions(-) create mode 100644 retroshare-gui/src/gui/forums/ForumDetails.cpp create mode 100644 retroshare-gui/src/gui/forums/ForumDetails.h create mode 100644 retroshare-gui/src/gui/forums/ForumDetails.ui diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index a566196c9..3328cd297 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -134,6 +134,7 @@ HEADERS += rshare.h \ gui/AddLinksDialog.h \ gui/LinksDialog.h \ gui/ForumsDialog.h \ + gui/forums/ForumDetails.h \ gui/forums/CreateForum.h \ gui/forums/CreateForumMsg.h \ gui/NetworkView.h \ @@ -246,6 +247,7 @@ FORMS += gui/StartDialog.ui \ gui/LinksDialog.ui \ gui/forums/CreateForum.ui \ gui/forums/CreateForumMsg.ui \ + gui/forums/ForumDetails.ui \ gui/NetworkView.ui \ gui/TrustView.ui \ gui/MessengerWindow.ui \ @@ -305,6 +307,7 @@ SOURCES += main.cpp \ gui/MainWindow.cpp \ gui/LinksDialog.cpp \ gui/ForumsDialog.cpp \ + gui/forums/ForumDetails.cpp \ gui/forums/CreateForum.cpp \ gui/forums/CreateForumMsg.cpp \ gui/NetworkView.cpp \ diff --git a/retroshare-gui/src/gui/ForumsDialog.cpp b/retroshare-gui/src/gui/ForumsDialog.cpp index d9882379b..0ded1faec 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -23,6 +23,7 @@ #include "ForumsDialog.h" #include "gui/forums/CreateForum.h" #include "gui/forums/CreateForumMsg.h" +#include "gui/forums/ForumDetails.h" #include "rsiface/rsiface.h" #include "rsiface/rspeers.h" @@ -891,8 +892,8 @@ void ForumsDialog::forumSubscribe(bool subscribe) void ForumsDialog::showForumDetails() { -#if 0 -static ForumDisplay *fui = new ForumDisplay(); + + static ForumDetails *fui = new ForumDetails(); if (mCurrForumId == "") { @@ -901,7 +902,7 @@ static ForumDisplay *fui = new ForumDisplay(); fui->showDetails(mCurrForumId); fui->show(); -#endif + } diff --git a/retroshare-gui/src/gui/forums/ForumDetails.cpp b/retroshare-gui/src/gui/forums/ForumDetails.cpp new file mode 100644 index 000000000..fc40dca4e --- /dev/null +++ b/retroshare-gui/src/gui/forums/ForumDetails.cpp @@ -0,0 +1,137 @@ +/**************************************************************** + * 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 "ForumDetails.h" + +#include "rsiface/rsiface.h" +#include "rsiface/rspeers.h" +#include "rsiface/rsdisc.h" +#include "rsiface/rsforums.h" + +#include +#include + +#include + + +/* Define the format used for displaying the date and time */ +#define DATETIME_FMT "MMM dd hh:mm:ss" + +/** Default constructor */ +ForumDetails::ForumDetails(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("Apply and 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() slot so we can set opacity*/ + +void +ForumDetails::show() +{ + //loadSettings(); + if(!this->isVisible()) { + QDialog::show(); + + } +} + +void ForumDetails::closeEvent (QCloseEvent * event) +{ + QWidget::closeEvent(event); +} + +void ForumDetails::closeinfodlg() +{ + close(); +} + +void ForumDetails::showDetails(std::string mCurrForumId) +{ + fId = mCurrForumId; + loadDialog(); +} + +void ForumDetails::loadDialog() +{ + + std::list::iterator it; + + if (!rsForums) + { + return; + } + + ForumInfo fi; + rsForums->getForumInfo(fId, fi); + + // Set Forum Name + ui.nameline->setText(QString::fromStdWString(fi.forumName)); + + // Set Popularity + /*{ + std::ostringstream out; + out << it->pop; + ui.popline -> setText(QString::fromStdString(out.str())); + }*/ + + // Set Last Post Date + /*{ + QDateTime qtime; + qtime.setTime_t(it->lastPost); + QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss"); + ui.postline -> setText(timestamp); + }*/ + + // Set Forum ID + ui.IDline->setText(QString::fromStdString(fi.forumId)); + + // Set Forum Description + ui.DescriptiontextEdit->setText(QString::fromStdWString(fi.forumDesc)); + +} + +void ForumDetails::applyDialog() +{ + + /* reload now */ + loadDialog(); + + /* close the Dialog after the Changes applied */ + closeinfodlg(); + +} + + + diff --git a/retroshare-gui/src/gui/forums/ForumDetails.h b/retroshare-gui/src/gui/forums/ForumDetails.h new file mode 100644 index 000000000..26d294d8f --- /dev/null +++ b/retroshare-gui/src/gui/forums/ForumDetails.h @@ -0,0 +1,67 @@ +/**************************************************************** + * 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 _FORUMDETAILS_H +#define _FORUMDETAILS_H + +#include + +#include "ui_ForumDetails.h" + +class ForumDetails : public QDialog +{ + Q_OBJECT + + public: + + /** Default constructor */ + ForumDetails(QWidget *parent = 0, Qt::WFlags flags = 0); + /** Default destructor */ + + void showDetails(std::string mCurrForumId); + +signals: + void configChanged() ; + +public slots: + /** Overloaded QWidget.show */ + void show(); + +protected: + void closeEvent (QCloseEvent * event); + +private slots: + + void closeinfodlg(); + void applyDialog(); + +private: + + void loadDialog(); + + std::string fId; + /** Qt Designer generated object */ + Ui::ForumDetails ui; + +}; + +#endif + diff --git a/retroshare-gui/src/gui/forums/ForumDetails.ui b/retroshare-gui/src/gui/forums/ForumDetails.ui new file mode 100644 index 000000000..45e555fed --- /dev/null +++ b/retroshare-gui/src/gui/forums/ForumDetails.ui @@ -0,0 +1,151 @@ + + + ForumDetails + + + + 0 + 0 + 427 + 348 + + + + Forum Details + + + + :/images/rstray3.png:/images/rstray3.png + + + + + + 0 + + + + + :/images/konversation16.png:/images/konversation16.png + + + Forum Details + + + + + + Forum Info + + + + + + Forum Name + + + + + + + + + + Popularity + + + + + + + true + + + + + + + Last Post + + + + + + + true + + + + + + + Forum ID + + + + + + + + + + Forum Description + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 311 + 20 + + + + + + + + Cancel + + + + + + + OK + + + false + + + true + + + + + + + + + + + +