forked from blue/squawk
qt6 build
This commit is contained in:
parent
a04693e39d
commit
d4cec645b5
35 changed files with 279 additions and 632 deletions
|
@ -141,7 +141,15 @@ void FeedView::updateGeometries() {
|
|||
const QStyle* st = style();
|
||||
|
||||
QSize layoutBounds = maximumViewportSize();
|
||||
QStyleOptionViewItem option = viewOptions();
|
||||
|
||||
|
||||
QStyleOptionViewItem option;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
initViewItemOption(&option);
|
||||
#else
|
||||
option = viewOptions();
|
||||
#endif
|
||||
|
||||
option.rect.setHeight(maxMessageHeight);
|
||||
option.rect.setWidth(layoutBounds.width());
|
||||
int frameAroundContents = 0;
|
||||
|
@ -182,7 +190,7 @@ void FeedView::updateGeometries() {
|
|||
previousOffset += elementMargin;
|
||||
}
|
||||
lastDate = currentDate;
|
||||
QSize messageSize = itemDelegate(index)->sizeHint(option, index);
|
||||
QSize messageSize = itemDelegateForIndex(index)->sizeHint(option, index);
|
||||
uint32_t offsetX(0);
|
||||
if (specialDelegate) {
|
||||
if (index.data(Models::MessageFeed::SentByMe).toBool())
|
||||
|
@ -232,7 +240,7 @@ bool FeedView::tryToCalculateGeometriesWithNoScrollbars(const QStyleOptionViewIt
|
|||
previousOffset += elementMargin;
|
||||
}
|
||||
lastDate = currentDate;
|
||||
QSize messageSize = itemDelegate(index)->sizeHint(option, index);
|
||||
QSize messageSize = itemDelegateForIndex(index)->sizeHint(option, index);
|
||||
|
||||
if (previousOffset + messageSize.height() + elementMargin > totalHeight)
|
||||
return false;
|
||||
|
@ -288,8 +296,14 @@ void FeedView::paintEvent(QPaintEvent* event) {
|
|||
}
|
||||
}
|
||||
|
||||
QStyleOptionViewItem option;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
initViewItemOption(&option);
|
||||
#else
|
||||
option = viewOptions();
|
||||
#endif
|
||||
|
||||
QPainter painter(vp);
|
||||
QStyleOptionViewItem option = viewOptions();
|
||||
option.features = QStyleOptionViewItem::WrapText;
|
||||
QPoint cursor = vp->mapFromGlobal(QCursor::pos());
|
||||
|
||||
|
@ -319,7 +333,7 @@ void FeedView::paintEvent(QPaintEvent* event) {
|
|||
stripe.setWidth(viewportRect.width());
|
||||
bool mouseOver = stripe.contains(cursor) && viewportRect.contains(cursor);
|
||||
option.state.setFlag(QStyle::State_MouseOver, mouseOver);
|
||||
itemDelegate(index)->paint(&painter, option, index);
|
||||
itemDelegateForIndex(index)->paint(&painter, option, index);
|
||||
|
||||
if (!lastDate.isNull() && currentDate.daysTo(lastDate) > 0)
|
||||
drawDateDevider(option.rect.bottom(), lastDate, painter);
|
||||
|
@ -380,7 +394,7 @@ void FeedView::mouseMoveEvent(QMouseEvent* event) {
|
|||
if (!isVisible())
|
||||
return;
|
||||
|
||||
dragEndPoint = event->localPos().toPoint();
|
||||
dragEndPoint = event->position().toPoint();
|
||||
if (mousePressed) {
|
||||
QPoint distance = dragStartPoint - dragEndPoint;
|
||||
if (distance.manhattanLength() > 5)
|
||||
|
@ -423,7 +437,7 @@ void FeedView::mousePressEvent(QMouseEvent* event) {
|
|||
|
||||
mousePressed = event->button() == Qt::LeftButton;
|
||||
if (mousePressed) {
|
||||
dragStartPoint = event->localPos().toPoint();
|
||||
dragStartPoint = event->position().toPoint();
|
||||
if (specialDelegate && specialModel) {
|
||||
MessageDelegate* del = static_cast<MessageDelegate*>(itemDelegate());
|
||||
QString lastSelectedId = del->clearSelection();
|
||||
|
@ -441,7 +455,7 @@ void FeedView::mouseDoubleClickEvent(QMouseEvent* event) {
|
|||
QAbstractItemView::mouseDoubleClickEvent(event);
|
||||
mousePressed = event->button() == Qt::LeftButton;
|
||||
if (mousePressed) {
|
||||
dragStartPoint = event->localPos().toPoint();
|
||||
dragStartPoint = event->position().toPoint();
|
||||
if (specialDelegate && specialModel) {
|
||||
MessageDelegate* del = static_cast<MessageDelegate*>(itemDelegate());
|
||||
QString lastSelectedId = del->clearSelection();
|
||||
|
@ -469,7 +483,7 @@ void FeedView::mouseReleaseEvent(QMouseEvent* event) {
|
|||
|
||||
if (mousePressed) {
|
||||
if (!dragging && specialDelegate) {
|
||||
QPoint point = event->localPos().toPoint();
|
||||
QPoint point = event->position().toPoint();
|
||||
QModelIndex index = indexAt(point);
|
||||
if (index.isValid()) {
|
||||
QRect rect = visualRect(index);
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FEEDVIEW_H
|
||||
#define FEEDVIEW_H
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractItemView>
|
||||
#include <QDesktopServices>
|
||||
|
@ -30,11 +29,7 @@
|
|||
#include <ui/utils/progress.h>
|
||||
#include <shared/utils.h>
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class FeedView : public QAbstractItemView
|
||||
{
|
||||
class FeedView : public QAbstractItemView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FeedView(QWidget* parent = nullptr);
|
||||
|
@ -111,5 +106,3 @@ private:
|
|||
static const std::set<int> geometryChangingRoles;
|
||||
|
||||
};
|
||||
|
||||
#endif //FEEDVIEW_H
|
||||
|
|
|
@ -659,7 +659,7 @@ QLabel * MessageDelegate::getStatusIcon(const Models::FeedItem& data) const {
|
|||
QIcon q(Shared::icon(Shared::messageStateThemeIcons[static_cast<uint8_t>(data.state)]));
|
||||
QString tt = Shared::Global::getName(data.state);
|
||||
if (data.state == Shared::Message::State::error) {
|
||||
if (data.error > 0)
|
||||
if (data.error.size() > 0)
|
||||
tt += ": " + data.error;
|
||||
}
|
||||
if (result->toolTip() != tt) { //If i just assign pixmap every time unconditionally
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue