From 024479d518755804523bbe3db99c6cb131281b6e Mon Sep 17 00:00:00 2001 From: thunder2 Date: Fri, 19 Jul 2013 21:06:19 +0000 Subject: [PATCH] GXS: - Enabled generate of mass data for forums and channels git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6521 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 34 +++++++- .../gui/gxschannels/CreateGxsChannelMsg.ui | 45 ++++++++--- .../src/gui/gxschannels/GxsChannelDialog.cpp | 6 -- .../src/gui/gxschannels/GxsChannelDialog.h | 2 - .../src/gui/gxsforums/CreateGxsForumMsg.cpp | 44 +++++++++-- .../src/gui/gxsforums/CreateGxsForumMsg.ui | 79 ++++++++----------- .../src/gui/gxsforums/GxsForumsDialog.cpp | 43 ---------- .../src/gui/gxsforums/GxsForumsDialog.h | 2 - 8 files changed, 134 insertions(+), 121 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 17b1b73f6..3c4651bb2 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -34,6 +34,8 @@ #include +//#define ENABLE_GENERATE + #define CREATEMSG_CHANNELINFO 0x002 /** Constructor */ @@ -58,6 +60,9 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(std::string cId) connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail())); connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool))); connect(tabWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint))); + connect(generateCheckBox, SIGNAL(toggled(bool)), generateSpinBox, SLOT(setEnabled(bool))); + + generateSpinBox->setEnabled(false); thumbNailCb->setVisible(false); thumbNailCb->setEnabled(false); @@ -71,6 +76,11 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(std::string cId) setAcceptDrops(true); newChannelMsg(); + +#ifndef ENABLE_GENERATE + generateCheckBox->hide(); + generateSpinBox->hide(); +#endif } void CreateGxsChannelMsg::contextMenu(QPoint /*point*/) @@ -628,8 +638,30 @@ void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::str post.mThumbnail.copy((uint8_t *) ba.data(), ba.size()); } + int generateCount = 0; + +#ifdef ENABLE_GENERATE + if (generateCheckBox->isChecked()) { + generateCount = generateSpinBox->value(); + if (QMessageBox::question(this, "Generate mass data", QString("Do you really want to generate %1 messages ?").arg(generateCount), QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) { + return; + } + } +#endif + uint32_t token; - rsGxsChannels->createPost(token, post); + if (generateCount) { +#ifdef ENABLE_GENERATE + for (int count = 0; count < generateCount; ++count) { + RsGxsChannelPost generatePost = post; + generatePost.mMeta.mMsgName = QString("%1 %2").arg(QString::fromUtf8(post.mMeta.mMsgName.c_str())).arg(count + 1, 3, 10, QChar('0')).toUtf8().constData(); + + rsGxsChannels->createPost(token, generatePost); + } +#endif + } else { + rsGxsChannels->createPost(token, post); + } } accept(); diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index cd07a88b2..aa19602a3 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -161,8 +161,8 @@ p, li { white-space: pre-wrap; } Message - - + + @@ -182,7 +182,7 @@ p, li { white-space: pre-wrap; } - + @@ -293,7 +293,7 @@ p, li { white-space: pre-wrap; } 0 0 - 98 + 518 24 @@ -336,14 +336,35 @@ p, li { white-space: pre-wrap; } - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - + + + + + Generate mass data + + + + + + + 1 + + + 999 + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp index f789e4496..a35e7a522 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp @@ -338,12 +338,6 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ ) QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink())); action->setEnabled(!mChannelId.empty()); -#ifdef DEBUG_CHANNEL - contextMnu.addSeparator(); - action = contextMnu.addAction("Generate mass data", this, SLOT(generateMassData())); - action->setEnabled (!mChannelId.empty() && (ci.channelFlags & RS_DISTRIB_PUBLISH)); -#endif - contextMnu.exec(QCursor::pos()); #endif diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h index 49ac28dbc..9eb1c01f2 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h @@ -86,8 +86,6 @@ private slots: // void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status); - //void generateMassData(); - //void fillThreadFinished(); //void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count); diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index c5578f5df..29c0370af 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -45,6 +45,8 @@ #define CREATEGXSFORUMMSG_FORUMINFO 1 #define CREATEGXSFORUMMSG_PARENTMSG 2 +//#define ENABLE_GENERATE + /** Constructor */ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &pId) : QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId) @@ -77,6 +79,8 @@ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string & ui.headerFrame->setHeaderImage(QPixmap(":/images/konversation64.png")); ui.headerFrame->setHeaderText(text); + ui.generateSpinBox->setEnabled(false); + Settings->loadWidgetInformation(this); connect(ui.forumMessage, SIGNAL( customContextMenuRequested(QPoint)), this, SLOT(forumMessageCostumPopupMenu(QPoint))); @@ -89,6 +93,7 @@ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string & connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums())); connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile())); connect(ui.pastersButton, SIGNAL(clicked()), this, SLOT(pasteLink())); + connect(ui.generateCheckBox, SIGNAL(toggled(bool)), ui.generateSpinBox, SLOT(setEnabled(bool))); setAcceptDrops(true); ui.hashBox->setDropWidget(this); @@ -98,6 +103,11 @@ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string & mForumMetaLoaded = false; newMsg(); + +#ifndef ENABLE_GENERATE + ui.generateCheckBox->hide(); + ui.generateSpinBox->hide(); +#endif } CreateGxsForumMsg::~CreateGxsForumMsg() @@ -277,8 +287,7 @@ void CreateGxsForumMsg::createMsg() if(name.isEmpty()) { /* error message */ - QMessageBox::warning(this, tr("RetroShare"),tr("Please set a Forum Subject and Forum Message"), - QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::warning(this, tr("RetroShare"),tr("Please set a Forum Subject and Forum Message"), QMessageBox::Ok, QMessageBox::Ok); return; //Don't add a empty Subject!! } @@ -314,8 +323,7 @@ void CreateGxsForumMsg::createMsg() { std::cerr << "CreateGxsForumMsg::createMsg() ERROR GETTING AuthorId!"; std::cerr << std::endl; - QMessageBox::warning(this, tr("RetroShare"),tr("Please choose Signing Id"), - QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::warning(this, tr("RetroShare"),tr("Please choose Signing Id"), QMessageBox::Ok, QMessageBox::Ok); return; } @@ -324,13 +332,35 @@ void CreateGxsForumMsg::createMsg() { std::cerr << "CreateGxsForumMsg::createMsg() No Signature (for now :)"; std::cerr << std::endl; - QMessageBox::warning(this, tr("RetroShare"),tr("Please choose Signing Id, it is required"), - QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::warning(this, tr("RetroShare"),tr("Please choose Signing Id, it is required"), QMessageBox::Ok, QMessageBox::Ok); return; } + int generateCount = 0; + +#ifdef ENABLE_GENERATE + if (ui.generateCheckBox->isChecked()) { + generateCount = ui.generateSpinBox->value(); + if (QMessageBox::question(this, "Generate mass data", QString("Do you really want to generate %1 messages ?").arg(generateCount), QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) { + return; + } + } +#endif + uint32_t token; - rsGxsForums->createMsg(token, msg); + if (generateCount) { +#ifdef ENABLE_GENERATE + for (int count = 0; count < generateCount; ++count) { + RsGxsForumMsg generateMsg = msg; + generateMsg.mMeta.mMsgName = QString("%1 %2").arg(QString::fromUtf8(msg.mMeta.mMsgName.c_str())).arg(count + 1, 3, 10, QChar('0')).toUtf8().constData(); + + rsGxsForums->createMsg(token, generateMsg); + } +#endif + } else { + rsGxsForums->createMsg(token, msg); + } + close(); } diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui index 0622e77b6..7e69a30bf 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui @@ -21,22 +21,11 @@ 0 - - 0 - - - 0 - - - 0 - - + 0 - - buttonBox - + @@ -50,16 +39,7 @@ - - 0 - - - 0 - - - 0 - - + 0 @@ -71,16 +51,7 @@ QFrame::Raised - - 0 - - - 0 - - - 0 - - + 0 @@ -125,16 +96,7 @@ QFrame::Sunken - - 6 - - - 6 - - - 6 - - + 6 @@ -300,11 +262,32 @@ p, li { white-space: pre-wrap; } - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - + + + + + Generate mass data + + + + + + + 1 + + + 999 + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp index ddafb9439..bf5cb7952 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp @@ -239,12 +239,6 @@ void GxsForumsDialog::forumListCustomPopupMenu(QPoint /*point*/) action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread())); action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags)); -#ifdef DEBUG_FORUMS - contextMnu.addSeparator(); - action = contextMnu.addAction("Generate mass data", this, SLOT(generateMassData())); - action->setEnabled (!mCurrForumId.empty() && IS_GROUP_SUBSCRIBED(mSubscribeFlags)); -#endif - contextMnu.exec(QCursor::pos()); } @@ -650,43 +644,6 @@ bool GxsForumsDialog::navigate(const std::string& forumId, const std::string& ms return false; } -void GxsForumsDialog::generateMassData() -{ -#ifdef DEBUG_FORUMS - if (mCurrForumId.empty ()) { - return; - } - - if (QMessageBox::question(this, "Generate mass data", "Do you really want to generate mass data ?", QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) { - return; - } - - for (int thread = 1; thread < 1000; thread++) { - ForumMsgInfo threadInfo; - threadInfo.forumId = mCurrForumId; - threadInfo.title = QString("Test %1").arg(thread, 3, 10, QChar('0')).toStdWString(); - threadInfo.msg = QString("That is only a test").toStdWString(); - - if (rsGxsForums->ForumMessageSend(threadInfo) == false) { - return; - } - - for (int msg = 1; msg < 3; msg++) { - ForumMsgInfo msgInfo; - msgInfo.forumId = mCurrForumId; - msgInfo.threadId = threadInfo.msgId; - msgInfo.parentId = threadInfo.msgId; - msgInfo.title = threadInfo.title; - msgInfo.msg = threadInfo.msg; - - if (rsGxsForums->ForumMessageSend(msgInfo) == false) { - return; - } - } - } -#endif -} - /*********************** **** **** **** ***********************/ /** Request / Response of Data ********************************/ /*********************** **** **** **** ***********************/ diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h index 7aa3c3b58..344f2d7a0 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h @@ -85,8 +85,6 @@ private slots: void markMsgAsRead(); void markMsgAsUnread(); - void generateMassData(); - void shareKey(); private: