diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.cpp b/retroshare-gui/src/gui/TheWire/WireDialog.cpp index 35f6f20b9..4c15ca801 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireDialog.cpp @@ -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 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 references; std::map pulseGrouping; + // setup time filtering. + uint32_t filterTimestamp; + bool filterTime = (ui.comboBox_filterTime->currentIndex() > 0); + if (filterTime) + { + filterTimestamp = getFilterTimestamp(); + } + std::vector::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::iterator git = mAllGroups.find(gid); if (git != mAllGroups.end()) @@ -630,6 +678,7 @@ bool WireDialog::loadPulseData(const uint32_t &token) std::map::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::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; } diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.h b/retroshare-gui/src/gui/TheWire/WireDialog.h index b64ea6a21..904c09ade 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.h +++ b/retroshare-gui/src/gui/TheWire/WireDialog.h @@ -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 &groups); + // utils. + rstime_t getFilterTimestamp(); + // Loading Data. void requestGroupData(); bool loadGroupData(const uint32_t &token); diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.ui b/retroshare-gui/src/gui/TheWire/WireDialog.ui index 84f76e5b1..0c0ab6f75 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.ui +++ b/retroshare-gui/src/gui/TheWire/WireDialog.ui @@ -19,13 +19,13 @@ - - - + + + 0 - 0 + 1 @@ -49,20 +49,6 @@ - - - - ... - - - - - - - ... - - - @@ -95,6 +81,9 @@ + + false + Settings @@ -103,237 +92,247 @@ - - - - true + + + + + 0 + 100 + - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + Qt::Horizontal - - - - 0 - 0 - 434 - 412 - + + + + 1 + 0 + - - QWidget#scrollAreaWidgetContents{border: none;} + + + 250 + 0 + - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - + + + 400 + 16777215 + + + + QFrame::StyledPanel + + + QFrame::Raised + + - - - Qt::Vertical + + + + All + + + + + Yourself + + + + + Subscribed + + + + + Others + + + + + + + + true - - - 20 - 40 - - - + + + + 0 + 0 + 231 + 435 + + + + + + + Qt::Vertical + + + + 20 + 116 + + + + + + + - - - - - - - - - - - Search/Filter - - - - - - - Network Wide - - - - - - - - All - - - - - Last Month - - - - - Last Week - - - - - Today - - - - - New - - - - - - - - - from - - - - - until - - - - - - - - TimeRange - - - - - - - - - - - - - 400 - 16777215 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 + + + + 3 + 0 + - - 0 + + QFrame::StyledPanel - - 0 + + QFrame::Raised - - 0 - - - 0 - - - - - true - - - - - 0 - 0 - 262 - 416 - - - + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + - + - Qt::Vertical + Qt::Horizontal - 20 - 116 + 40 + 20 + + + + + 0 + 0 + + + + Show Posts from + + + + + + + + 0 + 0 + + + + + All Time + + + + + Last 24 hours + + + + + Last 7 days + + + + + Last 30 days + + + + - - - - - - - - - - All - - - - - Yourself - - - - - Subscribed - - - - - Auto - - - - - Recommended - - - - - Others - - - - - - - - Post Pulse to Wire - + + + + + true + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + 0 + 0 + 429 + 435 + + + + QWidget#scrollAreaWidgetContents{border: none;} + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + +