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
10 #include "variables.h"
12 #include <qcheckbox.h>
15 #include <qlineedit.h>
16 #include <qpushbutton.h>
17 #include <qradiobutton.h>
21 #include <qwhatsthis.h>
22 #include <qmessagebox.h>
25 * Constructs a lineswindow which is a child of 'parent', with the
26 * name 'name' and widget flags set to 'f'
28 * The dialog will by default be modeless, unless you set 'modal' to
29 * TRUE to construct a modal dialog.
31 @author Bruno M. Carvalho
33 lineswindow::lineswindow( QWidget* parent, const char* name, bool modal, WFlags fl )
34 : QDialog( parent, name, modal, fl )
37 setName( "lineswindow" );
39 setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sizePolicy().hasHeightForWidth() ) );
40 setMinimumSize( QSize( 400, 350 ) );
41 setMaximumSize( QSize( 400, 350 ) );
42 setCaption( tr( "Lines Window" ) );
44 lineslabel = new QLabel( this, "lineslabel" );
45 lineslabel->setGeometry( QRect( 10, 10, 70, 30 ) );
46 lineslabel->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, lineslabel->sizePolicy().hasHeightForWidth() ) );
47 lineslabel->setMinimumSize( QSize( 70, 30 ) );
48 lineslabel->setMaximumSize( QSize( 70, 30 ) );
49 lineslabel->setText( tr( "LINES" ) );
51 scalebox = new QCheckBox( this, "scalebox" );
52 scalebox->setGeometry( QRect( 30, 60, 80, 30 ) );
53 scalebox->setText( tr( "SCALE" ) );
54 QObject::connect(scalebox,SIGNAL(clicked()),this,SLOT(activateScaleFields()));
56 scale = new QLineEdit( this, "scale" );
57 scale->setGeometry( QRect( 150, 60, 50, 30 ) );
58 scale->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, scale->sizePolicy().hasHeightForWidth() ) );
59 scale->setEnabled(FALSE);
61 scalelabel = new QLabel( this, "scalelabel" );
62 scalelabel->setGeometry( QRect( 150, 40, 40, 20 ) );
63 scalelabel->setText( tr( "scale" ) );
64 scalelabel->setEnabled(FALSE);
66 columnslabel = new QLabel( this, "columnslabel" );
67 columnslabel->setGeometry( QRect( 30, 130, 100, 30 ) );
68 columnslabel->setText( tr( "COLUMNS" ) );
70 col1 = new QLineEdit( this, "col1" );
71 col1->setGeometry( QRect( 150, 130, 50, 30 ) );
72 col1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, col1->sizePolicy().hasHeightForWidth() ) );
74 col1label = new QLabel( this, "col1label" );
75 col1label->setGeometry( QRect( 160, 110, 30, 20 ) );
76 col1label->setText( tr( "col1" ) );
78 col2 = new QLineEdit( this, "col2" );
79 col2->setGeometry( QRect( 210, 130, 50, 30 ) );
80 col2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, col2->sizePolicy().hasHeightForWidth() ) );
82 col2label = new QLabel( this, "col2label" );
83 col2label->setGeometry( QRect( 220, 110, 30, 20 ) );
84 col2label->setText( tr( "col2" ) );
86 col3 = new QLineEdit( this, "col3" );
87 col3->setGeometry( QRect( 270, 130, 50, 30 ) );
88 col3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, col3->sizePolicy().hasHeightForWidth() ) );
90 col3label = new QLabel( this, "col3label" );
91 col3label->setGeometry( QRect( 280, 110, 30, 20 ) );
92 col3label->setText( tr( "col3" ) );
94 col4 = new QLineEdit( this, "col4" );
95 col4->setGeometry( QRect( 330, 130, 50, 30 ) );
96 col4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, col4->sizePolicy().hasHeightForWidth() ) );
98 col4label = new QLabel( this, "col4label" );
99 col4label->setGeometry( QRect( 340, 110, 30, 20 ) );
100 col4label->setText( tr( "col4" ) );
102 iterationflaglabel = new QLabel( this, "iterationflaglabel" );
103 iterationflaglabel->setGeometry( QRect( 135, 190, 130, 20 ) );
104 iterationflaglabel->setText( tr( "iteration_flag_line" ) );
106 iterationflagline = new QLineEdit( this, "iterationflagline" );
107 iterationflagline->setGeometry( QRect( 50, 210, 310, 30 ) );
109 okbutton = new QPushButton( this, "okbutton" );
110 okbutton->setGeometry( QRect( 50, 290, 100, 40 ) );
111 okbutton->setText( tr( "OK" ) );
112 QObject::connect(okbutton,SIGNAL(clicked()),this,SLOT(checkValues()));
114 cancelbutton = new QPushButton( this, "cancelbutton" );
115 cancelbutton->setGeometry( QRect( 250, 290, 100, 40 ) );
116 cancelbutton->setText( tr( "Cancel" ) );
117 QObject::connect(cancelbutton,SIGNAL(clicked()),this,SLOT(reject()));
119 Line7 = new QFrame( this, "Line7" );
120 Line7->setGeometry( QRect( 0, 275, 400, 1 ) );
121 Line7->setFrameStyle( QFrame::HLine | QFrame::Sunken );
125 * Destroys the object and frees any allocated resources
127 lineswindow::~lineswindow()
129 // no need to delete child widgets, Qt does it all for us
132 /** Activates scale subfields
134 @author Bruno M. Carvalho
136 void lineswindow::activateScaleFields()
138 if(scalebox->isChecked()) {
139 scale->setEnabled(TRUE);
140 scalelabel->setEnabled(TRUE);
143 scale->setEnabled(FALSE);
144 scalelabel->setEnabled(FALSE);
148 /** Returns a string for LINES input sequence
151 @author Bruno M. Carvalho
153 QString lineswindow::getOutput()
158 output.sprintf("LINES ");
159 if(scalebox->isChecked()) {
160 output.append("SCALE ");
161 output+=scale->text();
164 output.append("COLUMNS ");
165 output+=col1->text();
167 output+=col2->text();
169 output+=col3->text();
171 output+=col4->text();
174 output+=iterationflagline->text();
175 //output.append("\n");
180 void lineswindow::checkValues()
185 if(scalebox->isChecked()) {
186 s=strtof((const char *)scale->text());
192 c1=strtoi((const char *)col1->text());
195 c2=strtoi((const char *)col2->text());
198 c3=strtoi((const char *)col3->text());
201 c4=strtoi((const char *)col4->text());
212 if(!isintspace(iterationflagline->text()))
217 case 1: QMessageBox::information(this,"SnarkInput","Error!\n"
218 "Invalid scale format");
221 case 2: QMessageBox::information(this,"SnarkInput","Error!\n"
222 "scale should be positive");
225 case 3: QMessageBox::information(this,"SnarkInput","Error!\n"
226 "Invalid col1 format");
229 case 4: QMessageBox::information(this,"SnarkInput","Error!\n"
230 "Invalid col2 format");
233 case 5: QMessageBox::information(this,"SnarkInput","Error!\n"
234 "Invalid col3 format");
237 case 6: QMessageBox::information(this,"SnarkInput","Error!\n"
238 "Invalid col4 format");
241 case 7: QMessageBox::information(this,"SnarkInput","Error!\n"
242 "col1 must be positive");
245 case 8: QMessageBox::information(this,"SnarkInput","Error!\n"
246 "col2 must be positive or empty");
249 case 9: QMessageBox::information(this,"SnarkInput","Error!\n"
250 "col3 must be positive or empty");
253 case 10: QMessageBox::information(this,"SnarkInput","Error!\n"
254 "col4 must be positive or empty");
257 case 11: QMessageBox::information(this,"SnarkInput","Error!\n"
258 "iteration_flag_line must contain\n"
259 "only 0-9 and spaces and must\n"
261 iterationflagline->setFocus();