Cleanup WireDialog

Cleanup WIreDialog UI, removing unused bits
Switch Groups to LHS and Add Simple Time Filter.
This commit is contained in:
drbob 2020-04-11 16:07:40 +10:00
parent 124781c1e0
commit 7d8323f3e2
3 changed files with 290 additions and 236 deletions

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
@ -60,10 +61,10 @@ WireDialog::WireDialog(QWidget *parent)
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()));
@ -401,8 +402,17 @@ 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() void WireDialog::showSelectedGroups()
{ {
ui.comboBox_filterTime->setEnabled(false);
if (mGroupSelected) if (mGroupSelected)
{ {
deletePulses(); deletePulses();
@ -419,6 +429,7 @@ void WireDialog::showSelectedGroups()
void WireDialog::showGroups() void WireDialog::showGroups()
{ {
ui.comboBox_filterTime->setEnabled(false);
deleteGroups(); deleteGroups();
deletePulses(); deletePulses();
@ -438,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) {
@ -545,6 +550,32 @@ 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);
filterTimestamp -= (1800);
break;
case 2: // Last 7 Days.
//filterTimestamp -= (3600 * 24 * 7);
filterTimestamp -= (3600);
break;
case 3: // Last 30 Days.
//filterTimestamp -= (3600 * 24 * 30);
filterTimestamp -= (4 * 3600);
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()";
@ -556,6 +587,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++)
{ {
@ -570,6 +609,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())
@ -630,6 +678,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;
@ -648,6 +697,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:
@ -84,6 +85,9 @@ private:
void showSelectedGroups(); 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,7 +92,193 @@
</layout> </layout>
</widget> </widget>
</item> </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"> <widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
@ -116,8 +291,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>434</width> <width>429</width>
<height>412</height> <height>435</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
@ -156,188 +331,12 @@
</widget> </widget>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </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> <resources>
<include location="TheWire_images.qrc"/> <include location="TheWire_images.qrc"/>
</resources> </resources>