~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to languages/ruby/debugger/rdboutputwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// *************************************************************************
 
2
//                          rdboutputwidget.cpp  -  description
 
3
//                             -------------------
 
4
//    begin                : 10th April 2003
 
5
//    copyright            : (C) 2003 by John Birch
 
6
//    email                : jbb@kdevelop.org
 
7
//      
 
8
//                          Adapted for ruby debugging
 
9
//                          --------------------------
 
10
//    begin                : Mon Nov 1 2004
 
11
//   copyright            : (C) 2004 by Richard Dale
 
12
//    email                : Richard_Dale@tipitina.demon.co.uk
 
13
// **************************************************************************
 
14
//
 
15
// **************************************************************************
 
16
// *                                                                        *
 
17
// *   This program is free software; you can redistribute it and/or modify *
 
18
// *   it under the terms of the GNU General Public License as published by *
 
19
// *   the Free Software Foundation; either version 2 of the License, or    *
 
20
// *   (at your option) any later version.                                  *
 
21
// *                                                                        *
 
22
// **************************************************************************
 
23
 
 
24
#include "rdboutputwidget.h"
 
25
#include "dbgcontroller.h"
 
26
 
 
27
#include <kcombobox.h>
 
28
#include <kdebug.h>
 
29
#include <kiconloader.h>
 
30
#include <klocale.h>
 
31
 
 
32
#include <qlabel.h>
 
33
#include <qlayout.h>
 
34
#include <qtextedit.h>
 
35
#include <qtoolbutton.h>
 
36
#include <qtooltip.h>
 
37
 
 
38
/***************************************************************************/
 
39
/***************************************************************************/
 
40
/***************************************************************************/
 
41
 
 
42
namespace RDBDebugger
 
43
{
 
44
 
 
45
/***************************************************************************/
 
46
 
 
47
RDBOutputWidget::RDBOutputWidget( QWidget *parent, const char *name) :
 
48
    QWidget(parent, name),
 
49
    m_userRDBCmdEditor(0),
 
50
    m_Interrupt(0),
 
51
    m_rdbView(0)
 
52
{
 
53
 
 
54
    m_rdbView = new QTextEdit (this, name);
 
55
    m_rdbView->setReadOnly(true);
 
56
 
 
57
    QBoxLayout *userRDBCmdEntry = new QHBoxLayout();
 
58
    m_userRDBCmdEditor = new KHistoryCombo (this, "rdb-user-cmd-editor");
 
59
 
 
60
    QLabel *label = new QLabel(i18n("&RDB cmd:"), this);
 
61
    label->setBuddy(m_userRDBCmdEditor);
 
62
    userRDBCmdEntry->addWidget(label);
 
63
 
 
64
    userRDBCmdEntry->addWidget(m_userRDBCmdEditor);
 
65
    userRDBCmdEntry->setStretchFactor(m_userRDBCmdEditor, 1);
 
66
 
 
67
    m_Interrupt = new QToolButton( this, "add breakpoint" );
 
68
    m_Interrupt->setSizePolicy ( QSizePolicy ( (QSizePolicy::SizeType)0,
 
69
                                         ( QSizePolicy::SizeType)0,
 
70
                                         0,
 
71
                                         0,
 
72
                                         m_Interrupt->sizePolicy().hasHeightForWidth())
 
73
                                         );
 
74
    m_Interrupt->setPixmap ( SmallIcon ( "player_pause" ) );
 
75
    userRDBCmdEntry->addWidget(m_Interrupt);
 
76
    QToolTip::add ( m_Interrupt, i18n ( "Pause execution of the app to enter rdb commands" ) );
 
77
 
 
78
    QVBoxLayout *topLayout = new QVBoxLayout(this, 2);
 
79
    topLayout->addWidget(m_rdbView, 10);
 
80
    topLayout->addLayout(userRDBCmdEntry);
 
81
 
 
82
    slotDbgStatus( "", s_dbgNotStarted);
 
83
 
 
84
    connect( m_userRDBCmdEditor, SIGNAL(returnPressed()), SLOT(slotRDBCmd()) );
 
85
    connect( m_Interrupt,        SIGNAL(clicked()),       SIGNAL(breakInto()));
 
86
}
 
87
 
 
88
/***************************************************************************/
 
89
 
 
90
RDBOutputWidget::~RDBOutputWidget()
 
91
{
 
92
    delete m_rdbView;
 
93
    delete m_userRDBCmdEditor;
 
94
}
 
95
 
 
96
/***************************************************************************/
 
97
 
 
98
void RDBOutputWidget::clear()
 
99
{
 
100
    if (m_rdbView)
 
101
        m_rdbView->clear();
 
102
}
 
103
 
 
104
/***************************************************************************/
 
105
 
 
106
void RDBOutputWidget::slotReceivedStdout(const char* line)
 
107
{
 
108
    if (strncmp(line, "(rdb:", 5) == 0)
 
109
        m_rdbView->append(QString("<font color=\"blue\">").append( line ).append("</font>") );
 
110
    else
 
111
        m_rdbView->append(line);
 
112
}
 
113
 
 
114
/***************************************************************************/
 
115
 
 
116
void RDBOutputWidget::slotReceivedStderr(const char* line)
 
117
{
 
118
    m_rdbView->append(QString("<font color=\"red\">").append( line ).append("</font>") );
 
119
}
 
120
 
 
121
/***************************************************************************/
 
122
 
 
123
void RDBOutputWidget::slotRDBCmd()
 
124
{
 
125
    QString RDBCmd(m_userRDBCmdEditor->currentText());
 
126
    if (!RDBCmd.isEmpty())
 
127
    {
 
128
        m_userRDBCmdEditor->addToHistory(RDBCmd);
 
129
        m_userRDBCmdEditor->clearEdit();
 
130
        emit userRDBCmd(RDBCmd);
 
131
    }
 
132
}
 
133
 
 
134
/***************************************************************************/
 
135
 
 
136
void RDBOutputWidget::slotDbgStatus(const QString &, int statusFlag)
 
137
{
 
138
    if (statusFlag & s_dbgNotStarted)
 
139
    {
 
140
        m_Interrupt->setEnabled(false);
 
141
        m_userRDBCmdEditor->setEnabled(false);
 
142
        return;
 
143
    }
 
144
 
 
145
    if (statusFlag & s_appBusy)
 
146
    {
 
147
        m_Interrupt->setEnabled(true);
 
148
        m_userRDBCmdEditor->setEnabled(false);
 
149
    }
 
150
    else
 
151
    {
 
152
        m_Interrupt->setEnabled(false);
 
153
        m_userRDBCmdEditor->setEnabled(true);
 
154
    }
 
155
}
 
156
 
 
157
/***************************************************************************/
 
158
 
 
159
void RDBOutputWidget::focusInEvent(QFocusEvent */*e*/)
 
160
{
 
161
    m_userRDBCmdEditor->setFocus();
 
162
}
 
163
 
 
164
/***************************************************************************/
 
165
/***************************************************************************/
 
166
/***************************************************************************/
 
167
}
 
168
 
 
169
 
 
170
#include "rdboutputwidget.moc"
 
171