Merge pull request #1852 from drbob/theWire-ui-improvements

Improvements for TheWire UI
This commit is contained in:
csoler 2020-04-11 13:25:10 +02:00 committed by GitHub
commit eb14a5ed4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 662 additions and 511 deletions

View File

@ -28,6 +28,7 @@
#include "retroshare/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h"
#include "retroshare/rsgxscommon.h"
/* The Main Interface Class - for information about your Peers */
@ -38,6 +39,7 @@ struct RsWireGroup: RsGxsGenericGroupData
{
public:
std::string mDescription;
RsGxsImage mIcon;
};
@ -93,9 +95,10 @@ class RsWirePlace
#define WIRE_PULSE_TYPE_REPLY_MSG (0x0002)
#define WIRE_PULSE_TYPE_REPLY_REFERENCE (0x0004)
#define WIRE_PULSE_TYPE_SENTIMENT_POSITIVE (0x0010)
#define WIRE_PULSE_TYPE_SENTIMENT_NEUTRAL (0x0020)
#define WIRE_PULSE_TYPE_SENTIMENT_NEGATIVE (0x0040)
#define WIRE_PULSE_SENTIMENT_NO_SENTIMENT (0x0000)
#define WIRE_PULSE_SENTIMENT_POSITIVE (0x0001)
#define WIRE_PULSE_SENTIMENT_NEUTRAL (0x0002)
#define WIRE_PULSE_SENTIMENT_NEGATIVE (0x0003)
class RsWirePulse
{
@ -107,6 +110,7 @@ class RsWirePulse
std::string mPulseText;
uint32_t mPulseType;
uint32_t mReplySentiment; // only relevant if a reply.
// These Ref to the related (parent or reply) if reply (MODE_REPLY_MSG set)
// Mode REPLY_MSG only REPLY_REFERENCE

View File

@ -44,17 +44,20 @@ RsItem *RsGxsWireSerialiser::create_item(uint16_t service,uint8_t item_subtype)
void RsGxsWireGroupItem::clear()
{
group.mDescription.clear();
group.mIcon.clear();
}
void RsGxsWireGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR,group.mDescription,"group.mDescription") ;
group.mIcon.serial_process(j, ctx);
}
void RsGxsWirePulseItem::clear()
{
pulse.mPulseText.clear();
pulse.mPulseType = 0;
pulse.mReplySentiment = 0;
pulse.mRefGroupId.clear();
pulse.mRefGroupName.clear();
pulse.mRefOrigMsgId.clear();
@ -66,6 +69,7 @@ void RsGxsWirePulseItem::serial_process(RsGenericSerializer::SerializeJob j,RsGe
{
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,pulse.mPulseText,"pulse.mPulseText") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mPulseType,"pulse.mPulseType") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mReplySentiment,"pulse.mReplySentiment") ;
RsTypeSerializer::serial_process(j,ctx,pulse.mRefGroupId,"pulse.mRefGroupId") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME,pulse.mRefGroupName,"pulse.mRefGroupName") ;
RsTypeSerializer::serial_process(j,ctx,pulse.mRefOrigMsgId,"pulse.mRefOrigMsgId") ;

View File

