2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef DEBUGGER_WATCHHANDLER_H
|
|
|
|
|
#define DEBUGGER_WATCHHANDLER_H
|
|
|
|
|
|
2010-04-26 18:54:08 +02:00
|
|
|
#include "watchdata.h"
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QPointer>
|
|
|
|
|
#include <QtCore/QHash>
|
|
|
|
|
#include <QtCore/QSet>
|
2010-06-25 09:07:14 +02:00
|
|
|
#include <QtCore/QStringList>
|
2009-12-09 16:27:34 +01:00
|
|
|
#include <QtCore/QAbstractItemModel>
|
2009-08-12 11:21:44 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Debugger {
|
2010-09-13 13:30:35 +02:00
|
|
|
class DebuggerEngine;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
class WatchItem;
|
2009-06-17 16:00:03 +02:00
|
|
|
class WatchHandler;
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
enum WatchType
|
2009-06-24 12:31:09 +02:00
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
ReturnWatch,
|
|
|
|
|
LocalsWatch,
|
|
|
|
|
WatchersWatch,
|
|
|
|
|
TooltipsWatch
|
2009-06-24 12:31:09 +02:00
|
|
|
};
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-07-06 10:44:08 +02:00
|
|
|
enum IntegerFormat
|
|
|
|
|
{
|
2010-03-12 11:14:50 +01:00
|
|
|
DecimalFormat = 0, // Keep that at 0 as default.
|
2009-07-06 10:44:08 +02:00
|
|
|
HexadecimalFormat,
|
|
|
|
|
BinaryFormat,
|
2010-12-16 12:05:48 +01:00
|
|
|
OctalFormat
|
2009-07-06 10:44:08 +02:00
|
|
|
};
|
|
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
class WatchModel : public QAbstractItemModel
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2009-07-10 14:36:28 +02:00
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
private:
|
|
|
|
|
explicit WatchModel(WatchHandler *handler, WatchType type);
|
2009-11-04 17:11:35 +01:00
|
|
|
virtual ~WatchModel();
|
2009-07-13 09:11:07 +02:00
|
|
|
|
2010-03-22 13:41:10 +01:00
|
|
|
public:
|
2011-02-11 15:00:13 +01:00
|
|
|
virtual int rowCount(const QModelIndex &idx = QModelIndex()) const;
|
|
|
|
|
virtual int columnCount(const QModelIndex &idx) const;
|
2010-03-22 13:41:10 +01:00
|
|
|
|
|
|
|
|
private:
|
2009-07-13 09:11:07 +02:00
|
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
|
|
|
|
QModelIndex index(int, int, const QModelIndex &idx) const;
|
|
|
|
|
QModelIndex parent(const QModelIndex &idx) const;
|
|
|
|
|
bool hasChildren(const QModelIndex &idx) const;
|
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &idx) const;
|
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation,
|
|
|
|
|
int role = Qt::DisplayRole) const;
|
|
|
|
|
bool canFetchMore(const QModelIndex &parent) const;
|
|
|
|
|
void fetchMore(const QModelIndex &parent);
|
|
|
|
|
|
|
|
|
|
friend class WatchHandler;
|
2009-06-24 12:31:09 +02:00
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
WatchItem *watchItem(const QModelIndex &) const;
|
|
|
|
|
QModelIndex watchIndex(const WatchItem *needle) const;
|
|
|
|
|
QModelIndex watchIndexHelper(const WatchItem *needle,
|
|
|
|
|
const WatchItem *parentItem, const QModelIndex &parentIndex) const;
|
|
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
void insertData(const WatchData &data);
|
2009-07-13 12:28:47 +02:00
|
|
|
void insertBulkData(const QList<WatchData> &data);
|
2010-01-05 16:51:55 +01:00
|
|
|
WatchItem *findItem(const QByteArray &iname, WatchItem *root) const;
|
2009-06-17 16:00:03 +02:00
|
|
|
void reinitialize();
|
2009-07-13 09:11:07 +02:00
|
|
|
void removeOutdated();
|
|
|
|
|
void removeOutdatedHelper(WatchItem *item);
|
2009-07-13 11:25:05 +02:00
|
|
|
WatchItem *rootItem() const;
|
2009-11-04 17:11:35 +01:00
|
|
|
void destroyItem(WatchItem *item);
|
2009-06-17 16:00:03 +02:00
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
void emitDataChanged(int column,
|
|
|
|
|
const QModelIndex &parentIndex = QModelIndex());
|
2010-03-09 17:37:36 +01:00
|
|
|
void beginCycle(); // Called at begin of updateLocals() cycle.
|
|
|
|
|
void endCycle(); // Called after all results have been received.
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2009-08-12 11:21:44 +02:00
|
|
|
friend QDebug operator<<(QDebug d, const WatchModel &m);
|
2009-08-31 09:14:04 +02:00
|
|
|
|
|
|
|
|
void dump();
|
|
|
|
|
void dumpHelper(WatchItem *item);
|
2009-11-25 08:35:02 +01:00
|
|
|
void emitAllChanged();
|
|
|
|
|
|
2009-08-31 09:14:04 +02:00
|
|
|
signals:
|
|
|
|
|
void enableUpdates(bool);
|
|
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
private:
|
2010-09-24 10:35:22 +02:00
|
|
|
QString displayType(const WatchData &typeIn) const;
|
2010-03-11 18:55:52 +01:00
|
|
|
void formatRequests(QByteArray *out, const WatchItem *item) const;
|
2010-06-16 11:08:54 +02:00
|
|
|
DebuggerEngine *engine() const;
|
2010-09-22 17:30:22 +02:00
|
|
|
int itemFormat(const WatchData &data) const;
|
2009-11-25 08:35:02 +01:00
|
|
|
|
2009-07-10 14:36:28 +02:00
|
|
|
WatchHandler *m_handler;
|
2009-07-13 09:11:07 +02:00
|
|
|
WatchType m_type;
|
|
|
|
|
WatchItem *m_root;
|
2010-01-05 16:51:55 +01:00
|
|
|
QSet<QByteArray> m_fetchTriggered;
|
2009-06-17 16:00:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class WatchHandler : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2010-06-16 11:08:54 +02:00
|
|
|
explicit WatchHandler(DebuggerEngine *engine);
|
2009-06-17 16:00:03 +02:00
|
|
|
WatchModel *model(WatchType type) const;
|
2010-01-05 16:51:55 +01:00
|
|
|
WatchModel *modelForIName(const QByteArray &iname) const;
|
2009-06-17 16:00:03 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void cleanup();
|
2010-06-23 15:13:51 +02:00
|
|
|
void watchExpression(const QString &exp);
|
|
|
|
|
void removeWatchExpression(const QString &exp);
|
2011-01-14 17:28:37 +01:00
|
|
|
Q_SLOT void clearWatches();
|
2009-11-25 08:35:02 +01:00
|
|
|
Q_SLOT void emitAllChanged();
|
2010-02-04 16:23:51 +01:00
|
|
|
|
2010-09-13 08:32:12 +02:00
|
|
|
void beginCycle(bool fullCycle = true); // Called at begin of updateLocals() cycle
|
2010-03-09 17:37:36 +01:00
|
|
|
void updateWatchers(); // Called after locals are fetched
|
2010-09-13 08:32:12 +02:00
|
|
|
void endCycle(bool fullCycle = true); // Called after all results have been received
|
2009-06-17 16:00:03 +02:00
|
|
|
void showEditValue(const WatchData &data);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
void insertData(const WatchData &data);
|
2009-07-13 12:28:47 +02:00
|
|
|
void insertBulkData(const QList<WatchData> &data);
|
2010-01-05 16:51:55 +01:00
|
|
|
void removeData(const QByteArray &iname);
|
2010-11-22 17:06:08 +01:00
|
|
|
|
|
|
|
|
const WatchData *watchData(WatchType type, const QModelIndex &) const;
|
|
|
|
|
const WatchData *findItem(const QByteArray &iname) const;
|
|
|
|
|
QModelIndex itemIndex(const QByteArray &iname) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-11-23 13:44:37 +01:00
|
|
|
void loadSessionData();
|
|
|
|
|
void saveSessionData();
|
2010-09-15 19:02:12 +02:00
|
|
|
void removeTooltip();
|
2011-02-23 16:09:56 +01:00
|
|
|
void rebuildModel();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-01-05 16:51:55 +01:00
|
|
|
bool isExpandedIName(const QByteArray &iname) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{ return m_expandedINames.contains(iname); }
|
2010-01-05 16:51:55 +01:00
|
|
|
QSet<QByteArray> expandedINames() const
|
2009-05-12 14:28:27 +02:00
|
|
|
{ return m_expandedINames; }
|
2010-11-04 18:11:09 +01:00
|
|
|
static QStringList watchedExpressions();
|
|
|
|
|
static QHash<QByteArray, int> watcherNames()
|
2009-12-04 13:36:14 +01:00
|
|
|
{ return m_watcherNames; }
|
2010-04-27 08:53:18 +02:00
|
|
|
|
|
|
|
|
QByteArray expansionRequests() const;
|
|
|
|
|
QByteArray typeFormatRequests() const;
|
|
|
|
|
QByteArray individualFormatRequests() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-11 18:55:52 +01:00
|
|
|
int format(const QByteArray &iname) const;
|
2009-06-18 10:34:53 +02:00
|
|
|
|
2010-09-01 19:02:56 +02:00
|
|
|
void addTypeFormats(const QByteArray &type, const QStringList &formats);
|
2010-06-25 09:07:14 +02:00
|
|
|
|
2011-08-03 14:36:07 +02:00
|
|
|
void setUnprintableBase(int base);
|
|
|
|
|
static int unprintableBase();
|
2011-02-17 19:00:33 +01:00
|
|
|
|
2010-06-25 14:08:53 +02:00
|
|
|
QByteArray watcherName(const QByteArray &exp);
|
2010-11-04 18:11:09 +01:00
|
|
|
void synchronizeWatchers();
|
2010-11-05 19:38:40 +01:00
|
|
|
QString editorContents();
|
2010-06-25 14:08:53 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2009-07-13 09:11:07 +02:00
|
|
|
friend class WatchModel;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-11-23 13:44:37 +01:00
|
|
|
void saveWatchers();
|
2010-11-04 18:11:09 +01:00
|
|
|
static void loadTypeFormats();
|
|
|
|
|
static void saveTypeFormats();
|
2008-12-17 17:43:01 +01:00
|
|
|
|
2010-09-01 19:02:56 +02:00
|
|
|
void setFormat(const QByteArray &type, int format);
|
2010-06-16 11:08:54 +02:00
|
|
|
void updateWatchersWindow();
|
2010-09-08 09:09:09 +02:00
|
|
|
void showInEditorHelper(QString *contents, WatchItem *item, int level);
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
bool m_inChange;
|
|
|
|
|
|
2010-03-15 17:44:56 +01:00
|
|
|
// QWidgets and QProcesses taking care of special displays.
|
|
|
|
|
typedef QMap<QString, QPointer<QObject> > EditHandlers;
|
|
|
|
|
EditHandlers m_editHandlers;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-11-04 18:11:09 +01:00
|
|
|
static QHash<QByteArray, int> m_watcherNames;
|
|
|
|
|
static QHash<QByteArray, int> m_typeFormats;
|
2010-06-25 09:07:14 +02:00
|
|
|
QHash<QByteArray, int> m_individualFormats; // Indexed by iname.
|
|
|
|
|
QHash<QString, QStringList> m_reportedTypeFormats;
|
2010-03-15 17:44:56 +01:00
|
|
|
|
|
|
|
|
// Items expanded in the Locals & Watchers view.
|
2010-07-22 15:34:35 +02:00
|
|
|
QSet<QByteArray> m_expandedINames;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-05-19 12:00:01 +02:00
|
|
|
WatchModel *m_return;
|
2009-07-13 09:11:07 +02:00
|
|
|
WatchModel *m_locals;
|
|
|
|
|
WatchModel *m_watchers;
|
|
|
|
|
WatchModel *m_tooltips;
|
2010-06-16 11:08:54 +02:00
|
|
|
DebuggerEngine *m_engine;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
|
|
|
|
#endif // DEBUGGER_WATCHHANDLER_H
|