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/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h" #include "retroshare/rsgxsifacehelper.h"
#include "retroshare/rsgxscommon.h"
/* The Main Interface Class - for information about your Peers */ /* The Main Interface Class - for information about your Peers */
@ -38,6 +39,7 @@ struct RsWireGroup: RsGxsGenericGroupData
{ {
public: public:
std::string mDescription; std::string mDescription;
RsGxsImage mIcon;
}; };
@ -93,9 +95,10 @@ class RsWirePlace
#define WIRE_PULSE_TYPE_REPLY_MSG (0x0002) #define WIRE_PULSE_TYPE_REPLY_MSG (0x0002)
#define WIRE_PULSE_TYPE_REPLY_REFERENCE (0x0004) #define WIRE_PULSE_TYPE_REPLY_REFERENCE (0x0004)
#define WIRE_PULSE_TYPE_SENTIMENT_POSITIVE (0x0010) #define WIRE_PULSE_SENTIMENT_NO_SENTIMENT (0x0000)
#define WIRE_PULSE_TYPE_SENTIMENT_NEUTRAL (0x0020) #define WIRE_PULSE_SENTIMENT_POSITIVE (0x0001)
#define WIRE_PULSE_TYPE_SENTIMENT_NEGATIVE (0x0040) #define WIRE_PULSE_SENTIMENT_NEUTRAL (0x0002)
#define WIRE_PULSE_SENTIMENT_NEGATIVE (0x0003)
class RsWirePulse class RsWirePulse
{ {
@ -107,6 +110,7 @@ class RsWirePulse
std::string mPulseText; std::string mPulseText;
uint32_t mPulseType; 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) // These Ref to the related (parent or reply) if reply (MODE_REPLY_MSG set)
// Mode REPLY_MSG only REPLY_REFERENCE // 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() void RsGxsWireGroupItem::clear()
{ {
group.mDescription.clear(); group.mDescription.clear();
group.mIcon.clear();
} }
void RsGxsWireGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) void RsGxsWireGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{ {
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR,group.mDescription,"group.mDescription") ; RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR,group.mDescription,"group.mDescription") ;
group.mIcon.serial_process(j, ctx);
} }
void RsGxsWirePulseItem::clear() void RsGxsWirePulseItem::clear()
{ {
pulse.mPulseText.clear(); pulse.mPulseText.clear();
pulse.mPulseType = 0; pulse.mPulseType = 0;
pulse.mReplySentiment = 0;
pulse.mRefGroupId.clear(); pulse.mRefGroupId.clear();
pulse.mRefGroupName.clear(); pulse.mRefGroupName.clear();
pulse.mRefOrigMsgId.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_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.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,pulse.mRefGroupId,"pulse.mRefGroupId") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME,pulse.mRefGroupName,"pulse.mRefGroupName") ; RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME,pulse.mRefGroupName,"pulse.mRefGroupName") ;
RsTypeSerializer::serial_process(j,ctx,pulse.mRefOrigMsgId,"pulse.mRefOrigMsgId") ; RsTypeSerializer::serial_process(j,ctx,pulse.mRefOrigMsgId,"pulse.mRefOrigMsgId") ;

View file

