mirror of
https://github.com/RetroShare/RetroShare.git
synced 2026-09-12 19:50:17 +05:00
Wiki: Core event logic and cleanup
This commit is contained in:
parent
32a3c860ae
commit
bedfc39d61
4
.gitignore
vendored
4
.gitignore
vendored
@ -35,3 +35,7 @@ Thumbs.db
|
|||||||
/retroshare-gui/src/temp/
|
/retroshare-gui/src/temp/
|
||||||
/retroshare-service/src/retroshare-service
|
/retroshare-service/src/retroshare-service
|
||||||
/*.tar.?z
|
/*.tar.?z
|
||||||
|
|
||||||
|
# Build artifacts
|
||||||
|
build/
|
||||||
|
.vscode/
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit 7643654403b5779e56dd20c5e73e4e47583f27e6
|
Subproject commit cb57e66e2741ad985cdf31b8f92ef9b0a4cfebd0
|
||||||
@ -33,6 +33,8 @@
|
|||||||
#include "util/DateTime.h"
|
#include "util/DateTime.h"
|
||||||
|
|
||||||
#include <retroshare/rswiki.h>
|
#include <retroshare/rswiki.h>
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
|
|
||||||
|
|
||||||
// These should be in retroshare/ folder.
|
// These should be in retroshare/ folder.
|
||||||
#include "retroshare/rsgxsflags.h"
|
#include "retroshare/rsgxsflags.h"
|
||||||
@ -79,60 +81,68 @@
|
|||||||
|
|
||||||
|
|
||||||
/** Constructor */
|
/** 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 */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
mAddPageDialog = NULL;
|
mAddPageDialog = NULL;
|
||||||
mAddGroupDialog = NULL;
|
mAddGroupDialog = NULL;
|
||||||
mEditDialog = NULL;
|
mEditDialog = NULL;
|
||||||
|
|
||||||
connect( ui.toolButton_NewPage, SIGNAL(clicked()), this, SLOT(OpenOrShowAddPageDialog()));
|
connect( ui.toolButton_NewPage, SIGNAL(clicked()), this, SLOT(OpenOrShowAddPageDialog()));
|
||||||
connect( ui.toolButton_Edit, SIGNAL(clicked()), this, SLOT(OpenOrShowEditDialog()));
|
connect( ui.toolButton_Edit, SIGNAL(clicked()), this, SLOT(OpenOrShowEditDialog()));
|
||||||
connect( ui.toolButton_Republish, SIGNAL(clicked()), this, SLOT(OpenOrShowRepublishDialog()));
|
connect( ui.toolButton_Republish, SIGNAL(clicked()), this, SLOT(OpenOrShowRepublishDialog()));
|
||||||
|
|
||||||
// Usurped until Refresh works normally
|
connect( ui.treeWidget_Pages, SIGNAL(itemSelectionChanged()), this, SLOT(groupTreeChanged()));
|
||||||
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()));
|
// GroupTreeWidget.
|
||||||
|
connect(ui.groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupListCustomPopupMenu(QPoint)));
|
||||||
|
connect(ui.groupTreeWidget, SIGNAL(treeItemActivated(QString)), this, SLOT(wikiGroupChanged(QString)));
|
||||||
|
|
||||||
// GroupTreeWidget.
|
/* setup TokenQueue */
|
||||||
connect(ui.groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupListCustomPopupMenu(QPoint)));
|
mWikiQueue = new TokenQueue(rsWiki->getTokenService(), this);
|
||||||
connect(ui.groupTreeWidget, SIGNAL(treeItemActivated(QString)), this, SLOT(wikiGroupChanged(QString)));
|
|
||||||
|
|
||||||
/* setup TokenQueue */
|
// Set initial size of the splitter
|
||||||
mWikiQueue = new TokenQueue(rsWiki->getTokenService(), this);
|
ui.listSplitter->setStretchFactor(0, 0);
|
||||||
|
ui.listSplitter->setStretchFactor(1, 1);
|
||||||
|
|
||||||
// Set initial size of the splitter
|
/* Setup Group Tree */
|
||||||
ui.listSplitter->setStretchFactor(0, 0);
|
mYourGroups = ui.groupTreeWidget->addCategoryItem(tr("My Groups"), QIcon(), true);
|
||||||
ui.listSplitter->setStretchFactor(1, 1);
|
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 */
|
// load settings
|
||||||
mYourGroups = ui.groupTreeWidget->addCategoryItem(tr("My Groups"), QIcon(), true);
|
processSettings(true);
|
||||||
mSubscribedGroups = ui.groupTreeWidget->addCategoryItem(tr("Subscribed Groups"), QIcon(), true);
|
updateDisplay(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);
|
|
||||||
|
|
||||||
//QTimer *timer = new QTimer(this);
|
/* Get dynamic event type ID for Wiki. This avoids hardcoding IDs in rsevents.h */
|
||||||
//timer->connect(timer, SIGNAL(timeout()), this, SLOT(insertWikiGroups()));
|
RsEventType wikiEventType = (RsEventType)rsEvents->getDynamicEventType("GXS_WIKI");
|
||||||
//timer->start(5000);
|
|
||||||
|
|
||||||
// load settings
|
/* Register events handler using the dynamic type */
|
||||||
processSettings(true);
|
rsEvents->registerEventsHandler(
|
||||||
updateDisplay(true);
|
[this](std::shared_ptr<const RsEvent> event) {
|
||||||
|
RsQThreadUtils::postToObject([=]() {
|
||||||
|
handleEvent_main_thread(event);
|
||||||
|
}, this );
|
||||||
|
},
|
||||||
|
mEventHandlerId, wikiEventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
WikiDialog::~WikiDialog()
|
WikiDialog::~WikiDialog()
|
||||||
{
|
{
|
||||||
|
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||||
|
|
||||||
// save settings
|
// save settings
|
||||||
processSettings(false);
|
processSettings(false);
|
||||||
|
|
||||||
@ -158,6 +168,7 @@ void WikiDialog::processSettings(bool load)
|
|||||||
Settings->endGroup();
|
Settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WikiDialog::OpenOrShowAddPageDialog()
|
void WikiDialog::OpenOrShowAddPageDialog()
|
||||||
{
|
{
|
||||||
RsGxsGroupId groupId = getSelectedGroup();
|
RsGxsGroupId groupId = getSelectedGroup();
|
||||||
@ -722,13 +733,6 @@ void WikiDialog::GroupMetaDataToGroupItemInfo(const RsGroupMetaData &groupInfo,
|
|||||||
groupItemInfo.icon = QIcon(IMAGE_WIKI);
|
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)
|
void WikiDialog::updateDisplay(bool complete)
|
||||||
{
|
{
|
||||||
@ -751,3 +755,26 @@ void WikiDialog::insertWikiGroups()
|
|||||||
{
|
{
|
||||||
updateDisplay(true);
|
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 WikiAddDialog;
|
||||||
class WikiEditDialog;
|
class WikiEditDialog;
|
||||||
|
class UserNotify;
|
||||||
|
|
||||||
class WikiDialog : public RsGxsUpdateBroadcastPage, public TokenResponse
|
class WikiDialog : public RsGxsUpdateBroadcastPage, public TokenResponse
|
||||||
{
|
{
|
||||||
@ -54,6 +55,8 @@ public:
|
|||||||
public:
|
public:
|
||||||
virtual void updateDisplay(bool complete);
|
virtual void updateDisplay(bool complete);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void OpenOrShowAddPageDialog();
|
void OpenOrShowAddPageDialog();
|
||||||
@ -73,7 +76,6 @@ private slots:
|
|||||||
void unsubscribeToGroup();
|
void unsubscribeToGroup();
|
||||||
void wikiGroupChanged(const QString &groupId);
|
void wikiGroupChanged(const QString &groupId);
|
||||||
|
|
||||||
void todo();
|
|
||||||
void insertWikiGroups();
|
void insertWikiGroups();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -87,6 +89,9 @@ private:
|
|||||||
std::string getSelectedPage();
|
std::string getSelectedPage();
|
||||||
const RsGxsGroupId &getSelectedGroup();
|
const RsGxsGroupId &getSelectedGroup();
|
||||||
|
|
||||||
|
uint32_t mEventHandlerId;
|
||||||
|
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||||
|
|
||||||
// Using GroupTreeWidget.
|
// Using GroupTreeWidget.
|
||||||
void wikiSubscribe(bool subscribe);
|
void wikiSubscribe(bool subscribe);
|
||||||
void GroupMetaDataToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo);
|
void GroupMetaDataToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo);
|
||||||
|
|||||||
@ -432,7 +432,6 @@ HEADERS += rshare.h \
|
|||||||
util/RsNetUtil.h \
|
util/RsNetUtil.h \
|
||||||
util/DateTime.h \
|
util/DateTime.h \
|
||||||
util/RetroStyleLabel.h \
|
util/RetroStyleLabel.h \
|
||||||
util/dllexport.h \
|
|
||||||
util/NonCopyable.h \
|
util/NonCopyable.h \
|
||||||
util/rsutildll.h \
|
util/rsutildll.h \
|
||||||
util/dllexport.h \
|
util/dllexport.h \
|
||||||
@ -1179,27 +1178,31 @@ gxsphotoshare {
|
|||||||
|
|
||||||
|
|
||||||
wikipoos {
|
wikipoos {
|
||||||
DEFINES += RS_USE_WIKI
|
message(Including WikiPoos)
|
||||||
|
DEFINES += RS_USE_WIKI
|
||||||
DEPENDPATH += ../../supportlibs/pegmarkdown
|
INCLUDEPATH += ../../supportlibs/pegmarkdown
|
||||||
INCLUDEPATH += ../../supportlibs/pegmarkdown
|
|
||||||
|
|
||||||
HEADERS += gui/WikiPoos/WikiDialog.h \
|
|
||||||
gui/WikiPoos/WikiAddDialog.h \
|
|
||||||
gui/WikiPoos/WikiEditDialog.h \
|
|
||||||
gui/gxs/WikiGroupDialog.h \
|
|
||||||
|
|
||||||
FORMS += gui/WikiPoos/WikiDialog.ui \
|
HEADERS += gui/WikiPoos/WikiDialog.h \
|
||||||
gui/WikiPoos/WikiAddDialog.ui \
|
gui/WikiPoos/WikiAddDialog.h \
|
||||||
gui/WikiPoos/WikiEditDialog.ui \
|
gui/WikiPoos/WikiEditDialog.h \
|
||||||
|
gui/gxs/WikiGroupDialog.h \
|
||||||
SOURCES += gui/WikiPoos/WikiDialog.cpp \
|
gui/gxs/RsGxsUpdateBroadcastBase.h \
|
||||||
gui/WikiPoos/WikiAddDialog.cpp \
|
gui/gxs/RsGxsUpdateBroadcastWidget.h \
|
||||||
gui/WikiPoos/WikiEditDialog.cpp \
|
gui/gxs/RsGxsUpdateBroadcastPage.h
|
||||||
gui/gxs/WikiGroupDialog.cpp \
|
|
||||||
|
|
||||||
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
|
#Define qmake_info.h file so GUI can get wath was used to compil
|
||||||
# This must be at end to get all informations
|
# 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
|
no_rs_sam3_libsam3:CONFIG -= rs_sam3_libsam3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#Wikipoos
|
||||||
|
#CONFIG *= wikipoos
|
||||||
|
|
||||||
# Specify host precompiled jsonapi-generator path, appending the following
|
# Specify host precompiled jsonapi-generator path, appending the following
|
||||||
# assignation to qmake command line
|
# assignation to qmake command line
|
||||||
# 'JSONAPI_GENERATOR_EXE=/myBuildDir/jsonapi-generator'. Required for JSON API
|
# '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_002
|
||||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_003
|
||||||
|
|
||||||
#CONFIG += rs_v07_changes
|
#CONFIG *= wikipoos rs_v07_changes
|
||||||
rs_v07_changes {
|
rs_v07_changes {
|
||||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_001
|
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_001
|
||||||
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
DEFINES += V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
||||||
@ -532,7 +536,7 @@ versionAtLeast(CMAKE_VERSION, 3.5) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gxsdistsync:DEFINES *= RS_USE_GXS_DISTANT_SYNC
|
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:DEFINES *= RS_ENABLE_GXS
|
||||||
rs_gxs_send_all:DEFINES *= RS_GXS_SEND_ALL
|
rs_gxs_send_all:DEFINES *= RS_GXS_SEND_ALL
|
||||||
rs_service_webui_terminal_password:DEFINES *= RS_SERVICE_TERMINAL_WEBUI_PASSWORD
|
rs_service_webui_terminal_password:DEFINES *= RS_SERVICE_TERMINAL_WEBUI_PASSWORD
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user