mirror of https://github.com/procxx/kepka.git
parent
0e41fbf5e4
commit
789570a9ec
|
@ -258,6 +258,7 @@ add_executable(Kepka WIN32 MACOSX_BUNDLE
|
|||
SourceFiles/core/utils.cpp
|
||||
|
||||
SourceFiles/data/data_abstract_structure.cpp
|
||||
SourceFiles/data/data_document.cpp
|
||||
SourceFiles/data/data_drafts.cpp
|
||||
SourceFiles/data/data_game.cpp
|
||||
SourceFiles/data/data_photo.cpp
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
//
|
||||
// This file is part of Kepka,
|
||||
// an unofficial desktop version of Telegram messaging app,
|
||||
// see https://github.com/procxx/kepka
|
||||
//
|
||||
// Kepka is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// It is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give permission
|
||||
// to link the code of portions of this program with the OpenSSL library.
|
||||
//
|
||||
// Full license: https://github.com/procxx/kepka/blob/master/LICENSE
|
||||
// Copyright (c) 2019- Kepka Contributors, https://github.com/procxx
|
||||
//
|
||||
/// @file data/data_document.cpp Implementation and internals (and Qt QFixed)
|
||||
/// @todo Get rid of QFixed.
|
||||
|
||||
#include "data/data_document.h"
|
||||
#include "private/qfixed_p.h"
|
||||
#include <QTextEdit>
|
||||
|
||||
void MessageCursor::fillFrom(const QTextEdit *edit) {
|
||||
QTextCursor c = edit->textCursor();
|
||||
position = c.position();
|
||||
anchor = c.anchor();
|
||||
QScrollBar *s = edit->verticalScrollBar();
|
||||
scroll = (s && (s->value() != s->maximum())) ? s->value() : QFIXED_MAX;
|
||||
}
|
||||
|
||||
const int MessageCursor::kMaxScroll = QFIXED_MAX;
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "scheme.h"
|
||||
|
||||
#include "private/qfixed_p.h" // QFIXED_MAX, warn: temporary, should be eliminated.
|
||||
class QTextEdit;
|
||||
|
||||
class HistoryItem;
|
||||
|
||||
|
@ -522,6 +522,7 @@ QString saveFileName(const QString &title, const QString &filter, const QString
|
|||
MsgId clientMsgId();
|
||||
|
||||
struct MessageCursor {
|
||||
static const int kMaxScroll;
|
||||
MessageCursor() = default;
|
||||
MessageCursor(int position, int anchor, int scroll)
|
||||
: position(position)
|
||||
|
@ -530,13 +531,7 @@ struct MessageCursor {
|
|||
MessageCursor(const QTextEdit *edit) {
|
||||
fillFrom(edit);
|
||||
}
|
||||
void fillFrom(const QTextEdit *edit) {
|
||||
QTextCursor c = edit->textCursor();
|
||||
position = c.position();
|
||||
anchor = c.anchor();
|
||||
QScrollBar *s = edit->verticalScrollBar();
|
||||
scroll = (s && (s->value() != s->maximum())) ? s->value() : QFIXED_MAX;
|
||||
}
|
||||
void fillFrom(const QTextEdit *edit);
|
||||
void applyTo(QTextEdit *edit) {
|
||||
auto cursor = edit->textCursor();
|
||||
cursor.setPosition(anchor, QTextCursor::MoveAnchor);
|
||||
|
@ -548,7 +543,7 @@ struct MessageCursor {
|
|||
}
|
||||
int position = 0;
|
||||
int anchor = 0;
|
||||
int scroll = QFIXED_MAX;
|
||||
int scroll = kMaxScroll;
|
||||
};
|
||||
|
||||
inline bool operator==(const MessageCursor &a, const MessageCursor &b) {
|
||||
|
|
Loading…
Reference in New Issue