Fixed text file permissions
[snark14.git] / tools / Input / punch.cpp
1 /** @file punch.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 /****************************************************************************
9 ** Form implementation generated from reading ui file 'punch.ui'
10 **
11 ** Created: Wed May 15 18:20:01 2002
12 **      by:  The User Interface Compiler (uic)
13 **
14 ** WARNING! All changes made in this file will be lost!
15 ****************************************************************************/
16 #include "punch.h"
17 #include "misc.h"
18 #include "variables.h"
19
20 #include <qcheckbox.h>
21 #include <qframe.h>
22 #include <qlabel.h>
23 #include <qlineedit.h>
24 #include <qpushbutton.h>
25 #include <qradiobutton.h>
26 #include <qlayout.h>
27 #include <qvariant.h>
28 #include <qtooltip.h>
29 #include <qwhatsthis.h>
30 #include <qmessagebox.h>
31
32 /** 
33  *  Constructs a punchwindow which is a child of 'parent', with the 
34  *  name 'name' and widget flags set to 'f' 
35  *
36  *  The dialog will by default be modeless, unless you set 'modal' to
37  *  TRUE to construct a modal dialog.
38 @param void
39 @author Bruno M. Carvalho
40 @version 1.0 */
41 punchwindow::punchwindow( QWidget* parent,  const char* name, bool modal, WFlags fl )
42     : QDialog( parent, name, modal, fl )
43 {
44     if ( !name )
45         setName( "punchwindow" );
46     resize( 400, 300 ); 
47     setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sizePolicy().hasHeightForWidth() ) );
48     setMinimumSize( QSize( 400, 240 ) );
49     setMaximumSize( QSize( 400, 240 ) );
50     setCaption( tr( "Punch Window" ) );
51
52     punchlabel = new QLabel( this, "punchlabel" );
53     punchlabel->setGeometry( QRect( 10, 10, 100, 30 ) ); 
54     punchlabel->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, punchlabel->sizePolicy().hasHeightForWidth() ) );
55     punchlabel->setMinimumSize( QSize( 100, 30 ) );
56     punchlabel->setMaximumSize( QSize( 100, 30 ) );
57     punchlabel->setText( tr( "PUNCH" ) );
58
59     phantombox = new QCheckBox( this, "phantombox" );
60     phantombox->setGeometry( QRect( 30, 60, 110, 30 ) ); 
61     phantombox->setText( tr( "PHANTOM" ) );
62
63     iterationflaglabel = new QLabel( this, "iterationflaglabel" );
64     iterationflaglabel->setGeometry( QRect( 130, 100, 130, 20 ) ); 
65     iterationflaglabel->setText( tr( "iteration_flag_line" ) );
66
67     iterationflagline = new QLineEdit( this, "iterationflagline" );
68     iterationflagline->setGeometry( QRect( 50, 120, 290, 30 ) ); 
69     iterationflagline->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, iterationflagline->sizePolicy().hasHeightForWidth() ) ); 
70
71     Line11 = new QFrame( this, "Line11" );
72     Line11->setGeometry( QRect( 0, 165, 400, 16 ) ); 
73     Line11->setFrameStyle( QFrame::HLine | QFrame::Sunken );
74
75     okbutton = new QPushButton( this, "okbutton" );
76     okbutton->setGeometry( QRect( 50, 180, 100, 40 ) ); 
77     okbutton->setText( tr( "OK" ) );
78     QObject::connect(okbutton,SIGNAL(clicked()),this,SLOT(checkValues()));
79
80     cancelbutton = new QPushButton( this, "cancelbutton" );
81     cancelbutton->setGeometry( QRect( 250, 180, 100, 40 ) ); 
82     cancelbutton->setText( tr( "Cancel" ) );
83     QObject::connect(cancelbutton,SIGNAL(clicked()),this,SLOT(reject()));
84 }
85
86 /**  
87  *  Destroys the object and frees any allocated resources
88  */
89 punchwindow::~punchwindow()
90 {
91     // no need to delete child widgets, Qt does it all for us
92 }
93
94
95 /** Returns a string for PUNCH input sequence
96 @param void
97 @return punch
98 @author Bruno M. Carvalho
99 @version 1.0 */
100 QString punchwindow::getOutput()
101 {
102   QString output;
103
104   output.sprintf("PUNCH ");
105   if(phantombox->isChecked()) {
106     output.append("PHANTOM ");
107   }
108   output.append("\n");
109   output+=iterationflagline->text();
110   
111   return output;
112 }
113
114 void punchwindow::checkValues()
115 {
116   int f=0;
117
118   if(!isintspace(iterationflagline->text()))
119     f=1;
120   switch(f) {
121   case 0: accept();
122     break;
123   case 1: QMessageBox::information(this,"SnarkInput","Error!\n"
124                                    "iteration_flag_line must contain\n"
125                                    "only 0-9 and spaces and must\n"
126                                    "be non-empty");
127     break;
128   }
129 }