watchwindow.h 3.59 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22 23 24 25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30 31 32
#ifndef DEBUGGER_WATCHWINDOW_H
#define DEBUGGER_WATCHWINDOW_H

33
#include "basewindow.h"
con's avatar
con committed
34

35
namespace Debugger {
con's avatar
con committed
36 37 38 39 40 41 42 43
namespace Internal {

/////////////////////////////////////////////////////////////////////
//
// WatchWindow
//
/////////////////////////////////////////////////////////////////////

44 45
enum WatchType { LocalsType, InspectType, WatchersType, ReturnType, TooltipType };

hjk's avatar
hjk committed
46
class WatchTreeView : public BaseTreeView
con's avatar
con committed
47 48 49 50 51
{
    Q_OBJECT

public:

52 53
    explicit WatchTreeView(WatchType type, QWidget *parent = 0);
    WatchType type() const { return m_type; }
hjk's avatar
hjk committed
54
    void setModel(QAbstractItemModel *model);
55
    void rowActivated(const QModelIndex &index);
hjk's avatar
hjk committed
56
    void reset();
57

hjk's avatar
hjk committed
58 59
    void fillFormatMenu(QMenu *, const QModelIndex &mi);

con's avatar
con committed
60
public slots:
61
    void watchExpression(const QString &exp);
62
    void watchExpression(const QString &exp, const QString &name);
hjk's avatar
hjk committed
63
    void handleItemIsExpanded(const QModelIndex &idx);
con's avatar
con committed
64

65 66 67
signals:
    void currentIndexChanged(const QModelIndex &currentIndex);

hjk's avatar
hjk committed
68 69 70 71 72 73 74 75
private slots:
    void resetHelper();
    void expandNode(const QModelIndex &idx);
    void collapseNode(const QModelIndex &idx);

    void onClearIndividualFormat();
    void onClearTypeFormat();
    void onShowUnprintable();
76

hjk's avatar
hjk committed
77 78 79 80
    void onTypeFormatChange();
    void onIndividualFormatChange();

private:
81
    void keyPressEvent(QKeyEvent *ev);
con's avatar
con committed
82
    void contextMenuEvent(QContextMenuEvent *ev);
83 84 85
    void dragEnterEvent(QDragEnterEvent *ev);
    void dropEvent(QDropEvent *ev);
    void dragMoveEvent(QDragMoveEvent *ev);
86
    void mouseDoubleClickEvent(QMouseEvent *ev);
87
    bool event(QEvent *ev);
88
    void currentChanged(const QModelIndex &current, const QModelIndex &previous);
89

con's avatar
con committed
90
    void editItem(const QModelIndex &idx);
hjk's avatar
hjk committed
91
    void resetHelper(const QModelIndex &idx);
con's avatar
con committed
92

93 94 95
    void setModelData(int role, const QVariant &value = QVariant(),
        const QModelIndex &index = QModelIndex());

96
    WatchType m_type;
97
    bool m_grabbing;
con's avatar
con committed
98 99
};

hjk's avatar
hjk committed
100 101
class WatchWindow : public BaseWindow
{
hjk's avatar
hjk committed
102 103
    Q_OBJECT

hjk's avatar
hjk committed
104
public:
105
    explicit WatchWindow(WatchType type)
hjk's avatar
hjk committed
106
        : BaseWindow(new WatchTreeView(type))
107 108 109
    {
        setWindowTitle(tr("Locals and Expressions"));
    }
hjk's avatar
hjk committed
110
};
con's avatar
con committed
111 112 113 114 115

} // namespace Internal
} // namespace Debugger

#endif // DEBUGGER_WATCHWINDOW_H