32 int type; /* 0 - explicit */
33 char progdir[255],homedir[255];
37 class QInstall: public QFrame
44 QList<VLPEntry> Nodes;
48 bool check_addr(char*);
64 QFont f("Helvetica",12,QFont::Bold);
67 infob = new QPushButton(this);
71 bar = new QMenuBar(this);
72 bar->insertItem("Configure",this,SLOT(SetOptions()));
73 bar->insertItem("Quit",app,SLOT(quit()));
75 setCaption("VLP Configuration Tool");
76 infob->setGeometry(0,bar->height(),200,30);
77 if( mp.load("logo.bmp"))
80 infob->resize(mp.width(),mp.height());
83 resize(infob->width(),infob->height()+bar->height());
88 bool QInstall::check_id(int id)
95 if (pom->ID == id) return(FALSE);
103 bool QInstall::check_addr(char *addr)
110 if (strcmp(pom->addr,addr) == 0) return(FALSE);
117 void QInstall::Info()
122 void QInstall::AddNode()
124 QDialog dlg(this,"",TRUE);
126 QLineEdit *id,*addr,*progs,*home;
127 QPushButton *okbtn,*cancelbtn;
131 tmpQLabel = new QLabel( &dlg, "Label_2" );
132 tmpQLabel->setGeometry( 110, 10, 180, 30 );
133 tmpQLabel->setFrameStyle( 49 );
134 tmpQLabel->setText( "Virtual Processor Properties" );
136 id = new QLineEdit( &dlg, "LineEdit_1" );
137 id->setGeometry( 130, 50, 50, 30 );
140 tmpQLabel = new QLabel( &dlg, "Label_3" );
141 tmpQLabel->setGeometry( 20, 50, 90, 30 );
142 tmpQLabel->setText( "Node number" );
144 tmpQLabel = new QLabel( &dlg, "Label_4" );
145 tmpQLabel->setGeometry( 20, 90, 80, 30 );
146 tmpQLabel->setText( "IP Address" );
148 addr = new QLineEdit( &dlg, "LineEdit_2" );
149 addr->setGeometry( 130, 90, 120, 30 );
152 tmpQLabel = new QLabel( &dlg, "Label_5" );
153 tmpQLabel->setGeometry( 20, 130, 100, 30 );
154 tmpQLabel->setText( "Connection type" );
156 QComboBox* tmpQComboBox;
157 tmpQComboBox = new QComboBox( FALSE, &dlg, "ComboBox_1" );
158 tmpQComboBox->setGeometry( 130, 130, 100, 30 );
159 tmpQComboBox->setSizeLimit( 2 );
160 tmpQComboBox->setAutoResize( FALSE );
161 tmpQComboBox->insertItem( "Explicit" );
163 tmpQLabel = new QLabel( &dlg, "Label_6" );
164 tmpQLabel->setGeometry( 20, 170, 110, 30 );
165 tmpQLabel->setText( "Programs directory" );
167 progs = new QLineEdit( &dlg, "LineEdit_4" );
168 progs->setGeometry( 130, 170, 230, 30 );
169 progs->setText( "" );
171 tmpQLabel = new QLabel( &dlg, "Label_7" );
172 tmpQLabel->setGeometry( 20, 210, 100, 30 );
173 tmpQLabel->setText( "VLP directory" );
175 home = new QLineEdit( &dlg, "LineEdit_5" );
176 home->setGeometry( 130, 210, 230, 30 );
179 okbtn = new QPushButton( &dlg, "PushButton_5" );
180 okbtn->setGeometry( 80, 250, 100, 30 );
181 okbtn->setText( "Ok" );
182 connect(okbtn,SIGNAL(clicked()),&dlg,SLOT(accept()));
183 cancelbtn = new QPushButton( &dlg, "PushButton_6" );
184 cancelbtn->setGeometry( 210, 250, 100, 30 );
185 cancelbtn->setText( "Cancel" );
186 connect(cancelbtn,SIGNAL(clicked()),&dlg,SLOT(reject()));
187 dlg.resize( 380, 300 );
191 pom->ID = atoi(id->text());
192 if (check_id(pom->ID))
194 strcpy(pom->addr,addr->text());
195 if (check_addr(pom->addr))
198 if (strcmp(tmpQComboBox->currentText(),"Explicit")==0) pom->type=0;
199 strcpy(pom->progdir,progs->text());
200 strcpy(pom->homedir,home->text());
202 sprintf(pomstr,"Node: %d Addr:%s Home dir: %s",pom->ID,pom->addr,pom->homedir);
203 nodelist->insertItem(pomstr);
204 strcpy(pom->item,pomstr);
205 } else QMessageBox::message("Error!","Only one VLP on a single computer!","Ok");
207 else QMessageBox::message("Error!","ID must be unique!","Ok");
212 void QInstall::DelNode()
217 if (nodelist->currentItem()>=0)
219 strcpy(pom,nodelist->text(nodelist->currentItem()));
220 vpom = Nodes.first();
223 if (strcmp(pom,vpom->item)==0) break;
227 if (QMessageBox::query("Delete VLP","Are you sure?","Yes","No"))
229 nodelist->removeItem(nodelist->currentItem());
236 void QInstall::SetOptions()
238 QDialog dlg(this,"",TRUE);
240 QPushButton *addbtn,*delbtn,*okbtn,*cancelbtn;
244 char pomstr[255],line[255];
246 //dlg.setStyle(WindowsStyle);
247 nodelist = new QListBox( &dlg, "ListBox_1" );
248 nodelist->setGeometry( 20, 40, 480, 160 );
250 tmpQLabel = new QLabel( &dlg, "Label_1" );
251 tmpQLabel->setGeometry( 20, 10, 100, 30 );
252 tmpQLabel->setText( "Nodes:" );
254 addbtn = new QPushButton( &dlg, "PushButton_1" );
255 addbtn->setGeometry( 30, 210, 100, 30 );
256 addbtn->setText( "Add VLP" );
257 connect(addbtn,SIGNAL(clicked()),this,SLOT(AddNode()));
258 delbtn = new QPushButton( &dlg, "PushButton_2" );
259 delbtn->setGeometry( 150, 210, 100, 30 );
260 delbtn->setText( "Del VLP" );
261 connect(delbtn,SIGNAL(clicked()),this,SLOT(DelNode()));
262 okbtn = new QPushButton( &dlg, "PushButton_3" );
263 okbtn->setGeometry( 270, 210, 100, 30 );
264 okbtn->setText( "Save files" );
265 connect(okbtn,SIGNAL(clicked()),&dlg,SLOT(accept()));
266 cancelbtn = new QPushButton( &dlg, "PushButton_4" );
267 cancelbtn->setGeometry( 390, 210, 100, 30 );
268 cancelbtn->setText( "Cancel" );
269 connect(cancelbtn,SIGNAL(clicked()),&dlg,SLOT(reject()));
270 dlg.resize( 520, 260 );
274 if (!Nodes.isEmpty())
280 sprintf(pomstr,"%s.cfg",pom->addr);
281 vlp_file = new QFile(pomstr);
282 vlp_file->open(IO_WriteOnly);
283 sprintf(line,"progdir=%s\n",pom->progdir);
284 vlp_file->writeBlock(line,strlen(line));
285 sprintf(line,"homedir=%s\n",pom->homedir);
286 vlp_file->writeBlock(line,strlen(line));
287 sprintf(line,"node_number=%d\n",pom->ID);
288 vlp_file->writeBlock(line,strlen(line));
291 sprintf(line,"type=explicit\n");
292 vlp_file->writeBlock(line,strlen(line));
294 for(i=0;i<Nodes.count();i++)
295 if (pom!=Nodes.at(i)) {
296 sprintf(line,"host=%s\n",Nodes.at(i)->addr);
297 vlp_file->writeBlock(line,strlen(line));
312 #include "lgconfig.moc"
314 int main( int argc, char **argv )
317 app = new QApplication(argc,argv);
319 //app->setStyle(WindowsStyle);
320 app->setMainWidget(&cfg);