- 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
This commit is contained in:
thunder2 2013-07-19 21:06:19 +00:00
parent 5090913630
commit 024479d518
8 changed files with 134 additions and 121 deletions

View File

@ -34,6 +34,8 @@
#include <iostream>
//#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,9 +638,31 @@ 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;
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();
}

View File

@ -161,8 +161,8 @@ p, li { white-space: pre-wrap; }
<property name="title">
<string>Message</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_5">
@ -182,7 +182,7 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<item>
<widget class="QTextEdit" name="msgEdit"/>
</item>
</layout>
@ -293,7 +293,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<width>518</width>
<height>24</height>
</rect>
</property>
@ -336,6 +336,25 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="generateCheckBox">
<property name="text">
<string>Generate mass data</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="generateSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -346,6 +365,8 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>

View File

@ -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

View File

@ -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);

View File

@ -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;
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();
}

View File

@ -21,22 +21,11 @@
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="HeaderFrame" name="headerFrame">
<zorder>buttonBox</zorder>
</widget>
<widget class="HeaderFrame" name="headerFrame"/>
</item>
<item>
<widget class="QFrame" name="frame">
@ -50,16 +39,7 @@
<item>
<widget class="QFrame" name="innerFrame">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -71,16 +51,7 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
@ -125,16 +96,7 @@
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>6</number>
</property>
<item>
@ -299,6 +261,25 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="generateCheckBox">
<property name="text">
<string>Generate mass data</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="generateSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
@ -307,6 +288,8 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>

View File

@ -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 ********************************/
/*********************** **** **** **** ***********************/

View File

@ -85,8 +85,6 @@ private slots:
void markMsgAsRead();
void markMsgAsUnread();
void generateMassData();
void shareKey();
private: