Commit 239e4ca5 authored by hjk's avatar hjk
Browse files

debugger: move toggleBreakpoint() from DebuggerManager to DebuggerPlugin

parent d4aed1ae
......@@ -707,11 +707,6 @@ void BreakHandler::toggleBreakpointEnabled(BreakpointData *data)
updateMarkers();
}
void BreakHandler::toggleBreakpointEnabled(const QString &fileName, int lineNumber)
{
toggleBreakpointEnabled(at(findBreakpoint(fileName, lineNumber)));
}
void BreakHandler::appendBreakpoint(BreakpointData *data)
{
append(data);
......
......@@ -159,7 +159,6 @@ public:
public slots:
void appendBreakpoint(BreakpointData *data);
void toggleBreakpointEnabled(BreakpointData *data);
void toggleBreakpointEnabled(const QString &fileName, int lineNumber);
void breakByFunction(const QString &functionName);
void activateBreakpoint(int index);
void removeBreakpoint(int index);
......
......@@ -566,8 +566,6 @@ void DebuggerManager::init()
this, SLOT(addToWatchWindow()));
connect(d->m_actions.watchAction2, SIGNAL(triggered()),
this, SLOT(addToWatchWindow()));
connect(d->m_actions.breakAction, SIGNAL(triggered()),
this, SLOT(toggleBreakpoint()));
connect(d->m_actions.snapshotAction, SIGNAL(triggered()),
this, SLOT(makeSnapshot()));
......@@ -889,16 +887,6 @@ BreakpointData *DebuggerManager::findBreakpoint(const QString &fileName, int lin
return index == -1 ? 0 : d->m_breakHandler->at(index);
}
void DebuggerManager::toggleBreakpoint()
{
ITextEditor *textEditor = d->m_plugin->currentTextEditor();
QTC_ASSERT(textEditor, return);
QString fileName = textEditor->file()->fileName();
int lineNumber = textEditor->currentLine();
if (lineNumber >= 0)
toggleBreakpoint(fileName, lineNumber);
}
// FIXME: move further up the plugin where there's more specific context
// information available.
static BreakpointData *createBreakpointByFileAndLine
......@@ -946,23 +934,6 @@ void DebuggerManager::toggleBreakpoint(const QString &fileName, int lineNumber)
attemptBreakpointSynchronization();
}
void DebuggerManager::toggleBreakpointEnabled(const QString &fileName, int lineNumber)
{
STATE_DEBUG(fileName << lineNumber);
QTC_ASSERT(d->m_breakHandler, return);
if (state() != InferiorRunning
&& state() != InferiorStopped
&& state() != DebuggerNotReady) {
showStatusMessage(tr("Changing breakpoint state requires either a "
"fully running or fully stopped application."));
return;
}
d->m_breakHandler->toggleBreakpointEnabled(fileName, lineNumber);
attemptBreakpointSynchronization();
}
void DebuggerManager::attemptBreakpointSynchronization()
{
if (d->m_engine)
......
......@@ -216,7 +216,6 @@ public slots:
void executeJumpToLine();
void executeRunToLine();
void executeRunToFunction();
void toggleBreakpoint();
void breakByFunction(const QString &functionName);
void breakByFunctionMain();
void activateFrame(int index);
......@@ -341,7 +340,6 @@ private:
void shutdown();
void toggleBreakpoint(const QString &fileName, int lineNumber);
void toggleBreakpointEnabled(const QString &fileName, int lineNumber);
Internal::BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
void setToolTipExpression(const QPoint &mousePos,
TextEditor::ITextEditor *editor, int cursorPos);
......
......@@ -890,6 +890,8 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
Constants::TOGGLE_BREAK, cppeditorcontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::TOGGLE_BREAK_KEY));
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
connect(actions.breakAction, SIGNAL(triggered()),
this, SLOT(toggleBreakpoint()));
//mcppcontext->addAction(cmd);
......@@ -1181,11 +1183,20 @@ void DebuggerPlugin::breakpointSetRemoveMarginActionTriggered()
void DebuggerPlugin::breakpointEnableDisableMarginActionTriggered()
{
if (QAction *act = qobject_cast<QAction *>(sender())) {
QString str = act->data().toString();
int pos = str.lastIndexOf(':');
m_manager->toggleBreakpointEnabled(str.left(pos), str.mid(pos + 1).toInt());
}
QAction *act = qobject_cast<QAction *>(sender());
QTC_ASSERT(act, return);
BreakHandler *handler = m_manager->breakHandler();
QTC_ASSERT(handler, return);
QString str = act->data().toString();
int pos = str.lastIndexOf(':');
QString fileName = str.left(pos);
int lineNumber = str.mid(pos + 1).toInt();
BreakpointData *data = handler->at(handler->findBreakpoint(fileName, lineNumber));
handler->toggleBreakpointEnabled(data);
m_manager->attemptBreakpointSynchronization();
}
void DebuggerPlugin::requestMark(ITextEditor *editor, int lineNumber)
......@@ -1487,6 +1498,16 @@ void DebuggerPlugin::enableReverseDebuggingTriggered(const QVariant &value)
m_manager->debuggerManagerActions().reverseDirectionAction->setChecked(false);
}
void DebuggerPlugin::toggleBreakpoint()
{
ITextEditor *textEditor = currentTextEditor();
QTC_ASSERT(textEditor, return);
QString fileName = textEditor->file()->fileName();
int lineNumber = textEditor->currentLine();
if (lineNumber >= 0)
m_manager->toggleBreakpoint(fileName, lineNumber);
}
#include "debuggerplugin.moc"
Q_EXPORT_PLUGIN(DebuggerPlugin)
......@@ -109,6 +109,7 @@ private slots:
void openTextEditor(const QString &titlePattern, const QString &contents);
void toggleBreakpoint();
void breakpointSetRemoveMarginActionTriggered();
void breakpointEnableDisableMarginActionTriggered();
void onModeChanged(Core::IMode *mode);
......
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