Remove UserItem class
This commit is contained in:
parent
2132863a7e
commit
b0c3fd5a7d
@ -37,68 +37,6 @@ PopupItem::paintEvent(QPaintEvent *)
|
|||||||
p.fillRect(rect(), hoverColor_);
|
p.fillRect(rect(), hoverColor_);
|
||||||
}
|
}
|
||||||
|
|
||||||
UserItem::UserItem(QWidget *parent)
|
|
||||||
: PopupItem(parent)
|
|
||||||
{
|
|
||||||
userName_ = new QLabel("Placeholder", this);
|
|
||||||
avatar_->setLetter("P");
|
|
||||||
topLayout_->addWidget(avatar_);
|
|
||||||
topLayout_->addWidget(userName_, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
UserItem::UserItem(QWidget *parent, const QString &user_id)
|
|
||||||
: PopupItem(parent)
|
|
||||||
, userId_{user_id}
|
|
||||||
{
|
|
||||||
auto displayName = cache::displayName(ChatPage::instance()->currentRoom(), userId_);
|
|
||||||
|
|
||||||
avatar_->setLetter(utils::firstChar(displayName));
|
|
||||||
|
|
||||||
// If it's a matrix id we use the second letter.
|
|
||||||
if (displayName.size() > 1 && displayName.at(0) == '@')
|
|
||||||
avatar_->setLetter(QChar(displayName.at(1)));
|
|
||||||
|
|
||||||
userName_ = new QLabel(displayName, this);
|
|
||||||
|
|
||||||
topLayout_->addWidget(avatar_);
|
|
||||||
topLayout_->addWidget(userName_, 1);
|
|
||||||
|
|
||||||
resolveAvatar(user_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
UserItem::updateItem(const QString &user_id)
|
|
||||||
{
|
|
||||||
userId_ = user_id;
|
|
||||||
|
|
||||||
auto displayName = cache::displayName(ChatPage::instance()->currentRoom(), userId_);
|
|
||||||
|
|
||||||
// If it's a matrix id we use the second letter.
|
|
||||||
if (displayName.size() > 1 && displayName.at(0) == '@')
|
|
||||||
avatar_->setLetter(QChar(displayName.at(1)));
|
|
||||||
else
|
|
||||||
avatar_->setLetter(utils::firstChar(displayName));
|
|
||||||
|
|
||||||
userName_->setText(displayName);
|
|
||||||
resolveAvatar(user_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
UserItem::resolveAvatar(const QString &user_id)
|
|
||||||
{
|
|
||||||
avatar_->setImage(ChatPage::instance()->currentRoom(), user_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
UserItem::mousePressEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (event->buttons() != Qt::RightButton)
|
|
||||||
emit clicked(
|
|
||||||
cache::displayName(ChatPage::instance()->currentRoom(), selectedText()));
|
|
||||||
|
|
||||||
QWidget::mousePressEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
RoomItem::RoomItem(QWidget *parent, const RoomSearchResult &res)
|
RoomItem::RoomItem(QWidget *parent, const RoomSearchResult &res)
|
||||||
: PopupItem(parent)
|
: PopupItem(parent)
|
||||||
, roomId_{QString::fromStdString(res.room_id)}
|
, roomId_{QString::fromStdString(res.room_id)}
|
||||||
|
@ -43,26 +43,6 @@ protected:
|
|||||||
bool hovering_;
|
bool hovering_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class UserItem : public PopupItem
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
UserItem(QWidget *parent);
|
|
||||||
UserItem(QWidget *parent, const QString &user_id);
|
|
||||||
QString selectedText() const { return userId_; }
|
|
||||||
void updateItem(const QString &user_id);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void resolveAvatar(const QString &user_id);
|
|
||||||
|
|
||||||
QLabel *userName_;
|
|
||||||
QString userId_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class RoomItem : public PopupItem
|
class RoomItem : public PopupItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Loading…
Reference in New Issue
Block a user