@ -24,6 +24,7 @@
#include "PulseAddDialog.h"
const uint32_t PULSE_MAX_SIZE = 1000; // 1k char.
/** Constructor */
PulseAddDialog::PulseAddDialog(QWidget *parent)
@ -35,8 +36,9 @@ PulseAddDialog::PulseAddDialog(QWidget *parent)
connect(ui.pushButton_Post, SIGNAL( clicked( void ) ), this, SLOT( postPulse( void ) ) );
connect(ui.pushButton_AddURL, SIGNAL( clicked( void ) ), this, SLOT( addURL( void ) ) );
connect(ui.pushButton_AddTo, SIGNAL( clicked( void ) ), this, SLOT( addTo( void ) ) );
connect(ui.pushButton_ClearDisplayAs, SIGNAL( clicked( void ) ), this, SLOT( clearDisplayAs( void ) ) );
connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelPulse( void ) ) );
connect(ui.textEdit_Pulse, SIGNAL( textChanged( void ) ), this, SLOT( pulseTextChanged( void ) ) );
}
void PulseAddDialog::setGroup(RsWireGroup &group)
@ -47,11 +49,59 @@ void PulseAddDialog::setGroup(RsWireGroup &group)
}
void PulseAddDialog::cleanup()
{
if (mIsReply)
{
std::cerr << "PulseAddDialog::setReplyTo() cleaning up old replyto";
std::cerr << std::endl;
QLayout *layout = ui.widget_replyto->layout();
// completely delete layout and sublayouts
QLayoutItem * item;
QWidget * widget;
while ((item = layout->takeAt(0)))
{
if ((widget = item->widget()) != 0)
{
std::cerr << "PulseAddDialog::setReplyTo() removing widget";
std::cerr << std::endl;
widget->hide();
delete widget;
}
else
{
std::cerr << "PulseAddDialog::setReplyTo() removing item";
std::cerr << std::endl;
delete item;
}
}
// then finally
delete layout;
mIsReply = false;
}
ui.frame_reply->setVisible(false);
ui.comboBox_sentiment->setCurrentIndex(0);
ui.lineEdit_URL->setText("");
ui.lineEdit_DisplayAs->setText("");
ui.textEdit_Pulse->setPlainText("");
ui.pushButton_Post->setEnabled(false);
// disable URL until functionality finished.
ui.frame_URL->setEnabled(false);
}
void PulseAddDialog::pulseTextChanged()
{
std::string pulseText = ui.textEdit_Pulse->toPlainText().toStdString();
bool enable = (pulseText.size() > 0) && (pulseText.size() < PULSE_MAX_SIZE);
ui.pushButton_Post->setEnabled(enable);
}
void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName)
{
mIsReply = true;
mReplyToPulse = pulse;
mReplyGroupName = groupName;
ui.frame_reply->setVisible(true);
{
std::map<rstime_t, RsWirePulse *> replies;
@ -75,12 +125,10 @@ void PulseAddDialog::addURL()
return;
}
void PulseAddDialog::addTo()
void PulseAddDialog::clearDisplayAs()
{
std::cerr << "PulseAddDialog::addTo()";
std::cerr << "PulseAddDialog::clearDisplayAs()";
std::cerr << std::endl;
return;
}
@ -96,7 +144,6 @@ void PulseAddDialog::cancelPulse()
return;
}
void PulseAddDialog::postPulse()
{
std::cerr << "PulseAddDialog::postPulse()";
@ -126,6 +173,7 @@ void PulseAddDialog::postOriginalPulse()
pulse.mMeta.mOrigMsgId.clear();
pulse.mPulseType = WIRE_PULSE_TYPE_ORIGINAL_MSG;
pulse.mReplySentiment = WIRE_PULSE_SENTIMENT_NO_SENTIMENT;
pulse.mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
// all mRefs should empty.
@ -136,6 +184,27 @@ void PulseAddDialog::postOriginalPulse()
hide();
}
uint32_t PulseAddDialog::toPulseSentiment(int index)
{
switch(index)
{
case 1:
return WIRE_PULSE_SENTIMENT_POSITIVE;
break;
case 2:
return WIRE_PULSE_SENTIMENT_NEUTRAL;
break;
case 3:
return WIRE_PULSE_SENTIMENT_NEGATIVE;
break;
case -1:
case 0:
default:
return WIRE_PULSE_SENTIMENT_NO_SENTIMENT;
break;
}
return 0;
}
void PulseAddDialog::postReplyPulse()
{
@ -151,6 +220,7 @@ void PulseAddDialog::postReplyPulse()
pulse.mMeta.mOrigMsgId.clear();
pulse.mPulseType = WIRE_PULSE_TYPE_REPLY_MSG;
pulse.mReplySentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex());
pulse.mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
// mRefs refer to parent post.
@ -185,6 +255,8 @@ void PulseAddDialog::postRefPulse(RsWirePulse &pulse)
refPulse.mMeta.mOrigMsgId.clear();
refPulse.mPulseType = WIRE_PULSE_TYPE_REPLY_REFERENCE;
refPulse.mReplySentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex());
// Dont put parent PulseText into refPulse - it is available on Thread Msg.
// otherwise gives impression it is correctly setup Parent / Reply...
// when in fact the parent PublishTS, and AuthorId are wrong.

