TheWire UI Improvements

Ensure that PulseAddDialog updates ReplyTo pulse correcly.
PulseDetails actions enabled correctly.
Allow selection of WireGroup by clicking in list.
This commit is contained in:
drbob 2020-04-10 21:36:31 +10:00
parent b51520bccf
commit 9e0d56f408
6 changed files with 115 additions and 14 deletions

View File

@ -49,6 +49,34 @@ void PulseAddDialog::setGroup(RsWireGroup &group)
void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName) void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName)
{ {
if (mIsReply)
{
std::cerr << "PulseAddDialog::setReplyTo() cleaning up old replyto";
std::cerr << std::endl;
QLayout *layout = ui.widget_replyto->layout();
// completely delete layout and sublayouts
QLayoutItem * item;
QWidget * widget;
while ((item = layout->takeAt(0)))
{
if ((widget = item->widget()) != 0)
{
std::cerr << "PulseAddDialog::setReplyTo() removing widget";
std::cerr << std::endl;
widget->hide();
delete widget;
}
else
{
std::cerr << "PulseAddDialog::setReplyTo() removing item";
std::cerr << std::endl;
delete item;
}
}
// then finally
delete layout;
}
mIsReply = true; mIsReply = true;
mReplyToPulse = pulse; mReplyToPulse = pulse;
mReplyGroupName = groupName; mReplyGroupName = groupName;

View File

@ -92,6 +92,10 @@ void PulseDetails::setup()
label_replies->setText(""); label_replies->setText("");
frame_replies->setVisible(false); frame_replies->setVisible(false);
mHasReplies = false; mHasReplies = false;
toolButton_follow->setEnabled(mActions != NULL);
toolButton_rate->setEnabled(mActions != NULL);
toolButton_reply->setEnabled(mActions != NULL);
} }
void PulseDetails::addReplies(std::map<rstime_t, RsWirePulse *> replies) void PulseDetails::addReplies(std::map<rstime_t, RsWirePulse *> replies)
@ -183,18 +187,28 @@ QString PulseDetails::getSummary()
void PulseDetails::follow() void PulseDetails::follow()
{ {
// follow group. // follow group.
mActions->follow(mPulse.mMeta.mGroupId); if (mActions)
{
mActions->follow(mPulse.mMeta.mGroupId);
}
} }
void PulseDetails::rate() void PulseDetails::rate()
{ {
// rate author // rate author
mActions->rate(mPulse.mMeta.mAuthorId); if (mActions)
{
mActions->rate(mPulse.mMeta.mAuthorId);
}
} }
void PulseDetails::reply() void PulseDetails::reply()
{ {
mActions->reply(mPulse, mGroupName); // reply
if (mActions)
{
mActions->reply(mPulse, mGroupName);
}
} }

View File

