Commit b8d5f256 authored by hjk's avatar hjk
Browse files

debugger: add missing 'Use full path' toggle in recently added 'Add Breakpoints' dialog

Reviewed-by: Friedemann Kleint
parent 19638d3d
......@@ -285,6 +285,9 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
const BreakpointData *data = at(mi.row());
if (role == BreakpointRole)
return qulonglong(data);
if (role == BreakpointUseFullPathRole)
return data->useFullPath;
......@@ -502,6 +505,15 @@ bool BreakHandler::setData(const QModelIndex &index, const QVariant &value, int
return false;
}
void BreakHandler::reinsertBreakpoint(BreakpointData *data)
{
// FIXME: Use some more direct method?
appendBreakpoint(data->clone());
removeBreakpoint(data);
m_engine->attemptBreakpointSynchronization();
emit layoutChanged();
}
void BreakHandler::append(BreakpointData *data)
{
data->m_handler = this;
......
......@@ -66,7 +66,6 @@ public:
BreakpointData *at(int index) const;
int size() const { return m_bp.size(); }
bool hasPendingBreakpoints() const;
void append(BreakpointData *data);
void removeAt(int index); // This also deletes the marker.
void clear(); // This also deletes all the marker.
int indexOf(BreakpointData *data) { return m_bp.indexOf(data); }
......@@ -99,6 +98,7 @@ public:
public slots:
void appendBreakpoint(BreakpointData *data);
void reinsertBreakpoint(BreakpointData *data);
void toggleBreakpointEnabled(BreakpointData *data);
void breakByFunction(const QString &functionName);
void removeBreakpoint(int index);
......@@ -119,6 +119,7 @@ private:
void loadBreakpoints();
void saveBreakpoints();
void removeBreakpointHelper(int index);
void append(BreakpointData *data);
const QIcon m_breakpointIcon;
const QIcon m_disabledBreakpointIcon;
......
......@@ -364,6 +364,12 @@ bool BreakpointData::conditionsMatch() const
return s1 == s2;
}
void BreakpointData::reinsertBreakpoint()
{
QTC_ASSERT(m_handler, return);
m_handler->reinsertBreakpoint(this);
}
} // namespace Internal
} // namespace Debugger
......
......@@ -56,6 +56,7 @@ public:
void updateMarker();
QString toToolTip() const;
BreakHandler *handler() { return m_handler; }
void reinsertBreakpoint();
bool isLocatedAt(const QString &fileName, int lineNumber,
bool useMarkerPosition) const;
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>382</width>
<height>280</height>
<height>302</height>
</rect>
</property>
<property name="windowTitle">
......@@ -46,55 +46,69 @@
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditLineNumber"/>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkBoxUseFullPath">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelUseFullPath">
<property name="text">
<string>Use full path:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelFunction">
<widget class="QLabel" name="labelAddress">
<property name="text">
<string>Function:</string>
<string>Address:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditFunction"/>
<widget class="QLineEdit" name="lineEditAddress"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="labelCondition">
<widget class="QLabel" name="labelFunction">
<property name="text">
<string>Condition:</string>
<string>Function:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditCondition"/>
<widget class="QLineEdit" name="lineEditFunction"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelIgnoreCount">
<widget class="QLabel" name="labelCondition">
<property name="text">
<string>Ignore count:</string>
<string>Condition:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lineEditIgnoreCount"/>
<widget class="QLineEdit" name="lineEditCondition"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="labelThreadSpec">
<widget class="QLabel" name="labelIgnoreCount">
<property name="text">
<string>Thread specification:</string>
<string>Ignore count:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="lineEditThreadSpec"/>
<widget class="QLineEdit" name="lineEditIgnoreCount"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelAddress">
<item row="8" column="0">
<widget class="QLabel" name="labelThreadSpec">
<property name="text">
<string>Address:</string>
<string>Thread specification:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEditAddress"/>
<item row="8" column="1">
<widget class="QLineEdit" name="lineEditThreadSpec"/>
</item>
</layout>
</item>
......
......@@ -64,7 +64,7 @@ class BreakpointDialog : public QDialog, public Ui::BreakpointDialog
{
Q_OBJECT
public:
explicit BreakpointDialog(QWidget *parent)
explicit BreakpointDialog(QWidget *parent, BreakpointData *data)
: QDialog(parent)
{
setupUi(this);
......@@ -72,8 +72,21 @@ public:
comboBoxType->insertItem(1, tr("Function Name"));
comboBoxType->insertItem(2, tr("Function \"main()\""));
comboBoxType->insertItem(3, tr("Address"));
connect(comboBoxType, SIGNAL(activated(int)),
SLOT(typeChanged(int)));
lineEditFileName->setText(data->fileName);
lineEditLineNumber->setText(QByteArray::number(data->lineNumber));
lineEditFunction->setText(data->funcName);
lineEditCondition->setText(data->condition);
lineEditIgnoreCount->setText(QByteArray::number(data->ignoreCount));
checkBoxUseFullPath->setChecked(data->useFullPath);
if (data->address)
lineEditAddress->setText("0x" + QByteArray::number(data->address, 16));
int initialType = 0;
if (!data->funcName.isEmpty())
initialType = lineEditFunction->text() == "main" ? 2 : 1;
if (data->address)
initialType = 3;
typeChanged(initialType);
connect(comboBoxType, SIGNAL(activated(int)), SLOT(typeChanged(int)));
}
public slots:
......@@ -86,6 +99,8 @@ public slots:
lineEditFileName->setEnabled(isLineVisible);
labelLineNumber->setEnabled(isLineVisible);
lineEditLineNumber->setEnabled(isLineVisible);
labelUseFullPath->setEnabled(isLineVisible);
checkBoxUseFullPath->setEnabled(isLineVisible);
labelFunction->setEnabled(isFunctionVisible);
lineEditFunction->setEnabled(isFunctionVisible);
labelAddress->setEnabled(isAddressVisible);
......@@ -279,16 +294,13 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
pathAction->setEnabled(si.size() > 0);
QAction *addBreakpointAction =
new QAction(tr("Set Breakpoint..."), this);
//QAction *breakAtFunctionAction =
// new QAction(tr("Set Breakpoint at Function..."), this);
//QAction *breakAtMainAction =
// new QAction(tr("Set Breakpoint at Function \"main\""), this);
new QAction(tr("Add Breakpoint..."), this);
QAction *breakAtThrowAction =
new QAction(tr("Set Breakpoint at \"throw\""), this);
QAction *breakAtCatchAction =
new QAction(tr("Set Breakpoint at \"catch\""), this);
menu.addAction(addBreakpointAction);
menu.addAction(deleteAction);
menu.addAction(editBreakpointAction);
menu.addAction(associateBreakpointAction);
......@@ -299,11 +311,8 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
menu.addAction(deleteByFileAction);
menu.addSeparator();
menu.addAction(synchronizeAction);
menu.addSeparator();
//menu.addAction(breakAtFunctionAction);
//menu.addAction(breakAtMainAction);
menu.addAction(addBreakpointAction);
if (engineCapabilities & BreakOnThrowAndCatchCapability) {
menu.addSeparator();
menu.addAction(breakAtThrowAction);
menu.addAction(breakAtCatchAction);
}
......@@ -392,41 +401,58 @@ void BreakWindow::deleteBreakpoints(QList<int> list)
setModelData(RequestSynchronizeBreakpointsRole);
}
void BreakWindow::addBreakpoint()
bool BreakWindow::editBreakpoint(BreakpointData *data)
{
BreakpointDialog dialog(this);
BreakpointDialog dialog(this, data);
if (dialog.exec() == QDialog::Rejected)
return;
BreakpointData *data = new BreakpointData();
if (!dialog.lineEditAddress->text().isEmpty()) {
bool ok = false;
return false;
bool ok = false;
if (!dialog.lineEditAddress->text().isEmpty())
data->address = dialog.lineEditAddress->text().toULongLong(&ok, 0);
}
if (!dialog.lineEditFunction->text().isEmpty())
data->funcName = dialog.lineEditFunction->text();
if (!dialog.lineEditFunction->text().isEmpty())
data->funcName = dialog.lineEditFunction->text();
if (!dialog.lineEditFileName->text().isEmpty())
data->fileName = dialog.lineEditFileName->text();
if (!dialog.lineEditFileName->text().isEmpty())
data->fileName = dialog.lineEditFileName->text();
data->lineNumber = dialog.lineEditLineNumber->text().toInt();
data->useFullPath = dialog.checkBoxUseFullPath->isChecked();
if (!dialog.lineEditCondition->text().isEmpty())
data->condition = dialog.lineEditCondition->text().toUtf8();
if (!dialog.lineEditIgnoreCount->text().isEmpty())
data->ignoreCount = dialog.lineEditIgnoreCount->text().toInt();
if (!dialog.lineEditThreadSpec->text().isEmpty())
data->threadSpec = dialog.lineEditThreadSpec->text().toUtf8();
setModelData(RequestBreakpointRole, QVariant::fromValue(data));
return true;
}
void BreakWindow::addBreakpoint()
{
BreakpointData *data = new BreakpointData();
if (editBreakpoint(data))
setModelData(RequestBreakpointRole, QVariant::fromValue(data));
else
delete data;
}
void BreakWindow::editBreakpoints(const QModelIndexList &list)
{
if (list.size() == 1) {
QVariant var = model()->data(list.at(0), BreakpointRole);
BreakpointData *data = (BreakpointData *)var.toULongLong();
if (editBreakpoint(data))
data->reinsertBreakpoint();
return;
}
// This allows to change properties of multiple breakpoints at a time.
QDialog dlg(this);
Ui::BreakCondition ui;
ui.setupUi(&dlg);
QTC_ASSERT(!list.isEmpty(), return);
QModelIndex idx = list.front();
const int row = idx.row();
dlg.setWindowTitle(tr("Conditions on Breakpoint %1").arg(row));
dlg.setWindowTitle(tr("Edit Breakpoint Properties"));
ui.lineEditFunction->hide();
ui.labelFunction->hide();
ui.lineEditFileName->hide();
......@@ -436,7 +462,8 @@ void BreakWindow::editBreakpoints(const QModelIndexList &list)
QAbstractItemModel *m = model();
ui.lineEditCondition->setText(
m->data(idx, BreakpointConditionRole).toString());
ui.lineEditIgnoreCount->setValidator(new QIntValidator(0, 2147483647, ui.lineEditIgnoreCount));
ui.lineEditIgnoreCount->setValidator(
new QIntValidator(0, 2147483647, ui.lineEditIgnoreCount));
ui.lineEditIgnoreCount->setText(
m->data(idx, BreakpointIgnoreCountRole).toString());
ui.lineEditThreadSpec->setText(
......
......@@ -62,6 +62,7 @@ private:
void deleteBreakpoints(const QModelIndexList &list);
void deleteBreakpoints(QList<int> rows);
void addBreakpoint();
bool editBreakpoint(BreakpointData *data); // Returns 'Accept'.
void editBreakpoints(const QModelIndexList &list);
void associateBreakpoint(const QModelIndexList &list, int thread);
void setBreakpointsEnabled(const QModelIndexList &list, bool enabled);
......
......@@ -204,6 +204,7 @@ enum ModelRoles
RequestExecuteCommandRole,
// Breakpoints
BreakpointRole,
BreakpointEnabledRole,
BreakpointUseFullPathRole,
BreakpointFunctionNameRole,
......
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