View File

@ -33,15 +33,17 @@ class PulseAddDialog : public QWidget, public TokenResponse
public:
PulseAddDialog(QWidget *parent = 0);
void cleanup();
void setGroup(RsWireGroup &group);
void setReplyTo(RsWirePulse &pulse, std::string &groupName);
private slots:
void addURL();
void addTo();
void clearDisplayAs();
void postPulse();
void cancelPulse();
void clearDialog();
void pulseTextChanged();
private:
void postOriginalPulse();
@ -51,6 +53,7 @@ private:
void acknowledgeMessage(const uint32_t &token);
void loadPulseData(const uint32_t &token);
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
uint32_t toPulseSentiment(int index);
protected:

View File

@ -13,160 +13,18 @@
<property name="windowTitle">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1" colspan="3">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>In Reply to:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Positive / Neutral / Negative</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>238</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_replyto" native="true"/>
</item>
</layout>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QFrame" name="frame_3">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QTextEdit" name="textEdit_Pulse"/>
</item>
</layout>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>URL Adder</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>331</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_AddURL">
<property name="text">
<string>Add to Pulse</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Display As</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="lineEdit_2"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>URL</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="lineEdit"/>
</item>
</layout>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pushButton_Cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>298</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="pushButton_Post">
<property name="text">
<string>Post Pulse to Wire</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="4">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>160</width>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
@ -176,9 +34,15 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
@ -207,92 +71,170 @@
</item>
</layout>
</widget>
<widget class="QScrollArea" name="scrollArea_3">
<property name="widgetResizable">
<bool>true</bool>
</item>
<item>
<widget class="QFrame" name="frame_reply">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QWidget" name="widget_replyto" native="true"/>
</item>
<item>
<widget class="QWidget" name="widget_sentiment" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Response Sentiment: </string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_sentiment">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>423</height>
</rect>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButton_AddTo">
<property name="text">
<string>Add to Pulse</string>
<string>No Sentiment</string>
</property>
</item>
<item>
<property name="text">
<string>Positive</string>
</property>
</item>
<item>
<property name="text">
<string>Neutral</string>
</property>
</item>
<item>
<property name="text">
<string>Negative</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_3">
<property name="text">
<string>filter</string>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<height>341</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="checkBox_5">
<property name="text">
<string>Account 1</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_6">
<property name="text">
<string>Account 2</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_7">
<property name="text">
<string>Account 3</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>70</height>
<width>238</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_3">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QTextEdit" name="textEdit_Pulse"/>
</item>
<item>
<widget class="QFrame" name="frame_URL">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>URL</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_URL"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_AddURL">
<property name="text">
<string>Add to Pulse</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Display As</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_DisplayAs"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_ClearDisplayAs">
<property name="text">
<string>Clear Display As</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pushButton_Cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>298</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_Post">
<property name="text">
<string>Post Pulse to Wire</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>

View File

@ -92,6 +92,10 @@ void PulseDetails::setup()
label_replies->setText("");
frame_replies->setVisible(false);
mHasReplies = false;
toolButton_follow->setEnabled(false); // TODO
toolButton_rate->setEnabled(false); // TODO
toolButton_reply->setEnabled(mActions != NULL);
}
void PulseDetails::addReplies(std::map<rstime_t, RsWirePulse *> replies)
@ -183,18 +187,28 @@ QString PulseDetails::getSummary()
void PulseDetails::follow()
{
// follow group.
if (mActions)
{
mActions->follow(mPulse.mMeta.mGroupId);
}
}
void PulseDetails::rate()
{
// rate author
if (mActions)
{
mActions->rate(mPulse.mMeta.mAuthorId);
}
}
void PulseDetails::reply()
{
// reply
if (mActions)
{
mActions->reply(mPulse, mGroupName);
}
}

View File

