diff --git a/libretroshare/src/retroshare/rsforums.h b/libretroshare/src/retroshare/rsforums.h index af13b414b..1446c8f49 100644 --- a/libretroshare/src/retroshare/rsforums.h +++ b/libretroshare/src/retroshare/rsforums.h @@ -130,6 +130,14 @@ virtual bool forumsChanged(std::list &forumIds) = 0; virtual std::string createForum(std::wstring forumName, std::wstring forumDesc, uint32_t forumFlags) = 0; virtual bool getForumInfo(std::string fId, ForumInfo &fi) = 0; + +/*! + * allows peers to change information for the forum: + * can only change name and descriptions + * + */ +virtual bool setForumInfo(std::string fId, ForumInfo &fi) = 0; + virtual bool getForumList(std::list &forumList) = 0; virtual bool getForumThreadList(std::string fId, std::list &msgs) = 0; virtual bool getForumThreadMsgList(std::string fId, std::string pId, std::list &msgs) = 0; diff --git a/libretroshare/src/services/p3forums.cc b/libretroshare/src/services/p3forums.cc index d563b5b41..e82e2436f 100644 --- a/libretroshare/src/services/p3forums.cc +++ b/libretroshare/src/services/p3forums.cc @@ -128,6 +128,22 @@ bool p3Forums::getForumInfo(std::string fId, ForumInfo &fi) return true; } +/*! + * allows peers to change information for the forum: + * can only change name and descriptions + * + */ +bool p3Forums::setForumInfo(std::string fId, ForumInfo &fi) +{ + GroupInfo gi; + + RsStackMutex stack(distribMtx); + + gi.grpName = fi.forumName; + gi.grpDesc = fi.forumDesc; + + return locked_editGroup(fId, gi); + } bool p3Forums::getForumList(std::list &forumList) { diff --git a/libretroshare/src/services/p3forums.h b/libretroshare/src/services/p3forums.h index 4b3706ec1..3f0ec8b82 100644 --- a/libretroshare/src/services/p3forums.h +++ b/libretroshare/src/services/p3forums.h @@ -50,6 +50,7 @@ virtual bool forumsChanged(std::list &forumIds); virtual std::string createForum(std::wstring forumName, std::wstring forumDesc, uint32_t forumFlags); virtual bool getForumInfo(std::string fId, ForumInfo &fi); +virtual bool setForumInfo(std::string fId, ForumInfo &fi); virtual bool getForumList(std::list &forumList); virtual bool getForumThreadList(std::string fId, std::list &msgs); virtual bool getForumThreadMsgList(std::string fId, std::string tId, std::list &msgs); diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 0bf4abe90..f6eb549bc 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -182,6 +182,7 @@ HEADERS += rshare.h \ gui/LinksDialog.h \ gui/ForumsDialog.h \ gui/forums/ForumDetails.h \ + gui/forums/EditForumDetails.h \ gui/forums/CreateForum.h \ gui/forums/CreateForumMsg.h \ gui/NetworkView.h \ @@ -325,6 +326,7 @@ FORMS += gui/StartDialog.ui \ gui/forums/CreateForum.ui \ gui/forums/CreateForumMsg.ui \ gui/forums/ForumDetails.ui \ + gui/forums/EditForumDetails.ui \ gui/NetworkView.ui \ gui/TrustView.ui \ gui/MessengerWindow.ui \ @@ -405,6 +407,7 @@ SOURCES += main.cpp \ gui/LinksDialog.cpp \ gui/ForumsDialog.cpp \ gui/forums/ForumDetails.cpp \ + gui/forums/EditForumDetails.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 b969e161d..a86cdc0ea 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -30,6 +30,7 @@ #include "forums/CreateForum.h" #include "forums/CreateForumMsg.h" #include "forums/ForumDetails.h" +#include "forums/EditForumDetails.h" #include "msgs/MessageComposer.h" #include "settings/rsharesettings.h" #include "common/Emoticons.h" @@ -168,6 +169,7 @@ ForumsDialog::ForumsDialog(QWidget *parent) m_bProcessSettings = false; m_bIsForumSubscribed = false; + m_bIsForumAdmin = false; connect( ui.forumTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumListCustomPopupMenu( QPoint ) ) ); connect( ui.threadTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( threadListCustomPopupMenu( QPoint ) ) ); @@ -356,8 +358,13 @@ void ForumsDialog::forumListCustomPopupMenu( QPoint point ) detailsForumAct->setDisabled (true); connect( detailsForumAct , SIGNAL( triggered() ), this, SLOT( showForumDetails() ) ); + QAction *editForumDetailsAct = new QAction(QIcon(":/images/settings16.png"), tr("Edit Forum Details"), this); + editForumDetailsAct->setDisabled (true); + connect( editForumDetailsAct, SIGNAL( triggered() ), this, SLOT( editForumDetails() ) ); + if (!mCurrForumId.empty ()) { detailsForumAct->setEnabled (true); + editForumDetailsAct->setEnabled(m_bIsForumAdmin); } contextMnu.addAction( subForumAct ); @@ -365,6 +372,7 @@ void ForumsDialog::forumListCustomPopupMenu( QPoint point ) contextMnu.addSeparator(); contextMnu.addAction( newForumAct ); contextMnu.addAction( detailsForumAct ); + contextMnu.addAction( editForumDetailsAct ); contextMnu.exec(QCursor::pos()); } @@ -896,6 +904,7 @@ void ForumsDialog::insertThreads() std::cerr << "ForumsDialog::insertThreads()" << std::endl; m_bIsForumSubscribed = false; + m_bIsForumAdmin = false; QTreeWidgetItem *forumItem = ui.forumTreeWidget->currentItem(); if ((!forumItem) || (forumItem->parent() == NULL)) @@ -924,6 +933,9 @@ void ForumsDialog::insertThreads() ForumInfo fi; if (rsForums->getForumInfo (fId, fi)) { + if (fi.subscribeFlags & RS_DISTRIB_ADMIN) { + m_bIsForumAdmin = true; + } if (fi.subscribeFlags & (RS_DISTRIB_ADMIN | RS_DISTRIB_SUBSCRIBED)) { m_bIsForumSubscribed = true; } @@ -1628,7 +1640,7 @@ void ForumsDialog::createmessage() void ForumsDialog::createthread() { if (mCurrForumId.empty ()) { - QMessageBox::information(this, tr("RetroShare"),tr("No Forum Selected!")); + QMessageBox::information(this, tr("RetroShare"), tr("No Forum Selected!")); return; } @@ -1676,6 +1688,17 @@ void ForumsDialog::showForumDetails() fui.exec (); } +void ForumsDialog::editForumDetails() +{ + if (mCurrForumId == "") + { + return; + } + + EditForumDetails editUi(mCurrForumId, this); + editUi.exec(); +} + void ForumsDialog::replytomessage() { if (mCurrForumId.empty()) { diff --git a/retroshare-gui/src/gui/ForumsDialog.h b/retroshare-gui/src/gui/ForumsDialog.h index b5662f76a..177400dd5 100644 --- a/retroshare-gui/src/gui/ForumsDialog.h +++ b/retroshare-gui/src/gui/ForumsDialog.h @@ -69,6 +69,7 @@ private slots: void unsubscribeToForum(); void showForumDetails(); + void editForumDetails(); void previousMessage (); void nextMessage (); @@ -112,6 +113,7 @@ private: std::string mCurrForumId; std::string mCurrThreadId; bool m_bIsForumSubscribed; + bool m_bIsForumAdmin; QFont m_ForumNameFont; QFont m_ItemFont; diff --git a/retroshare-gui/src/gui/forums/EditForumDetails.cpp b/retroshare-gui/src/gui/forums/EditForumDetails.cpp new file mode 100644 index 000000000..1323f19ed --- /dev/null +++ b/retroshare-gui/src/gui/forums/EditForumDetails.cpp @@ -0,0 +1,79 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2010 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 "EditForumDetails.h" + +#include + +#include +#include +#include + + +/** Default constructor */ +EditForumDetails::EditForumDetails(std::string forumId, QWidget *parent, Qt::WFlags flags) + : QDialog(parent, flags), m_forumId(forumId) +{ + /* Invoke Qt Designer generated QObject setup routine */ + ui.setupUi(this); + + connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog())); + + loadForum(); +} + +void EditForumDetails::loadForum() +{ + if (!rsForums) { + return; + } + + ForumInfo info; + rsForums->getForumInfo(m_forumId, info); + + // set name + ui.nameline->setText(QString::fromStdWString(info.forumName)); + + // set description + ui.DescriptiontextEdit->setText(QString::fromStdWString(info.forumDesc)); +} + +void EditForumDetails::applyDialog() +{ + if (!rsForums) { + return; + } + + // if text boxes have not been edited leave alone + if (!ui.nameline->isModified() && !ui.DescriptiontextEdit->document()->isModified()) { + return; + } + + ForumInfo info; + + info.forumName = ui.nameline->text().toStdWString(); + info.forumDesc = ui.DescriptiontextEdit->document()->toPlainText().toStdWString(); + + rsForums->setForumInfo(m_forumId, info); + + /* close the Dialog after the Changes applied */ + close(); +} diff --git a/retroshare-gui/src/gui/forums/EditForumDetails.h b/retroshare-gui/src/gui/forums/EditForumDetails.h new file mode 100644 index 000000000..17e700a77 --- /dev/null +++ b/retroshare-gui/src/gui/forums/EditForumDetails.h @@ -0,0 +1,53 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2010 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 _EDITFORUMDETAILS_H +#define _EDITFORUMDETAILS_H + +#include + +#include "ui_EditForumDetails.h" + +class EditForumDetails : public QDialog +{ + Q_OBJECT + +public: + /** Default constructor */ + EditForumDetails(std::string forumId = "", QWidget *parent = 0, Qt::WFlags flags = 0); + +signals: + void configChanged(); + +private slots: + void applyDialog(); + +private: + void loadForum(); + + std::string m_forumId; + + /** Qt Designer generated object */ + Ui::EditForumDetails ui; +}; + +#endif + diff --git a/retroshare-gui/src/gui/forums/EditForumDetails.ui b/retroshare-gui/src/gui/forums/EditForumDetails.ui new file mode 100644 index 000000000..e5cdb8992 --- /dev/null +++ b/retroshare-gui/src/gui/forums/EditForumDetails.ui @@ -0,0 +1,130 @@ + + + EditForumDetails + + + + 0 + 0 + 436 + 355 + + + + Forum Details + + + + :/images/rstray3.png:/images/rstray3.png + + + + + + + + Qt::Horizontal + + + + 311 + 20 + + + + + + + + Cancel + + + + + + + OK + + + false + + + true + + + + + + + + + 0 + + + + + :/images/info16.png:/images/info16.png + + + Edit Forum Details + + + + + + Forum Info + + + + + + Forum Name + + + + + + + + + + Forum Description + + + + + + + + + + + + + + + + + + + + + + + cancelButton + clicked() + EditForumDetails + close() + + + 307 + 333 + + + 217 + 177 + + + + + diff --git a/retroshare-gui/src/lang/retroshare_de.qm b/retroshare-gui/src/lang/retroshare_de.qm index 890372627..b76aa1580 100644 Binary files a/retroshare-gui/src/lang/retroshare_de.qm and b/retroshare-gui/src/lang/retroshare_de.qm differ diff --git a/retroshare-gui/src/lang/retroshare_de.ts b/retroshare-gui/src/lang/retroshare_de.ts index 9789a588f..91e678033 100644 --- a/retroshare-gui/src/lang/retroshare_de.ts +++ b/retroshare-gui/src/lang/retroshare_de.ts @@ -1150,7 +1150,7 @@ Keine Beschreibung Abbrechen - + Quick Message Schnelle Nachrricht @@ -1244,7 +1244,7 @@ Keine Beschreibung Verlauf - + Incoming message in history Eingehehende Nachricht aus dem Verlauf @@ -1267,7 +1267,7 @@ Keine Beschreibung ChatStyle - + Standard style for group chat Standard Stil für den Gruppenchat @@ -2344,7 +2344,7 @@ p, li { white-space: pre-wrap; } Erstelle Forumbeitrag - + Paste retroshare Link RetroShare Link einfügen @@ -2364,7 +2364,7 @@ p, li { white-space: pre-wrap; } Bitte einen Betreff und eine Beitrag eingeben - + Add Extra File Zusätzliche Datei hinzufügen @@ -2731,6 +2731,44 @@ p, li { white-space: pre-wrap; } Kanal Logo hinzufügen + + EditForumDetails + + + Forum Details + Forum-Details + + + + Cancel + Abbrechen + + + + OK + OK + + + + Edit Forum Details + Forum-Details bearbeiten + + + + Forum Info + Forum Info + + + + Forum Name + Forum Name + + + + Forum Description + Forum Beschreibung + + EmailPage @@ -3111,12 +3149,12 @@ p, li { white-space: pre-wrap; } Forum Details - + Forum Details Forum Info - + Forum Info @@ -3258,7 +3296,7 @@ p, li { white-space: pre-wrap; } ForumsDialog - + Subscribe to Forum Forum abonnieren @@ -3278,7 +3316,12 @@ p, li { white-space: pre-wrap; } Zeige Foren-Details - + + Edit Forum Details + + + + Reply Antwort @@ -3298,7 +3341,7 @@ p, li { white-space: pre-wrap; } Alle reduzieren - + Hide Verbergen @@ -3315,7 +3358,7 @@ p, li { white-space: pre-wrap; } Beliebtheit: - + Anonymous Anonym @@ -3333,18 +3376,18 @@ p, li { white-space: pre-wrap; } keine - - + + RetroShare - + No Forum Selected! Kein Forum ausgewählt! - + Re: @@ -3354,7 +3397,7 @@ p, li { white-space: pre-wrap; } Du kannst einem anonymen Autor nicht antworten - + Your Forums Deine Foren @@ -3496,8 +3539,8 @@ p, li { white-space: pre-wrap; } Druckvorschau - - + + Start New Thread Erstelle neues Thema @@ -3525,7 +3568,7 @@ p, li { white-space: pre-wrap; } Inhalt - + Mark as read Als gelesen markieren @@ -4337,7 +4380,7 @@ p, li { white-space: pre-wrap; } - + Copy Kopieren @@ -6794,7 +6837,7 @@ p, li { white-space: pre-wrap; } Verbinde zum Freund - + Profile Profil @@ -6804,7 +6847,7 @@ p, li { white-space: pre-wrap; } RetroShare Link einfügen - + Welcome to RetroShare's group chat. Willkommen bei RetroShare's Gruppenchat. @@ -7067,12 +7110,12 @@ p, li { white-space: pre-wrap; } Status Spalte ausblenden - + Friends Storm Aktivitäten - + Recomend this Friend to... Freund weiterempfehlen... @@ -8071,7 +8114,7 @@ p, li { white-space: pre-wrap; } Prüfsumme - + Multiple instances Mehrere Instanzen