mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
refactor: ChannelView (#4926)
Co-authored-by: nerix <nerixdev@outlook.de>
This commit is contained in:
parent
25c776cfff
commit
7efe58cca9
|
@ -45,6 +45,7 @@
|
|||
- Dev: Removed direct dependency on Qt 5 compatibility module. (#4906)
|
||||
- Dev: Refactor `DebugCount` and add copy button to debug popup. (#4921)
|
||||
- Dev: Changed lifetime of context menus. (#4924)
|
||||
- Dev: Refactor `ChannelView`, removing a bunch of clang-tidy warnings. (#4926)
|
||||
|
||||
## 2.4.6
|
||||
|
||||
|
|
|
@ -60,7 +60,11 @@ public:
|
|||
void deleteBuffer();
|
||||
void deleteCache();
|
||||
|
||||
// Elements
|
||||
/**
|
||||
* Returns a raw pointer to the element at the given point
|
||||
*
|
||||
* If no element is found at the given point, this returns a null pointer
|
||||
*/
|
||||
const MessageLayoutElement *getElementAt(QPoint point);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1257,6 +1257,22 @@ const std::unordered_map<QString, std::weak_ptr<MessageThread>>
|
|||
return this->threads_;
|
||||
}
|
||||
|
||||
std::shared_ptr<MessageThread> TwitchChannel::getOrCreateThread(
|
||||
const MessagePtr &message)
|
||||
{
|
||||
assert(message != nullptr);
|
||||
|
||||
auto threadIt = this->threads_.find(message->id);
|
||||
if (threadIt != this->threads_.end() && !threadIt->second.expired())
|
||||
{
|
||||
return threadIt->second.lock();
|
||||
}
|
||||
|
||||
auto thread = std::make_shared<MessageThread>(message);
|
||||
this->addReplyThread(thread);
|
||||
return thread;
|
||||
}
|
||||
|
||||
void TwitchChannel::cleanUpReplyThreads()
|
||||
{
|
||||
for (auto it = this->threads_.begin(), last = this->threads_.end();
|
||||
|
|
|
@ -190,6 +190,12 @@ public:
|
|||
const std::unordered_map<QString, std::weak_ptr<MessageThread>> &threads()
|
||||
const;
|
||||
|
||||
/**
|
||||
* Get the thread for the given message
|
||||
* If no thread can be found for the message, create one
|
||||
*/
|
||||
std::shared_ptr<MessageThread> getOrCreateThread(const MessagePtr &message);
|
||||
|
||||
// Only TwitchChannel may invoke this signal
|
||||
pajlada::Signals::NoArgSignal userStateChanged;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -112,16 +112,17 @@ public:
|
|||
bool pausable() const;
|
||||
void setPausable(bool value);
|
||||
bool paused() const;
|
||||
void pause(PauseReason reason, std::optional<uint> msecs = std::nullopt);
|
||||
void pause(PauseReason reason,
|
||||
std::optional<uint32_t> msecs = std::nullopt);
|
||||
void unpause(PauseReason reason);
|
||||
|
||||
MessageElementFlags getFlags() const;
|
||||
|
||||
ChannelPtr channel();
|
||||
void setChannel(ChannelPtr channel_);
|
||||
void setChannel(const ChannelPtr &underlyingChannel);
|
||||
|
||||
void setFilters(const QList<QUuid> &ids);
|
||||
const QList<QUuid> getFilterIds() const;
|
||||
QList<QUuid> getFilterIds() const;
|
||||
FilterSetPtr getFilterSet() const;
|
||||
|
||||
ChannelPtr sourceChannel() const;
|
||||
|
@ -163,9 +164,9 @@ protected:
|
|||
void themeChangedEvent() override;
|
||||
void scaleChangedEvent(float scale) override;
|
||||
|
||||
void resizeEvent(QResizeEvent *) override;
|
||||
void resizeEvent(QResizeEvent * /*event*/) override;
|
||||
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
void paintEvent(QPaintEvent * /*event*/) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
|
@ -173,14 +174,14 @@ protected:
|
|||
#else
|
||||
void enterEvent(QEvent * /*event*/) override;
|
||||
#endif
|
||||
void leaveEvent(QEvent *) override;
|
||||
void leaveEvent(QEvent * /*event*/) override;
|
||||
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
|
||||
void hideEvent(QHideEvent *) override;
|
||||
void hideEvent(QHideEvent * /*event*/) override;
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
void handleLinkClick(QMouseEvent *event, const Link &link,
|
||||
|
@ -212,33 +213,18 @@ private:
|
|||
void setSelection(const SelectionItem &start, const SelectionItem &end);
|
||||
void setSelection(const Selection &newSelection);
|
||||
void selectWholeMessage(MessageLayout *layout, int &messageIndex);
|
||||
std::pair<size_t, size_t> getWordBounds(MessageLayout *layout,
|
||||
const MessageLayoutElement *element,
|
||||
const QPoint &relativePos);
|
||||
|
||||
void handleMouseClick(QMouseEvent *event,
|
||||
const MessageLayoutElement *hoveredElement,
|
||||
MessageLayoutPtr layout);
|
||||
void addContextMenuItems(const MessageLayoutElement *hoveredElement,
|
||||
MessageLayoutPtr layout, QMouseEvent *event);
|
||||
void addImageContextMenuItems(const MessageLayoutElement *hoveredElement,
|
||||
MessageLayoutPtr layout, QMouseEvent *event,
|
||||
QMenu &menu);
|
||||
void addLinkContextMenuItems(const MessageLayoutElement *hoveredElement,
|
||||
MessageLayoutPtr layout, QMouseEvent *event,
|
||||
QMenu &menu);
|
||||
void addMessageContextMenuItems(const MessageLayoutElement *hoveredElement,
|
||||
MessageLayoutPtr layout, QMouseEvent *event,
|
||||
QMenu &menu);
|
||||
void addMessageContextMenuItems(QMenu *menu,
|
||||
const MessageLayoutPtr &layout);
|
||||
void addTwitchLinkContextMenuItems(
|
||||
const MessageLayoutElement *hoveredElement, MessageLayoutPtr layout,
|
||||
QMouseEvent *event, QMenu &menu);
|
||||
void addHiddenContextMenuItems(const MessageLayoutElement *hoveredElement,
|
||||
MessageLayoutPtr layout, QMouseEvent *event,
|
||||
QMenu &menu);
|
||||
void addCommandExecutionContextMenuItems(
|
||||
const MessageLayoutElement *hoveredElement, MessageLayoutPtr layout,
|
||||
QMouseEvent *event, QMenu &menu);
|
||||
QMenu *menu, const MessageLayoutElement *hoveredElement);
|
||||
void addCommandExecutionContextMenuItems(QMenu *menu,
|
||||
const MessageLayoutPtr &layout);
|
||||
|
||||
int getLayoutWidth() const;
|
||||
void updatePauses();
|
||||
|
@ -311,7 +297,7 @@ private:
|
|||
QPointF lastLeftPressPosition_;
|
||||
QPointF lastRightPressPosition_;
|
||||
QPointF lastDoubleClickPosition_;
|
||||
QTimer *clickTimer_;
|
||||
QTimer clickTimer_;
|
||||
|
||||
bool isScrolling_ = false;
|
||||
QPointF lastMiddlePressPosition_;
|
||||
|
@ -346,16 +332,6 @@ private:
|
|||
MessageColors messageColors_;
|
||||
MessagePreferences messagePreferences_;
|
||||
|
||||
static constexpr int leftPadding = 8;
|
||||
static constexpr int scrollbarPadding = 8;
|
||||
|
||||
private slots:
|
||||
void wordFlagsChanged()
|
||||
{
|
||||
queueLayout();
|
||||
update();
|
||||
}
|
||||
|
||||
void scrollUpdateRequested();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue