KDevelop API Documentation

gdboutputwidget.cpp

Go to the documentation of this file.
00001 // *************************************************************************
00002 //                          gdboutputwidget.cpp  -  description
00003 //                             -------------------
00004 //    begin                : 10th April 2003
00005 //    copyright            : (C) 2003 by John Birch
00006 //    email                : jbb@kdevelop.org
00007 // **************************************************************************
00008 //
00009 // **************************************************************************
00010 // *                                                                        *
00011 // *   This program is free software; you can redistribute it and/or modify *
00012 // *   it under the terms of the GNU General Public License as published by *
00013 // *   the Free Software Foundation; either version 2 of the License, or    *
00014 // *   (at your option) any later version.                                  *
00015 // *                                                                        *
00016 // **************************************************************************
00017 
00018 #include "gdboutputwidget.h"
00019 #include "dbgcontroller.h"
00020 
00021 #include <kcombobox.h>
00022 #include <kdebug.h>
00023 #include <kiconloader.h>
00024 #include <klocale.h>
00025 
00026 #include <qlabel.h>
00027 #include <qlayout.h>
00028 #include <qtextedit.h>
00029 #include <qtoolbutton.h>
00030 #include <qtooltip.h>
00031 
00032 /***************************************************************************/
00033 /***************************************************************************/
00034 /***************************************************************************/
00035 
00036 namespace GDBDebugger
00037 {
00038 
00039 /***************************************************************************/
00040 
00041 GDBOutputWidget::GDBOutputWidget( QWidget *parent, const char *name) :
00042     QWidget(parent, name),
00043     m_userGDBCmdEditor(0),
00044     m_Interrupt(0),
00045     m_gdbView(0)
00046 {
00047 
00048     m_gdbView = new QTextEdit (this, name);
00049     m_gdbView->setReadOnly(true);
00050 
00051     QBoxLayout *userGDBCmdEntry = new QHBoxLayout();
00052     m_userGDBCmdEditor = new KHistoryCombo (this, "gdb-user-cmd-editor");
00053 
00054     QLabel *label = new QLabel(i18n("&GDB cmd:"), this);
00055     label->setBuddy(m_userGDBCmdEditor);
00056     userGDBCmdEntry->addWidget(label);
00057 
00058     userGDBCmdEntry->addWidget(m_userGDBCmdEditor);
00059     userGDBCmdEntry->setStretchFactor(m_userGDBCmdEditor, 1);
00060 
00061     m_Interrupt = new QToolButton( this, "add breakpoint" );
00062     m_Interrupt->setSizePolicy ( QSizePolicy ( (QSizePolicy::SizeType)0,
00063                                          ( QSizePolicy::SizeType)0,
00064                                          0,
00065                                          0,
00066                                          m_Interrupt->sizePolicy().hasHeightForWidth())
00067                                          );
00068     m_Interrupt->setPixmap ( SmallIcon ( "player_pause" ) );
00069     userGDBCmdEntry->addWidget(m_Interrupt);
00070     QToolTip::add ( m_Interrupt, i18n ( "Pause execution of the app to enter gdb commands" ) );
00071 
00072     QVBoxLayout *topLayout = new QVBoxLayout(this, 2);
00073     topLayout->addWidget(m_gdbView, 10);
00074     topLayout->addLayout(userGDBCmdEntry);
00075 
00076     slotDbgStatus( "", s_dbgNotStarted);
00077 
00078     connect( m_userGDBCmdEditor, SIGNAL(returnPressed()), SLOT(slotGDBCmd()) );
00079     connect( m_Interrupt,        SIGNAL(clicked()),       SIGNAL(breakInto()));
00080 }
00081 
00082 /***************************************************************************/
00083 
00084 GDBOutputWidget::~GDBOutputWidget()
00085 {
00086     delete m_gdbView;
00087     delete m_userGDBCmdEditor;
00088 }
00089 
00090 /***************************************************************************/
00091 
00092 void GDBOutputWidget::clear()
00093 {
00094     if (m_gdbView)
00095         m_gdbView->clear();
00096 }
00097 
00098 /***************************************************************************/
00099 
00100 void GDBOutputWidget::slotReceivedStdout(const char* line)
00101 {
00102     if (strncmp(line, "(gdb) ", 5) == 0)
00103         m_gdbView->append(QString("<font color=\"blue\">").append( line ).append("</font>") );
00104     else
00105         m_gdbView->append(line);
00106 }
00107 
00108 /***************************************************************************/
00109 
00110 void GDBOutputWidget::slotReceivedStderr(const char* line)
00111 {
00112     m_gdbView->append(QString("<font color=\"red\">").append( line ).append("</font>") );
00113 }
00114 
00115 /***************************************************************************/
00116 
00117 void GDBOutputWidget::slotGDBCmd()
00118 {
00119     QString GDBCmd(m_userGDBCmdEditor->currentText());
00120     if (!GDBCmd.isEmpty())
00121     {
00122         m_userGDBCmdEditor->addToHistory(GDBCmd);
00123         m_userGDBCmdEditor->clearEdit();
00124         emit userGDBCmd(GDBCmd);
00125     }
00126 }
00127 
00128 /***************************************************************************/
00129 
00130 void GDBOutputWidget::slotDbgStatus(const QString &, int statusFlag)
00131 {
00132     if (statusFlag & s_dbgNotStarted)
00133     {
00134         m_Interrupt->setEnabled(false);
00135         m_userGDBCmdEditor->setEnabled(false);
00136         return;
00137     }
00138 
00139     if (statusFlag & s_appBusy)
00140     {
00141         m_Interrupt->setEnabled(true);
00142         m_userGDBCmdEditor->setEnabled(false);
00143     }
00144     else
00145     {
00146         m_Interrupt->setEnabled(false);
00147         m_userGDBCmdEditor->setEnabled(true);
00148     }
00149 }
00150 
00151 /***************************************************************************/
00152 
00153 void GDBOutputWidget::focusInEvent(QFocusEvent */*e*/)
00154 {
00155     m_userGDBCmdEditor->setFocus();
00156 }
00157 
00158 /***************************************************************************/
00159 /***************************************************************************/
00160 /***************************************************************************/
00161 }
00162 
00163 
00164 #include "gdboutputwidget.moc"
00165 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:46 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003