From 3757f733cc3d88daa6d2eb57ec95200d7ab0591d Mon Sep 17 00:00:00 2001 From: Mick Sayson Date: Sat, 27 Feb 2021 22:06:52 -0800 Subject: [PATCH] refactor(chatlog): Remove unused getRow functions from ChatLine * The getRow functions would not track correctly since the rows indexes cannot be fixed to the view anymore --- src/chatlog/chatline.cpp | 19 +------------------ src/chatlog/chatline.h | 3 --- src/chatlog/chatlinecontent.cpp | 5 ----- src/chatlog/chatlinecontent.h | 1 - src/chatlog/chatlog.cpp | 7 ------- 5 files changed, 1 insertion(+), 34 deletions(-) diff --git a/src/chatlog/chatline.cpp b/src/chatlog/chatline.cpp index d9aef1b77..650564552 100644 --- a/src/chatlog/chatline.cpp +++ b/src/chatlog/chatline.cpp @@ -37,14 +37,6 @@ ChatLine::~ChatLine() } } -void ChatLine::setRow(int idx) -{ - row = idx; - - for (int c = 0; c < static_cast(content.size()); ++c) - content[c]->setIndex(row, c); -} - void ChatLine::visibilityChanged(bool visible) { if (isVisible != visible) { @@ -55,11 +47,6 @@ void ChatLine::visibilityChanged(bool visible) isVisible = visible; } -int ChatLine::getRow() const -{ - return row; -} - ChatLineContent* ChatLine::getContent(int col) const { if (col < static_cast(content.size()) && col >= 0) @@ -153,6 +140,7 @@ void ChatLine::addColumn(ChatLineContent* item, ColumnFormat fmt) format.push_back(fmt); content.push_back(item); + item->setIndex(0, content.size() -1 ); } void ChatLine::replaceContent(int col, ChatLineContent* lineContent) @@ -262,8 +250,3 @@ bool ChatLine::lessThanBSRectBottom(const ChatLine::Ptr& lhs, const qreal& rhs) { return lhs->sceneBoundingRect().bottom() < rhs; } - -bool ChatLine::lessThanRowIndex(const ChatLine::Ptr& lhs, const ChatLine::Ptr& rhs) -{ - return lhs->getRow() < rhs->getRow(); -} diff --git a/src/chatlog/chatline.h b/src/chatlog/chatline.h index 0872c3079..2d071c30b 100644 --- a/src/chatlog/chatline.h +++ b/src/chatlog/chatline.h @@ -84,7 +84,6 @@ public: void reloadTheme(); int getColumnCount(); - int getRow() const; ChatLineContent* getContent(int col) const; ChatLineContent* getContent(QPointF scenePos) const; @@ -94,7 +93,6 @@ public: // comparators static bool lessThanBSRectTop(const ChatLine::Ptr& lhs, const qreal& rhs); static bool lessThanBSRectBottom(const ChatLine::Ptr& lhs, const qreal& rhs); - static bool lessThanRowIndex(const ChatLine::Ptr& lhs, const ChatLine::Ptr& rhs); protected: friend class ChatLog; @@ -103,7 +101,6 @@ protected: void addColumn(ChatLineContent* item, ColumnFormat fmt); void updateBBox(); - void setRow(int idx); void visibilityChanged(bool visible); private: diff --git a/src/chatlog/chatlinecontent.cpp b/src/chatlog/chatlinecontent.cpp index d07733fc9..b1dc3e207 100644 --- a/src/chatlog/chatlinecontent.cpp +++ b/src/chatlog/chatlinecontent.cpp @@ -30,11 +30,6 @@ int ChatLineContent::getColumn() const return col; } -int ChatLineContent::getRow() const -{ - return row; -} - int ChatLineContent::type() const { return GraphicsItemType::ChatLineContentType; diff --git a/src/chatlog/chatlinecontent.h b/src/chatlog/chatlinecontent.h index c148cae82..dca2b796a 100644 --- a/src/chatlog/chatlinecontent.h +++ b/src/chatlog/chatlinecontent.h @@ -35,7 +35,6 @@ public: }; int getColumn() const; - int getRow() const; virtual void setWidth(qreal width) = 0; int type() const final; diff --git a/src/chatlog/chatlog.cpp b/src/chatlog/chatlog.cpp index ce274e83d..8ee603636 100644 --- a/src/chatlog/chatlog.cpp +++ b/src/chatlog/chatlog.cpp @@ -932,13 +932,6 @@ void ChatLog::checkVisibility() visibleLines = newVisibleLines; - // enforce order - std::sort(visibleLines.begin(), visibleLines.end(), ChatLine::lessThanRowIndex); - - // if (!visibleLines.empty()) - // qDebug() << "visible from " << visibleLines.first()->getRow() << "to " << - // visibleLines.last()->getRow() << " total " << visibleLines.size(); - if (!visibleLines.isEmpty()) { emit firstVisibleLineChanged(lastLineBeforeVisible, visibleLines.at(0)); }