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

/Go4GUI/TGo4MonitoredList.ui.h

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 void TGo4MonitoredList::ItemDoubleClicked ( QListViewItem *MonitoredObject)
00017 {
00018    fxDragItem=0;
00019    fxTGo4MonitoredListSlots->ItemDoubleClicked (MonitoredObject);
00020 }
00021 
00022 void TGo4MonitoredList::init()
00023 {
00024 // TGo4LockGuard glob;
00025     fxDragItem=0;
00026     TGo4GUIRegistry *fxTGo4GUIRegistry;
00027     fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00028     fxTGo4MonitoredListSlots = (TGo4MonitoredListSlots *) fxTGo4GUIRegistry->GetSlotClass("TGo4MonitoredListSlots");
00029     if(fxTGo4MonitoredListSlots  !=0) {
00030       fxTGo4MonitoredListSlots->SetGUI(this);
00031     }else{
00032       fxTGo4MonitoredListSlots = new TGo4MonitoredListSlots ("TGo4MonitoredListSlots", "Slots Class for Qt GUI", this);
00033     }
00034 
00035     fiMonitorState = 0;
00036     StopMonitor->setDisabled(TRUE);
00037 
00038    timer = new QTimer(this);
00039    connect(timer, SIGNAL(timeout()), this, SLOT(StartMonitoringAll()));
00040    vistimer = new QTimer(this);
00041    connect(vistimer ,SIGNAL(timeout()) ,this, SLOT(StartMonitoringVis()));
00042 
00043    fxContextMenu = new QPopupMenu( ListViewMonitor );
00044    Q_CHECK_PTR( fxContextMenu );
00045    fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "h1_t" ), "Plot",  this, SLOT(PlotSelected()));
00046    fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "clear.png" ), "Clear (Reset to 0)", this, SLOT(ResetRemotObj()));
00047    fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "delete.png" ), "Remove from monitoring", this, SLOT(DeleteItem()));
00048    fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "right" ), "Copy to local memory", this, SLOT(SendToLocalList()));
00049    fxContextMenu->insertSeparator();
00050    fiMenuStartVisID=fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "startselected.png" ), "Start monitoring visible", this, SLOT(MonitorVisible())); 
00051    fiMenuStopID=fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "Stop.png" ), "Stop monitoring", this, SLOT(StopMonitoring())); 
00052 }
00053 
00054 void TGo4MonitoredList::PlotSelected()
00055 {
00056    fxTGo4MonitoredListSlots->PlotSelected();
00057 }
00058 
00059 void TGo4MonitoredList::DeleteItem()
00060 {
00061    fxTGo4MonitoredListSlots->DeleteItem();
00062 }
00063 
00064 void TGo4MonitoredList::SendToLocalList()
00065 {
00066     fxTGo4MonitoredListSlots->SendToLocalList();
00067 }
00068 
00069 void TGo4MonitoredList::closeEvent( QCloseEvent * ce )
00070 {
00071    // TGo4LockGuard glob;
00072     ce->accept();
00073      delete this;
00074 }
00075 
00076 void TGo4MonitoredList::destroy()
00077 {
00078    // TGo4LockGuard glob;
00079     ListViewMonitor->clear();
00080     fxTGo4MonitoredListSlots->SetGUI(0);
00081 }
00082 
00083 
00084 void TGo4MonitoredList::MonitorAll()
00085 {
00086 
00087     timer->start(update_time->value()*1000);
00088     update_time->setDisabled(TRUE);
00089     StartMonitor->setDisabled(TRUE);
00090     StartMonitorVis->setDisabled(TRUE);
00091     StopMonitor->setDisabled(FALSE);
00092     Monitor_label->clear();
00093     Monitor_label->setText("All objects are Monitored");
00094     fiMonitorState = 2;
00095 }
00096 
00097 void TGo4MonitoredList::SetMonitorInterval(int time_sec) {
00098   if (time_sec<2) time_sec = 2;
00099   update_time->setValue(time_sec);
00100 }
00101 
00102 void TGo4MonitoredList::MonitorVisible()
00103 {
00104     vistimer->start(update_time->value()*1000);
00105     update_time->setDisabled(TRUE);
00106     StartMonitor->setDisabled(TRUE);
00107     StartMonitorVis->setDisabled(TRUE);
00108     StopMonitor->setDisabled(FALSE);
00109     Monitor_label->clear();
00110     Monitor_label->setText("Only visible objects are Monitored");
00111     fiMonitorState = 1;
00112 }
00113 
00114 void TGo4MonitoredList::StartMonitoringAll()
00115 {
00116    fxTGo4MonitoredListSlots->StartMonitoring();
00117 }
00118 
00119 void TGo4MonitoredList::StartMonitoringVis()
00120 {
00121    fxTGo4MonitoredListSlots->MonitorVisible();
00122 }
00123 
00124 
00125 void TGo4MonitoredList::StopMonitoring()
00126 {
00127    if(timer->isActive()) timer->stop();
00128    if(vistimer->isActive()) vistimer->stop();
00129     update_time->setDisabled(FALSE);
00130     StartMonitor->setDisabled(FALSE);
00131     StartMonitorVis->setDisabled(FALSE);
00132     StopMonitor->setDisabled(TRUE);
00133     Monitor_label->clear();
00134     Monitor_label->setText("Monitoring is inactive");
00135     fiMonitorState = 0;
00136     // have to reset the monitordone flags:
00137     QListViewItemIterator it(ListViewMonitor);
00138     for ( ; it.current(); ++it )
00139         {
00140             TGo4QItem* item1=dynamic_cast <TGo4QItem *> (it.current());
00141             if (item1!=0) item1->SetMonitorDone(true);
00142         }
00143     
00144     
00145 }
00146 
00147 void TGo4MonitoredList::ResetRemotObj()
00148 {
00149    // TGo4LockGuard glob;
00150     QListViewItem *SelectedItem;
00151     SelectedItem = ListViewMonitor->selectedItem();
00152     if(ListViewMonitor->isMultiSelection()){
00153       QListViewItemIterator it(ListViewMonitor);
00154       // iterate through all items of the list view
00155        for ( ; it.current(); ++it ) {
00156           if ( it.current()->isSelected() ){
00157 
00158                 fxTGo4MonitoredListSlots->ResetRemoteObj(it.current()->text(0));
00159           }
00160       }
00161     }else{
00162       if (SelectedItem !=0){
00163 
00164           fxTGo4MonitoredListSlots->ResetRemoteObj(SelectedItem->text(0));
00165       }
00166     }
00167      ListViewMonitor->clearSelection();
00168 }
00169 
00170 QPtrList  <TGo4QItem>* TGo4MonitoredList::GetSelectedItems()
00171 {
00172    // TGo4LockGuard global;
00173    // Create the list
00174 
00175    QPtrList <TGo4QItem> *lst = new QPtrList <TGo4QItem>;
00176 
00177    if(ListViewMonitor->isMultiSelection()){
00178        QListViewItemIterator it(ListViewMonitor);
00179       // iterate through all items of the list view
00180           for ( ; it.current(); ++it ) {
00181                if ( it.current()->isSelected() ){
00182                     lst->append((TGo4QItem *)it.current() );
00183             }
00184            }
00185    }
00186 
00187    return lst;
00188 
00189 }
00190 
00191 int TGo4MonitoredList::GetMonitorState() {
00192    return fiMonitorState;
00193 }
00194 
00195 int TGo4MonitoredList::GetMonitorInterval() {
00196    return update_time->value();
00197 }
00198 
00199 
00200 
00201 void TGo4MonitoredList::SetListFocus()
00202 {
00203 ListViewMonitor->setFocus();
00204 }
00205 
00206 
00207 void TGo4MonitoredList::ListViewMonitor_pressed( QListViewItem * SelectedItem)
00208 {
00209   fxDragItem=SelectedItem;
00210   int timems=QApplication::startDragTime();
00211   QTimer::singleShot( timems, this, SLOT(StartListviewDrag()) );  
00212 }
00213 
00214 void TGo4MonitoredList::ListViewMonitor_clicked( QListViewItem * )
00215 {
00216 fxDragItem=0; // no drag after click complete
00217 }
00218 
00219 
00220 void TGo4MonitoredList::StartListviewDrag()
00221 {
00222 if(fxDragItem==0) return;
00223 ListViewMonitor->setCurrentItem(fxDragItem); // drop will always refer to currently selected item
00224 QDragObject *d = new QTextDrag(fxDragItem->text(0),ListViewMonitor);
00225 d->dragCopy();
00226 fxDragItem=0;
00227 }
00228 
00229 
00230 void TGo4MonitoredList::ListViewMonitor_contextMenuRequested( QListViewItem* selitem, const QPoint& pt, int )
00231 {
00232 fxDragItem=0;// no drag start after context menu  
00233 if(selitem==0) return;
00234 // change selectability of start/stop. fiMonitorState is 0 if monitoring is off.
00235 fxContextMenu-> setItemEnabled (fiMenuStartVisID, !fiMonitorState);
00236 fxContextMenu-> setItemEnabled (fiMenuStopID, fiMonitorState);
00237 fxContextMenu->exec(pt);
00238 
00239 
00240 }
00241 
00242 //----------------------------END OF GO4 SOURCE FILE ---------------------

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