00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 enum PropertyIndex
00026 {
00027 CONTITLE,
00028 CONCLASS,
00029 CONDIM,
00030 CONX,
00031 CONY,
00032 CONCOUNTS,
00033 CONRESULT,
00034 CONMODE,
00035 CONSIZE,
00036 CONTIME
00037 };
00038
00039
00040
00041 void TGo4ConditionInfo::init()
00042 {
00043 setAcceptDrops( TRUE );
00044 fbRemotedrop=true;
00045 fxLastCondition=0;
00046 TGo4LockGuard glob;
00047 fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00048 char SlotName[256];
00049 char Caption[256];
00050 sprintf(SlotName,"%s","Go4ConditionInfo_Slots" );
00051 sprintf(Caption,"%s","Condition Info:");
00052 setCaption( trUtf8( Caption ) );
00053 fxTGo4ConditionInfoSlots = (TGo4ConditionInfoSlots *) fxTGo4GUIRegistry->GetSlotClass(SlotName);
00054 if(fxTGo4ConditionInfoSlots !=0) {
00055 fxTGo4ConditionInfoSlots->SetGUI(this);
00056 }else{
00057 fxTGo4ConditionInfoSlots = new TGo4ConditionInfoSlots (SlotName, "Slots Class for Qt GUI", this);
00058 }
00059 fxTGo4ConditionInfoStatus= dynamic_cast <TGo4ConditionInfoStatus *> (fxTGo4ConditionInfoSlots->GetStatus());
00060 }
00061
00062
00063 void TGo4ConditionInfo::destroy()
00064 {
00065 TGo4LockGuard glob;
00066 fxTGo4GUIRegistry->UnRegisterClass(fxTGo4ConditionInfoSlots,fxTGo4ConditionInfoStatus);
00067 delete fxTGo4ConditionInfoSlots;
00068 delete fxLastCondition;
00069 }
00070
00071 void TGo4ConditionInfo::closeEvent( QCloseEvent *ce )
00072 {
00073 TGo4LockGuard glob;
00074 ce->accept();
00075 fxTGo4ConditionInfoSlots->SetGUI(0);
00076 delete this;
00077 }
00078
00079 void TGo4ConditionInfo::RefreshConditionInfo(TGo4Condition* condi)
00080 {
00081 if(condi==0) return;
00082 TGo4LockGuard glob;
00083 char buffer[256];
00084 snprintf(buffer,256,"%s",condi->GetTitle());
00085 PropertyBox->changeItem(buffer,CONTITLE);
00086 snprintf(buffer,256,"%s",condi->IsA()->GetName());
00087 PropertyBox->changeItem(buffer,CONCLASS);
00088 int dimension=0;
00089 if(condi->InheritsFrom("TGo4WinCond"))
00090 {
00091
00092 TGo4WinCond* wcon=dynamic_cast<TGo4WinCond*>(condi);
00093 double xmin,xmax,ymin,ymax=0;
00094 wcon->GetValues(dimension,xmin,xmax,ymin,ymax);
00095 snprintf(buffer,256,"X: [%.1f,%.1f]",xmin, xmax);
00096 PropertyBox->changeItem(buffer,CONX);
00097 snprintf(buffer,256,"Y: [%.1f,%.1f]",ymin, ymax);
00098 PropertyBox->changeItem(buffer,CONY);
00099 }
00100 else
00101 {
00102 snprintf(buffer,256,"X:-");
00103 PropertyBox->changeItem(buffer,CONX);
00104 snprintf(buffer,256,"Y:-");
00105 PropertyBox->changeItem(buffer,CONY);
00106 dimension=2;
00107 }
00108 snprintf(buffer,256,"Dim:%d",dimension);
00109 PropertyBox->changeItem(buffer,CONDIM);
00110 snprintf(buffer,256,"Counts:%d",condi->Counts());
00111 PropertyBox->changeItem(buffer,CONCOUNTS);
00112 snprintf(buffer,256,"True:%d",condi->TrueCounts());
00113 PropertyBox->changeItem(buffer,CONRESULT);
00114 char* invertstate;
00115 if(condi->IsTrue())
00116 {
00117 invertstate="regular";
00118 }
00119 else
00120 {
00121 invertstate="inverse";
00122 }
00123
00124 if(condi->IsEnabled())
00125 {
00126 snprintf(buffer,256,"test enabled - %s",invertstate);
00127 }
00128 else
00129 {
00130 if(condi->FixedResult())
00131 {
00132 snprintf(buffer,256,"always true - %s", invertstate);
00133 }
00134 else
00135 {
00136 snprintf(buffer,256,"always false - %s", invertstate);
00137 }
00138 }
00139 PropertyBox->changeItem(buffer,CONMODE);
00140
00141
00142 TGo4ConditionStatus cstat(condi);
00143 Int_t condsize=cstat.GetObjectSize();
00144 snprintf(buffer,256,"size:%d b",condsize);
00145 PropertyBox->changeItem(buffer,CONSIZE);
00146 TDatime now;
00147 PropertyBox->changeItem(now.AsSQLString(),CONTIME);
00148 polish();
00149 update();
00150 show();
00151 raise();
00152 if(TGo4Log::IsAutoEnabled()) PrintoutLog();
00153 }
00154
00155 void TGo4ConditionInfo::ClearConditionInfo()
00156 {
00157 TGo4LockGuard glob;
00158 PropertyBox->changeItem("Title",CONTITLE);
00159 PropertyBox->changeItem("Class:",CONCLASS);
00160 fxTGo4ConditionInfoSlots->SetConditionClass("no");
00161 PropertyBox->changeItem("X Testrange",CONX);
00162 PropertyBox->changeItem("Y Testrange",CONY);
00163 PropertyBox->changeItem("Dimension",CONDIM);
00164 PropertyBox->changeItem("Counts",CONCOUNTS);
00165 PropertyBox->changeItem("Result",CONRESULT);
00166 PropertyBox->changeItem("Test mode",CONMODE);
00167 PropertyBox->changeItem("Size",CONSIZE);
00168 TDatime now;
00169 PropertyBox->changeItem(now.AsSQLString(),CONTIME);
00170 polish();
00171 update();
00172 show();
00173 raise();
00174 }
00175
00176 void TGo4ConditionInfo::ConditionInfo()
00177 {
00178 fxTGo4ConditionInfoSlots->SendConditionInfoCommand();
00179 fbRemotedrop=true;
00180 }
00181
00182 void TGo4ConditionInfo::PrintConditions()
00183 {
00184 fxTGo4ConditionInfoSlots->SendConditionPrintCommand();
00185 }
00186
00187 void TGo4ConditionInfo::EditConditionClicked()
00188 {
00189 if(fbRemotedrop)
00190 {
00191 fxTGo4ConditionInfoSlots->SendConditionEditCommand();
00192 }
00193 else
00194 {
00195 if(fxLastCondition)
00196 {
00197 const char* condi=fxLastCondition->GetName();
00198 char SlotName[256];
00199 snprintf(SlotName,256,"%s%s",condi,"_Slots" );
00200 TGo4SlotsBaseClass* condislot= fxTGo4GUIRegistry->GetSlotClass(SlotName);
00201 if(condislot==0)
00202 {
00203 condislot = new TGo4WindowEditSlots(SlotName, "Condition Editor");
00204 }
00205 condislot->AddObject(fxLastCondition);
00206 }
00207 }
00208 }
00209
00210
00211 const char* TGo4ConditionInfo::GetConditionName()
00212 {
00213 const char* name=CondnameEdit->text().stripWhiteSpace();
00214 return name;
00215 }
00216
00217
00218 void TGo4ConditionInfo::SetConditionName( const char * name )
00219 {
00220 CondnameEdit->setText(name);
00221 }
00222
00223 void TGo4ConditionInfo::dropEvent( QDropEvent *e )
00224 {
00225 TGo4LockGuard glob;
00226 QListView *dragsource=dynamic_cast <QListView *> (e->source());
00227 if(dragsource==0) return;
00228 TGo4QConItem *dragitem= dynamic_cast <TGo4QConItem *>(dragsource->currentItem());
00229 if(dragitem==0) return;
00230 if(strcmp(dragsource->name(),"ListViewRemote")==0)
00231 fbRemotedrop=true;
00232 else if(strcmp(dragsource->name(),"FileListView")==0)
00233 fbRemotedrop=false;
00234 else if(strcmp(dragsource->name(),"ListViewLocal")==0)
00235 fbRemotedrop=false;
00236
00237 QString name;
00238 QCString plain = "plain";
00239 bool decoded = QTextDrag::decode(e, name, plain);
00240
00241 if (! decoded) decoded = QTextDrag::decode(e, name);
00242 CondnameEdit->setText(name);
00243 delete fxLastCondition;
00244 fxLastCondition=0;
00245 if(fbRemotedrop)
00246 {
00247 ClearConditionInfo();
00248 ConditionInfo();
00249 }
00250 else
00251 {
00252 TGo4Condition* conny=dynamic_cast<TGo4Condition*>(dragitem->GetWorkObject());
00253 ShowProperties(conny);
00254 }
00255 dragsource->clearSelection();
00256 dragsource->setSelected(dragitem,true);
00257 e->acceptAction();
00258 }
00259
00260 void TGo4ConditionInfo::dragEnterEvent( QDragEnterEvent *Event)
00261 {
00262 if ( QTextDrag::canDecode( Event )){
00263 Event->accept();
00264 }
00265 }
00266
00267
00268
00269 void TGo4ConditionInfo::PrintoutLog()
00270 {
00271 QString textbuffer;
00272 textbuffer="Condition ";
00273 textbuffer+=CondnameEdit->text();
00274 textbuffer+=" Status: \n ";
00275 textbuffer+="Title: ";
00276 textbuffer+=PropertyBox->item(CONTITLE)->text();
00277 textbuffer+=" Class: ";
00278 textbuffer+=PropertyBox->item(CONCLASS)->text();
00279 textbuffer+=" ";
00280 textbuffer+=PropertyBox->item(CONDIM)->text();
00281 textbuffer+=" ";
00282 textbuffer+=PropertyBox->item(CONMODE)->text();
00283 textbuffer+="\n ";
00284 textbuffer+=PropertyBox->item(CONX)->text();
00285 textbuffer+=" ";
00286 textbuffer+=PropertyBox->item(CONY)->text();
00287 textbuffer+="\n ";
00288 textbuffer+=PropertyBox->item(CONCOUNTS)->text();
00289 textbuffer+=" ";
00290 textbuffer+=PropertyBox->item(CONRESULT)->text();
00291 textbuffer+="\n ";
00292 textbuffer+=PropertyBox->item(CONSIZE)->text();
00293 textbuffer+=" Status received at: ";
00294 textbuffer+=PropertyBox->item(CONTIME)->text();
00295
00296 TGo4Log::Message(1,(const char*) textbuffer);
00297 }
00298
00299
00300 void TGo4ConditionInfo::ShowProperties( TGo4Condition * conny)
00301 {
00302 if(conny==0) return;
00303 fbRemotedrop=false;
00304 fxTGo4ConditionInfoSlots->AddObject(conny);
00305 delete fxLastCondition;
00306 fxLastCondition=dynamic_cast<TGo4Condition*>(conny->Clone());
00307 }
00308
00309