@ -40,9 +40,10 @@
#define GROUP_SET_ALL (0)
#define GROUP_SET_OWN (1)
#define GROUP_SET_SUBSCRIBED (2)
#define GROUP_SET_AUTO (3)
#define GROUP_SET_RECOMMENDED (4)
#define GROUP_SET_OTHERS (5)
#define GROUP_SET_OTHERS (3)
// Future Extensions.
// #define GROUP_SET_AUTO (4)
// #define GROUP_SET_RECOMMENDED (5)
#define WIRE_TOKEN_TYPE_SUBSCRIBE_CHANGE 1
@ -56,13 +57,14 @@ WireDialog::WireDialog(QWidget *parent)
mAddDialog = NULL;
mPulseSelected = NULL;
mGroupSelected = NULL;
connect( ui.toolButton_createAccount, SIGNAL(clicked()), this, SLOT(createGroup()));
connect( ui.toolButton_createPulse, SIGNAL(clicked()), this, SLOT(createPulse()));
connect( ui.pushButton_Post, SIGNAL(clicked()), this, SLOT(createPulse()));
connect( ui.toolButton_refresh, SIGNAL(clicked()), this, SLOT(refreshGroups()));
connect(ui.comboBox_groupSet, SIGNAL(currentIndexChanged(int)), this, SLOT(selectGroupSet(int)));
connect(ui.comboBox_filterTime, SIGNAL(currentIndexChanged(int)), this, SLOT(selectFilterTime(int)));
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
@ -136,6 +138,7 @@ void WireDialog::reply(RsWirePulse &pulse, std::string &groupName)
// publishing group.
RsWireGroup group = mOwnGroups[idx];
mAddDialog->cleanup();
mAddDialog->setGroup(group);
// establish replyTo.
@ -177,17 +180,33 @@ void WireDialog::notifyGroupSelection(WireGroupItem *item)
std::cerr << "WireDialog::notifyGroupSelection() from : " << item;
std::cerr << std::endl;
bool doSelection = true;
if (mGroupSelected)
{
std::cerr << "WireDialog::notifyGroupSelection() unselecting old one : " << mGroupSelected;
std::cerr << std::endl;
mGroupSelected->setSelected(false);
if (mGroupSelected == item)
{
std::cerr << "WireDialog::notifyGroupSelection() current -> unselect";
std::cerr << std::endl;
/* de-selection of current item */
mGroupSelected = NULL;
doSelection = false;
}
}
if (doSelection)
{
item->setSelected(true);
mGroupSelected = item;
}
/* update display */
showSelectedGroups();
}
void WireDialog::checkUpdate()
{
@ -229,6 +248,7 @@ void WireDialog::createPulse()
RsWireGroup group = mOwnGroups[idx];
mAddDialog->cleanup();
mAddDialog->setGroup(group);
mAddDialog->show();
}
@ -320,6 +340,8 @@ void WireDialog::deleteGroups()
std::cerr << "WireDialog::deleteGroups()";
std::cerr << std::endl;
mGroupSelected = NULL;
QLayout *alayout = ui.scrollAreaWidgetContents_groups->layout();
QLayoutItem *item;
int i = 0;
@ -380,11 +402,39 @@ void WireDialog::selectGroupSet(int index)
showGroups();
}
void WireDialog::selectFilterTime(int index)
{
std::cerr << "WireDialog::selectFilterTime(" << index << ")";
std::cerr << std::endl;
showSelectedGroups();
}
void WireDialog::showSelectedGroups()
{
ui.comboBox_filterTime->setEnabled(false);
if (mGroupSelected)
{
deletePulses();
// request data.
std::list<RsGxsGroupId> grpIds;
grpIds.push_back(mGroupSelected->groupId());
requestPulseData(grpIds);
}
else
{
showGroups();
}
}
void WireDialog::showGroups()
{
ui.comboBox_filterTime->setEnabled(false);
deleteGroups();
deletePulses();
/* depends on the comboBox */
std::map<RsGxsGroupId, RsWireGroup>::const_iterator it;
for (it = mAllGroups.begin(); it != mAllGroups.end(); it++)
@ -399,12 +449,6 @@ void WireDialog::showGroups()
if (mGroupSet == GROUP_SET_SUBSCRIBED) {
add = true;
}
if (mGroupSet == GROUP_SET_AUTO) {
add = true;
}
if (mGroupSet == GROUP_SET_RECOMMENDED) {
add = true;
}
}
else {
if (mGroupSet == GROUP_SET_OTHERS) {
@ -506,6 +550,29 @@ public:
std::map<rstime_t, RsWirePulse *> replies; // publish -> replies.
};
rstime_t WireDialog::getFilterTimestamp()
{
rstime_t filterTimestamp = time(NULL);
switch(ui.comboBox_filterTime->currentIndex())
{
case 1: // Last 24 Hours.
filterTimestamp -= (3600 * 24);
break;
case 2: // Last 7 Days.
filterTimestamp -= (3600 * 24 * 7);
break;
case 3: // Last 30 Days.
filterTimestamp -= (3600 * 24 * 30);
break;
case 0: // All Time.
case -1: // no index.
default:
filterTimestamp = 0; // back to Epoch! effectively all.
break;
}
return filterTimestamp;
}
bool WireDialog::loadPulseData(const uint32_t &token)
{
std::cerr << "WireDialog::loadPulseData()";
@ -517,6 +584,14 @@ bool WireDialog::loadPulseData(const uint32_t &token)
std::list<RsWirePulse *> references;
std::map<RsGxsMessageId, PulseReplySet> pulseGrouping;
// setup time filtering.
uint32_t filterTimestamp;
bool filterTime = (ui.comboBox_filterTime->currentIndex() > 0);
if (filterTime)
{
filterTimestamp = getFilterTimestamp();
}
std::vector<RsWirePulse>::iterator vit = pulses.begin();
for(; vit != pulses.end(); vit++)
{
@ -531,6 +606,15 @@ bool WireDialog::loadPulseData(const uint32_t &token)
}
else
{
// Filter timestamp now. (as soon as possible).
if (filterTime && (pulse.mMeta.mPublishTs < filterTimestamp))
{
std::cerr << "WireDialog::loadPulseData() SKipping OLD MSG: GroupId: " << pulse.mMeta.mGroupId;
std::cerr << " PulseId: " << pulse.mMeta.mMsgId;
std::cerr << std::endl;
continue;
}
RsGxsGroupId &gid = pulse.mMeta.mGroupId;
std::map<RsGxsGroupId, RsWireGroup>::iterator git = mAllGroups.find(gid);
if (git != mAllGroups.end())
@ -591,6 +675,7 @@ bool WireDialog::loadPulseData(const uint32_t &token)
std::map<RsGxsMessageId, PulseReplySet>::iterator pgit;
for(pgit = pulseGrouping.begin(); pgit != pulseGrouping.end(); pgit++)
{
PulseOrderedReply &msg = pulseOrdering[pgit->second.msg->mMeta.mPublishTs] =
PulseOrderedReply(pgit->second.msg, pgit->second.group);
std::map<RsGxsMessageId, RsWirePulse *>::iterator rmit;
@ -609,6 +694,8 @@ bool WireDialog::loadPulseData(const uint32_t &token)
addPulse(poit->second.msg, poit->second.group, poit->second.replies);
}
// allow filterTime to be changed again
ui.comboBox_filterTime->setEnabled(true);
return true;
}

View File

@ -68,6 +68,7 @@ private slots:
void checkUpdate();
void refreshGroups();
void selectGroupSet(int index);
void selectFilterTime(int index);
private:
@ -81,8 +82,12 @@ private:
void deletePulses();
void deleteGroups();
void showGroups();
void showSelectedGroups();
void updateGroups(std::vector<RsWireGroup> &groups);
// utils.
rstime_t getFilterTimestamp();
// Loading Data.
void requestGroupData();
bool loadGroupData(const uint32_t &token);

View File

@ -19,13 +19,13 @@
<property name="windowTitle">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QFrame" name="frame_2">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QFrame" name="frame_toolbar">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
@ -49,20 +49,6 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_3">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_4">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_5">
<property name="text">
@ -95,6 +81,9 @@
</item>
<item>
<widget class="QToolButton" name="toolButton_Settings">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Settings</string>
</property>
@ -103,7 +92,193 @@
</layout>
</widget>
</item>
<item row="6" column="0">
<item>
<widget class="QSplitter" name="splitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>100</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QComboBox" name="comboBox_groupSet">
<item>
<property name="text">
<string>All</string>
</property>
</item>
<item>
<property name="text">
<string>Yourself</string>
</property>
</item>
<item>
<property name="text">
<string>Subscribed</string>
</property>
</item>
<item>
<property name="text">
<string>Others</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea_2">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_groups">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>231</width>
<height>435</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>116</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QFrame" name="frame_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QWidget" name="widget_range" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<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">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Show Posts from </string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_filterTime">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string> All Time</string>
</property>
</item>
<item>
<property name="text">
<string>Last 24 hours</string>
</property>
</item>
<item>
<property name="text">
<string>Last 7 days</string>
</property>
</item>
<item>
<property name="text">
<string>Last 30 days</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
@ -116,8 +291,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>434</width>
<height>412</height>
<width>429</width>
<height>435</height>
</rect>
</property>
<property name="styleSheet">
@ -156,188 +331,12 @@
</widget>
</widget>
</item>
<item row="1" column="0" rowspan="5">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="3" colspan="2">
<widget class="QDateTimeEdit" name="dateTimeEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Search/Filter</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QCheckBox" name="checkBox_9">
<property name="text">
<string>Network Wide</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>All</string>
</property>
</item>
<item>
<property name="text">
<string>Last Month</string>
</property>
</item>
<item>
<property name="text">
<string>Last Week</string>
</property>
</item>
<item>
<property name="text">
<string>Today</string>
</property>
</item>
<item>
<property name="text">
<string>New</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="comboBox_2">
<item>
<property name="text">
<string>from</string>
</property>
</item>
<item>
<property name="text">
<string>until</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>TimeRange</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QLineEdit" name="lineEdit"/>
</item>
</layout>
</item>
<item row="5" column="1" rowspan="2">
<widget class="QFrame" name="frame">
<property name="maximumSize">
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<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">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_2">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_groups">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>262</width>
<height>416</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>116</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboBox_groupSet">
<item>
<property name="text">
<string>All</string>
</property>
</item>
<item>
<property name="text">
<string>Yourself</string>
</property>
</item>
<item>
<property name="text">
<string>Subscribed</string>
</property>
</item>
<item>
<property name="text">
<string>Auto</string>
</property>
</item>
<item>
<property name="text">
<string>Recommended</string>
</property>
</item>
<item>
<property name="text">
<string>Others</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_Post">
<property name="text">
<string>Post Pulse to Wire</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="TheWire_images.qrc"/>
</resources>

View File

@ -39,6 +39,11 @@ WireGroupItem::WireGroupItem(WireGroupHolder *holder, const RsWireGroup &grp)
}
RsGxsGroupId &WireGroupItem::groupId()
{
return mGroup.mMeta.mGroupId;
}
void WireGroupItem::setup()
{
label_groupName->setText(QString::fromStdString(mGroup.mMeta.mGroupName));
@ -91,8 +96,28 @@ void WireGroupItem::removeItem()
{
}
void WireGroupItem::setSelected(bool /* on */)
void WireGroupItem::setSelected(bool on)
{
mSelected = on;
// set color too
if (mSelected)
{
setBackground("red");
}
else
{
setBackground("gray");
}
}
void WireGroupItem::setBackground(QString color)
{
QWidget *tocolor = this;
QPalette p = tocolor->palette();
p.setColor(tocolor->backgroundRole(), QColor(color));
tocolor->setPalette(p);
tocolor->setAutoFillBackground(true);
}
bool WireGroupItem::isSelected()
@ -102,20 +127,14 @@ bool WireGroupItem::isSelected()
void WireGroupItem::mousePressEvent(QMouseEvent *event)
{
/* We can be very cunning here?
* grab out position.
* flag ourselves as selected.
* then pass the mousePressEvent up for handling by the parent
*/
QPoint pos = event->pos();
std::cerr << "WireGroupItem::mousePressEvent(" << pos.x() << ", " << pos.y() << ")";
std::cerr << std::endl;
setSelected(true);
QWidget::mousePressEvent(event);
// notify of selection.
// Holder will setSelected() flag.
mHolder->notifyGroupSelection(this);
}
const QPixmap *WireGroupItem::getPixmap()

View File

@ -50,6 +50,7 @@ public:
bool isSelected();
const QPixmap *getPixmap();
RsGxsGroupId &groupId();
private slots:
void show();
@ -61,6 +62,7 @@ protected:
private:
void setup();
void setGroupSet();
void setBackground(QString color);
WireGroupHolder *mHolder;
RsWireGroup mGroup;