mirror of
https://github.com/RetroShare/RetroShare.git
synced 2026-01-11 05:21:11 -05:00
Wiki: Core event logic and cleanup
This commit is contained in:
parent
32a3c860ae
commit
bedfc39d61
6 changed files with 112 additions and 81 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -35,3 +35,7 @@ Thumbs.db
|
|||
/retroshare-gui/src/temp/
|
||||
/retroshare-service/src/retroshare-service
|
||||
/*.tar.?z
|
||||
|
||||
# Build artifacts
|
||||
build/
|
||||
.vscode/
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 7643654403b5779e56dd20c5e73e4e47583f27e6
|
||||
Subproject commit cb57e66e2741ad985cdf31b8f92ef9b0a4cfebd0
|
||||
|
|
@ -33,6 +33,8 @@
|
|||
#include "util/DateTime.h"
|
||||
|
||||
#include <retroshare/rswiki.h>
|
||||
#include "util/qtthreadsutils.h"
|
||||
|
||||
|
||||
// These should be in retroshare/ folder.
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
|
|
@ -79,60 +81,68 @@
|
|||
|
||||
|
||||
/** Constructor */
|
||||
WikiDialog::WikiDialog(QWidget *parent) : RsGxsUpdateBroadcastPage(rsWiki, parent)
|
||||
WikiDialog::WikiDialog(QWidget *parent) :
|
||||
RsGxsUpdateBroadcastPage(rsWiki, parent),
|
||||
mEventHandlerId(0) // Initialize handler ID
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
mAddPageDialog = NULL;
|
||||
mAddGroupDialog = NULL;
|
||||
mEditDialog = NULL;
|
||||
mAddPageDialog = NULL;
|
||||
mAddGroupDialog = NULL;
|
||||
mEditDialog = NULL;
|
||||
|
||||
connect( ui.toolButton_NewPage, SIGNAL(clicked()), this, SLOT(OpenOrShowAddPageDialog()));
|
||||
connect( ui.toolButton_Edit, SIGNAL(clicked()), this, SLOT(OpenOrShowEditDialog()));
|
||||
connect( ui.toolButton_Republish, SIGNAL(clicked()), this, SLOT(OpenOrShowRepublishDialog()));
|
||||
connect( ui.toolButton_NewPage, SIGNAL(clicked()), this, SLOT(OpenOrShowAddPageDialog()));
|
||||
connect( ui.toolButton_Edit, SIGNAL(clicked()), this, SLOT(OpenOrShowEditDialog()));
|
||||
connect( ui.toolButton_Republish, SIGNAL(clicked()), this, SLOT(OpenOrShowRepublishDialog()));
|
||||
|
||||
// Usurped until Refresh works normally
|
||||
connect( ui.toolButton_Delete, SIGNAL(clicked()), this, SLOT(insertWikiGroups()));
|
||||
connect( ui.pushButton, SIGNAL(clicked()), this, SLOT(todo()));
|
||||
connect( ui.treeWidget_Pages, SIGNAL(itemSelectionChanged()), this, SLOT(groupTreeChanged()));
|
||||
|
||||
connect( ui.treeWidget_Pages, SIGNAL(itemSelectionChanged()), this, SLOT(groupTreeChanged()));
|
||||
// GroupTreeWidget.
|
||||
connect(ui.groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupListCustomPopupMenu(QPoint)));
|
||||
connect(ui.groupTreeWidget, SIGNAL(treeItemActivated(QString)), this, SLOT(wikiGroupChanged(QString)));
|
||||
|
||||
// GroupTreeWidget.
|
||||
connect(ui.groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupListCustomPopupMenu(QPoint)));
|
||||
connect(ui.groupTreeWidget, SIGNAL(treeItemActivated(QString)), this, SLOT(wikiGroupChanged(QString)));
|
||||
/* setup TokenQueue */
|
||||
mWikiQueue = new TokenQueue(rsWiki->getTokenService(), this);
|
||||
|
||||
/* setup TokenQueue */
|
||||
mWikiQueue = new TokenQueue(rsWiki->getTokenService(), this);
|
||||
// Set initial size of the splitter
|
||||
ui.listSplitter->setStretchFactor(0, 0);
|
||||
ui.listSplitter->setStretchFactor(1, 1);
|
||||
|
||||
// Set initial size of the splitter
|
||||
ui.listSplitter->setStretchFactor(0, 0);
|
||||
ui.listSplitter->setStretchFactor(1, 1);
|
||||
/* Setup Group Tree */
|
||||
mYourGroups = ui.groupTreeWidget->addCategoryItem(tr("My Groups"), QIcon(), true);
|
||||
mSubscribedGroups = ui.groupTreeWidget->addCategoryItem(tr("Subscribed Groups"), QIcon(), true);
|
||||
mPopularGroups = ui.groupTreeWidget->addCategoryItem(tr("Popular Groups"), QIcon(), false);
|
||||
mOtherGroups = ui.groupTreeWidget->addCategoryItem(tr("Other Groups"), QIcon(), false);
|
||||
|
||||
/* Add the New Group button */
|
||||
QToolButton *newGroupButton = new QToolButton(this);
|
||||
newGroupButton->setIcon(QIcon(":/icons/png/add.png"));
|
||||
newGroupButton->setToolTip(tr("Create Group"));
|
||||
connect(newGroupButton, SIGNAL(clicked()), this, SLOT(OpenOrShowAddGroupDialog()));
|
||||
ui.groupTreeWidget->addToolButton(newGroupButton);
|
||||
|
||||
/* Setup Group Tree */
|
||||
mYourGroups = ui.groupTreeWidget->addCategoryItem(tr("My Groups"), QIcon(), true);
|
||||
mSubscribedGroups = ui.groupTreeWidget->addCategoryItem(tr("Subscribed Groups"), QIcon(), true);
|
||||
mPopularGroups = ui.groupTreeWidget->addCategoryItem(tr("Popular Groups"), QIcon(), false);
|
||||
mOtherGroups = ui.groupTreeWidget->addCategoryItem(tr("Other Groups"), QIcon(), false);
|
||||
|
||||
/* Add the New Group button */
|
||||
QToolButton *newGroupButton = new QToolButton(this);
|
||||
newGroupButton->setIcon(QIcon(":/icons/png/add.png"));
|
||||
newGroupButton->setToolTip(tr("Create Group"));
|
||||
connect(newGroupButton, SIGNAL(clicked()), this, SLOT(OpenOrShowAddGroupDialog()));
|
||||
ui.groupTreeWidget->addToolButton(newGroupButton);
|
||||
// load settings
|
||||
processSettings(true);
|
||||
updateDisplay(true);
|
||||
|
||||
//QTimer *timer = new QTimer(this);
|
||||
//timer->connect(timer, SIGNAL(timeout()), this, SLOT(insertWikiGroups()));
|
||||
//timer->start(5000);
|
||||
/* Get dynamic event type ID for Wiki. This avoids hardcoding IDs in rsevents.h */
|
||||
RsEventType wikiEventType = (RsEventType)rsEvents->getDynamicEventType("GXS_WIKI");
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
updateDisplay(true);
|
||||
/* Register events handler using the dynamic type */
|
||||
rsEvents->registerEventsHandler(
|
||||
[this](std::shared_ptr<const RsEvent> event) {
|
||||
RsQThreadUtils::postToObject([=]() {
|
||||
handleEvent_main_thread(event);
|
||||
}, this );
|
||||
},
|
||||
mEventHandlerId, wikiEventType);
|
||||
}
|
||||
|
||||
WikiDialog::~WikiDialog()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
|
||||
// save settings
|
||||
processSettings(false);
|
||||
|
||||
|
|
@ -158,6 +168,7 @@ void WikiDialog::processSettings(bool load)
|
|||
Settings->endGroup();
|
||||
}
|
||||
|
||||
|
||||
void WikiDialog::OpenOrShowAddPageDialog()
|
||||
{
|
||||
RsGxsGroupId groupId = getSelectedGroup();
|
||||
|
|
@ -722,13 +733,6 @@ void WikiDialog::GroupMetaDataToGroupItemInfo(const RsGroupMetaData &groupInfo,
|
|||
groupItemInfo.icon = QIcon(IMAGE_WIKI);
|
||||
|
||||
}
|
||||
void WikiDialog::todo()
|
||||
{
|
||||
QMessageBox::information(this, "Todo",
|
||||
"<b>Open points:</b><ul>"
|
||||
"<li>Auto update Group trees"
|
||||
"</ul>");
|
||||
}
|
||||
|
||||
void WikiDialog::updateDisplay(bool complete)
|
||||
{
|
||||
|
|
@ -751,3 +755,26 @@ void WikiDialog::insertWikiGroups()
|
|||
{
|
||||
updateDisplay(true);
|
||||
}
|
||||
|
||||
void WikiDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
// Cast to the specific Wiki event
|
||||
const RsGxsWikiEvent *e = dynamic_cast<const RsGxsWikiEvent*>(event.get());
|
||||
|
||||
if(e) {
|
||||
std::cerr << "WikiDialog: Received event for group " << e->mWikiGroupId.toStdString() << std::endl;
|
||||
|
||||
switch(e->mWikiEventCode) {
|
||||
case RsWikiEventCode::UPDATED_COLLECTION:
|
||||
updateDisplay(true); // Refresh global list
|
||||
break;
|
||||
case RsWikiEventCode::UPDATED_SNAPSHOT:
|
||||
// Only refresh if we are currently looking at the changed group
|
||||
if (e->mWikiGroupId == mGroupId) {
|
||||
wikiGroupChanged(QString::fromStdString(mGroupId.toStdString()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
class WikiAddDialog;
|
||||
class WikiEditDialog;
|
||||
class UserNotify;
|
||||
|
||||
class WikiDialog : public RsGxsUpdateBroadcastPage, public TokenResponse
|
||||
{
|
||||
|
|
@ -54,6 +55,8 @@ public:
|
|||
public:
|
||||
virtual void updateDisplay(bool complete);
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
void OpenOrShowAddPageDialog();
|
||||
|
|
@ -73,7 +76,6 @@ private slots:
|
|||
void unsubscribeToGroup();
|
||||
void wikiGroupChanged(const QString &groupId);
|
||||
|
||||
void todo();
|
||||
void insertWikiGroups();
|
||||
|
||||
private:
|
||||
|
|
@ -87,6 +89,9 @@ private:
|
|||
std::string getSelectedPage();
|
||||
const RsGxsGroupId &getSelectedGroup();
|
||||
|
||||
uint32_t mEventHandlerId;
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
// Using GroupTreeWidget.
|
||||
void wikiSubscribe(bool subscribe);
|
||||
void GroupMetaDataToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo);
|
||||
|
|
|
|||
|
|
@ -432,7 +432,6 @@ HEADERS += rshare.h \
|
|||
util/RsNetUtil.h \
|
||||
util/DateTime.h \
|
||||
util/RetroStyleLabel.h \
|
||||
util/dllexport.h \
|
||||
util/NonCopyable.h \
|
||||
util/rsutildll.h \
|
||||
util/dllexport.h \
|
||||
|
|
@ -1179,27 +1178,31 @@ gxsphotoshare {
|
|||
|
||||
|
||||
wikipoos {
|
||||
DEFINES += RS_USE_WIKI
|
||||
|
||||
DEPENDPATH += ../../supportlibs/pegmarkdown
|
||||
INCLUDEPATH += ../../supportlibs/pegmarkdown
|
||||
|
||||
HEADERS += gui/WikiPoos/WikiDialog.h \
|
||||
gui/WikiPoos/WikiAddDialog.h \
|
||||
gui/WikiPoos/WikiEditDialog.h \
|
||||
gui/gxs/WikiGroupDialog.h \
|
||||
message(Including WikiPoos)
|
||||
DEFINES += RS_USE_WIKI
|
||||
INCLUDEPATH += ../../supportlibs/pegmarkdown
|
||||
|
||||
FORMS += gui/WikiPoos/WikiDialog.ui \
|
||||
gui/WikiPoos/WikiAddDialog.ui \
|
||||
gui/WikiPoos/WikiEditDialog.ui \
|
||||
|
||||
SOURCES += gui/WikiPoos/WikiDialog.cpp \
|
||||
gui/WikiPoos/WikiAddDialog.cpp \
|
||||
gui/WikiPoos/WikiEditDialog.cpp \
|
||||
gui/gxs/WikiGroupDialog.cpp \
|
||||
HEADERS += gui/WikiPoos/WikiDialog.h \
|
||||
gui/WikiPoos/WikiAddDialog.h \
|
||||
gui/WikiPoos/WikiEditDialog.h \
|
||||
gui/gxs/WikiGroupDialog.h \
|
||||
gui/gxs/RsGxsUpdateBroadcastBase.h \
|
||||
gui/gxs/RsGxsUpdateBroadcastWidget.h \
|
||||
gui/gxs/RsGxsUpdateBroadcastPage.h
|
||||
|
||||
RESOURCES += gui/WikiPoos/Wiki_images.qrc
|
||||
SOURCES += gui/WikiPoos/WikiDialog.cpp \
|
||||
gui/WikiPoos/WikiAddDialog.cpp \
|
||||
gui/WikiPoos/WikiEditDialog.cpp \
|
||||
gui/gxs/WikiGroupDialog.cpp \
|
||||
gui/gxs/RsGxsUpdateBroadcastBase.cpp \
|
||||
gui/gxs/RsGxsUpdateBroadcastWidget.cpp \
|
||||
gui/gxs/RsGxsUpdateBroadcastPage.cpp
|
||||
|
||||
FORMS += gui/WikiPoos/WikiDialog.ui \
|
||||
gui/WikiPoos/WikiAddDialog.ui \
|
||||
gui/WikiPoos/WikiEditDialog.ui
|
||||
|
||||
RESOURCES += gui/WikiPoos/Wiki_images.qrc
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1474,18 +1477,6 @@ gxsgui {
|
|||
}
|
||||
|
||||
|
||||
wikipoos {
|
||||
HEADERS += \
|
||||
gui/gxs/RsGxsUpdateBroadcastBase.h \
|
||||
gui/gxs/RsGxsUpdateBroadcastWidget.h \
|
||||
gui/gxs/RsGxsUpdateBroadcastPage.h
|
||||
|
||||
SOURCES += \
|
||||
gui/gxs/RsGxsUpdateBroadcastBase.cpp \
|
||||
gui/gxs/RsGxsUpdateBroadcastWidget.cpp \
|
||||
gui/gxs/RsGxsUpdateBroadcastPage.cpp \
|
||||
}
|
||||
|
||||
################################################################
|
||||
#Define qmake_info.h file so GUI can get wath was used to compil
|
||||
# This must be at end to get all informations
|
||||
|
|
|
|||
|
|
@ -227,6 +227,10 @@ CONFIG *= rs_sam3_libsam3
|
|||
no_rs_sam3_libsam3:CONFIG -= rs_sam3_libsam3
|
||||
|
||||
|
||||
|
||||
#Wikipoos
|
||||
#CONFIG *= wikipoos
|
||||
|
||||
# Specify host precompiled jsonapi-generator path, appending the following
|
||||
# assignation to qmake command line
|
||||
# 'JSONAPI_GENERATOR_EXE=/myBuildDir/jsonapi-generator'. Required for JSON API
|
||||
|
|
@ -334,7 +338,7 @@ DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_001
|
|||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||
|
||||
#CONFIG += rs_v07_changes
|
||||
#CONFIG *= wikipoos rs_v07_changes
|
||||
rs_v07_changes {
|
||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_001
|
||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
||||
|
|
@ -532,7 +536,7 @@ versionAtLeast(CMAKE_VERSION, 3.5) {
|
|||
}
|
||||
|
||||
gxsdistsync:DEFINES *= RS_USE_GXS_DISTANT_SYNC
|
||||
wikipoos:DEFINES *= RS_USE_WIKI
|
||||
#wikipoos:DEFINES *= RS_USE_WIKI
|
||||
rs_gxs:DEFINES *= RS_ENABLE_GXS
|
||||
rs_gxs_send_all:DEFINES *= RS_GXS_SEND_ALL
|
||||
rs_service_webui_terminal_password:DEFINES *= RS_SERVICE_TERMINAL_WEBUI_PASSWORD
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue