Fixed text file permissions
[snark14.git] / tools / Input / trace.cpp
1 /** @file trace.cpp
2     @package snark14Input
3     @author Bruno M. Carvalho and Deniz Sarioz
4     licensed under (open-source) QPL v1.0
5     which accompanies this distribution in the file QPL
6 */
7
8 #include "trace.h"
9
10 #include <qbuttongroup.h>
11 #include <qlabel.h>
12 #include <qframe.h>
13 #include <qpushbutton.h>
14 #include <qradiobutton.h>
15 #include <qlayout.h>
16 #include <qvariant.h>
17
18 /** 
19  *  Constructs a tracewindow which is a child of 'parent', with the 
20  *  name 'name' and widget flags set to 'f' 
21  *
22  *  The dialog will by default be modeless, unless you set 'modal' to
23  *  TRUE to construct a modal dialog.
24 @param void
25 @author Bruno M. Carvalho
26 @version 1.0 */
27 tracewindow::tracewindow( QWidget* parent,  const char* name, bool modal, WFlags fl )
28     : QDialog( parent, name, modal, fl )
29 {
30   int width = 340;
31     if ( !name )
32         setName( "tracewindow" );
33     resize( width, 270 ); 
34     setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sizePolicy().hasHeightForWidth() ) );
35     setMinimumSize( QSize( width, 270 ) );
36     setMaximumSize( QSize( width, 270 ) );
37     setCaption( tr( "Trace Window" ) );
38
39     tracelabel = new QLabel( this, "tracelabel" );
40     tracelabel->setGeometry( QRect( 10, 10, 90, 30 ) ); 
41     tracelabel->setMinimumSize( QSize( 90, 30 ) );
42     tracelabel->setMaximumSize( QSize( 90, 30 ) );
43     tracelabel->setText( tr( "TRACE" ) );
44
45     Line18 = new QFrame( this, "Line18" );
46     Line18->setGeometry( QRect( -5, 190, width + 10, 16 ) ); 
47     Line18->setFrameStyle( QFrame::HLine | QFrame::Sunken );
48
49     tracebuttongroup = new QButtonGroup( this, "tracebuttongroup" );
50     tracebuttongroup->setGeometry( QRect( 80, 10, 200, 180 ) ); 
51     tracebuttongroup->setTitle( tr( "trace_level" ) );
52     tracebuttongroup->setAlignment( int( QButtonGroup::AlignHCenter ) );
53
54     tracebuttonslayout = new QGridLayout( tracebuttongroup, 5, 2 );
55
56     tl0button = new QRadioButton( tracebuttongroup, "tl0button" );
57     tl0button->setChecked( TRUE );
58     tl0button->setText( tr( "0 (unspecified)" ) );
59     // rows start from 0: leave some space on top
60     tracebuttonslayout->addMultiCellWidget(tl0button, 1, 1, 0, 1, Qt::AlignHCenter | Qt::AlignTop );
61
62     tl1button = new QRadioButton( tracebuttongroup, "tl1button" );
63     tl1button->setText( tr( "1" ) );
64     tracebuttonslayout->addWidget(tl1button, 2, 0, Qt::AlignHCenter | Qt::AlignVCenter );
65
66     tl5button = new QRadioButton( tracebuttongroup, "tl5button" );
67     tl5button->setText( tr( "5" ) );
68     tracebuttonslayout->addWidget(tl5button, 2, 1, Qt::AlignHCenter | Qt::AlignVCenter );
69
70     tl6button = new QRadioButton( tracebuttongroup, "tl6button" );
71     tl6button->setText( tr( "6" ) );
72     tracebuttonslayout->addWidget(tl6button, 3, 0, Qt::AlignHCenter | Qt::AlignVCenter );
73
74     tl7button = new QRadioButton( tracebuttongroup, "tl7button" );
75     tl7button->setText( tr( "7" ) );
76     tracebuttonslayout->addWidget(tl7button, 3, 1, Qt::AlignHCenter | Qt::AlignVCenter );
77
78     tl8button = new QRadioButton( tracebuttongroup, "tl8button" );
79     tl8button->setText( tr( "8" ) );
80     tracebuttonslayout->addWidget(tl8button, 4, 0, Qt::AlignHCenter | Qt::AlignVCenter );
81
82     tl10button = new QRadioButton( tracebuttongroup, "tl10button" );
83     tl10button->setText( tr( "10" ) );
84     tracebuttonslayout->addWidget(tl10button, 4, 1, Qt::AlignHCenter | Qt::AlignVCenter );
85
86     okbutton = new QPushButton( this, "okbutton" );
87     okbutton->setGeometry( QRect( 50, 210, 100, 40 ) ); 
88     okbutton->setText( tr( "OK" ) );
89     QObject::connect(okbutton,SIGNAL(clicked()),this,SLOT(accept()));
90
91     cancelbutton = new QPushButton( this, "cancelbutton" );
92     cancelbutton->setGeometry( QRect( width - 150, 210, 100, 40 ) ); 
93     cancelbutton->setText( tr( "Cancel" ) );
94     QObject::connect(cancelbutton,SIGNAL(clicked()),this,SLOT(reject()));
95 }
96
97 /**  
98  *  Destroys the object and frees any allocated resources
99  */
100 tracewindow::~tracewindow()
101 {
102     // no need to delete child widgets, Qt does it all for us
103 }
104
105 /** Returns a string for TRACE input sequence
106 @param void
107 @return trace
108 @author Bruno M. Carvalho
109 @version 1.0 */
110 QString tracewindow::getOutput()
111 {
112   QString selectedText = tracebuttongroup->selected()->text();
113   QString traceText = (selectedText.startsWith("0")) ? "0" : selectedText;
114   QString output = "TRACE " + traceText + " ";
115   return output;
116 }