mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 07:59:35 -05:00
Add view history to WireDialog.
- record views as triggered. - Back and Forward buttons above the view.
This commit is contained in:
parent
dbd4f4f6c7
commit
c64fb331f7
@ -62,6 +62,7 @@ WireDialog::WireDialog(QWidget *parent)
|
||||
|
||||
mAddDialog = NULL;
|
||||
mGroupSelected = NULL;
|
||||
mHistoryIndex = -1;
|
||||
|
||||
connect( ui.toolButton_createAccount, SIGNAL(clicked()), this, SLOT(createGroup()));
|
||||
connect( ui.toolButton_createPulse, SIGNAL(clicked()), this, SLOT(createPulse()));
|
||||
@ -70,6 +71,11 @@ WireDialog::WireDialog(QWidget *parent)
|
||||
connect(ui.comboBox_groupSet, SIGNAL(currentIndexChanged(int)), this, SLOT(selectGroupSet(int)));
|
||||
connect(ui.comboBox_filterTime, SIGNAL(currentIndexChanged(int)), this, SLOT(selectFilterTime(int)));
|
||||
|
||||
connect( ui.toolButton_back, SIGNAL(clicked()), this, SLOT(back()));
|
||||
connect( ui.toolButton_forward, SIGNAL(clicked()), this, SLOT(forward()));
|
||||
ui.toolButton_back->setEnabled(false);
|
||||
ui.toolButton_forward->setEnabled(false);
|
||||
|
||||
QTimer *timer = new QTimer(this);
|
||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
||||
timer->start(1000);
|
||||
@ -310,7 +316,7 @@ void WireDialog::showSelectedGroups()
|
||||
grpIds.push_back(mGroupSelected->groupId());
|
||||
|
||||
// show GroupFocus.
|
||||
showGroupFocus(mGroupSelected->groupId());
|
||||
requestGroupFocus(mGroupSelected->groupId());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -355,7 +361,7 @@ void WireDialog::showGroups()
|
||||
}
|
||||
}
|
||||
|
||||
showGroupsPulses(allGroupIds);
|
||||
requestGroupsPulses(allGroupIds);
|
||||
}
|
||||
|
||||
|
||||
@ -543,7 +549,7 @@ void WireDialog::PVHviewGroup(const RsGxsGroupId &groupId)
|
||||
std::cerr << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
showGroupFocus(groupId);
|
||||
requestGroupFocus(groupId);
|
||||
}
|
||||
|
||||
void WireDialog::PVHviewPulse(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId)
|
||||
@ -554,7 +560,7 @@ void WireDialog::PVHviewPulse(const RsGxsGroupId &groupId, const RsGxsMessageId
|
||||
std::cerr << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
showPulseFocus(groupId, msgId);
|
||||
requestPulseFocus(groupId, msgId);
|
||||
}
|
||||
|
||||
void WireDialog::PVHviewReply(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId)
|
||||
@ -565,7 +571,7 @@ void WireDialog::PVHviewReply(const RsGxsGroupId &groupId, const RsGxsMessageId
|
||||
std::cerr << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
// showPulseFocus(groupId, msgId);
|
||||
// requestPulseFocus(groupId, msgId);
|
||||
}
|
||||
|
||||
void WireDialog::PVHfollow(const RsGxsGroupId &groupId)
|
||||
@ -647,6 +653,98 @@ void WireDialog::addTwitterView(PulseViewItem *item)
|
||||
boxlayout->addWidget(item);
|
||||
}
|
||||
|
||||
// HISTORY -------------------------------------------------------------------------------
|
||||
|
||||
void printWireViewHistory(const WireViewHistory &view)
|
||||
{
|
||||
std::cerr << "WireViewHistory(" << (int) view.viewType << "): ";
|
||||
switch(view.viewType) {
|
||||
case WireViewType::PULSE_FOCUS:
|
||||
std::cerr << " PULSE_FOCUS: grpId: " << view.groupId;
|
||||
std::cerr << " msgId: " << view.msgId;
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
case WireViewType::GROUP_FOCUS:
|
||||
std::cerr << " GROUP_FOCUS: grpId: " << view.groupId;
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
case WireViewType::GROUPS:
|
||||
std::cerr << " GROUPS_PULSES: grpIds: TBD";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void WireDialog::AddToHistory(const WireViewHistory &view)
|
||||
{
|
||||
std::cerr << "AddToHistory():";
|
||||
printWireViewHistory(view);
|
||||
|
||||
/* clear future history */
|
||||
mHistory.resize(mHistoryIndex + 1);
|
||||
|
||||
mHistory.push_back(view);
|
||||
mHistoryIndex = mHistory.size() - 1;
|
||||
|
||||
// at end of history.
|
||||
// enable back, disable forward.
|
||||
ui.toolButton_back->setEnabled(mHistoryIndex > 0);
|
||||
ui.toolButton_forward->setEnabled(false);
|
||||
}
|
||||
|
||||
void WireDialog::back()
|
||||
{
|
||||
LoadHistory(mHistoryIndex-1);
|
||||
}
|
||||
|
||||
void WireDialog::forward()
|
||||
{
|
||||
LoadHistory(mHistoryIndex+1);
|
||||
}
|
||||
|
||||
void WireDialog::LoadHistory(uint32_t index)
|
||||
{
|
||||
if (index >= mHistory.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHistoryIndex = index;
|
||||
WireViewHistory view = mHistory[index];
|
||||
|
||||
std::cerr << "LoadHistory:";
|
||||
printWireViewHistory(view);
|
||||
|
||||
switch(view.viewType) {
|
||||
case WireViewType::PULSE_FOCUS:
|
||||
showPulseFocus(view.groupId, view.msgId);
|
||||
break;
|
||||
case WireViewType::GROUP_FOCUS:
|
||||
showGroupFocus(view.groupId);
|
||||
break;
|
||||
case WireViewType::GROUPS:
|
||||
showGroupsPulses(view.groupIds);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ui.toolButton_back->setEnabled(index > 0);
|
||||
ui.toolButton_forward->setEnabled(index + 1 < mHistory.size());
|
||||
}
|
||||
// HISTORY -------------------------------------------------------------------------------
|
||||
|
||||
void WireDialog::requestPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId msgId)
|
||||
{
|
||||
WireViewHistory view;
|
||||
view.viewType = WireViewType::PULSE_FOCUS;
|
||||
view.groupId = groupId;
|
||||
view.msgId = msgId;
|
||||
|
||||
AddToHistory(view);
|
||||
showPulseFocus(groupId, msgId);
|
||||
}
|
||||
|
||||
void WireDialog::showPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId msgId)
|
||||
{
|
||||
@ -719,6 +817,16 @@ void WireDialog::postPulseFocus(RsWirePulseSPtr pPulse)
|
||||
}
|
||||
}
|
||||
|
||||
void WireDialog::requestGroupFocus(const RsGxsGroupId groupId)
|
||||
{
|
||||
WireViewHistory view;
|
||||
view.viewType = WireViewType::GROUP_FOCUS;
|
||||
view.groupId = groupId;
|
||||
|
||||
AddToHistory(view);
|
||||
showGroupFocus(groupId);
|
||||
}
|
||||
|
||||
void WireDialog::showGroupFocus(const RsGxsGroupId groupId)
|
||||
{
|
||||
clearTwitterView();
|
||||
@ -787,6 +895,16 @@ void WireDialog::postGroupFocus(RsWireGroupSPtr group, std::list<RsWirePulseSPtr
|
||||
}
|
||||
}
|
||||
|
||||
void WireDialog::requestGroupsPulses(const std::list<RsGxsGroupId> groupIds)
|
||||
{
|
||||
WireViewHistory view;
|
||||
view.viewType = WireViewType::GROUPS;
|
||||
view.groupIds = groupIds;
|
||||
|
||||
AddToHistory(view);
|
||||
showGroupsPulses(groupIds);
|
||||
}
|
||||
|
||||
void WireDialog::showGroupsPulses(const std::list<RsGxsGroupId> groupIds)
|
||||
{
|
||||
clearTwitterView();
|
||||
|
@ -40,6 +40,34 @@
|
||||
|
||||
#define IMAGE_WIRE ":/icons/wire.png"
|
||||
|
||||
//--------------------------- Classes for Wire View History
|
||||
enum class WireViewType
|
||||
{
|
||||
GROUPS,
|
||||
GROUP_FOCUS,
|
||||
PULSE_FOCUS,
|
||||
};
|
||||
|
||||
enum class WireViewTimeRange
|
||||
{
|
||||
FOREVER,
|
||||
LAST_DAY, // last 24 hours.
|
||||
LAST_WEEK, // actually last 7 days.
|
||||
LAST_MONTH // actually last 30 days.
|
||||
};
|
||||
|
||||
class WireViewHistory
|
||||
{
|
||||
public:
|
||||
WireViewType viewType;
|
||||
WireViewTimeRange viewTimeRange;
|
||||
|
||||
RsGxsGroupId groupId;
|
||||
RsGxsMessageId msgId;
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
};
|
||||
//---------------------------------------------------------
|
||||
|
||||
class WireDialog : public MainPage, public TokenResponse, public WireGroupHolder, public PulseViewHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -73,12 +101,19 @@ public:
|
||||
void clearTwitterView();
|
||||
void addTwitterView(PulseViewItem *item);
|
||||
|
||||
// TwitterView History
|
||||
void AddToHistory(const WireViewHistory &view);
|
||||
void LoadHistory(uint32_t index);
|
||||
|
||||
void requestPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId msgId);
|
||||
void showPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId msgId);
|
||||
void postPulseFocus(RsWirePulseSPtr pulse);
|
||||
|
||||
void requestGroupFocus(const RsGxsGroupId groupId);
|
||||
void showGroupFocus(const RsGxsGroupId groupId);
|
||||
void postGroupFocus(RsWireGroupSPtr group, std::list<RsWirePulseSPtr> pulses);
|
||||
|
||||
void requestGroupsPulses(const std::list<RsGxsGroupId> groupIds);
|
||||
void showGroupsPulses(const std::list<RsGxsGroupId> groupIds);
|
||||
void postGroupsPulses(std::list<RsWirePulseSPtr> pulses);
|
||||
|
||||
@ -91,6 +126,10 @@ private slots:
|
||||
void selectGroupSet(int index);
|
||||
void selectFilterTime(int index);
|
||||
|
||||
// history navigation.
|
||||
void back();
|
||||
void forward();
|
||||
|
||||
private:
|
||||
|
||||
bool setupPulseAddDialog();
|
||||
@ -122,6 +161,9 @@ private:
|
||||
std::map<RsGxsGroupId, RsWireGroup> mAllGroups;
|
||||
std::vector<RsWireGroup> mOwnGroups;
|
||||
|
||||
int32_t mHistoryIndex;
|
||||
std::vector<WireViewHistory> mHistory;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::WireDialog ui;
|
||||
|
||||
|
@ -248,6 +248,36 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_back">
|
||||
<property name="text">
|
||||
<string><</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_forward">
|
||||
<property name="text">
|
||||
<string>></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_viewMode">
|
||||
<property name="text">
|
||||
|
Loading…
Reference in New Issue
Block a user