mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Remove old Pulse display
Remove PulseItem / PulseDetails classes Switch all Message retrieval away from TokenQueues Remove Original PulseItem View
This commit is contained in:
parent
8c869f0bbf
commit
3f9acd7ef8
@ -21,7 +21,7 @@
|
||||
#include <iostream>
|
||||
#include <QtGui>
|
||||
|
||||
#include "PulseDetails.h"
|
||||
#include "PulseReply.h"
|
||||
|
||||
#include "PulseAddDialog.h"
|
||||
|
||||
@ -128,7 +128,8 @@ void PulseAddDialog::pulseTextChanged()
|
||||
}
|
||||
|
||||
// Old Interface, deprecate / make internal.
|
||||
void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName, uint32_t replyType)
|
||||
// TODO: Convert mReplyToPulse to be an SPtr, and remove &pulse parameter.
|
||||
void PulseAddDialog::setReplyTo(RsWirePulse &pulse, RsWirePulseSPtr pPulse, std::string &groupName, uint32_t replyType)
|
||||
{
|
||||
mIsReply = true;
|
||||
mReplyToPulse = pulse;
|
||||
@ -136,11 +137,11 @@ void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName, uint
|
||||
ui.frame_reply->setVisible(true);
|
||||
|
||||
{
|
||||
std::map<rstime_t, RsWirePulse *> replies;
|
||||
PulseDetails *details = new PulseDetails(NULL, &pulse, groupName, replies);
|
||||
PulseReply *reply = new PulseReply(NULL, pPulse);
|
||||
|
||||
// add extra widget into layout.
|
||||
QVBoxLayout *vbox = new QVBoxLayout();
|
||||
vbox->addWidget(details);
|
||||
vbox->addWidget(reply);
|
||||
vbox->setSpacing(1);
|
||||
vbox->setContentsMargins(0,0,0,0);
|
||||
ui.widget_replyto->setLayout(vbox);
|
||||
@ -186,7 +187,13 @@ void PulseAddDialog::setReplyTo(const RsGxsGroupId &grpId, const RsGxsMessageId
|
||||
return;
|
||||
}
|
||||
|
||||
setReplyTo(*pPulse, pGroup->mMeta.mGroupName, replyType);
|
||||
// update GroupPtr
|
||||
// TODO - this should be handled in libretroshare if possible.
|
||||
if (pPulse->mGroupPtr == NULL) {
|
||||
pPulse->mGroupPtr = pGroup;
|
||||
}
|
||||
|
||||
setReplyTo(*pPulse, pPulse, pGroup->mMeta.mGroupName, replyType);
|
||||
}
|
||||
|
||||
void PulseAddDialog::addURL()
|
||||
|
@ -56,7 +56,7 @@ private slots:
|
||||
private:
|
||||
// OLD VERSIONs, private now.
|
||||
void setGroup(RsWireGroup &group);
|
||||
void setReplyTo(RsWirePulse &pulse, std::string &groupName, uint32_t replyType);
|
||||
void setReplyTo(RsWirePulse &pulse, RsWirePulseSPtr pPulse, std::string &groupName, uint32_t replyType);
|
||||
|
||||
void postOriginalPulse();
|
||||
void postReplyPulse();
|
||||
|
@ -1,226 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* gui/TheWire/PulseDetails.cpp *
|
||||
* *
|
||||
* Copyright (c) 2020 Robert Fernie <retroshare.project@gmail.com> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
#include <QMouseEvent>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "PulseDetails.h"
|
||||
|
||||
#include "util/DateTime.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
/** Constructor */
|
||||
PulseDetails::PulseDetails(PulseHolder *actions, RsWirePulse *pulse, std::string &groupName,
|
||||
std::map<rstime_t, RsWirePulse *> replies)
|
||||
:QWidget(NULL), mActions(actions), mPulse(*pulse), mGroupName(groupName)
|
||||
{
|
||||
setupUi(this);
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
setup();
|
||||
addReplies(replies);
|
||||
}
|
||||
|
||||
PulseDetails::PulseDetails(PulseHolder *actions,
|
||||
RsGxsGroupId &parentGroupId,
|
||||
std::string &parentGroupName,
|
||||
RsGxsMessageId &parentOrigMsgId,
|
||||
RsGxsId &parentAuthorId,
|
||||
rstime_t &parentPublishTs,
|
||||
std::string &parentPulseText)
|
||||
:QWidget(NULL), mActions(actions), mPulse(), mGroupName(parentGroupName)
|
||||
{
|
||||
setupUi(this);
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
// reuse Meta data structure.
|
||||
mPulse.mMeta.mGroupId = parentGroupId;
|
||||
mPulse.mMeta.mOrigMsgId = parentOrigMsgId;
|
||||
mPulse.mMeta.mMsgId = parentOrigMsgId; // add in, for completeness.
|
||||
mPulse.mMeta.mAuthorId = parentAuthorId;
|
||||
mPulse.mMeta.mPublishTs = parentPublishTs;
|
||||
mPulse.mPulseText = parentPulseText;
|
||||
setup();
|
||||
}
|
||||
|
||||
void PulseDetails::setBackground(QString color)
|
||||
{
|
||||
QWidget *tocolor = this;
|
||||
QPalette p = tocolor->palette();
|
||||
p.setColor(tocolor->backgroundRole(), QColor(color));
|
||||
tocolor->setPalette(p);
|
||||
tocolor->setAutoFillBackground(true);
|
||||
}
|
||||
|
||||
void PulseDetails::setup()
|
||||
{
|
||||
connect(toolButton_expand, SIGNAL(clicked()), this, SLOT(toggle()));
|
||||
|
||||
connect(toolButton_follow, SIGNAL(clicked()), this, SLOT(follow()));
|
||||
connect(toolButton_rate, SIGNAL(clicked()), this, SLOT(rate()));
|
||||
connect(toolButton_reply, SIGNAL(clicked()), this, SLOT(reply()));
|
||||
|
||||
label_wireName->setText(QString::fromStdString(mGroupName));
|
||||
label_idName->setId(mPulse.mMeta.mAuthorId);
|
||||
|
||||
label_date->setText(DateTime::formatDateTime(mPulse.mMeta.mPublishTs));
|
||||
label_summary->setText(getSummary());
|
||||
|
||||
// label_icon->setText();
|
||||
textBrowser->setPlainText(QString::fromStdString(mPulse.mPulseText));
|
||||
frame_expand->setVisible(false);
|
||||
|
||||
label_replies->setText("");
|
||||
frame_replies->setVisible(false);
|
||||
mHasReplies = false;
|
||||
|
||||
// TMP toolButton_follow->setEnabled(false); // TODO
|
||||
toolButton_rate->setEnabled(false); // TODO
|
||||
toolButton_reply->setEnabled(mActions != NULL);
|
||||
}
|
||||
|
||||
void PulseDetails::addReplies(std::map<rstime_t, RsWirePulse *> replies)
|
||||
{
|
||||
if (replies.size() == 0)
|
||||
{
|
||||
// do nothing.
|
||||
return;
|
||||
}
|
||||
else if (replies.size() == 1)
|
||||
{
|
||||
label_replies->setText("1 reply");
|
||||
}
|
||||
else if (replies.size() > 1)
|
||||
{
|
||||
label_replies->setText(QString("%1 replies").arg(replies.size()));
|
||||
}
|
||||
|
||||
// add extra widgets into layout.
|
||||
QLayout *vbox = frame_replies->layout();
|
||||
mHasReplies = true;
|
||||
|
||||
std::map<rstime_t, RsWirePulse *> emptyReplies;
|
||||
std::map<rstime_t, RsWirePulse *>::reverse_iterator it;
|
||||
for (it = replies.rbegin(); it != replies.rend(); it++)
|
||||
{
|
||||
// add Ref as child reply.
|
||||
PulseDetails *pd = new PulseDetails(mActions,
|
||||
it->second->mRefGroupId,
|
||||
it->second->mRefGroupName,
|
||||
it->second->mRefOrigMsgId,
|
||||
it->second->mRefAuthorId,
|
||||
it->second->mRefPublishTs,
|
||||
it->second->mRefPulseText);
|
||||
pd->setBackground("goldenrod");
|
||||
vbox->addWidget(pd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PulseDetails::toggle()
|
||||
{
|
||||
if (frame_expand->isVisible()) {
|
||||
// switch to minimal view.
|
||||
label_summary->setVisible(true);
|
||||
frame_expand->setVisible(false);
|
||||
frame_replies->setVisible(false);
|
||||
} else {
|
||||
// switch to expanded view.
|
||||
label_summary->setVisible(false);
|
||||
frame_expand->setVisible(true);
|
||||
if (mHasReplies) {
|
||||
frame_replies->setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const int SUMMARY_MAX_LEN = 50;
|
||||
QString PulseDetails::getSummary()
|
||||
{
|
||||
std::string summary = mPulse.mPulseText;
|
||||
std::cerr << "PulseDetails::getSummary() orig: " << summary;
|
||||
std::cerr << std::endl;
|
||||
int len = summary.size();
|
||||
bool in_whitespace = false;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (isspace(summary[i])) {
|
||||
if (in_whitespace) {
|
||||
// trim
|
||||
summary.erase(i, 1);
|
||||
// rollback index / len.
|
||||
--i;
|
||||
--len;
|
||||
} else {
|
||||
// replace whitespace with space.
|
||||
summary[i] = ' ';
|
||||
in_whitespace = true;
|
||||
}
|
||||
} else {
|
||||
in_whitespace = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (SUMMARY_MAX_LEN < len)
|
||||
{
|
||||
summary = summary.substr(0,SUMMARY_MAX_LEN-3);
|
||||
summary += "...";
|
||||
}
|
||||
|
||||
std::cerr << "PulseDetails::getSummary() summary: " << summary;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return QString::fromStdString(summary);
|
||||
}
|
||||
|
||||
void PulseDetails::follow()
|
||||
{
|
||||
// follow group.
|
||||
if (mActions)
|
||||
{
|
||||
// tmp hack for developing.
|
||||
mActions->focus(mPulse.mMeta.mGroupId, mPulse.mMeta.mOrigMsgId);
|
||||
|
||||
//mActions->follow(mPulse.mMeta.mGroupId);
|
||||
}
|
||||
}
|
||||
|
||||
void PulseDetails::rate()
|
||||
{
|
||||
// rate author
|
||||
if (mActions)
|
||||
{
|
||||
mActions->rate(mPulse.mMeta.mAuthorId);
|
||||
}
|
||||
}
|
||||
|
||||
void PulseDetails::reply()
|
||||
{
|
||||
// reply
|
||||
if (mActions)
|
||||
{
|
||||
mActions->reply(mPulse, mGroupName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,66 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* gui/TheWire/PulseDetails.h *
|
||||
* *
|
||||
* Copyright (c) 2020 Robert Fernie <retroshare.project@gmail.com> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef MRK_PULSE_DETAILS_H
|
||||
#define MRK_PULSE_DETAILS_H
|
||||
|
||||
#include "ui_PulseDetails.h"
|
||||
#include "PulseItem.h"
|
||||
|
||||
#include <retroshare/rswire.h>
|
||||
|
||||
class PulseDetails : public QWidget, private Ui::PulseDetails
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PulseDetails(PulseHolder *actions, RsWirePulse *pulse, std::string &groupName,
|
||||
std::map<rstime_t, RsWirePulse *> replies);
|
||||
|
||||
// when Reply parent....
|
||||
PulseDetails(PulseHolder *actions,
|
||||
RsGxsGroupId &parentGroupId,
|
||||
std::string &parentGroupName,
|
||||
RsGxsMessageId &parentOrigMsgId,
|
||||
RsGxsId &parentAuthorId,
|
||||
rstime_t &parentPublishTs,
|
||||
std::string &parentPulseText);
|
||||
|
||||
void setup();
|
||||
|
||||
void setBackground(QString color);
|
||||
|
||||
private slots:
|
||||
void toggle();
|
||||
void follow();
|
||||
void rate();
|
||||
void reply();
|
||||
|
||||
private:
|
||||
void addReplies(std::map<rstime_t, RsWirePulse *> replies);
|
||||
QString getSummary();
|
||||
|
||||
PulseHolder *mActions;
|
||||
RsWirePulse mPulse;
|
||||
std::string mGroupName;
|
||||
bool mHasReplies;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,243 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PulseDetails</class>
|
||||
<widget class="QWidget" name="PulseDetails">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>807</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_expand">
|
||||
<property name="text">
|
||||
<string>\/</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wireName">
|
||||
<property name="text">
|
||||
<string>WireGroupName</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>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_replies">
|
||||
<property name="text">
|
||||
<string># replies</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_summary">
|
||||
<property name="text">
|
||||
<string>Summary Text</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_date">
|
||||
<property name="text">
|
||||
<string>DateTime 02/02/20</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame_expand">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_follow">
|
||||
<property name="text">
|
||||
<string>follow</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_reply">
|
||||
<property name="text">
|
||||
<string>reply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_rate">
|
||||
<property name="text">
|
||||
<string>rate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="GxsIdLabel" name="label_idName">
|
||||
<property name="text">
|
||||
<string>idLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_icon">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Image</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame_replies">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</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_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Replies</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>GxsIdLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>gui/gxs/GxsIdLabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,157 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* gui/TheWire/PulseItem.cpp *
|
||||
* *
|
||||
* Copyright (c) 2012-2020 Robert Fernie <retroshare.project@gmail.com> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
#include <QMouseEvent>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "PulseItem.h"
|
||||
|
||||
#include "PulseDetails.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
/****
|
||||
* #define DEBUG_ITEM 1
|
||||
****/
|
||||
|
||||
/** Constructor */
|
||||
|
||||
PulseItem::PulseItem(PulseHolder *holder, std::string path)
|
||||
:QWidget(NULL), mHolder(holder), mType(0)
|
||||
{
|
||||
setupUi(this);
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
}
|
||||
|
||||
PulseItem::PulseItem(PulseHolder *holder, RsWirePulse *pulse_ptr, RsWireGroup *group_ptr, std::map<rstime_t, RsWirePulse *> replies)
|
||||
:QWidget(NULL), mHolder(holder), mPulse(*pulse_ptr), mType(0)
|
||||
{
|
||||
setupUi(this);
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
QWidget *pulse_widget = widget_parent; // default msg goes into widget_parent.
|
||||
|
||||
/* if it is a reply */
|
||||
if (mPulse.mPulseType & WIRE_PULSE_TYPE_RESPONSE) {
|
||||
|
||||
std::cerr << "Installing Reply Msg";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "GroupID: " << mPulse.mRefGroupId;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "GroupName: " << mPulse.mRefGroupName;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "OrigMsgId: " << mPulse.mRefOrigMsgId;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "AuthorId: " << mPulse.mRefAuthorId;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "PublishTs: " << mPulse.mRefPublishTs;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "PulseText: " << mPulse.mRefPulseText;
|
||||
std::cerr << std::endl;
|
||||
|
||||
// fill in the parent.
|
||||
PulseDetails *parent = new PulseDetails(
|
||||
mHolder,
|
||||
mPulse.mRefGroupId,
|
||||
mPulse.mRefGroupName,
|
||||
mPulse.mRefOrigMsgId,
|
||||
mPulse.mRefAuthorId,
|
||||
mPulse.mRefPublishTs,
|
||||
mPulse.mRefPulseText);
|
||||
|
||||
parent->setBackground("sienna");
|
||||
|
||||
// add extra widget into layout.
|
||||
QVBoxLayout *vbox = new QVBoxLayout();
|
||||
vbox->addWidget(parent);
|
||||
vbox->setContentsMargins(0,0,0,0);
|
||||
widget_parent->setLayout(vbox);
|
||||
|
||||
// if its a reply, the real msg goes into reply slot.
|
||||
pulse_widget = widget_reply;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ORIGINAL PULSE.
|
||||
// hide widget_reply, as it will be empty.
|
||||
widget_reply->setVisible(false);
|
||||
}
|
||||
|
||||
{
|
||||
std::cerr << "Adding Main Message";
|
||||
std::cerr << std::endl;
|
||||
PulseDetails *details = new PulseDetails(mHolder, &mPulse, group_ptr->mMeta.mGroupName, replies);
|
||||
|
||||
// add extra widget into layout.
|
||||
QVBoxLayout *vbox = new QVBoxLayout();
|
||||
vbox->addWidget(details);
|
||||
vbox->setSpacing(1);
|
||||
vbox->setContentsMargins(0,0,0,0);
|
||||
pulse_widget->setLayout(vbox);
|
||||
pulse_widget->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
rstime_t PulseItem::publishTs()
|
||||
{
|
||||
return mPulse.mMeta.mPublishTs;
|
||||
}
|
||||
|
||||
void PulseItem::removeItem()
|
||||
{
|
||||
}
|
||||
|
||||
void PulseItem::setSelected(bool on)
|
||||
{
|
||||
}
|
||||
|
||||
bool PulseItem::isSelected()
|
||||
{
|
||||
return mSelected;
|
||||
}
|
||||
|
||||
void PulseItem::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();
|
||||
|
||||
std::cerr << "PulseItem::mousePressEvent(" << pos.x() << ", " << pos.y() << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
setSelected(true);
|
||||
|
||||
QWidget::mousePressEvent(event);
|
||||
|
||||
mHolder->notifyPulseSelection(this);
|
||||
}
|
||||
|
||||
const QPixmap *PulseItem::getPixmap()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1,72 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* gui/TheWire/PulseItem.h *
|
||||
* *
|
||||
* Copyright (c) 2012-2020 Robert Fernie <retroshare.project@gmail.com> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef MRK_PULSE_ITEM_H
|
||||
#define MRK_PULSE_ITEM_H
|
||||
|
||||
#include "ui_PulseItem.h"
|
||||
|
||||
#include <retroshare/rswire.h>
|
||||
|
||||
class PulseItem;
|
||||
|
||||
class PulseHolder
|
||||
{
|
||||
public:
|
||||
virtual ~PulseHolder() {}
|
||||
virtual void deletePulseItem(PulseItem *, uint32_t ptype) = 0;
|
||||
virtual void notifyPulseSelection(PulseItem *item) = 0;
|
||||
|
||||
// Actions.
|
||||
virtual void focus(RsGxsGroupId &groupId, RsGxsMessageId &msgId) = 0;
|
||||
virtual void follow(RsGxsGroupId &groupId) = 0;
|
||||
virtual void rate(RsGxsId &authorId) = 0;
|
||||
virtual void reply(RsWirePulse &pulse, std::string &groupName) = 0;
|
||||
};
|
||||
|
||||
|
||||
class PulseItem : public QWidget, private Ui::PulseItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PulseItem(PulseHolder *holder, std::string url);
|
||||
PulseItem(PulseHolder *holder, RsWirePulse *pulse_ptr, RsWireGroup *group_ptr, std::map<rstime_t, RsWirePulse *> replies);
|
||||
|
||||
rstime_t publishTs();
|
||||
void removeItem();
|
||||
|
||||
void setSelected(bool on);
|
||||
bool isSelected();
|
||||
|
||||
const QPixmap *getPixmap();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
|
||||
PulseHolder *mHolder;
|
||||
RsWirePulse mPulse;
|
||||
uint32_t mType;
|
||||
bool mSelected;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,192 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PulseItem</class>
|
||||
<widget class="QWidget" name="PulseItem">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>802</width>
|
||||
<height>322</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QFrame#frame{border: 2px solid #CCCCCC;
|
||||
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #EEEEEE, stop: 1 #CCCCCC);
|
||||
border-radius: 10px}</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QFrame" name="widget_parent">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>20</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="widget_reply">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>20</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="TheWire_images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* gui/TheWire/PulseItem.cpp *
|
||||
* gui/TheWire/PulseTopLevel.cpp *
|
||||
* *
|
||||
* Copyright (c) 2020-2020 Robert Fernie <retroshare.project@gmail.com> *
|
||||
* *
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef MRK_PULSE_VIEW_ITEM_H
|
||||
#define MRK_PULSE_VIEW_ITEM_H
|
||||
|
||||
#include "ui_PulseItem.h"
|
||||
#include <QWidget>
|
||||
|
||||
#include <retroshare/rswire.h>
|
||||
|
||||
|
@ -61,7 +61,6 @@ WireDialog::WireDialog(QWidget *parent)
|
||||
ui.setupUi(this);
|
||||
|
||||
mAddDialog = NULL;
|
||||
mPulseSelected = NULL;
|
||||
mGroupSelected = NULL;
|
||||
|
||||
connect( ui.toolButton_createAccount, SIGNAL(clicked()), this, SLOT(createGroup()));
|
||||
@ -96,42 +95,6 @@ void WireDialog::addGroup(QWidget *item)
|
||||
alayout->addWidget(item);
|
||||
}
|
||||
|
||||
// PulseHolder interface.
|
||||
void WireDialog::deletePulseItem(PulseItem * /* item */, uint32_t /* type */)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Actions from PulseHolder.
|
||||
void WireDialog::focus(RsGxsGroupId &groupId, RsGxsMessageId &msgId)
|
||||
{
|
||||
std::cerr << "WireDialog::focus(";
|
||||
std::cerr << groupId.toStdString() << ",";
|
||||
std::cerr << msgId.toStdString();
|
||||
std::cerr << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
showPulseFocus(groupId, msgId);
|
||||
}
|
||||
|
||||
|
||||
void WireDialog::follow(RsGxsGroupId &groupId)
|
||||
{
|
||||
std::cerr << "WireDialog::follow(";
|
||||
std::cerr << groupId.toStdString();
|
||||
std::cerr << ")";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
void WireDialog::rate(RsGxsId &authorId)
|
||||
{
|
||||
std::cerr << "WireDialog::rate(";
|
||||
std::cerr << authorId.toStdString();
|
||||
std::cerr << ")";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
bool WireDialog::setupPulseAddDialog()
|
||||
{
|
||||
std::cerr << "WireDialog::setupPulseAddDialog()";
|
||||
@ -161,37 +124,6 @@ bool WireDialog::setupPulseAddDialog()
|
||||
return true;
|
||||
}
|
||||
|
||||
void WireDialog::reply(RsWirePulse &pulse, std::string &groupName)
|
||||
{
|
||||
std::cerr << "WireDialog::reply(";
|
||||
std::cerr << pulse.mMeta.mGroupId.toStdString();
|
||||
std::cerr << ", MsgId:";
|
||||
std::cerr << pulse.mMeta.mMsgId.toStdString();
|
||||
std::cerr << ", OrigMsgId:";
|
||||
std::cerr << pulse.mMeta.mOrigMsgId.toStdString();
|
||||
std::cerr << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (setupPulseAddDialog())
|
||||
{
|
||||
mAddDialog->setReplyTo(pulse.mMeta.mGroupId, pulse.mMeta.mMsgId, WIRE_PULSE_TYPE_REPLY);
|
||||
mAddDialog->show();
|
||||
}
|
||||
}
|
||||
|
||||
void WireDialog::notifyPulseSelection(PulseItem *item)
|
||||
{
|
||||
if (mPulseSelected)
|
||||
{
|
||||
std::cerr << "WireDialog::notifyPulseSelection() unselecting old one : " << mPulseSelected;
|
||||
std::cerr << std::endl;
|
||||
|
||||
mPulseSelected->setSelected(false);
|
||||
}
|
||||
mPulseSelected = item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WireDialog::subscribe(RsGxsGroupId &groupId)
|
||||
{
|
||||
@ -285,49 +217,6 @@ void WireDialog::createPulse()
|
||||
mAddDialog->show();
|
||||
}
|
||||
|
||||
void WireDialog::addPulse(RsWirePulse *pulse, RsWireGroup *group,
|
||||
std::map<rstime_t, RsWirePulse *> replies)
|
||||
{
|
||||
std::cerr << "WireDialog::addPulse() GroupId : " << pulse->mMeta.mGroupId;
|
||||
std::cerr << " OrigMsgId : " << pulse->mMeta.mOrigMsgId;
|
||||
std::cerr << " Replies : " << replies.size();
|
||||
std::cerr << std::endl;
|
||||
|
||||
PulseItem *pulseItem = new PulseItem(this, pulse, group, replies);
|
||||
|
||||
/* ensure its a boxlayout */
|
||||
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
||||
QBoxLayout *boxlayout = dynamic_cast<QBoxLayout *>(alayout);
|
||||
if (boxlayout == NULL) {
|
||||
std::cerr << "WireDialog::addPulse() ERROR not boxlayout, inserting at end";
|
||||
std::cerr << std::endl;
|
||||
alayout->addWidget(pulseItem);
|
||||
return;
|
||||
}
|
||||
|
||||
/* iterate through layout, and insert at the correct time */
|
||||
for(int i = 0; i < alayout->count(); i++)
|
||||
{
|
||||
QLayoutItem *layoutItem = boxlayout->itemAt(i);
|
||||
PulseItem *pitem = dynamic_cast<PulseItem *>(layoutItem->widget());
|
||||
if (pitem != NULL)
|
||||
{
|
||||
if (pitem->publishTs() < pulseItem->publishTs())
|
||||
{
|
||||
std::cerr << "WireDialog::addPulse() Inserting at index: " << i;
|
||||
std::cerr << std::endl;
|
||||
/* insert at this index */
|
||||
boxlayout->insertWidget(i, pulseItem);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// last item.
|
||||
std::cerr << "WireDialog::addPulse() Inserting at end";
|
||||
std::cerr << std::endl;
|
||||
boxlayout->addWidget(pulseItem);
|
||||
}
|
||||
|
||||
void WireDialog::addGroup(const RsWireGroup &group)
|
||||
{
|
||||
std::cerr << "WireDialog::addGroup() GroupId : " << group.mMeta.mGroupId;
|
||||
@ -336,37 +225,6 @@ void WireDialog::addGroup(const RsWireGroup &group)
|
||||
addGroup(new WireGroupItem(this, group));
|
||||
}
|
||||
|
||||
void WireDialog::deletePulses()
|
||||
{
|
||||
std::cerr << "WireDialog::deletePulses()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
||||
QLayoutItem *item;
|
||||
int i = 0;
|
||||
while (i < alayout->count())
|
||||
{
|
||||
item = alayout->itemAt(i);
|
||||
QWidget *widget = item->widget();
|
||||
if (NULL != dynamic_cast<PulseItem *>(widget))
|
||||
{
|
||||
std::cerr << "WireDialog::deletePulses() Removing Item at: " << i;
|
||||
std::cerr << std::endl;
|
||||
|
||||
item = alayout->takeAt(i);
|
||||
delete item->widget();
|
||||
delete item;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "WireDialog::deletePulses() Leaving Item at: " << i;
|
||||
std::cerr << std::endl;
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WireDialog::deleteGroups()
|
||||
{
|
||||
std::cerr << "WireDialog::deleteGroups()";
|
||||
@ -447,11 +305,9 @@ void WireDialog::showSelectedGroups()
|
||||
ui.comboBox_filterTime->setEnabled(false);
|
||||
if (mGroupSelected)
|
||||
{
|
||||
deletePulses();
|
||||
// request data.
|
||||
std::list<RsGxsGroupId> grpIds;
|
||||
grpIds.push_back(mGroupSelected->groupId());
|
||||
requestPulseData(grpIds);
|
||||
|
||||
// show GroupFocus.
|
||||
showGroupFocus(mGroupSelected->groupId());
|
||||
@ -466,8 +322,6 @@ void WireDialog::showGroups()
|
||||
{
|
||||
ui.comboBox_filterTime->setEnabled(false);
|
||||
deleteGroups();
|
||||
deletePulses();
|
||||
|
||||
|
||||
std::list<RsGxsGroupId> allGroupIds;
|
||||
|
||||
@ -498,7 +352,6 @@ void WireDialog::showGroups()
|
||||
std::list<RsGxsGroupId> grpIds;
|
||||
grpIds.push_back(it->second.mMeta.mGroupId);
|
||||
allGroupIds.push_back(it->second.mMeta.mGroupId);
|
||||
requestPulseData(grpIds);
|
||||
}
|
||||
}
|
||||
|
||||
@ -533,62 +386,6 @@ bool WireDialog::loadGroupData(const uint32_t &token)
|
||||
return true;
|
||||
}
|
||||
|
||||
void WireDialog::requestPulseData(const std::list<RsGxsGroupId>& grpIds)
|
||||
{
|
||||
std::cerr << "WireDialog::requestPulseData()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
|
||||
uint32_t token;
|
||||
mWireQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, 0);
|
||||
}
|
||||
|
||||
|
||||
/* LoadPulseData...
|
||||
*
|
||||
* group into threads, using std::map<RsGxsMessageId, PulseReplySet>
|
||||
* then sort by publishTS, using std::map<time, PulseOrderedReply>
|
||||
* then add into gui.
|
||||
* - use pointers to avoid copying everywhere.
|
||||
*
|
||||
* should we mutex Groups, or copy so we don't lose a pointer?
|
||||
* should be fine, as mAllGroups only modified from loadData calls.
|
||||
******
|
||||
*
|
||||
* NB: Potentially, this should be changed to use GXS to do the bulk of the work.
|
||||
* - request Top-Level Msgs, sorted by PublishTS.
|
||||
* - Insert into GUI.
|
||||
* - for each request children Msg, and fill in "replies"
|
||||
*
|
||||
* This needs sorted option on GXS Data fetch.
|
||||
*/
|
||||
|
||||
class PulseReplySet
|
||||
{
|
||||
public:
|
||||
PulseReplySet() : group(NULL), msg(NULL) {}
|
||||
PulseReplySet(RsWirePulse *m, RsWireGroup *g)
|
||||
: group(g), msg(m) {}
|
||||
|
||||
RsWireGroup *group;
|
||||
RsWirePulse *msg;
|
||||
std::map<RsGxsMessageId, RsWirePulse *> replies; // orig ID -> replies.
|
||||
};
|
||||
|
||||
class PulseOrderedReply
|
||||
{
|
||||
public:
|
||||
PulseOrderedReply() : group(NULL), msg(NULL) {}
|
||||
PulseOrderedReply(RsWirePulse *m, RsWireGroup *g)
|
||||
: group(g), msg(m) {}
|
||||
|
||||
RsWireGroup *group;
|
||||
RsWirePulse *msg;
|
||||
std::map<rstime_t, RsWirePulse *> replies; // publish -> replies.
|
||||
};
|
||||
|
||||
rstime_t WireDialog::getFilterTimestamp()
|
||||
{
|
||||
rstime_t filterTimestamp = time(NULL);
|
||||
@ -612,135 +409,6 @@ rstime_t WireDialog::getFilterTimestamp()
|
||||
return filterTimestamp;
|
||||
}
|
||||
|
||||
bool WireDialog::loadPulseData(const uint32_t &token)
|
||||
{
|
||||
std::cerr << "WireDialog::loadPulseData()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::vector<RsWirePulse> pulses;
|
||||
rsWire->getPulseData(token, pulses);
|
||||
|
||||
std::cerr << "WireDialog::loadPulseData() pulses.size(): " << pulses.size();
|
||||
std::cerr << std::endl;
|
||||
|
||||
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++)
|
||||
{
|
||||
RsWirePulse& pulse = *vit;
|
||||
if (pulse.mPulseType & WIRE_PULSE_TYPE_REFERENCE)
|
||||
{
|
||||
// store references to add in later.
|
||||
std::cerr << "WireDialog::loadPulseData() REF: GroupId: " << pulse.mMeta.mGroupId;
|
||||
std::cerr << " PulseId: " << pulse.mMeta.mMsgId;
|
||||
std::cerr << std::endl;
|
||||
references.push_back(&pulse);
|
||||
}
|
||||
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())
|
||||
{
|
||||
RsWireGroup &group = git->second;
|
||||
std::cerr << "WireDialog::loadPulseData() MSG: GroupId: " << pulse.mMeta.mGroupId;
|
||||
std::cerr << " PulseId: " << pulse.mMeta.mMsgId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
// install into pulseGrouping.
|
||||
pulseGrouping[pulse.mMeta.mOrigMsgId] = PulseReplySet(&pulse, &group);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "WireDialog::loadPulseData() ERROR Missing GroupId: " << pulse.mMeta.mGroupId;
|
||||
std::cerr << " PulseId: " << pulse.mMeta.mMsgId;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add references.
|
||||
std::list<RsWirePulse *>::iterator lrit;
|
||||
for(lrit = references.begin(); lrit != references.end(); lrit++)
|
||||
{
|
||||
std::map<RsGxsMessageId, PulseReplySet>::iterator pgit;
|
||||
pgit = pulseGrouping.find((*lrit)->mMeta.mThreadId);
|
||||
if (pgit != pulseGrouping.end())
|
||||
{
|
||||
// install into reply map.
|
||||
// TODO handle Edits / Latest MSGS.
|
||||
std::map<RsGxsMessageId, RsWirePulse *>::iterator rmit;
|
||||
rmit = pgit->second.replies.find((*lrit)->mMeta.mOrigMsgId);
|
||||
if (rmit == pgit->second.replies.end())
|
||||
{
|
||||
std::cerr << "WireDialog::loadPulseData() Installing REF: " << (*lrit)->mMeta.mOrigMsgId;
|
||||
std::cerr << " to threadId: " << (*lrit)->mMeta.mThreadId;
|
||||
std::cerr << std::endl;
|
||||
pgit->second.replies[(*lrit)->mMeta.mOrigMsgId] = (*lrit);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "WireDialog::loadPulseData() ERROR Duplicate reply REF: " << (*lrit)->mMeta.mOrigMsgId;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// no original msg for REF.
|
||||
std::cerr << "WireDialog::loadPulseData() ERROR No matching ThreadId REF: " << (*lrit)->mMeta.mThreadId;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
references.clear();
|
||||
|
||||
// sort by publish time.
|
||||
std::map<rstime_t, PulseOrderedReply> pulseOrdering;
|
||||
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;
|
||||
for(rmit = pgit->second.replies.begin();
|
||||
rmit != pgit->second.replies.end(); rmit++)
|
||||
{
|
||||
msg.replies[rmit->second->mMeta.mPublishTs] = rmit->second;
|
||||
}
|
||||
}
|
||||
|
||||
// now add to the GUI.
|
||||
std::map<rstime_t, PulseOrderedReply>::reverse_iterator poit;
|
||||
for (poit = pulseOrdering.rbegin(); poit != pulseOrdering.rend(); poit++)
|
||||
{
|
||||
// add into GUI should insert at correct time point, amongst all other ones.
|
||||
addPulse(poit->second.msg, poit->second.group, poit->second.replies);
|
||||
}
|
||||
|
||||
// allow filterTime to be changed again
|
||||
ui.comboBox_filterTime->setEnabled(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void WireDialog::acknowledgeGroup(const uint32_t &token, const uint32_t &userType)
|
||||
{
|
||||
/* reload groups */
|
||||
@ -769,9 +437,6 @@ void WireDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
case TOKENREQ_GROUPINFO:
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
// case RS_TOKREQ_ANSTYPE_LIST:
|
||||
// loadGroupList(req.mToken);
|
||||
// break;
|
||||
case RS_TOKREQ_ANSTYPE_DATA:
|
||||
loadGroupData(req.mToken);
|
||||
break;
|
||||
@ -784,40 +449,6 @@ void WireDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case TOKENREQ_MSGINFO:
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
#if 0
|
||||
case RS_TOKREQ_ANSTYPE_LIST:
|
||||
loadPhotoList(req.mToken);
|
||||
break;
|
||||
case RS_TOKREQ_ANSTYPE_ACK:
|
||||
acknowledgeMessage(req.mToken);
|
||||
break;
|
||||
#endif
|
||||
case RS_TOKREQ_ANSTYPE_DATA:
|
||||
loadPulseData(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "WireDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
case TOKENREQ_MSGRELATEDINFO:
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
case RS_TOKREQ_ANSTYPE_DATA:
|
||||
loadPhotoData(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "WireDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
std::cerr << "WireDialog::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
@ -970,7 +601,7 @@ void WireDialog::clearTwitterView()
|
||||
std::cerr << "WireDialog::clearTwitterView()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QLayout *alayout = ui.scrollAreaWidgetContents_2->layout();
|
||||
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
||||
QLayoutItem *item;
|
||||
int i = 0;
|
||||
while (i < alayout->count())
|
||||
@ -1002,7 +633,7 @@ void WireDialog::addTwitterView(PulseViewItem *item)
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* ensure its a boxlayout */
|
||||
QLayout *alayout = ui.scrollAreaWidgetContents_2->layout();
|
||||
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
||||
QBoxLayout *boxlayout = dynamic_cast<QBoxLayout *>(alayout);
|
||||
if (boxlayout == NULL) {
|
||||
std::cerr << "WireDialog::addTwitterView() ERROR not boxlayout, not Inserting";
|
||||
@ -1029,7 +660,7 @@ void WireDialog::showPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId
|
||||
int type = 0;
|
||||
bool success = rsWire->getPulseFocus(groupId, msgId, type, pPulse);
|
||||
|
||||
sleep(2);
|
||||
// sleep(2);
|
||||
|
||||
/* now insert the pulse + children into the layput */
|
||||
RsQThreadUtils::postToObject([pPulse,this]()
|
||||
@ -1103,7 +734,7 @@ void WireDialog::showGroupFocus(const RsGxsGroupId groupId)
|
||||
std::list<RsGxsGroupId> groupIds = { groupId };
|
||||
success = rsWire->getPulsesForGroups(groupIds, pulses);
|
||||
|
||||
sleep(2);
|
||||
// sleep(2);
|
||||
|
||||
/* now insert the pulse + children into the layput */
|
||||
RsQThreadUtils::postToObject([grp, pulses,this]()
|
||||
@ -1167,7 +798,7 @@ void WireDialog::showGroupsPulses(const std::list<RsGxsGroupId> groupIds)
|
||||
std::list<RsWirePulseSPtr> pulses;
|
||||
bool success = rsWire->getPulsesForGroups(groupIds, pulses);
|
||||
|
||||
sleep(2);
|
||||
// sleep(2);
|
||||
|
||||
/* now insert the pulse + children into the layput */
|
||||
RsQThreadUtils::postToObject([pulses,this]()
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "gui/TheWire/PulseItem.h"
|
||||
#include "gui/TheWire/WireGroupItem.h"
|
||||
#include "gui/TheWire/PulseAddDialog.h"
|
||||
|
||||
@ -41,7 +40,7 @@
|
||||
|
||||
#define IMAGE_WIRE ":/icons/wire.png"
|
||||
|
||||
class WireDialog : public MainPage, public TokenResponse, public PulseHolder, public WireGroupHolder, public PulseViewHolder
|
||||
class WireDialog : public MainPage, public TokenResponse, public WireGroupHolder, public PulseViewHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -52,16 +51,6 @@ public:
|
||||
virtual QString pageName() const { return tr("The Wire") ; }
|
||||
virtual QString helpText() const { return ""; }
|
||||
|
||||
// PulseHolder interface.
|
||||
virtual void deletePulseItem(PulseItem *, uint32_t type);
|
||||
virtual void notifyPulseSelection(PulseItem *item);
|
||||
|
||||
virtual void focus(RsGxsGroupId &groupId, RsGxsMessageId &msgId) override;
|
||||
virtual void follow(RsGxsGroupId &groupId) override;
|
||||
virtual void rate(RsGxsId &authorId) override;
|
||||
virtual void reply(RsWirePulse &pulse, std::string &groupName) override;
|
||||
|
||||
|
||||
// WireGroupHolder interface.
|
||||
virtual void subscribe(RsGxsGroupId &groupId) override;
|
||||
virtual void unsubscribe(RsGxsGroupId &groupId) override;
|
||||
@ -107,13 +96,8 @@ private:
|
||||
bool setupPulseAddDialog();
|
||||
|
||||
void addGroup(QWidget *item);
|
||||
|
||||
void addPulse(RsWirePulse *pulse, RsWireGroup *group,
|
||||
std::map<rstime_t, RsWirePulse *> replies);
|
||||
|
||||
void addGroup(const RsWireGroup &group);
|
||||
|
||||
void deletePulses();
|
||||
void deleteGroups();
|
||||
void showGroups();
|
||||
void showSelectedGroups();
|
||||
@ -127,18 +111,12 @@ private:
|
||||
bool loadGroupData(const uint32_t &token);
|
||||
void acknowledgeGroup(const uint32_t &token, const uint32_t &userType);
|
||||
|
||||
void requestPulseData(const std::list<RsGxsGroupId>& grpIds);
|
||||
bool loadPulseData(const uint32_t &token);
|
||||
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
int mGroupSet;
|
||||
|
||||
PulseAddDialog *mAddDialog;
|
||||
|
||||
PulseItem *mPulseSelected;
|
||||
WireGroupItem *mGroupSelected;
|
||||
|
||||
TokenQueue *mWireQueue;
|
||||
|
||||
std::map<RsGxsGroupId, RsWireGroup> mAllGroups;
|
||||
|
@ -223,11 +223,11 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabWidget_Page1">
|
||||
<attribute name="title">
|
||||
<string>Orig View</string>
|
||||
<string>HomePage</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
@ -248,6 +248,13 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_viewMode">
|
||||
<property name="text">
|
||||
<string>Most Recent</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
@ -362,73 +369,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Fancy View</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_viewMode">
|
||||
<property name="text">
|
||||
<string>Most Recent</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_3">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>508</width>
|
||||
<height>443</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<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_3">
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -1230,9 +1230,7 @@ gxsthewire {
|
||||
|
||||
DEFINES += RS_USE_WIRE
|
||||
|
||||
HEADERS += gui/TheWire/PulseItem.h \
|
||||
gui/TheWire/PulseDetails.h \
|
||||
gui/TheWire/WireDialog.h \
|
||||
HEADERS += gui/TheWire/WireDialog.h \
|
||||
gui/TheWire/WireGroupItem.h \
|
||||
gui/TheWire/WireGroupDialog.h \
|
||||
gui/TheWire/WireGroupExtra.h \
|
||||
@ -1243,12 +1241,10 @@ gxsthewire {
|
||||
gui/TheWire/PulseReply.h \
|
||||
gui/TheWire/PulseReplySeperator.h \
|
||||
gui/TheWire/PulseMessage.h \
|
||||
|
||||
FORMS += gui/TheWire/PulseItem.ui \
|
||||
gui/TheWire/PulseDetails.ui \
|
||||
|
||||
FORMS += gui/TheWire/WireDialog.ui \
|
||||
gui/TheWire/WireGroupItem.ui \
|
||||
gui/TheWire/WireGroupExtra.ui \
|
||||
gui/TheWire/WireDialog.ui \
|
||||
gui/TheWire/PulseAddDialog.ui \
|
||||
gui/TheWire/PulseTopLevel.ui \
|
||||
gui/TheWire/PulseViewGroup.ui \
|
||||
@ -1256,9 +1252,7 @@ gxsthewire {
|
||||
gui/TheWire/PulseReplySeperator.ui \
|
||||
gui/TheWire/PulseMessage.ui \
|
||||
|
||||
SOURCES += gui/TheWire/PulseItem.cpp \
|
||||
gui/TheWire/PulseDetails.cpp \
|
||||
gui/TheWire/WireDialog.cpp \
|
||||
SOURCES += gui/TheWire/WireDialog.cpp \
|
||||
gui/TheWire/WireGroupItem.cpp \
|
||||
gui/TheWire/WireGroupDialog.cpp \
|
||||
gui/TheWire/WireGroupExtra.cpp \
|
||||
|
Loading…
Reference in New Issue
Block a user