1 /*
2     SPDX-FileCopyrightText: 2012 Sven Brauch <svenbrauch@googlemail.com>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "breakpointcontroller.h"
8 #include <debugger/breakpoint/breakpointmodel.h>
9 
10 #include <QDebug>
11 #include "debuggerdebug.h"
12 
13 namespace Python {
14 
BreakpointController(IDebugSession * parent)15 BreakpointController::BreakpointController(IDebugSession* parent): IBreakpointController(parent)
16 {
17     qCDebug(KDEV_PYTHON_DEBUGGER) << "constructing breakpoint controller";
18     connect(debugSession(), SIGNAL(event(IDebugSession::event_t)), this, SLOT(slotEvent(IDebugSession::event_t)));
19 }
20 
session()21 DebugSession* BreakpointController::session()
22 {
23     return static_cast<DebugSession*>(parent());
24 }
25 
slotEvent(IDebugSession::event_t evt)26 void BreakpointController::slotEvent(IDebugSession::event_t evt)
27 {
28     qCDebug(KDEV_PYTHON_DEBUGGER) << evt;
29     if ( evt == IDebugSession::connected_to_program ) {
30         foreach ( Breakpoint* bp, breakpointModel()->breakpoints() ) {
31             if ( bp->deleted() ) {
32                 continue;
33             }
34             session()->addBreakpoint(bp);
35         }
36     }
37 }
38 
sendMaybe(KDevelop::Breakpoint * breakpoint)39 void BreakpointController::sendMaybe(KDevelop::Breakpoint* breakpoint)
40 {
41     qCDebug(KDEV_PYTHON_DEBUGGER) << "sending breakpoint: " << breakpoint << "( deleted:" << breakpoint->deleted() << ")";
42     if ( breakpoint->deleted() ) {
43         session()->removeBreakpoint(breakpoint);
44     }
45     else {
46         session()->addBreakpoint(breakpoint);
47     }
48 }
49 
50 }
51 
52