Files
qt-creator/src/plugins/debugger/watchwindow.h
David Schulz 15e56078b6 Debugger: Improve keyboard navigation in locals view
Expanding items in the locals view results in replacing the original
tree item with a newly created one. This ultimately resets the selection
and the current item of the view, which in turn makes it cumbersome to
navigate by keyboard.

Save a list of selected inames and the iname of the current index when
requesting the update and try to reselect them after the update
finished.

Fixes: QTCREATORBUG-27569
Change-Id: I9d8f51631e4ee490e19307877cbef44798506016
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-04-30 10:56:02 +00:00

56 lines
1.4 KiB
C++

// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <utils/basetreeview.h>
#include <QTimer>
namespace Debugger {
namespace Internal {
enum WatchType { LocalsType, InspectType, WatchersType, ReturnType, TooltipType };
class WatchTreeView : public Utils::BaseTreeView
{
Q_OBJECT
public:
explicit WatchTreeView(WatchType type);
WatchType type() const { return m_type; }
void setModel(QAbstractItemModel *model) override;
void reset() override;
static void reexpand(QTreeView *view, const QModelIndex &idx);
void watchExpression(const QString &exp);
void watchExpression(const QString &exp, const QString &name);
void handleItemIsExpanded(const QModelIndex &idx);
void handleUpdateStarted();
void handleUpdateFinished();
signals:
void currentIndexChanged(const QModelIndex &currentIndex);
private:
void resetHelper();
void expandNode(const QModelIndex &idx);
void collapseNode(const QModelIndex &idx);
void updateTimeColumn();
void adjustSlider();
void doItemsLayout() override;
void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
WatchType m_type;
int m_sliderPosition = 0;
QStringList m_selectedInames;
QString m_currentIname;
QTimer m_progressDelayTimer;
};
} // namespace Internal
} // namespace Debugger