diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp index a23af7f54..fa0e7bd9a 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp @@ -49,6 +49,34 @@ void PulseAddDialog::setGroup(RsWireGroup &group) 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; mReplyToPulse = pulse; mReplyGroupName = groupName; diff --git a/retroshare-gui/src/gui/TheWire/PulseDetails.cpp b/retroshare-gui/src/gui/TheWire/PulseDetails.cpp index 067b1e99e..c29268762 100644 --- a/retroshare-gui/src/gui/TheWire/PulseDetails.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseDetails.cpp @@ -92,6 +92,10 @@ void PulseDetails::setup() label_replies->setText(""); frame_replies->setVisible(false); mHasReplies = false; + + toolButton_follow->setEnabled(mActions != NULL); + toolButton_rate->setEnabled(mActions != NULL); + toolButton_reply->setEnabled(mActions != NULL); } void PulseDetails::addReplies(std::map replies) @@ -183,18 +187,28 @@ QString PulseDetails::getSummary() void PulseDetails::follow() { // follow group. - mActions->follow(mPulse.mMeta.mGroupId); + if (mActions) + { + mActions->follow(mPulse.mMeta.mGroupId); + } } void PulseDetails::rate() { // rate author - mActions->rate(mPulse.mMeta.mAuthorId); + if (mActions) + { + mActions->rate(mPulse.mMeta.mAuthorId); + } } void PulseDetails::reply() { - mActions->reply(mPulse, mGroupName); + // reply + if (mActions) + { + mActions->reply(mPulse, mGroupName); + } } diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.cpp b/retroshare-gui/src/gui/TheWire/WireDialog.cpp index 6b1cd87ae..16df723bb 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireDialog.cpp @@ -56,6 +56,7 @@ WireDialog::WireDialog(QWidget *parent) mAddDialog = NULL; mPulseSelected = NULL; + mGroupSelected = NULL; connect( ui.toolButton_createAccount, SIGNAL(clicked()), this, SLOT(createGroup())); 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 << std::endl; + bool doSelection = true; if (mGroupSelected) { std::cerr << "WireDialog::notifyGroupSelection() unselecting old one : " << mGroupSelected; std::cerr << std::endl; 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 << std::endl; + mGroupSelected = NULL; + QLayout *alayout = ui.scrollAreaWidgetContents_groups->layout(); QLayoutItem *item; int i = 0; @@ -380,11 +399,29 @@ void WireDialog::selectGroupSet(int index) showGroups(); } +void WireDialog::showSelectedGroups() +{ + if (mGroupSelected) + { + deletePulses(); + // request data. + std::list grpIds; + grpIds.push_back(mGroupSelected->groupId()); + requestPulseData(grpIds); + } + else + { + showGroups(); + } +} + void WireDialog::showGroups() { deleteGroups(); deletePulses(); + + /* depends on the comboBox */ std::map::const_iterator it; for (it = mAllGroups.begin(); it != mAllGroups.end(); it++) diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.h b/retroshare-gui/src/gui/TheWire/WireDialog.h index b2a9198e0..b64ea6a21 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.h +++ b/retroshare-gui/src/gui/TheWire/WireDialog.h @@ -81,6 +81,7 @@ private: void deletePulses(); void deleteGroups(); void showGroups(); + void showSelectedGroups(); void updateGroups(std::vector &groups); // Loading Data. diff --git a/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp b/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp index d1f2ae1e4..d09a9e1e5 100644 --- a/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp +++ b/retroshare-gui/src/gui/TheWire/WireGroupItem.cpp @@ -39,6 +39,11 @@ WireGroupItem::WireGroupItem(WireGroupHolder *holder, const RsWireGroup &grp) } +RsGxsGroupId &WireGroupItem::groupId() +{ + return mGroup.mMeta.mGroupId; +} + void WireGroupItem::setup() { 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() @@ -102,20 +127,14 @@ bool WireGroupItem::isSelected() 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(); std::cerr << "WireGroupItem::mousePressEvent(" << pos.x() << ", " << pos.y() << ")"; std::cerr << std::endl; - setSelected(true); - - QWidget::mousePressEvent(event); + // notify of selection. + // Holder will setSelected() flag. + mHolder->notifyGroupSelection(this); } const QPixmap *WireGroupItem::getPixmap() diff --git a/retroshare-gui/src/gui/TheWire/WireGroupItem.h b/retroshare-gui/src/gui/TheWire/WireGroupItem.h index 82863ea89..7f8643a7e 100644 --- a/retroshare-gui/src/gui/TheWire/WireGroupItem.h +++ b/retroshare-gui/src/gui/TheWire/WireGroupItem.h @@ -50,6 +50,7 @@ public: bool isSelected(); const QPixmap *getPixmap(); + RsGxsGroupId &groupId(); private slots: void show(); @@ -61,6 +62,7 @@ protected: private: void setup(); void setGroupSet(); + void setBackground(QString color); WireGroupHolder *mHolder; RsWireGroup mGroup;