@ -56,6 +56,7 @@ WireDialog::WireDialog(QWidget *parent)
mAddDialog = NULL; mAddDialog = NULL;
mPulseSelected = NULL; mPulseSelected = NULL;
mGroupSelected = NULL;
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()));
@ -177,15 +178,31 @@ void WireDialog::notifyGroupSelection(WireGroupItem *item)
std::cerr << "WireDialog::notifyGroupSelection() from : " << item; std::cerr << "WireDialog::notifyGroupSelection() from : " << item;
std::cerr << std::endl; std::cerr << std::endl;
bool doSelection = true;
if (mGroupSelected) if (mGroupSelected)
{ {
std::cerr << "WireDialog::notifyGroupSelection() unselecting old one : " << mGroupSelected; std::cerr << "WireDialog::notifyGroupSelection() unselecting old one : " << mGroupSelected;
std::cerr << std::endl; std::cerr << std::endl;
mGroupSelected->setSelected(false); mGroupSelected->setSelected(false);
if (mGroupSelected == item)
{
std::cerr << "WireDialog::notifyGroupSelection() current -> unselect";
std::cerr << std::endl;
/* de-selection of current item */
mGroupSelected = NULL;
doSelection = false;
}
} }
mGroupSelected = item; if (doSelection)
{
item->setSelected(true);
mGroupSelected = item;
}
/* update display */
showSelectedGroups();
} }
@ -320,6 +337,8 @@ void WireDialog::deleteGroups()
std::cerr << "WireDialog::deleteGroups()"; std::cerr << "WireDialog::deleteGroups()";
std::cerr << std::endl; std::cerr << std::endl;
mGroupSelected = NULL;
QLayout *alayout = ui.scrollAreaWidgetContents_groups->layout(); QLayout *alayout = ui.scrollAreaWidgetContents_groups->layout();
QLayoutItem *item; QLayoutItem *item;
int i = 0; int i = 0;
@ -380,11 +399,29 @@ void WireDialog::selectGroupSet(int index)
showGroups(); showGroups();
} }
void WireDialog::showSelectedGroups()
{
if (mGroupSelected)
{
deletePulses();
// request data.
std::list<RsGxsGroupId> grpIds;
grpIds.push_back(mGroupSelected->groupId());
requestPulseData(grpIds);
}
else
{
showGroups();
}
}
void WireDialog::showGroups() void WireDialog::showGroups()
{ {
deleteGroups(); deleteGroups();
deletePulses(); deletePulses();
/* depends on the comboBox */ /* depends on the comboBox */
std::map<RsGxsGroupId, RsWireGroup>::const_iterator it; std::map<RsGxsGroupId, RsWireGroup>::const_iterator it;
for (it = mAllGroups.begin(); it != mAllGroups.end(); it++) for (it = mAllGroups.begin(); it != mAllGroups.end(); it++)

View File

@ -81,6 +81,7 @@ private:
void deletePulses(); void deletePulses();
void deleteGroups(); void deleteGroups();
void showGroups(); void showGroups();
void showSelectedGroups();
void updateGroups(std::vector<RsWireGroup> &groups); void updateGroups(std::vector<RsWireGroup> &groups);
// Loading Data. // Loading Data.

View File

@ -39,6 +39,11 @@ WireGroupItem::WireGroupItem(WireGroupHolder *holder, const RsWireGroup &grp)
} }
RsGxsGroupId &WireGroupItem::groupId()
{
return mGroup.mMeta.mGroupId;
}
void WireGroupItem::setup() void WireGroupItem::setup()
{ {
label_groupName->setText(QString::fromStdString(mGroup.mMeta.mGroupName)); label_groupName->setText(QString::fromStdString(mGroup.mMeta.mGroupName));
@ -91,8 +96,28 @@ void WireGroupItem::removeItem()
{ {
} }
void WireGroupItem::setSelected(bool /* on */) void WireGroupItem::setSelected(bool on)
{ {
mSelected = on;
// set color too
if (mSelected)
{
setBackground("red");
}
else
{
setBackground("gray");
}
}
void WireGroupItem::setBackground(QString color)
{
QWidget *tocolor = this;
QPalette p = tocolor->palette();
p.setColor(tocolor->backgroundRole(), QColor(color));
tocolor->setPalette(p);
tocolor->setAutoFillBackground(true);
} }
bool WireGroupItem::isSelected() bool WireGroupItem::isSelected()
@ -102,20 +127,14 @@ bool WireGroupItem::isSelected()
void WireGroupItem::mousePressEvent(QMouseEvent *event) void WireGroupItem::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(); QPoint pos = event->pos();
std::cerr << "WireGroupItem::mousePressEvent(" << pos.x() << ", " << pos.y() << ")"; std::cerr << "WireGroupItem::mousePressEvent(" << pos.x() << ", " << pos.y() << ")";
std::cerr << std::endl; std::cerr << std::endl;
setSelected(true); // notify of selection.
// Holder will setSelected() flag.
QWidget::mousePressEvent(event); mHolder->notifyGroupSelection(this);
} }
const QPixmap *WireGroupItem::getPixmap() const QPixmap *WireGroupItem::getPixmap()

View File

@ -50,6 +50,7 @@ public:
bool isSelected(); bool isSelected();
const QPixmap *getPixmap(); const QPixmap *getPixmap();
RsGxsGroupId &groupId();
private slots: private slots:
void show(); void show();
@ -61,6 +62,7 @@ protected:
private: private:
void setup(); void setup();
void setGroupSet(); void setGroupSet();
void setBackground(QString color);
WireGroupHolder *mHolder; WireGroupHolder *mHolder;
RsWireGroup mGroup; RsWireGroup mGroup;