@ -24,6 +24,7 @@
#include "PulseAddDialog.h" #include "PulseAddDialog.h"
const uint32_t PULSE_MAX_SIZE = 1000; // 1k char.
/** Constructor */ /** Constructor */
PulseAddDialog::PulseAddDialog(QWidget *parent) 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_Post, SIGNAL( clicked( void ) ), this, SLOT( postPulse( void ) ) );
connect(ui.pushButton_AddURL, SIGNAL( clicked( void ) ), this, SLOT( addURL( 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.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) 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) void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName)
{ {
mIsReply = true; mIsReply = true;
mReplyToPulse = pulse; mReplyToPulse = pulse;
mReplyGroupName = groupName; mReplyGroupName = groupName;
ui.frame_reply->setVisible(true);
{ {
std::map<rstime_t, RsWirePulse *> replies; std::map<rstime_t, RsWirePulse *> replies;
@ -75,12 +125,10 @@ void PulseAddDialog::addURL()
return; return;
} }
void PulseAddDialog::clearDisplayAs()
void PulseAddDialog::addTo()
{ {
std::cerr << "PulseAddDialog::addTo()"; std::cerr << "PulseAddDialog::clearDisplayAs()";
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
@ -96,7 +144,6 @@ void PulseAddDialog::cancelPulse()
return; return;
} }
void PulseAddDialog::postPulse() void PulseAddDialog::postPulse()
{ {
std::cerr << "PulseAddDialog::postPulse()"; std::cerr << "PulseAddDialog::postPulse()";
@ -126,6 +173,7 @@ void PulseAddDialog::postOriginalPulse()
pulse.mMeta.mOrigMsgId.clear(); pulse.mMeta.mOrigMsgId.clear();
pulse.mPulseType = WIRE_PULSE_TYPE_ORIGINAL_MSG; pulse.mPulseType = WIRE_PULSE_TYPE_ORIGINAL_MSG;
pulse.mReplySentiment = WIRE_PULSE_SENTIMENT_NO_SENTIMENT;
pulse.mPulseText = ui.textEdit_Pulse->toPlainText().toStdString(); pulse.mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
// all mRefs should empty. // all mRefs should empty.
@ -136,6 +184,27 @@ void PulseAddDialog::postOriginalPulse()
hide(); 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() void PulseAddDialog::postReplyPulse()
{ {
@ -151,6 +220,7 @@ void PulseAddDialog::postReplyPulse()
pulse.mMeta.mOrigMsgId.clear(); pulse.mMeta.mOrigMsgId.clear();
pulse.mPulseType = WIRE_PULSE_TYPE_REPLY_MSG; pulse.mPulseType = WIRE_PULSE_TYPE_REPLY_MSG;
pulse.mReplySentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex());
pulse.mPulseText = ui.textEdit_Pulse->toPlainText().toStdString(); pulse.mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
// mRefs refer to parent post. // mRefs refer to parent post.
@ -185,6 +255,8 @@ void PulseAddDialog::postRefPulse(RsWirePulse &pulse)
refPulse.mMeta.mOrigMsgId.clear(); refPulse.mMeta.mOrigMsgId.clear();
refPulse.mPulseType = WIRE_PULSE_TYPE_REPLY_REFERENCE; 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. // Dont put parent PulseText into refPulse - it is available on Thread Msg.
// otherwise gives impression it is correctly setup Parent / Reply... // otherwise gives impression it is correctly setup Parent / Reply...
// when in fact the parent PublishTS, and AuthorId are wrong. // when in fact the parent PublishTS, and AuthorId are wrong.

View file

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

View file

@ -13,9 +13,67 @@
<property name="windowTitle"> <property name="windowTitle">
<string/> <string/>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QVBoxLayout" name="verticalLayout">
<item row="0" column="1" colspan="3"> <item>
<widget class="QFrame" name="frame_2"> <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>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<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>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Post From:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_groupName">
<property name="text">
<string>GroupLabel</string>
</property>
</widget>
</item>
<item>
<widget class="GxsIdLabel" name="label_idName">
<property name="text">
<string>IDLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_reply">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
</property> </property>
@ -24,50 +82,74 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <widget class="QWidget" name="widget_replyto" native="true"/>
<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>
<item> <item>
<widget class="QWidget" name="widget_replyto" native="true"/> <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>0</height>
</size>
</property>
<item>
<property name="text">
<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>
<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>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="3"> <item>
<widget class="QFrame" name="frame_3"> <widget class="QFrame" name="frame_3">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
@ -79,220 +161,80 @@
<item> <item>
<widget class="QTextEdit" name="textEdit_Pulse"/> <widget class="QTextEdit" name="textEdit_Pulse"/>
</item> </item>
</layout> <item>
</widget> <widget class="QFrame" name="frame_URL">
</item> <layout class="QGridLayout" name="gridLayout">
<item row="2" column="1" colspan="3"> <item row="0" column="0">
<widget class="QGroupBox" name="groupBox"> <widget class="QLabel" name="label_3">
<property name="title"> <property name="text">
<string>URL Adder</string> <string>URL</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="maximumSize">
<size>
<width>160</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_4">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Post From:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_groupName">
<property name="text">
<string>GroupLabel</string>
</property>
</widget>
</item>
<item>
<widget class="GxsIdLabel" name="label_idName">
<property name="text">
<string>IDLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QScrollArea" name="scrollArea_3">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>150</width>
<height>423</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButton_AddTo">
<property name="text">
<string>Add to Pulse</string>
</property>
</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> </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">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>70</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget> </widget>
</widget> </item>
</item> <item row="0" column="1">
</layout> <widget class="QLineEdit" name="lineEdit_URL"/>
</widget> </item>
</widget> <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> </widget>
</item> </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> </layout>
</widget> </widget>
<customwidgets> <customwidgets>

View file

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

View file

@ -40,9 +40,10 @@
#define GROUP_SET_ALL (0) #define GROUP_SET_ALL (0)
#define GROUP_SET_OWN (1) #define GROUP_SET_OWN (1)
#define GROUP_SET_SUBSCRIBED (2) #define GROUP_SET_SUBSCRIBED (2)
#define GROUP_SET_AUTO (3) #define GROUP_SET_OTHERS (3)
#define GROUP_SET_RECOMMENDED (4) // Future Extensions.
#define GROUP_SET_OTHERS (5) // #define GROUP_SET_AUTO (4)
// #define GROUP_SET_RECOMMENDED (5)
#define WIRE_TOKEN_TYPE_SUBSCRIBE_CHANGE 1 #define WIRE_TOKEN_TYPE_SUBSCRIBE_CHANGE 1
@ -56,13 +57,14 @@ WireDialog::WireDialog(QWidget *parent)
mAddDialog = NULL; mAddDialog = NULL;
mPulseSelected = NULL; mPulseSelected = NULL;
mGroupSelected = NULL;
connect( ui.toolButton_createAccount, SIGNAL(clicked()), this, SLOT(createGroup())); connect( ui.toolButton_createAccount, SIGNAL(clicked()), this, SLOT(createGroup()));
connect( ui.toolButton_createPulse, SIGNAL(clicked()), this, SLOT(createPulse())); 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.toolButton_refresh, SIGNAL(clicked()), this, SLOT(refreshGroups()));
connect(ui.comboBox_groupSet, SIGNAL(currentIndexChanged(int)), this, SLOT(selectGroupSet(int))); 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); QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
@ -136,6 +138,7 @@ void WireDialog::reply(RsWirePulse &pulse, std::string &groupName)
// publishing group. // publishing group.
RsWireGroup group = mOwnGroups[idx]; RsWireGroup group = mOwnGroups[idx];
mAddDialog->cleanup();
mAddDialog->setGroup(group); mAddDialog->setGroup(group);
// establish replyTo. // establish replyTo.
@ -177,15 +180,31 @@ void WireDialog::notifyGroupSelection(WireGroupItem *item)
std::cerr << "WireDialog::notifyGroupSelection() from : " << item; std::cerr << "WireDialog::notifyGroupSelection() from : " << item;
std::cerr << std::endl; std::cerr << std::endl;
bool doSelection = true;
if (mGroupSelected) if (mGroupSelected)
{ {
std::cerr << "WireDialog::notifyGroupSelection() unselecting old one : " << mGroupSelected; std::cerr << "WireDialog::notifyGroupSelection() unselecting old one : " << mGroupSelected;
std::cerr << std::endl; std::cerr << std::endl;
mGroupSelected->setSelected(false); 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;
}
} }
mGroupSelected = item; if (doSelection)
{
item->setSelected(true);
mGroupSelected = item;
}
/* update display */
showSelectedGroups();
} }
@ -229,6 +248,7 @@ void WireDialog::createPulse()
RsWireGroup group = mOwnGroups[idx]; RsWireGroup group = mOwnGroups[idx];
mAddDialog->cleanup();
mAddDialog->setGroup(group); mAddDialog->setGroup(group);
mAddDialog->show(); mAddDialog->show();
} }
@ -320,6 +340,8 @@ void WireDialog::deleteGroups()
std::cerr << "WireDialog::deleteGroups()"; std::cerr << "WireDialog::deleteGroups()";
std::cerr << std::endl; std::cerr << std::endl;
mGroupSelected = NULL;
QLayout *alayout = ui.scrollAreaWidgetContents_groups->layout(); QLayout *alayout = ui.scrollAreaWidgetContents_groups->layout();
QLayoutItem *item; QLayoutItem *item;
int i = 0; int i = 0;
@ -380,11 +402,39 @@ void WireDialog::selectGroupSet(int index)
showGroups(); 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() void WireDialog::showGroups()
{ {
ui.comboBox_filterTime->setEnabled(false);
deleteGroups(); deleteGroups();
deletePulses(); deletePulses();
/* depends on the comboBox */ /* depends on the comboBox */
std::map<RsGxsGroupId, RsWireGroup>::const_iterator it; std::map<RsGxsGroupId, RsWireGroup>::const_iterator it;
for (it = mAllGroups.begin(); it != mAllGroups.end(); it++) for (it = mAllGroups.begin(); it != mAllGroups.end(); it++)
@ -399,12 +449,6 @@ void WireDialog::showGroups()
if (mGroupSet == GROUP_SET_SUBSCRIBED) { if (mGroupSet == GROUP_SET_SUBSCRIBED) {
add = true; add = true;
} }
if (mGroupSet == GROUP_SET_AUTO) {
add = true;
}
if (mGroupSet == GROUP_SET_RECOMMENDED) {
add = true;
}
} }
else { else {
if (mGroupSet == GROUP_SET_OTHERS) { if (mGroupSet == GROUP_SET_OTHERS) {
@ -506,6 +550,29 @@ public:
std::map<rstime_t, RsWirePulse *> replies; // publish -> replies. 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) bool WireDialog::loadPulseData(const uint32_t &token)
{ {
std::cerr << "WireDialog::loadPulseData()"; std::cerr << "WireDialog::loadPulseData()";
@ -517,6 +584,14 @@ bool WireDialog::loadPulseData(const uint32_t &token)
std::list<RsWirePulse *> references; std::list<RsWirePulse *> references;
std::map<RsGxsMessageId, PulseReplySet> pulseGrouping; 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(); std::vector<RsWirePulse>::iterator vit = pulses.begin();
for(; vit != pulses.end(); vit++) for(; vit != pulses.end(); vit++)
{ {
@ -531,6 +606,15 @@ bool WireDialog::loadPulseData(const uint32_t &token)
} }
else 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; RsGxsGroupId &gid = pulse.mMeta.mGroupId;
std::map<RsGxsGroupId, RsWireGroup>::iterator git = mAllGroups.find(gid); std::map<RsGxsGroupId, RsWireGroup>::iterator git = mAllGroups.find(gid);
if (git != mAllGroups.end()) if (git != mAllGroups.end())
@ -591,6 +675,7 @@ bool WireDialog::loadPulseData(const uint32_t &token)
std::map<RsGxsMessageId, PulseReplySet>::iterator pgit; std::map<RsGxsMessageId, PulseReplySet>::iterator pgit;
for(pgit = pulseGrouping.begin(); pgit != pulseGrouping.end(); pgit++) for(pgit = pulseGrouping.begin(); pgit != pulseGrouping.end(); pgit++)
{ {
PulseOrderedReply &msg = pulseOrdering[pgit->second.msg->mMeta.mPublishTs] = PulseOrderedReply &msg = pulseOrdering[pgit->second.msg->mMeta.mPublishTs] =
PulseOrderedReply(pgit->second.msg, pgit->second.group); PulseOrderedReply(pgit->second.msg, pgit->second.group);
std::map<RsGxsMessageId, RsWirePulse *>::iterator rmit; 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); addPulse(poit->second.msg, poit->second.group, poit->second.replies);
} }
// allow filterTime to be changed again
ui.comboBox_filterTime->setEnabled(true);
return true; return true;
} }

View file

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

View file

@ -19,13 +19,13 @@
<property name="windowTitle"> <property name="windowTitle">
<string/> <string/>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_5">
<item row="0" column="0" colspan="2"> <item>
<widget class="QFrame" name="frame_2"> <widget class="QFrame" name="frame_toolbar">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>1</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="frameShape"> <property name="frameShape">
@ -49,20 +49,6 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<widget class="QToolButton" name="toolButton_5"> <widget class="QToolButton" name="toolButton_5">
<property name="text"> <property name="text">
@ -95,6 +81,9 @@
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButton_Settings"> <widget class="QToolButton" name="toolButton_Settings">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Settings</string> <string>Settings</string>
</property> </property>
@ -103,237 +92,247 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item>
<widget class="QScrollArea" name="scrollArea"> <widget class="QSplitter" name="splitter">
<property name="widgetResizable"> <property name="sizePolicy">
<bool>true</bool> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>100</verstretch>
</sizepolicy>
</property> </property>
<property name="alignment"> <property name="orientation">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> <enum>Qt::Horizontal</enum>
</property> </property>
<widget class="QWidget" name="scrollAreaWidgetContents"> <widget class="QFrame" name="frame">
<property name="geometry"> <property name="sizePolicy">
<rect> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<x>0</x> <horstretch>1</horstretch>
<y>0</y> <verstretch>0</verstretch>
<width>434</width> </sizepolicy>
<height>412</height>
</rect>
</property> </property>
<property name="styleSheet"> <property name="minimumSize">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string> <size>
<width>250</width>
<height>0</height>
</size>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <property name="maximumSize">
<property name="spacing"> <size>
<number>0</number> <width>400</width>
</property> <height>16777215</height>
<property name="leftMargin"> </size>
<number>0</number> </property>
</property> <property name="frameShape">
<property name="topMargin"> <enum>QFrame::StyledPanel</enum>
<number>0</number> </property>
</property> <property name="frameShadow">
<property name="rightMargin"> <enum>QFrame::Raised</enum>
<number>0</number> </property>
</property> <layout class="QVBoxLayout" name="verticalLayout">
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<spacer name="verticalSpacer"> <widget class="QComboBox" name="comboBox_groupSet">
<property name="orientation"> <item>
<enum>Qt::Vertical</enum> <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> </property>
<property name="sizeHint" stdset="0"> <widget class="QWidget" name="scrollAreaWidgetContents_groups">
<size> <property name="geometry">
<width>20</width> <rect>
<height>40</height> <x>0</x>
</size> <y>0</y>
</property> <width>231</width>
</spacer> <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> </item>
</layout> </layout>
</widget> </widget>
</widget> <widget class="QFrame" name="frame_2">
</item> <property name="sizePolicy">
<item row="1" column="0" rowspan="5"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<layout class="QGridLayout" name="gridLayout"> <horstretch>3</horstretch>
<item row="0" column="3" colspan="2"> <verstretch>0</verstretch>
<widget class="QDateTimeEdit" name="dateTimeEdit"/> </sizepolicy>
</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>
<property name="leftMargin"> <property name="frameShape">
<number>0</number> <enum>QFrame::StyledPanel</enum>
</property> </property>
<property name="topMargin"> <property name="frameShadow">
<number>0</number> <enum>QFrame::Raised</enum>
</property> </property>
<property name="rightMargin"> <layout class="QVBoxLayout" name="verticalLayout_3">
<number>0</number> <item>
</property> <widget class="QWidget" name="widget_range" native="true">
<property name="bottomMargin"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<number>0</number> <property name="spacing">
</property> <number>0</number>
<item> </property>
<widget class="QScrollArea" name="scrollArea_2"> <property name="leftMargin">
<property name="widgetResizable"> <number>0</number>
<bool>true</bool> </property>
</property> <property name="topMargin">
<widget class="QWidget" name="scrollAreaWidgetContents_groups"> <number>0</number>
<property name="geometry"> </property>
<rect> <property name="rightMargin">
<x>0</x> <number>0</number>
<y>0</y> </property>
<width>262</width> <property name="bottomMargin">
<height>416</height> <number>0</number>
</rect> </property>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>40</width>
<height>116</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </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> </layout>
</widget> </widget>
</widget> </item>
</item> <item>
</layout> <widget class="QScrollArea" name="scrollArea">
</widget> <property name="widgetResizable">
</item> <bool>true</bool>
<item row="3" column="1"> </property>
<widget class="QComboBox" name="comboBox_groupSet"> <property name="alignment">
<item> <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
<property name="text"> </property>
<string>All</string> <widget class="QWidget" name="scrollAreaWidgetContents">
</property> <property name="geometry">
</item> <rect>
<item> <x>0</x>
<property name="text"> <y>0</y>
<string>Yourself</string> <width>429</width>
</property> <height>435</height>
</item> </rect>
<item> </property>
<property name="text"> <property name="styleSheet">
<string>Subscribed</string> <string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property> </property>
</item> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <property name="spacing">
<property name="text"> <number>0</number>
<string>Auto</string> </property>
</property> <property name="leftMargin">
</item> <number>0</number>
<item> </property>
<property name="text"> <property name="topMargin">
<string>Recommended</string> <number>0</number>
</property> </property>
</item> <property name="rightMargin">
<item> <number>0</number>
<property name="text"> </property>
<string>Others</string> <property name="bottomMargin">
</property> <number>0</number>
</item> </property>
</widget> <item>
</item> <spacer name="verticalSpacer">
<item row="2" column="1"> <property name="orientation">
<widget class="QPushButton" name="pushButton_Post"> <enum>Qt::Vertical</enum>
<property name="text"> </property>
<string>Post Pulse to Wire</string> <property name="sizeHint" stdset="0">
</property> <size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>

View file

@ -39,6 +39,11 @@ WireGroupItem::WireGroupItem(WireGroupHolder *holder, const RsWireGroup &grp)
} }
RsGxsGroupId &WireGroupItem::groupId()
{
return mGroup.mMeta.mGroupId;
}
void WireGroupItem::setup() void WireGroupItem::setup()
{ {
label_groupName->setText(QString::fromStdString(mGroup.mMeta.mGroupName)); 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() bool WireGroupItem::isSelected()
@ -102,20 +127,14 @@ bool WireGroupItem::isSelected()
void WireGroupItem::mousePressEvent(QMouseEvent *event) 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(); QPoint pos = event->pos();
std::cerr << "WireGroupItem::mousePressEvent(" << pos.x() << ", " << pos.y() << ")"; std::cerr << "WireGroupItem::mousePressEvent(" << pos.x() << ", " << pos.y() << ")";
std::cerr << std::endl; std::cerr << std::endl;
setSelected(true); // notify of selection.
// Holder will setSelected() flag.
QWidget::mousePressEvent(event); mHolder->notifyGroupSelection(this);
} }
const QPixmap *WireGroupItem::getPixmap() const QPixmap *WireGroupItem::getPixmap()

View file

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