mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
cleanup
This commit is contained in:
parent
29fc6ab03f
commit
fb0c372c81
|
@ -207,14 +207,12 @@ void ChatLog::partialUpdate()
|
|||
checkVisibility();
|
||||
|
||||
setViewportUpdateMode(oldUpdateMode);
|
||||
updateSceneRect();
|
||||
}
|
||||
|
||||
void ChatLog::fullUpdate()
|
||||
{
|
||||
layout(0, lines.size(), useableWidth());
|
||||
checkVisibility();
|
||||
updateSceneRect();
|
||||
}
|
||||
|
||||
void ChatLog::mousePressEvent(QMouseEvent* ev)
|
||||
|
@ -292,10 +290,8 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
|
|||
}
|
||||
}
|
||||
|
||||
if(selectionMode != None && ev->pos() != lastPos)
|
||||
if(selectionMode != None)
|
||||
{
|
||||
lastPos = ev->pos();
|
||||
|
||||
ChatLineContent* content = getContentFromPos(scenePos);
|
||||
|
||||
if(content)
|
||||
|
@ -355,7 +351,7 @@ ChatLineContent* ChatLog::getContentFromPos(QPointF scenePos) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool ChatLog::isOverSelection(QPointF scenePos)
|
||||
bool ChatLog::isOverSelection(QPointF scenePos) const
|
||||
{
|
||||
if(selectionMode == Precise)
|
||||
{
|
||||
|
@ -373,7 +369,7 @@ bool ChatLog::isOverSelection(QPointF scenePos)
|
|||
return false;
|
||||
}
|
||||
|
||||
qreal ChatLog::useableWidth()
|
||||
qreal ChatLog::useableWidth() const
|
||||
{
|
||||
return width() - verticalScrollBar()->sizeHint().width() - margins.right() - margins.left();
|
||||
}
|
||||
|
@ -398,11 +394,11 @@ void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l)
|
|||
if(!l.get())
|
||||
return;
|
||||
|
||||
l->addToScene(scene);
|
||||
|
||||
stickToBtm = stickToBottom();
|
||||
bool stickToBtm = stickToBottom();
|
||||
|
||||
//insert
|
||||
l->setRowIndex(lines.size());
|
||||
l->addToScene(scene);
|
||||
lines.append(l);
|
||||
|
||||
//partial refresh
|
||||
|
@ -420,6 +416,8 @@ void ChatLog::insertChatlineOnTop(ChatLine::Ptr l)
|
|||
if(!l.get())
|
||||
return;
|
||||
|
||||
bool stickToBtm = stickToBottom();
|
||||
|
||||
//move all lines down by 1
|
||||
for(ChatLine::Ptr l : lines)
|
||||
l->setRowIndex(l->getRowIndex() + 1);
|
||||
|
@ -444,6 +442,8 @@ void ChatLog::insertChatlineOnTop(const QList<ChatLine::Ptr>& newLines)
|
|||
if(newLines.isEmpty())
|
||||
return;
|
||||
|
||||
bool stickToBtm = stickToBottom();
|
||||
|
||||
//move all lines down by n
|
||||
int n = newLines.size();
|
||||
for(ChatLine::Ptr l : lines)
|
||||
|
@ -467,16 +467,15 @@ void ChatLog::insertChatlineOnTop(const QList<ChatLine::Ptr>& newLines)
|
|||
checkVisibility();
|
||||
}
|
||||
|
||||
bool ChatLog::stickToBottom()
|
||||
bool ChatLog::stickToBottom() const
|
||||
{
|
||||
return verticalScrollBar()->value() == verticalScrollBar()->maximum();
|
||||
}
|
||||
|
||||
void ChatLog::scrollToBottom()
|
||||
{
|
||||
updateSceneRect();
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
updateGeometry();
|
||||
checkVisibility();
|
||||
}
|
||||
|
||||
QString ChatLog::getSelectedText() const
|
||||
|
@ -581,6 +580,8 @@ void ChatLog::checkVisibility()
|
|||
if(lines.empty())
|
||||
return;
|
||||
|
||||
updateSceneRect();
|
||||
|
||||
// find first visible row
|
||||
QVector<ChatLine::Ptr>::const_iterator upperBound;
|
||||
upperBound = std::upper_bound(lines.cbegin(), lines.cend(), getVisibleRect().top(), [](const qreal lhs, const ChatLine::Ptr rhs)
|
||||
|
|
|
@ -58,10 +58,10 @@ protected:
|
|||
ChatLineContent* getContentFromPos(QPointF scenePos) const;
|
||||
|
||||
qreal layout(int start, int end, qreal width);
|
||||
bool isOverSelection(QPointF scenePos);
|
||||
bool stickToBottom();
|
||||
bool isOverSelection(QPointF scenePos) const;
|
||||
bool stickToBottom() const;
|
||||
|
||||
qreal useableWidth();
|
||||
qreal useableWidth() const;
|
||||
|
||||
void reposition(int start, int end, qreal deltaY);
|
||||
void updateSceneRect();
|
||||
|
@ -100,10 +100,6 @@ private:
|
|||
QList<ChatLine::Ptr> visibleLines;
|
||||
ChatLine::Ptr typingNotification;
|
||||
|
||||
bool multiLineInsert = false;
|
||||
bool stickToBtm = false;
|
||||
int insertStartIndex = -1;
|
||||
|
||||
// selection
|
||||
int selClickedRow = -1;
|
||||
int selClickedCol = -1;
|
||||
|
@ -111,7 +107,6 @@ private:
|
|||
int selLastRow = -1;
|
||||
SelectionMode selectionMode = None;
|
||||
QPointF clickPos;
|
||||
QPointF lastPos;
|
||||
QGraphicsRectItem* selGraphItem = nullptr;
|
||||
QTimer* selectionTimer = nullptr;
|
||||
QTimer* workerTimer = nullptr;
|
||||
|
|
Loading…
Reference in New Issue
Block a user