mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 23:19:29 -05:00
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:
parent
b51520bccf
commit
9e0d56f408
@ -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;
|
||||
|
@ -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<rstime_t, RsWirePulse *> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<RsGxsGroupId> grpIds;
|
||||
grpIds.push_back(mGroupSelected->groupId());
|
||||
requestPulseData(grpIds);
|
||||
}
|
||||
else
|
||||
{
|
||||
showGroups();
|
||||
}
|
||||
}
|
||||
|
||||
void WireDialog::showGroups()
|
||||
{
|
||||
deleteGroups();
|
||||
deletePulses();
|
||||
|
||||
|
||||
|
||||
/* depends on the comboBox */
|
||||
std::map<RsGxsGroupId, RsWireGroup>::const_iterator it;
|
||||
for (it = mAllGroups.begin(); it != mAllGroups.end(); it++)
|
||||
|
@ -81,6 +81,7 @@ private:
|
||||
void deletePulses();
|
||||
void deleteGroups();
|
||||
void showGroups();
|
||||
void showSelectedGroups();
|
||||
void updateGroups(std::vector<RsWireGroup> &groups);
|
||||
|
||||
// Loading Data.
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user