File indexing completed on 2024-05-05 16:41:33

0001 /*
0002     SPDX-FileCopyrightText: 2012 Sven Brauch <svenbrauch@googlemail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "breakpointcontroller.h"
0008 #include <debugger/breakpoint/breakpointmodel.h>
0009 
0010 #include <QDebug>
0011 #include "debuggerdebug.h"
0012 
0013 namespace Python {
0014     
0015 BreakpointController::BreakpointController(IDebugSession* parent): IBreakpointController(parent)
0016 {
0017     qCDebug(KDEV_PYTHON_DEBUGGER) << "constructing breakpoint controller";
0018     connect(debugSession(), SIGNAL(event(IDebugSession::event_t)), this, SLOT(slotEvent(IDebugSession::event_t)));
0019 }
0020 
0021 DebugSession* BreakpointController::session()
0022 {
0023     return static_cast<DebugSession*>(parent());
0024 }
0025 
0026 void BreakpointController::slotEvent(IDebugSession::event_t evt)
0027 {
0028     qCDebug(KDEV_PYTHON_DEBUGGER) << evt;
0029     if ( evt == IDebugSession::connected_to_program ) {
0030         foreach ( Breakpoint* bp, breakpointModel()->breakpoints() ) {
0031             if ( bp->deleted() ) {
0032                 continue;
0033             }
0034             session()->addBreakpoint(bp);
0035         }
0036     }
0037 }
0038 
0039 void BreakpointController::sendMaybe(KDevelop::Breakpoint* breakpoint)
0040 {
0041     qCDebug(KDEV_PYTHON_DEBUGGER) << "sending breakpoint: " << breakpoint << "( deleted:" << breakpoint->deleted() << ")";
0042     if ( breakpoint->deleted() ) {
0043         session()->removeBreakpoint(breakpoint);
0044     }
0045     else {
0046         session()->addBreakpoint(breakpoint);
0047     }
0048 }
0049 
0050 }
0051 
0052 #include "moc_breakpointcontroller.cpp"