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_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
@ -60,10 +61,10 @@ WireDialog::WireDialog(QWidget *parent)
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()));
@ -401,8 +402,17 @@ 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();
@ -419,6 +429,7 @@ void WireDialog::showSelectedGroups()
void WireDialog::showGroups()
{
ui.comboBox_filterTime->setEnabled(false);
deleteGroups();
deletePulses();
@ -438,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) {
@ -545,6 +550,32 @@ 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);
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)
{
std::cerr << "WireDialog::loadPulseData()";
@ -556,6 +587,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++)
{
@ -570,6 +609,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())
@ -630,6 +678,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;
@ -648,6 +697,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:
@ -84,6 +85,9 @@ private:
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,237 +92,247 @@
</layout>
</widget>
</item>
<item row="6" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
<item>
<widget class="QSplitter" name="splitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>100</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>434</width>
<height>412</height>
</rect>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_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>
<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>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<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>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
<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>
</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>
<widget class="QFrame" name="frame_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="leftMargin">
<number>0</number>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="topMargin">
<number>0</number>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</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">
<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="verticalSpacer_2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>116</height>
<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>
</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>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>429</width>
<height>435</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_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="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>