Commit b7fe1e79 authored by hjk's avatar hjk

some refactoring: make watchExpression/removeWatchExpression symmetric

wrt arguments
parent 02a679d9
...@@ -62,24 +62,24 @@ BreakWindow::BreakWindow(QWidget *parent) ...@@ -62,24 +62,24 @@ BreakWindow::BreakWindow(QWidget *parent)
this, SLOT(rowActivated(QModelIndex))); this, SLOT(rowActivated(QModelIndex)));
} }
void BreakWindow::keyPressEvent(QKeyEvent *event) void BreakWindow::keyPressEvent(QKeyEvent *ev)
{ {
if (event->key() == Qt::Key_Delete) if (ev->key() == Qt::Key_Delete)
deleteBreakpoint(currentIndex()); deleteBreakpoint(currentIndex());
QTreeView::keyPressEvent(event); QTreeView::keyPressEvent(ev);
} }
void BreakWindow::resizeEvent(QResizeEvent *event) void BreakWindow::resizeEvent(QResizeEvent *ev)
{ {
QHeaderView *hv = header(); QHeaderView *hv = header();
int totalSize = event->size().width() - 180; int totalSize = ev->size().width() - 180;
hv->resizeSection(0, 60); hv->resizeSection(0, 60);
hv->resizeSection(1, (totalSize * 30) / 100); hv->resizeSection(1, (totalSize * 30) / 100);
hv->resizeSection(2, (totalSize * 30) / 100); hv->resizeSection(2, (totalSize * 30) / 100);
hv->resizeSection(3, (totalSize * 30) / 100); hv->resizeSection(3, (totalSize * 30) / 100);
hv->resizeSection(4, 70); hv->resizeSection(4, 70);
hv->resizeSection(5, 50); hv->resizeSection(5, 50);
QTreeView::resizeEvent(event); QTreeView::resizeEvent(ev);
} }
void BreakWindow::contextMenuEvent(QContextMenuEvent *ev) void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
......
...@@ -731,9 +731,9 @@ void DebuggerManager::collapseChildren(const QModelIndex &idx) ...@@ -731,9 +731,9 @@ void DebuggerManager::collapseChildren(const QModelIndex &idx)
watchHandler()->collapseChildren(idx); watchHandler()->collapseChildren(idx);
} }
void DebuggerManager::removeWatchExpression(const QString &iname) void DebuggerManager::removeWatchExpression(const QString &exp)
{ {
watchHandler()->removeWatchExpression(iname); watchHandler()->removeWatchExpression(exp);
} }
QVariant DebuggerManager::sessionValue(const QString &name) QVariant DebuggerManager::sessionValue(const QString &name)
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#include <ctype.h> #include <ctype.h>
// creates debug output regarding pending watch data results // creates debug output regarding pending watch data results
//#define DEBUG_PENDING 1 #define DEBUG_PENDING 1
// creates debug output for accesses to the itemmodel // creates debug output for accesses to the itemmodel
//#define DEBUG_MODEL 1 //#define DEBUG_MODEL 1
...@@ -964,12 +964,19 @@ void WatchHandler::showEditValue(const WatchData &data) ...@@ -964,12 +964,19 @@ void WatchHandler::showEditValue(const WatchData &data)
w->show(); w->show();
} }
void WatchHandler::removeWatchExpression(const QString &iname) void WatchHandler::removeWatchExpression(const QString &exp)
{ {
MODEL_DEBUG("REMOVE WATCH: " << iname); MODEL_DEBUG("REMOVE WATCH: " << iname);
WatchData data = takeData(iname); m_watchers.removeOne(exp);
m_watchers.removeOne(data.iname); for (int i = m_completeSet.size(); --i >= 0;) {
const WatchData & data = m_completeSet.at(i);
if (data.iname.startsWith("watch.") && data.exp == exp) {
m_completeSet.takeAt(i);
break;
}
}
saveWatchers(); saveWatchers();
rebuildModel();
emit watchModelUpdateRequested(); emit watchModelUpdateRequested();
} }
......
...@@ -87,6 +87,17 @@ void WatchWindow::collapseNode(const QModelIndex &idx) ...@@ -87,6 +87,17 @@ void WatchWindow::collapseNode(const QModelIndex &idx)
emit requestCollapseChildren(idx); emit requestCollapseChildren(idx);
} }
void WatchWindow::keyPressEvent(QKeyEvent *ev)
{
if (ev->key() == Qt::Key_Delete) {
QModelIndex idx = currentIndex();
QModelIndex idx1 = idx.sibling(idx.row(), 0);
QString exp = model()->data(idx1).toString();
emit requestRemoveWatchExpression(exp);
}
QTreeView::keyPressEvent(ev);
}
void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
{ {
QMenu menu; QMenu menu;
...@@ -103,7 +114,6 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) ...@@ -103,7 +114,6 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
QModelIndex idx = indexAt(ev->pos()); QModelIndex idx = indexAt(ev->pos());
QModelIndex mi0 = idx.sibling(idx.row(), 0); QModelIndex mi0 = idx.sibling(idx.row(), 0);
QString exp = model()->data(mi0).toString(); QString exp = model()->data(mi0).toString();
QString iname = model()->data(mi0, INameRole).toString();
QModelIndex mi1 = idx.sibling(idx.row(), 0); QModelIndex mi1 = idx.sibling(idx.row(), 0);
QString value = model()->data(mi1).toString(); QString value = model()->data(mi1).toString();
bool visual = false; bool visual = false;
...@@ -134,7 +144,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) ...@@ -134,7 +144,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
if (m_type == LocalsType) if (m_type == LocalsType)
emit requestWatchExpression(exp); emit requestWatchExpression(exp);
else else
emit requestRemoveWatchExpression(iname); emit requestRemoveWatchExpression(exp);
else if (act == act4) else if (act == act4)
model()->setData(mi0, !visual, VisualRole); model()->setData(mi0, !visual, VisualRole);
} }
......
...@@ -63,7 +63,7 @@ public slots: ...@@ -63,7 +63,7 @@ public slots:
signals: signals:
void requestWatchExpression(const QString &exp); void requestWatchExpression(const QString &exp);
void requestRemoveWatchExpression(const QString &iname); void requestRemoveWatchExpression(const QString &exp);
void requestAssignValue(const QString &exp, const QString &value); void requestAssignValue(const QString &exp, const QString &value);
void requestExpandChildren(const QModelIndex &idx); void requestExpandChildren(const QModelIndex &idx);
void requestCollapseChildren(const QModelIndex &idx); void requestCollapseChildren(const QModelIndex &idx);
...@@ -74,6 +74,7 @@ private slots: ...@@ -74,6 +74,7 @@ private slots:
void collapseNode(const QModelIndex &index); void collapseNode(const QModelIndex &index);
private: private:
void keyPressEvent(QKeyEvent *ev);
void contextMenuEvent(QContextMenuEvent *ev); void contextMenuEvent(QContextMenuEvent *ev);
void editItem(const QModelIndex &idx); void editItem(const QModelIndex &idx);
void reset(); /* reimpl */ void reset(); /* reimpl */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment