diff --git a/retroshare-gui/src/gui/WikiPoos/WikiAddDialog.cpp b/retroshare-gui/src/gui/WikiPoos/WikiAddDialog.cpp new file mode 100644 index 000000000..b902383e6 --- /dev/null +++ b/retroshare-gui/src/gui/WikiPoos/WikiAddDialog.cpp @@ -0,0 +1,78 @@ +/* + * Retroshare Wiki Plugin. + * + * Copyright 2012-2012 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + +#include "gui/WikiPoos/WikiAddDialog.h" +#include + +#include + +/** Constructor */ +WikiAddDialog::WikiAddDialog(QWidget *parent) +: QWidget(parent) +{ + ui.setupUi(this); + + connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelGroup( void ) ) ); + connect(ui.pushButton_Create, SIGNAL( clicked( void ) ), this, SLOT( createGroup( void ) ) ); + + +} + + +void WikiAddDialog::cancelGroup() +{ + clearDialog(); + hide(); +} + + + +void WikiAddDialog::createGroup() +{ + std::cerr << "WikiAddDialog::createGroup()"; + std::cerr << std::endl; + + + RsWikiGroup group; + + group.mShareOptions.mShareType = 0; + group.mShareOptions.mShareGroupId = "unknown"; + group.mShareOptions.mPublishKey = "unknown"; + group.mShareOptions.mCommentMode = 0; + group.mShareOptions.mResizeMode = 0; + + group.mName = ui.lineEdit_Name->text().toStdString(); + group.mCategory = "Unknown"; + + rsWiki->createGroup(group); + clearDialog(); + hide(); +} + + +void WikiAddDialog::clearDialog() +{ + ui.lineEdit_Name->setText(QString("title")); +} + + diff --git a/retroshare-gui/src/gui/WikiPoos/WikiAddDialog.h b/retroshare-gui/src/gui/WikiPoos/WikiAddDialog.h new file mode 100644 index 000000000..87b3fbb41 --- /dev/null +++ b/retroshare-gui/src/gui/WikiPoos/WikiAddDialog.h @@ -0,0 +1,48 @@ +/* + * Retroshare Wiki Plugin. + * + * Copyright 2012-2012 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + +#ifndef MRK_WIKI_ADD_DIALOG_H +#define MRK_WIKI_ADD_DIALOG_H + +#include "ui_WikiAddDialog.h" + +class WikiAddDialog : public QWidget +{ + Q_OBJECT + +public: + WikiAddDialog(QWidget *parent = 0); + +private slots: + void clearDialog(); + void cancelGroup(); + void createGroup(); + +private: + + Ui::WikiAddDialog ui; + +}; + +#endif + diff --git a/retroshare-gui/src/gui/WikiPoos/WikiAddDialog.ui b/retroshare-gui/src/gui/WikiPoos/WikiAddDialog.ui new file mode 100644 index 000000000..9de9e6a3e --- /dev/null +++ b/retroshare-gui/src/gui/WikiPoos/WikiAddDialog.ui @@ -0,0 +1,273 @@ + + + WikiAddDialog + + + + 0 + 0 + 832 + 452 + + + + + + + + + + + 10 + 1 + + + + Basic Details + + + + + + Group Name: + + + + + + + + 0 + 0 + + + + + + + + Category: + + + + + + + + Travel + + + + + Holiday + + + + + Friends + + + + + Family + + + + + Work + + + + + Random + + + + + + + + Description: + + + + + + + + + + + + + + 1 + 0 + + + + Share Options + + + + + + + 0 + 0 + + + + + Public + + + + + All Friends + + + + + Restricted + + + + + + + + + 0 + 0 + + + + + N/A + + + + + University Friends + + + + + Family + + + + + This List Contains + + + + + All your Groups + + + + + + + + + 0 + 0 + + + + + No Comments Allowed + + + + + Authenticated Comments + + + + + Any Comments Allowed + + + + + + + + + 0 + 0 + + + + + Publish with XXX Key + + + + + + + + + + + Qt::Vertical + + + + 20 + 183 + + + + + + + + + 0 + 0 + + + + + + + Cancel + + + + + + + Qt::Horizontal + + + + 68 + 17 + + + + + + + + Create Group + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/WikiPoos/WikiDialog.cpp b/retroshare-gui/src/gui/WikiPoos/WikiDialog.cpp new file mode 100644 index 000000000..3b902122a --- /dev/null +++ b/retroshare-gui/src/gui/WikiPoos/WikiDialog.cpp @@ -0,0 +1,471 @@ +/* + * Retroshare Wiki Plugin. + * + * Copyright 2012-2012 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + +#include +#include + +#include "WikiDialog.h" +#include "gui/WikiPoos/WikiAddDialog.h" +#include "gui/WikiPoos/WikiEditDialog.h" + +#include + +#include +#include + +#include + +/****** + * #define WIKI_DEBUG 1 + *****/ + +#define WIKI_DEBUG 1 + + +/** Constructor */ +WikiDialog::WikiDialog(QWidget *parent) +: MainPage(parent) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + mAddPageDialog = NULL; + mAddGroupDialog = NULL; + mEditDialog = NULL; + + connect( ui.toolButton_NewGroup, SIGNAL(clicked()), this, SLOT(OpenOrShowAddGroupDialog())); + connect( ui.toolButton_NewPage, SIGNAL(clicked()), this, SLOT(OpenOrShowAddPageDialog())); + connect( ui.toolButton_Edit, SIGNAL(clicked()), this, SLOT(OpenOrShowEditDialog())); + + connect( ui.treeWidget_Pages, SIGNAL(itemSelectionChanged()), this, SLOT(groupTreeChanged())); + connect( ui.treeWidget_Mods, SIGNAL(itemSelectionChanged()), this, SLOT(modTreeChanged())); + + QTimer *timer = new QTimer(this); + timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); + timer->start(1000); + + +} + +void WikiDialog::checkUpdate() +{ + /* update */ + if (!rsWiki) + return; + + if (rsWiki->updated()) + { + insertWikiGroups(); + } + + return; +} + + +void WikiDialog::OpenOrShowAddPageDialog() +{ + std::string groupId = getSelectedGroup(); + if (groupId == "") + { + std::cerr << "WikiDialog::OpenOrShowAddPageDialog() No Group selected"; + std::cerr << std::endl; + return; + } + + if (!mEditDialog) + { + mEditDialog = new WikiEditDialog(NULL); + } + + std::cerr << "WikiDialog::OpenOrShowAddPageDialog() GroupId: " << groupId; + std::cerr << std::endl; + + RsWikiGroup group; + if (!rsWiki->getGroup(groupId, group)) + { + std::cerr << "WikiDialog::OpenOrShowAddPageDialog() Failed to Get Group"; + std::cerr << std::endl; + } + + + mEditDialog->setGroup(group); + mEditDialog->setNewPage(); + + mEditDialog->show(); +} + + +void WikiDialog::OpenOrShowAddGroupDialog() +{ + if (mAddGroupDialog) + { + mAddGroupDialog->show(); + } + else + { + mAddGroupDialog = new WikiAddDialog(NULL); + mAddGroupDialog->show(); + } +} + + +void WikiDialog::OpenOrShowEditDialog() +{ + std::string groupId = getSelectedGroup(); + if (groupId == "") + { + std::cerr << "WikiDialog::OpenOrShowAddPageDialog() No Group selected"; + std::cerr << std::endl; + return; + } + + std::string pageId = getSelectedPage(); + std::string modId = getSelectedMod(); + std::string realPageId; + if (pageId == "") + { + std::cerr << "WikiDialog::OpenOrShowAddPageDialog() No PageId selected"; + std::cerr << std::endl; + return; + } + + if (modId == "") + { + realPageId = pageId; + } + else + { + realPageId = modId; + } + + + if (!mEditDialog) + { + mEditDialog = new WikiEditDialog(NULL); + } + + RsWikiGroup group; + rsWiki->getGroup(groupId, group); + mEditDialog->setGroup(group); + + RsWikiPage page; + rsWiki->getPage(realPageId, page); + mEditDialog->setPreviousPage(page); + + mEditDialog->show(); +} + + + +void WikiDialog::groupTreeChanged() +{ + /* */ + std::string pageId = getSelectedPage(); + if (pageId == mPageSelected) + { + return; /* nothing changed */ + } + + if (pageId == "") + { + /* clear Mods */ + clearGroupTree(); + clearModsTree(); + + return; + } + + clearModsTree(); + RsWikiPage page; + + if (rsWiki->getPage(pageId, page)) + { + insertModsForPage(page.mOrigPageId); + updateWikiPage(page); + } +} + +void WikiDialog::modTreeChanged() +{ + /* */ + std::string pageId = getSelectedMod(); + if (pageId == mModSelected) + { + return; /* nothing changed */ + } + + if (pageId == "") + { + clearWikiPage(); + return; + } + + RsWikiPage page; + if (rsWiki->getPage(pageId, page)) + { + updateWikiPage(page); + } +} + + +void WikiDialog::updateWikiPage(const RsWikiPage &page) +{ + ui.textBrowser->setPlainText(QString::fromStdString(page.mPage)); +} + + +void WikiDialog::clearWikiPage() +{ + ui.textBrowser->setPlainText(""); +} + + +void WikiDialog::clearGroupTree() +{ + ui.treeWidget_Pages->clear(); +} + +void WikiDialog::clearModsTree() +{ + ui.treeWidget_Mods->clear(); +} + + + +#define WIKI_GROUP_COL_GROUPNAME 0 +#define WIKI_GROUP_COL_GROUPID 1 + +#define WIKI_GROUP_COL_PAGENAME 0 +#define WIKI_GROUP_COL_PAGEID 1 +#define WIKI_GROUP_COL_ORIGPAGEID 2 + + +void WikiDialog::insertWikiGroups() +{ + + std::cerr << "WikiDialog::insertWikiGroups()"; + std::cerr << std::endl; + + /* clear it all */ + clearGroupTree(); + + std::list groupIds; + std::list::iterator it; + + rsWiki->getGroupList(groupIds); + + for(it = groupIds.begin(); it != groupIds.end(); it++) + { + /* add a group Item */ + RsWikiGroup group; + rsWiki->getGroup(*it, group); + + QTreeWidgetItem *groupItem = new QTreeWidgetItem(NULL); + groupItem->setText(WIKI_GROUP_COL_GROUPNAME, QString::fromStdString(group.mName)); + groupItem->setText(WIKI_GROUP_COL_GROUPID, QString::fromStdString(group.mGroupId)); + ui.treeWidget_Pages->addTopLevelItem(groupItem); + + std::cerr << "Group: " << group.mName; + std::cerr << std::endl; + + std::list pageIds; + std::list::iterator pit; + + rsWiki->getOrigPageList(*it, pageIds); + + for(pit = pageIds.begin(); pit != pageIds.end(); pit++) + { + std::cerr << "\tOrigPageId: " << *pit; + std::cerr << std::endl; + + /* get newest page */ + RsWikiPage page; + std::string latestPageId; + if (!rsWiki->getLatestPage(*pit, latestPageId)) + { + std::cerr << "\tgetLatestPage() Failed"; + std::cerr << std::endl; + } + + if (!rsWiki->getPage(latestPageId, page)) + { + std::cerr << "\tgetPage() Failed"; + std::cerr << std::endl; + } + + std::cerr << "\tLatestPageId: " << latestPageId; + std::cerr << std::endl; + std::cerr << "\tExtracted OrigPageId: " << page.mOrigPageId; + std::cerr << std::endl; + std::cerr << "\tExtracted PageId: " << page.mPageId; + std::cerr << std::endl; + + QTreeWidgetItem *pageItem = new QTreeWidgetItem(NULL); + pageItem->setText(WIKI_GROUP_COL_PAGENAME, QString::fromStdString(page.mName)); + pageItem->setText(WIKI_GROUP_COL_PAGEID, QString::fromStdString(page.mPageId)); + pageItem->setText(WIKI_GROUP_COL_ORIGPAGEID, QString::fromStdString(page.mOrigPageId)); + + groupItem->addChild(pageItem); + + std::cerr << "\tPage: " << page.mName; + std::cerr << std::endl; + } + } +} + + +std::string WikiDialog::getSelectedPage() +{ + std::string pageId; +#ifdef WIKI_DEBUG + std::cerr << "WikiDialog::getSelectedPage()" << std::endl; +#endif + + /* get current item */ + QTreeWidgetItem *item = ui.treeWidget_Pages->currentItem(); + + if (!item) + { + /* leave current list */ +#ifdef WIKI_DEBUG + std::cerr << "WikiDialog::getSelectedPage() Nothing selected" << std::endl; +#endif + return pageId; + } + + QTreeWidgetItem *parent = item->parent(); + + if (!parent) + { +#ifdef WIKI_DEBUG + std::cerr << "WikiDialog::getSelectedPage() No Parent -> Group Selected" << std::endl; +#endif + return pageId; + } + + + /* check if it has changed */ + pageId = item->text(WIKI_GROUP_COL_PAGEID).toStdString(); +#ifdef WIKI_DEBUG + std::cerr << "WikiDialog::getSelectedPage() PageId: " << pageId << std::endl; +#endif + return pageId; +} + + +std::string WikiDialog::getSelectedGroup() +{ + std::string groupId; +#ifdef WIKI_DEBUG + std::cerr << "WikiDialog::getSelectedGroup()" << std::endl; +#endif + + /* get current item */ + QTreeWidgetItem *item = ui.treeWidget_Pages->currentItem(); + + if (!item) + { + /* leave current list */ +#ifdef WIKI_DEBUG + std::cerr << "WikiDialog::getSelectedGroup() Nothing selected" << std::endl; +#endif + return groupId; + } + + QTreeWidgetItem *parent = item->parent(); + + if (parent) + { + groupId = parent->text(WIKI_GROUP_COL_GROUPID).toStdString(); +#ifdef WIKI_DEBUG + std::cerr << "WikiDialog::getSelectedGroup() Page -> GroupId: " << groupId << std::endl; +#endif + return groupId; + } + + /* otherwise, we are on the group already */ + groupId = item->text(WIKI_GROUP_COL_GROUPID).toStdString(); +#ifdef WIKI_DEBUG + std::cerr << "WikiDialog::getSelectedGroup() GroupId: " << groupId << std::endl; +#endif + return groupId; +} + +#define WIKI_MODS_COL_ORIGPAGEID 0 +#define WIKI_MODS_COL_PAGEID 1 + +void WikiDialog::insertModsForPage(std::string &origPageId) +{ + /* clear it all */ + //clearPhotos(); + //ui.photoLayout->clear(); + + /* create a list of albums */ + + std::list pageIds; + std::list::const_iterator it; + + rsWiki->getPageVersions(origPageId, pageIds); + + + for(it = pageIds.begin(); it != pageIds.end(); it++) + { + RsWikiPage page; + rsWiki->getPage(*it, page); + + QTreeWidgetItem *modItem = new QTreeWidgetItem(NULL); + modItem->setText(WIKI_MODS_COL_ORIGPAGEID, QString::fromStdString(page.mOrigPageId)); + modItem->setText(WIKI_MODS_COL_PAGEID, QString::fromStdString(page.mPageId)); + ui.treeWidget_Mods->addTopLevelItem(modItem); + } +} + + + +std::string WikiDialog::getSelectedMod() +{ + std::string pageId; +#ifdef WIKI_DEBUG + std::cerr << "WikiDialog::getSelectedMod()" << std::endl; +#endif + + /* get current item */ + QTreeWidgetItem *item = ui.treeWidget_Mods->currentItem(); + + if (!item) + { + /* leave current list */ +#ifdef WIKI_DEBUG + std::cerr << "WikiDialog::getSelectedMod() Nothing selected" << std::endl; +#endif + return pageId; + } + + pageId = item->text(WIKI_MODS_COL_PAGEID).toStdString(); +#ifdef WIKI_DEBUG + std::cerr << "WikiDialog::getSelectedMod() PageId: " << pageId << std::endl; +#endif + return pageId; +} + + diff --git a/retroshare-gui/src/gui/WikiPoos/WikiDialog.h b/retroshare-gui/src/gui/WikiPoos/WikiDialog.h new file mode 100644 index 000000000..fbf077dc5 --- /dev/null +++ b/retroshare-gui/src/gui/WikiPoos/WikiDialog.h @@ -0,0 +1,83 @@ +/* + * Retroshare Wiki Plugin. + * + * Copyright 2012-2012 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + +#ifndef MRK_WIKI_DIALOG_H +#define MRK_WIKI_DIALOG_H + +#include "gui/mainpage.h" +#include "ui_WikiDialog.h" + +#include + +#include + +class WikiAddDialog; +class WikiEditDialog; + +class WikiDialog : public MainPage +{ + Q_OBJECT + +public: + WikiDialog(QWidget *parent = 0); + +private slots: + + void checkUpdate(); + void OpenOrShowAddPageDialog(); + void OpenOrShowAddGroupDialog(); + void OpenOrShowEditDialog(); + + void groupTreeChanged(); + void modTreeChanged(); + +private: + +void clearWikiPage(); +void clearGroupTree(); +void clearModsTree(); + +void insertWikiGroups(); +void insertModsForPage(std::string &origPageId); + +void updateWikiPage(const RsWikiPage &page); + +std::string getSelectedPage(); +std::string getSelectedGroup(); +std::string getSelectedMod(); + + WikiAddDialog *mAddPageDialog; + WikiAddDialog *mAddGroupDialog; + WikiEditDialog *mEditDialog; + + std::string mGroupSelected; + std::string mPageSelected; + std::string mModSelected; + + /* UI - from Designer */ + Ui::WikiDialog ui; + +}; + +#endif + diff --git a/retroshare-gui/src/gui/WikiPoos/WikiDialog.ui b/retroshare-gui/src/gui/WikiPoos/WikiDialog.ui new file mode 100644 index 000000000..433002c13 --- /dev/null +++ b/retroshare-gui/src/gui/WikiPoos/WikiDialog.ui @@ -0,0 +1,257 @@ + + + WikiDialog + + + + 0 + 0 + 774 + 608 + + + + + + + + + + Qt::Horizontal + + + + Qt::Vertical + + + + true + + + + + 0 + 0 + 205 + 285 + + + + + + + + Wiki Group + + + + + Page + + + + + Id + + + + + + + + + + true + + + + + 0 + 0 + 205 + 284 + + + + + + + + Page Modification + + + + + By + + + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + false + + + << + + + + + + + false + + + >> + + + + + + + Qt::Vertical + + + + + + + false + + + << Mod + + + + + + + Edit + + + + + + + false + + + Mod >> + + + + + + + Qt::Vertical + + + + + + + New Group + + + + + + + New Page + + + + + + + false + + + Delete + + + + + + + + + + true + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + 0 + 0 + 528 + 511 + + + + QWidget#scrollAreaWidgetContents{border: none;} + + + + 0 + + + 0 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 0 + 0 + + + + + + + + + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp b/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp new file mode 100644 index 000000000..1b7e72190 --- /dev/null +++ b/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp @@ -0,0 +1,110 @@ +/* + * Retroshare Wiki Plugin. + * + * Copyright 2012-2012 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + + +#include "gui/WikiPoos/WikiEditDialog.h" + +#include + +/** Constructor */ +WikiEditDialog::WikiEditDialog(QWidget *parent) +: QWidget(parent) +{ + ui.setupUi(this); + + connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelEdit( void ) ) ); + connect(ui.pushButton_Revert, SIGNAL( clicked( void ) ), this, SLOT( revertEdit( void ) ) ); + connect(ui.pushButton_Submit, SIGNAL( clicked( void ) ), this, SLOT( submitEdit( void ) ) ); + +} + +void WikiEditDialog::setGroup(RsWikiGroup &group) +{ + mWikiGroup = group; + + ui.lineEdit_Group->setText(QString::fromStdString(mWikiGroup.mName)); +} + + +void WikiEditDialog::setPreviousPage(RsWikiPage &page) +{ + mNewPage = false; + mWikiPage = page; + + ui.lineEdit_Page->setText(QString::fromStdString(mWikiPage.mName)); + ui.lineEdit_PrevVersion->setText(QString::fromStdString(mWikiPage.mPageId)); + ui.textEdit->setPlainText(QString::fromStdString(mWikiPage.mPage)); +} + + +void WikiEditDialog::setNewPage() +{ + mNewPage = true; + ui.lineEdit_Page->setText(""); + ui.lineEdit_PrevVersion->setText(""); + ui.textEdit->setPlainText(""); +} + + +void WikiEditDialog::cancelEdit() +{ + hide(); +} + + +void WikiEditDialog::revertEdit() +{ + if (mNewPage) + { + ui.textEdit->setPlainText(""); + } + else + { + ui.textEdit->setPlainText(QString::fromStdString(mWikiPage.mPage)); + } +} + + +void WikiEditDialog::submitEdit() +{ + if (mNewPage) + { + mWikiPage.mGroupId = mWikiGroup.mGroupId; + mWikiPage.mOrigPageId = ""; + mWikiPage.mPageId = ""; + mWikiPage.mPrevId = ""; + } + else + { + mWikiPage.mPrevId = mWikiPage.mPageId; + mWikiPage.mPageId = ""; + } + + mWikiPage.mName = ui.lineEdit_Page->text().toStdString(); + mWikiPage.mPage = ui.textEdit->toPlainText().toStdString(); + + rsWiki->createPage(mWikiPage); + hide(); +} + + diff --git a/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.h b/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.h new file mode 100644 index 000000000..245625a49 --- /dev/null +++ b/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.h @@ -0,0 +1,59 @@ +/* + * Retroshare Wiki Plugin. + * + * Copyright 2012-2012 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + +#ifndef MRK_WIKI_EDIT_DIALOG_H +#define MRK_WIKI_EDIT_DIALOG_H + +#include "ui_WikiEditDialog.h" + +#include + +class WikiEditDialog : public QWidget +{ + Q_OBJECT + +public: + WikiEditDialog(QWidget *parent = 0); + +void setGroup(RsWikiGroup &group); +void setPreviousPage(RsWikiPage &page); +void setNewPage(); + +private slots: + +void cancelEdit(); +void revertEdit(); +void submitEdit(); + +private: + + bool mNewPage; + RsWikiGroup mWikiGroup; + RsWikiPage mWikiPage; + + Ui::WikiEditDialog ui; + +}; + +#endif + diff --git a/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.ui b/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.ui new file mode 100644 index 000000000..5e8df9a33 --- /dev/null +++ b/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.ui @@ -0,0 +1,170 @@ + + + WikiEditDialog + + + + 0 + 0 + 647 + 618 + + + + + + + + + + Wiki Page + + + + + + Wiki Group: + + + groupBox + + + + + + + true + + + + + + + Qt::Horizontal + + + + 168 + 20 + + + + + + + + Page Name: + + + + + + + + 10 + 0 + + + + + + + + Edit ID + + + + + + + + + + Previous Version + + + + + + + + 10 + 0 + + + + true + + + + + + + Prev ID + + + + + + + + 1 + 0 + + + + true + + + + + + + + + + + + + + + Cancel + + + + + + + Revert + + + + + + + Qt::Horizontal + + + + 228 + 20 + + + + + + + + Submit + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/WikiPoos/Wiki_images.qrc b/retroshare-gui/src/gui/WikiPoos/Wiki_images.qrc new file mode 100644 index 000000000..3ab091103 --- /dev/null +++ b/retroshare-gui/src/gui/WikiPoos/Wiki_images.qrc @@ -0,0 +1,5 @@ + + + images/dummy.png + +