Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4GUI/TGo4RemoteBrowserSlots.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4RemoteBrowserSlots.h"
00017 
00018 #include "TFolder.h"
00019 
00020 #include "qlistview.h"
00021 #include "qtabwidget.h"
00022 #include "qstring.h"
00023 #include "qptrlist.h"
00024 #include "qmessagebox.h"
00025 
00026 #include "Go4LockGuard/TGo4LockGuard.h"
00027 #include "Go4Analysis/TGo4AnalysisObjectNames.h"
00028 #include "Go4Analysis/TGo4ConditionStatus.h"
00029 
00030 #include "Go4CommandsAnalysis/TGo4ComGetNamesList.h"
00031 #include "Go4CommandsAnalysis/TGo4ComClearObject.h"
00032 #include "Go4CommandsAnalysis/TGo4ComSetProtections.h"
00033 #include "Go4CommandsAnalysis/TGo4ComRemoveDynamicEntry.h"
00034 #include "Go4CommandsAnalysis/TGo4ComDeleteObject.h"
00035 
00036 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00037 #include "Go4Analysis/TGo4TreeStructure.h"
00038 #include "Go4DynamicList/TGo4DynamicListStatus.h"
00039 #include "Go4DynamicList/TGo4HistogramEntryStatus.h"
00040 #include "Go4DynamicList/TGo4TreeHistogramEntryStatus.h"
00041 #include "Go4StatusBase/TGo4ObjectStatus.h"
00042 #include "Go4StatusBase/TGo4BranchStatus.h"
00043 #include "Go4StatusAnalysis/TGo4ParameterStatus.h"
00044 
00045 #include "Go4QtBaseWidgets/TGo4QItem.h"
00046 #include "Go4QtBaseWidgets/TGo4QTHItem.h"
00047 #include "Go4QtBaseWidgets/TGo4QConItem.h"
00048 #include "Go4QtBaseWidgets/TGo4QFolderItem.h"
00049 #include "Go4QtBaseWidgets/TGo4QDynEntryItem.h"
00050 #include "Go4QtBaseWidgets/TGo4QFolderItem.h"
00051 #include "Go4QtBaseWidgets/TGo4QBranchItem.h"
00052 #include "Go4QtBaseWidgets/TGo4QFolderItem.h"
00053 #include "Go4QtBaseWidgets/TGo4QTreeItem.h"
00054 #include "Go4QtBaseWidgets/TGo4QLeafItem.h"
00055 #include "Go4QtBaseWidgets/TGo4QParaItem.h"
00056 
00057 #include "TGo4RemoteBrowser.h"
00058 #include "TGo4RemoteBrowserStatus.h"
00059 #include "TGo4MonitoredListSlots.h"
00060 #include "TGo4MonitoredListStatus.h"
00061 #include "TGo4MonitoredList.h"
00062 #include "TGo4DockBrowsers.h"
00063 #include "TGo4MainWindow.h"
00064 
00065 void TGo4RemoteBrowserSlots::RemoteSelectionChanged(const char *ObjName)
00066 {
00067 }
00068 
00069 TGo4RemoteBrowserSlots::TGo4RemoteBrowserSlots(const char * name, const char * title, TGo4RemoteBrowser * p)
00070                  : TGo4SlotsBaseClass(name , title), fxTGo4RemoteBrowser(p) {
00071    // TGo4LockGuard Global;
00072    fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00073    fxTGo4RemoteBrowserStatus= new TGo4RemoteBrowserStatus("TGo4RemoteBrowserStatus", "Test Status 1");
00074    fxTGo4GUIRegistry->RegisterSlotClass(this, fxTGo4RemoteBrowserStatus, p);
00075    TGo4DockBrowserTabs = dynamic_cast <QTabWidget *>((fxTGo4RemoteBrowser->parentWidget()->parentWidget()->parentWidget()));
00076    fxTGo4DockBrowsers = dynamic_cast <TGo4DockBrowsers *>((fxTGo4RemoteBrowser->parentWidget()->parentWidget()->parentWidget()->parentWidget()));
00077    fbBrowserRefreshed = kFALSE;
00078 }
00079 
00080 TGo4RemoteBrowserSlots::~TGo4RemoteBrowserSlots() {
00081    delete fxTGo4RemoteBrowserStatus;
00082 }
00083 
00084 void TGo4RemoteBrowserSlots::MonitorRemoteObj(QListViewItem *item) {
00085    // TGo4LockGuard Global;
00086 
00087 TGo4MonitoredListSlots* fxTGo4MonitoredListSlots = dynamic_cast <TGo4MonitoredListSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4MonitoredListSlots"));
00088 TGo4MonitoredListStatus* fxTGo4MonitoredListStatus = dynamic_cast <TGo4MonitoredListStatus *>(fxTGo4MonitoredListSlots->GetStatus());
00089 
00090 // automatic multiple selection if folder is selected:
00091 TGo4QFolderItem* folder=dynamic_cast<TGo4QFolderItem*>(item);
00092 if(folder)
00093  {
00094      QListViewItem* child=folder->firstChild(); 
00095      while(child)
00096          {
00097              MonitorRemoteObj(child);
00098              child=child->nextSibling();       
00099          } 
00100  }
00101 else
00102  {
00103 
00104 
00105 
00106    if (fxTGo4MonitoredListStatus->GetMonitoredObject(item->text(0).data())==0) 
00107       {
00108          TGo4QItem* fxTGo4QItem = dynamic_cast<TGo4QItem*> (item);
00109          if(fxTGo4QItem!=0) fxTGo4QItem->GetOnlineObj();
00110       }
00111    else
00112       {
00113           Text_t buf[128];
00114           snprintf(buf,125,"Object %s is already being monitored",item->text(0).data());
00115           TGo4MainWindow* mw= (TGo4MainWindow*) fxTGo4GUIRegistry->GetMainWindow();
00116           mw->StatusMessage(buf);
00117       }
00118       if(TGo4DockBrowserTabs!=0) TGo4DockBrowserTabs->setCurrentPage(2);
00119   }
00120 }
00121 
00122 void TGo4RemoteBrowserSlots::GetRemoteObj(QListViewItem *item) {
00123    // TGo4LockGuard Global;
00124 // automatic multiple selection if folder is selected:
00125 TGo4QFolderItem* folder=dynamic_cast<TGo4QFolderItem*>(item);
00126 if(folder)
00127  {
00128      QListViewItem* child=folder->firstChild(); 
00129      while(child)
00130          {
00131              GetRemoteObj(child);
00132              child=child->nextSibling();       
00133          } 
00134  }
00135 else
00136  {
00137          TGo4QItem* fxTGo4QItem = dynamic_cast<TGo4QItem*> (item);
00138          if(fxTGo4QItem!=0) fxTGo4QItem->GetRemoteObj();
00139       if(TGo4DockBrowserTabs!=0) TGo4DockBrowserTabs->setCurrentPage(3);
00140   }
00141 }
00142 
00143 
00144 
00145 
00146 void TGo4RemoteBrowserSlots::Refresh(Bool_t changepage) {
00147    // TGo4LockGuard Global;
00148    TGo4ComGetNamesList *com =new TGo4ComGetNamesList();
00149    fbBrowserRefreshed = kFALSE;
00150    fxTGo4GUIRegistry->SubmitCommand(com,"Go4NamesList", this);
00151    if (changepage && (TGo4DockBrowserTabs!=0))
00152       TGo4DockBrowserTabs->setCurrentPage(3);
00153 }
00154 
00155 void TGo4RemoteBrowserSlots::ResetRemoteObj(const char* ObjName) {
00156    // TGo4LockGuard Global;
00157    TGo4ComClearObject* com = new TGo4ComClearObject(ObjName);
00158    fxTGo4GUIRegistry->SubmitCommand(com);
00159 }
00160 
00161 void TGo4RemoteBrowserSlots::ChangeProtectionsRemoteObj(const char* ObjName, const char* flags)
00162 {
00163    TGo4ComSetProtections* com = new TGo4ComSetProtections(ObjName, flags);
00164    fxTGo4GUIRegistry->SubmitCommand(com);
00165 }
00166  
00167 
00168 
00169 void TGo4RemoteBrowserSlots::SetGUI(TGo4RemoteBrowser *GUI ) {
00170    // TGo4LockGuard Global;
00171    fxTGo4RemoteBrowser= GUI;
00172    fxTGo4GUIRegistry->GuiIsChanged(this, GUI);
00173 }
00174 
00175 TGo4Status * TGo4RemoteBrowserSlots::GetStatus() {
00176    return fxTGo4RemoteBrowserStatus;
00177 }
00178 
00179 void TGo4RemoteBrowserSlots::RemoveObjectFromAnalysis(QListViewItem* Item) {
00180    // TGo4LockGuard Global;
00181    if ((dynamic_cast <TGo4QDynEntryItem*> (Item)) != 0)
00182       {
00183       TGo4ComRemoveDynamicEntry *com = new TGo4ComRemoveDynamicEntry(Item->text(0).data());
00184       fxTGo4GUIRegistry->SubmitCommand(com);
00185       } 
00186    else if ((dynamic_cast <TGo4QTHItem*> (Item)) != 0 || 
00187                (dynamic_cast <TGo4QConItem*> (Item)) != 0 || 
00188                   (dynamic_cast <TGo4QFolderItem*> (Item)) != 0) 
00189       {
00190       TGo4ComDeleteObject *com = new TGo4ComDeleteObject(Item->text(0).data());
00191       fxTGo4GUIRegistry->SubmitCommand(com);
00192       }
00193       
00194    Refresh();
00195 }
00196 
00197 void TGo4RemoteBrowserSlots::AddObject(TNamed *fxData) {
00198    // TGo4LockGuard Global;
00199 
00200    TGo4AnalysisObjectNames* objnames = dynamic_cast<TGo4AnalysisObjectNames*> (fxData);
00201    if (objnames) {
00202       AddFolder(objnames->GetNamesFolder());
00203       fbBrowserRefreshed = kTRUE;
00204    }
00205 }
00206 
00207 
00208 void TGo4RemoteBrowserSlots::AddFolder(TFolder* folder,
00209                                        QListViewItem* folderitem,
00210                                        Bool_t isTreeFolders) {
00211    if (folder==0) return;
00212    TCollection* folderslist = folder->GetListOfFolders();
00213    if (folderslist==0) return;
00214    QString protections="";
00215    // remove all items, which no longer presents in folder
00216    QListViewItem* child = (folderitem!=0) ? folderitem->firstChild() : fxTGo4RemoteBrowser->ListViewRemote->firstChild();
00217    while (child != 0) {
00218       QListViewItem* next = child->nextSibling();
00219       if (folderslist->FindObject(child->text(0))==0) delete child;
00220       child = next;
00221    }
00222 
00223    TObject* entry=0;
00224    TIter iter(folder->GetListOfFolders());
00225 
00226    while( (entry = iter()) !=0 ) {
00227       const char* EntryName = entry->GetName();
00228 
00229       // find if item alreay exists
00230       QListViewItem* entryitem = (folderitem!=0) ? folderitem->firstChild() : fxTGo4RemoteBrowser->ListViewRemote->firstChild();
00231       while (entryitem != 0) {
00232          if (entryitem->text(0) == EntryName) break;
00233          entryitem = entryitem->nextSibling();
00234       }
00235 
00236       // process subitems of existing item
00237       if (entryitem!=0) {
00238          if(entry->InheritsFrom(TFolder::Class())) {
00239             TFolder* subfolder = dynamic_cast<TFolder*> (entry);
00240             AddFolder(subfolder, entryitem, isTreeFolders);
00241          } else
00242 
00243          if (entry->InheritsFrom(TGo4TreeStructure::Class())) {
00244             TGo4TreeStructure* TreeSubObj = dynamic_cast<TGo4TreeStructure*>(entry);
00245             AddFolder(TreeSubObj->GetNamesFolder(), entryitem, kTRUE);
00246          }
00247       } else {
00248 
00249           // create new item in folder
00250 
00251           if(entry->InheritsFrom(TFolder::Class())) {
00252              TFolder* subfolder= dynamic_cast<TFolder*> (entry);
00253 
00254              if (isTreeFolders)
00255                 entryitem = new TGo4QBranchItem(folderitem, EntryName, "TBranch");
00256              else
00257                 if (folderitem==0)
00258                    entryitem = new TGo4QFolderItem(fxTGo4RemoteBrowser->ListViewRemote, EntryName, "Folder");
00259                 else
00260                    entryitem = new TGo4QFolderItem(folderitem, EntryName);
00261 
00262              AddFolder(subfolder, entryitem, isTreeFolders);
00263           } else
00264 
00265           if (entry->InheritsFrom(TGo4TreeStructure::Class())) {
00266              entryitem = new TGo4QTreeItem(folderitem, EntryName);
00267              TGo4TreeStructure *TreeSubObj= dynamic_cast<TGo4TreeStructure*>(entry);
00268              AddFolder(TreeSubObj->GetNamesFolder(), entryitem, kTRUE);
00269           } else
00270 
00271           if(entry->InheritsFrom(TGo4TreeHistogramEntryStatus::Class())) {
00272              entryitem = new TGo4QDynEntryItem(folderitem, EntryName, "Dynamic Entry");
00273           } else
00274 
00275           if(entry->InheritsFrom(TGo4HistogramEntryStatus::Class())) {
00276              entryitem = new TGo4QDynEntryItem(folderitem, EntryName, "Dynamic Entry");
00277           } else
00278 
00279           if(entry->InheritsFrom(TGo4DynamicEntryStatus::Class())) {
00280              entryitem = new TGo4QItem(folderitem, 0, EntryName);
00281           } else
00282 
00283           if(entry->InheritsFrom(TGo4BranchStatus::Class())) {
00284              TGo4BranchStatus* status =  dynamic_cast <TGo4BranchStatus*> (entry);
00285              entryitem = new TGo4QLeafItem(folderitem, EntryName, status->GetObjectClass());
00286           } else
00287 
00288           if (entry->InheritsFrom(TGo4ParameterStatus::Class())) {
00289              TGo4ParameterStatus* status = dynamic_cast<TGo4ParameterStatus*> (entry);
00290              entryitem = new TGo4QParaItem(folderitem, EntryName, status->GetObjectClass());
00291           } else
00292 
00293           if(entry->InheritsFrom(TGo4ConditionStatus::Class())) {
00294              TGo4ConditionStatus* condstatus = dynamic_cast<TGo4ConditionStatus*> (entry);
00295              Text_t classname[256];
00296              Int_t arrtype = condstatus->GetArrayType();
00297              if(arrtype>0) snprintf(classname,256,"%s-%d", condstatus->GetObjectClass(), arrtype);
00298                       else snprintf(classname,256,"%s", condstatus->GetObjectClass());
00299 
00300              entryitem = fxTGo4DockBrowsers->CreateListViewItem(folderitem, EntryName, classname);
00301           } else
00302 
00303           if(entry->InheritsFrom(TGo4ObjectStatus::Class())) {
00304              TGo4ObjectStatus* status =  dynamic_cast <TGo4ObjectStatus*> (entry);
00305 
00306              entryitem = fxTGo4DockBrowsers->CreateListViewItem(folderitem, EntryName, status->GetObjectClass());
00307 
00308              if (entryitem==0) entryitem = new TGo4QItem(folderitem, 0, EntryName, status->GetObjectClass());
00309           }
00310       } // end create new item
00311 
00312       // set status object for item if any
00313       if (entry->InheritsFrom(TGo4Status::Class())) {
00314          TGo4QItem* qitem = dynamic_cast<TGo4QItem*> (entryitem);
00315          if (qitem) qitem->SetStatus(dynamic_cast<TGo4Status*>(entry));
00316       }
00317 
00318       if(entryitem==0)
00319         entryitem = new TGo4QItem(folderitem, 0, EntryName, "uncknown element");
00320    
00321       // set protection bits of item:
00322        if(entry->InheritsFrom(TGo4ObjectStatus::Class())) {
00323              TGo4ObjectStatus* status =  dynamic_cast <TGo4ObjectStatus*> (entry);
00324              protections="";
00325              if(status->IsDeleteProtect())
00326                protections+="D";
00327              else
00328                protections+=" ";
00329              if(status->IsResetProtect()) protections+="C";
00330              entryitem->setText(2,protections);
00331        }
00332    } // while
00333 }
00334 
00335 void TGo4RemoteBrowserSlots::ClearBrowser() {
00336    if(fxTGo4RemoteBrowser)
00337       {
00338          TGo4LockGuard Global; // might be called from local command thread!
00339          QListView* lv=fxTGo4RemoteBrowser->ListViewRemote;
00340          if(lv) lv->clear();
00341       }
00342 }
00343 
00344 
00345 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:02 2005 for Go4-v2.10-5 by doxygen1.2.15