File: logtreeview.h

package info (click to toggle)
deepin-log-viewer 6.5.8%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 14,752 kB
  • sloc: cpp: 61,723; ansic: 1,732; xml: 81; sh: 59; makefile: 12
file content (45 lines) | stat: -rw-r--r-- 1,458 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-FileCopyrightText: 2019 - 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef LOGTREEVIEW_H
#define LOGTREEVIEW_H

#include <DTreeView>
#include <QTime>

class QKeyEvent;
class LogViewHeaderView;
class LogViewItemDelegate;
class QTime;
class LogTreeView : public Dtk::Widget::DTreeView
{
public:
    explicit LogTreeView(QWidget *parent = nullptr);
    int singleRowHeight();
protected:
    void initUI();
    void paintEvent(QPaintEvent *event) override;
    void drawRow(QPainter *painter, const QStyleOptionViewItem &options,
                 const QModelIndex &index) const override;
    void keyPressEvent(QKeyEvent *event) override;
    bool event(QEvent *e) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
    void focusInEvent(QFocusEvent *event)override;

private:
    LogViewItemDelegate *m_itemDelegate;
    LogViewHeaderView *m_headerDelegate;
    // 记录触摸按下事件,在mouse move事件中使用,用于判断手指移动的距离,当大于
    // QPlatformTheme::TouchDoubleTapDistance 的值时认为触发触屏滚动
    QPoint lastTouchBeginPos;
    QModelIndex mouseLastPressedIndex;
//    int touchTapDistance = -1;
    bool m_isPressed = false;
    QPointF m_lastTouchBeginPos;
    QTime m_lastTouchTime;
    Qt::FocusReason m_reson = Qt::MouseFocusReason;
};

#endif  // LOGTREEVIEW_H