00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 const int NColumns = 7;
00017 const int ColumnWidths[NColumns] = { 150, 40, 120, 90, 60, 100, 50 };
00018 const char* ColumnNames[NColumns] = { "Name", "Flags", "Info", "Date", "Time", "Class", "Size" };
00019 const int ColumnAllign[NColumns] = { Qt::AlignLeft, Qt::AlignLeft, Qt::AlignLeft, Qt::AlignLeft, Qt::AlignLeft, Qt::AlignLeft, Qt::AlignRight };
00020
00021 void TGo4Browser::init()
00022 {
00023 setAcceptDrops(false);
00024 setCanDestroyWidget(FALSE);
00025
00026 fbUpdateTimerActive = false;
00027
00028 ListView->setSorting(-1);
00029 ListView->setSelectionMode(QListView::Extended);
00030 ListView->setAcceptDrops(false);
00031 ListView->viewport()->setAcceptDrops(true);
00032
00033 for(int indx=0;indx<NColumns;indx++) {
00034 fIndexes[indx] = indx;
00035
00036 int width = -1;
00037 if ((indx==0) || (indx==2))
00038 width = ColumnWidths[indx];
00039 width = go4sett->getBrowserColumn(ColumnNames[indx], width);
00040 fVisibleColumns[indx] = width>0;
00041 if (fVisibleColumns[indx])
00042 ListView->addColumn(ColumnNames[indx], width);
00043 }
00044
00045
00046 connect(ListView, SIGNAL(RequestDragObject(QDragObject**)),
00047 this, SLOT(RequestDragObjectSlot(QDragObject**)));
00048
00049 connect(ListView, SIGNAL(ItemDropAccept(void*, void*, bool*)),
00050 this, SLOT(ItemDropAcceptSlot(void*, void*, bool*)));
00051
00052 connect(ListView, SIGNAL(ItemDropProcess(void*, void*)),
00053 this, SLOT(ItemDropProcessSlot(void*, void*)));
00054
00055 connect(ListView->header(), SIGNAL(sizeChange(int, int, int)),
00056 this, SLOT(HeaderSizeChanged(int, int, int)));
00057
00058 QToolTip::add(ListView->header(),
00059 QString("You can change selected browser columns\n") +
00060 "by activating RMB. Flags has following meaning\n" +
00061 "m - monitored,\ns - static,\n" +
00062 "d - can be deleted,\np - protected against delete\n" +
00063 "r - can not be reset (read only),\nw - can be reset");
00064 }
00065
00066 void TGo4Browser::destroy()
00067 {
00068 }
00069
00070 void TGo4Browser::StartWorking()
00071 {
00072 AddLink("","Browser");
00073 ShootUpdateTimer();
00074 }
00075
00076 void TGo4Browser::linkedObjectUpdated(const char* linkname, TObject* obj)
00077 {
00078 if (strcmp(linkname,"Browser")==0) {
00079 ShootUpdateTimer();
00080 } else
00081
00082 if (strcmp(linkname,"TGo4Slot::evSubslotUpdated")==0) {
00083 TGo4Slot* itemslot = dynamic_cast<TGo4Slot*> (obj);
00084 if (itemslot!=0)
00085 SetViewItemProperties(itemslot, FindItemFor(itemslot));
00086 }
00087 }
00088
00089 void TGo4Browser::RequestDragObjectSlot(QDragObject** res)
00090 {
00091 *res = 0;
00092
00093 if (ListView->currentItem()==0) return;
00094
00095 QString fullname = FullItemName(ListView->currentItem());
00096
00097 *res = new QTextDrag(fullname, this);
00098 }
00099
00100 void TGo4Browser::ItemDropAcceptSlot(void* item, void* mime, bool* res)
00101 {
00102 *res = false;
00103 QString tgtname = FullItemName((QListViewItem*) item);
00104
00105 QString dropname;
00106 if (!QTextDrag::decode((const QMimeSource*)mime, dropname)) return;
00107
00108 TGo4Slot* tgtslot = Browser()->ItemSlot(tgtname);
00109 TGo4Slot* dropslot = Browser()->ItemSlot(dropname);
00110
00111 if ((tgtslot==0) || (dropslot==0)) return;
00112 if (Browser()->ItemKind(tgtslot)!=TGo4Access::kndFolder) return;
00113
00114 if (dropslot->GetParent()==tgtslot) return;
00115
00116 *res = true;
00117 }
00118
00119 void TGo4Browser::ItemDropProcessSlot(void* item, void* e)
00120 {
00121 QString tgtname = FullItemName((QListViewItem*) item);
00122 QString dropname;
00123 if (!QTextDrag::decode((QDropEvent*)e, dropname)) return;
00124 Browser()->ProduceExplicitCopy(dropname, tgtname, go4sett->getFetchDataWhenCopy());
00125 }
00126
00127 void TGo4Browser::ResetWidget()
00128 {
00129 }
00130
00131 TGo4BrowserProxy* TGo4Browser::BrowserProxy()
00132 {
00133 return (TGo4BrowserProxy*) GetLinked("Browser", 0);
00134 }
00135
00136 QString TGo4Browser::FullItemName(QListViewItem* item)
00137 {
00138 QString name;
00139 if (item!=0) {
00140 name = item->text(0);
00141 while (item->parent()!=0) {
00142 item = item->parent();
00143 name = item->text(0) + "/" + name;
00144 }
00145 }
00146 return name;
00147 }
00148
00149 QListViewItem* TGo4Browser::FindItemFor(TGo4Slot* slot)
00150 {
00151 TGo4BrowserProxy* br = BrowserProxy();
00152 if (br==0) return 0;
00153
00154 TString itemname;
00155 if (!br->BrowserItemName(slot, itemname)) return 0;
00156 const char* iname = itemname.Data();
00157
00158 QListViewItemIterator it(ListView);
00159 for ( ; it.current(); ++it ) {
00160 QString fullname = FullItemName(it.current());
00161 if (strcmp(fullname.latin1(), iname)==0) return it.current();
00162 }
00163 return 0;
00164 }
00165
00166 void TGo4Browser::SetViewItemProperties(TGo4Slot* itemslot, QListViewItem* item)
00167 {
00168 if ((itemslot==0) || (item==0)) return;
00169
00170 TGo4BrowserProxy* br = BrowserProxy();
00171
00172 bool mon = br->IsItemMonitored(itemslot);
00173 bool remote = br->IsItemRemote(itemslot);
00174 int kind = br->ItemKind(itemslot);
00175 int cando = br->ItemCanDo(itemslot);
00176 const char* iteminfo = TGo4BrowserProxy::ItemInfo(itemslot);
00177 const char* classname = TGo4BrowserProxy::ItemClassName(itemslot);
00178
00179 bool visible = false;
00180
00181 switch (br->GetItemFilter()) {
00182 case 1: visible = (itemslot->GetAssignedObject()!=0); break;
00183 case 2: visible = mon; break;
00184 default: visible = true;
00185 }
00186
00187 item->setDragEnabled(TGo4BrowserProxy::CanDragItem(cando));
00188
00189 item->setDropEnabled(false);
00190 if (kind==TGo4Access::kndFolder) {
00191 TGo4Slot* memslot = br->BrowserMemorySlot();
00192 if (itemslot->IsParent(memslot) || (itemslot==memslot))
00193 item->setDropEnabled(true);
00194 }
00195
00196 if (visible)
00197 item->setText(NColumns,"visible");
00198 else
00199 item->setText(NColumns,"hidden");
00200
00201
00202 if (visible && (br->GetItemFilter()>0)) {
00203 QListViewItem* parent = item->parent();
00204 while (parent!=0) {
00205 parent->setText(NColumns, "visible");
00206 parent = parent->parent();
00207 }
00208 }
00209
00210 QString flags;
00211
00212
00213
00214
00215
00216
00217
00218 if (remote && (kind == TGo4Access::kndObject)) {
00219 if (mon) flags+="m";
00220 else flags+="s";
00221 Int_t delprot, clearprot;
00222 br->GetProtectionBits(itemslot, delprot, clearprot);
00223
00224 switch (delprot) {
00225 case 0: flags+="d"; break;
00226 case 1: flags+="p"; break;
00227 default: flags+="-"; break;
00228 }
00229
00230 switch (clearprot) {
00231 case 0: flags+="w"; break;
00232 case 1: flags+="r"; break;
00233 default: flags+="-"; break;
00234 }
00235 }
00236 if (fIndexes[1]>0)
00237 item->setText(fIndexes[1], flags);
00238 if (fIndexes[2]>0)
00239 item->setText(fIndexes[2], iteminfo);
00240 if (fIndexes[3]>0)
00241 item->setText(fIndexes[3], br->ItemDate(itemslot));
00242 if (fIndexes[4]>0)
00243 item->setText(fIndexes[4], br->ItemTime(itemslot));
00244 if (fIndexes[5]>0)
00245 item->setText(fIndexes[5], classname);
00246 if (fIndexes[6]>0) {
00247 QString sizelbl = "";
00248 int sizeinfo = br->ItemSizeInfo(itemslot);
00249 int calcsize = br->GetCalcSize(itemslot);
00250 if (sizeinfo>0) sizelbl = QString::number(sizeinfo); else
00251 if (calcsize>0) sizelbl = QString("= ") + QString::number(calcsize);
00252 item->setText(fIndexes[6], sizelbl);
00253 }
00254 }
00255
00256 void TGo4Browser::updateListViewItems()
00257 {
00258 TGo4LockGuard lock;
00259
00260 fbUpdateTimerActive = false;
00261
00262
00263 int indx = 1;
00264 int ncolumn = 1;
00265 while (indx<NColumns) {
00266 if (fVisibleColumns[indx]) {
00267 while ((ncolumn<ListView->columns()) &&
00268 ListView->header()->label(ncolumn) != QString(ColumnNames[indx]))
00269 ListView->removeColumn(ncolumn);
00270 if (ncolumn>=ListView->columns())
00271 ListView->addColumn(ColumnNames[indx], ColumnWidths[indx]);
00272 fIndexes[indx]=ncolumn;
00273 ListView->setColumnAlignment(ncolumn, ColumnAllign[indx]);
00274 ncolumn++;
00275 } else
00276 fIndexes[indx]=-1;
00277
00278 indx++;
00279 }
00280
00281
00282 while (ncolumn<ListView->columns())
00283 ListView->removeColumn(ncolumn);
00284
00285 TGo4BrowserProxy* br = BrowserProxy();
00286 if (br==0) return;
00287
00288 ServiceCall("UpdateGuiLayout");
00289
00290 TGo4Slot* topslot = br->BrowserTopSlot();
00291 if (topslot==0) return;
00292
00293 checkVisisbilityFlags(true);
00294
00295
00296
00297 QListViewItem* curfold = 0;
00298 QListViewItem* curitem = ListView->firstChild();
00299 QListViewItem* previtem = 0;
00300
00301 TGo4Iter iter(topslot, kTRUE);
00302
00303 TObjArray testedClasses;
00304
00305 while (true) {
00306 Bool_t res = iter.next();
00307
00308
00309 Int_t levelchange = iter.levelchange();
00310 while (levelchange++<0) {
00311
00312 while (curitem!=0) {
00313 QListViewItem* next = curitem->nextSibling();
00314 delete curitem;
00315 curitem = next;
00316 }
00317
00318 if (curfold==0) break;
00319
00320 curitem = curfold->nextSibling();
00321 previtem = curfold;
00322 curfold = curfold->parent();
00323 }
00324
00325 if (!res) break;
00326
00327
00328 while ((curitem!=0) && (strcmp(iter.getname(), curitem->text(0))!=0)) {
00329 QListViewItem* next = curitem->nextSibling();
00330 delete curitem;
00331 curitem = next;
00332 }
00333
00334 TGo4Slot* curslot = iter.getslot();
00335 if (curslot==0) {
00336 cerr << "************* ERROR in gui slots ****************** " << endl;
00337 return;
00338 }
00339
00340 const char* classname = br->ItemClassName(curslot);
00341 Int_t itemkind = br->ItemKind(curslot);
00342 TClass* itemclass = 0;
00343
00344 if ((classname!=0) && (testedClasses.FindObject(classname)==0)) {
00345 itemclass = gROOT->GetClass(classname);
00346 if (itemclass==0)
00347 testedClasses.Add(new TNamed(classname,""));
00348 }
00349
00350 TString pixmap;
00351 int cando = TGo4BrowserProxy::DefineItemProperties(itemkind, itemclass, pixmap);
00352 TGo4BrowserProxy::SetItemCanDo(curslot, cando);
00353
00354 if (curitem==0) {
00355 if (curfold==0)
00356 curitem = new QGo4BrowserItem(ListView, previtem, iter.getname());
00357 else
00358 curitem = new QGo4BrowserItem(curfold, previtem, iter.getname());
00359 }
00360
00361 if ((pixmap.Length()>0) && (curitem->pixmap(0)==0))
00362 curitem->setPixmap(0, QPixmap::fromMimeSource(pixmap.Data()));
00363
00364 SetViewItemProperties(curslot, curitem);
00365
00366 if (iter.isfolder()) {
00367 curfold = curitem;
00368 curitem = curfold->firstChild();
00369 previtem = 0;
00370 } else {
00371
00372 while (curitem->firstChild()!=0)
00373 delete curitem->firstChild();
00374 previtem = curitem;
00375 curitem = curitem->nextSibling();
00376 }
00377 }
00378
00379 while (curitem!=0) {
00380 QListViewItem* next = curitem->nextSibling();
00381 delete curitem;
00382 curitem = next;
00383 }
00384
00385 if (br->GetItemFilter()>0)
00386 checkVisisbilityFlags(false);
00387
00388 ListView->update();
00389 ListView->viewport()->update();
00390
00391 testedClasses.Delete();
00392 }
00393
00394 void TGo4Browser::checkVisisbilityFlags(bool showall)
00395 {
00396 QListViewItemIterator it(ListView);
00397 for ( ; it.current(); ++it ) {
00398 QListViewItem* item = it.current();
00399 if (showall || (item->parent()==0))
00400 item->setVisible(true);
00401 else
00402 item->setVisible(item->text(NColumns)=="visible");
00403 }
00404 }
00405
00406 void TGo4Browser::DisplaySelectedItems()
00407 {
00408
00409 TGo4BrowserProxy* br = BrowserProxy();
00410
00411 int npads = 0;
00412
00413 {
00414 QListViewItemIterator it(ListView);
00415 for ( ; it.current(); ++it )
00416 if (it.current()->isSelected() &&
00417 canDrawItem(it.current())) npads++;
00418 }
00419
00420 if (npads==0) return;
00421
00422 TGo4ViewPanel* newpanel = CreateViewPanel(npads);
00423 TPad* subpad = 0;
00424
00425 int cnt = 0;
00426 QListViewItemIterator it(ListView);
00427 for ( ; it.current(); ++it )
00428 if ( it.current()->isSelected() && canDrawItem(it.current())) {
00429 QString itemname = FullItemName(it.current());
00430
00431 subpad = newpanel->GetSubPad(newpanel->GetCanvas(), cnt++, true);
00432
00433 DrawItem(itemname.latin1(), newpanel, subpad, false);
00434 }
00435 newpanel->ShootRepaintTimer();
00436
00437 }
00438
00439
00440 void TGo4Browser::SuperImposeSelectedItems()
00441 {
00442 TGo4ViewPanel* newpanel = 0;
00443
00444 QListViewItemIterator it(ListView);
00445 for ( ; it.current(); ++it )
00446 if ( it.current()->isSelected() && canDrawItem(it.current())) {
00447 if (newpanel==0) {
00448 newpanel = CreateViewPanel();
00449 newpanel->SetPadSuperImpose(newpanel->GetCanvas(), true);
00450 }
00451
00452 QString itemname = FullItemName(it.current());
00453
00454 DrawItem(itemname.latin1(), newpanel, newpanel->GetCanvas(), false);
00455 }
00456 if (newpanel!=0)
00457 newpanel->ShootRepaintTimer();
00458 }
00459
00460 void TGo4Browser::ListView_doubleClicked(QListViewItem* item)
00461 {
00462 if (item==0) return;
00463
00464 QString fullname = FullItemName(item);
00465
00466 TGo4BrowserProxy* br = BrowserProxy();
00467
00468 int cando = br->ItemCanDo(fullname.latin1());
00469 TGo4Slot* itemslot = br->ItemSlot(fullname.latin1());
00470
00471 if (TGo4BrowserProxy::CanDrawItem(cando))
00472 DrawItem(fullname.latin1(), 0, 0, true);
00473 else
00474 if (TGo4BrowserProxy::CanEditItem(cando))
00475 EditItem(fullname.latin1());
00476
00477
00478
00479
00480 }
00481
00482 void TGo4Browser::ListView_contextMenuRequested(QListViewItem* item, const QPoint& pos, int col)
00483 {
00484 if (col!=0) {
00485 QPopupMenu contextMenu;
00486 for(int indx=1;indx<NColumns;indx++) {
00487 contextMenu.insertItem(ColumnNames[indx], indx);
00488 contextMenu.setItemChecked(indx, fVisibleColumns[indx]);
00489 }
00490 connect(&contextMenu, SIGNAL(activated(int)), this, SLOT(ColumnToggled(int)));
00491
00492 contextMenu.exec(pos);
00493 return;
00494 }
00495
00496 TGo4BrowserProxy* br = BrowserProxy();
00497 TGo4Slot* memslot = br->BrowserMemorySlot();
00498 TGo4Slot* analslot = br->FindAnalysisSlot(false);
00499
00500 int nitems = 0;
00501 int nmemory = 0;
00502 bool istopmemory = false;
00503 int nclose = 0;
00504 int ndraw = 0;
00505 int nsuperimpose = 0;
00506 int si_kind = -1;
00507 int nremote = 0;
00508 int nanalysis = 0;
00509 int nmonitor = 0;
00510 int nclear = 0;
00511 int nclearproton = 0;
00512 int nclearprotoff = 0;
00513 int ndelprotoff = 0;
00514 int nobjects = 0;
00515 int nfolders = 0;
00516 int nedits = 0;
00517 int ninfo = 0;
00518 int nexport = 0;
00519 int ndelete = 0;
00520 int nassigned = 0;
00521
00522 QListViewItemIterator it(ListView);
00523 for ( ; it.current(); ++it )
00524 if (it.current()->isSelected()) {
00525 QString fullname = FullItemName(it.current());
00526 TGo4Slot* itemslot = br->ItemSlot(fullname.latin1());
00527 if (itemslot==0) continue;
00528 nitems++;
00529
00530 int cando = br->ItemCanDo(itemslot);
00531 int kind = br->ItemKind(itemslot);
00532 const char* itemclassname = br->ItemClassName(itemslot);
00533
00534 bool ismemitem = itemslot->IsParent(memslot);
00535
00536 if (br->IsCanDelete(itemslot) || ismemitem)
00537 ndelete++;
00538
00539 if (kind==TGo4Access::kndObject)
00540 nobjects++;
00541
00542 if (kind==TGo4Access::kndFolder)
00543 nfolders++;
00544
00545 if (TGo4BrowserProxy::CanDrawItem(cando)) {
00546 ndraw++;
00547 TClass* cl = gROOT->GetClass(br->ItemClassName(itemslot));
00548 if (cl!=0)
00549 if (cl->InheritsFrom("TH1")) {
00550 if (!cl->InheritsFrom("TH2") && !cl->InheritsFrom("TH3")) {
00551 if ((si_kind<0) || (si_kind==1)) {
00552 si_kind=1;
00553 nsuperimpose++;
00554 }
00555 }
00556 } else
00557 if (cl->InheritsFrom("TGraph")) {
00558 if ((si_kind<0) || (si_kind==2)) {
00559 si_kind=2;
00560 nsuperimpose++;
00561 }
00562 }
00563 }
00564
00565 if (TGo4BrowserProxy::CanEditItem(cando))
00566 nedits++;
00567
00568 if (TGo4BrowserProxy::CanCloseItem(cando))
00569 nclose++;
00570
00571 if (TGo4BrowserProxy::CanInfoItem(cando))
00572 ninfo++;
00573
00574 istopmemory = (itemslot==memslot);
00575
00576 if (ismemitem || istopmemory)
00577 nmemory++;
00578
00579 if ((kind==TGo4Access::kndObject) && (itemslot->GetAssignedObject()!=0)) {
00580 nassigned++;
00581 if (TGo4BrowserProxy::CanExportItem(cando))
00582 nexport++;
00583 }
00584
00585 bool isanalysisitem = (itemslot==analslot) || itemslot->IsParent(analslot);
00586
00587 if (isanalysisitem)
00588 nanalysis++;
00589
00590 if (br->IsItemRemote(itemslot)) {
00591 nremote++;
00592
00593 if (isanalysisitem) {
00594
00595 if (kind==TGo4Access::kndObject) {
00596 Int_t delprot, clearprot;
00597 br->GetProtectionBits(itemslot, delprot, clearprot);
00598 if (clearprot==1) nclearproton++; else
00599 if (clearprot==0) nclearprotoff++;
00600 if (delprot==0) ndelprotoff++;
00601 }
00602
00603 if (TGo4BrowserProxy::CanClearItem(cando) ||
00604 (kind==TGo4Access::kndFolder))
00605 nclear++;
00606 }
00607 }
00608
00609 if (br->IsItemMonitored(itemslot)) nmonitor++;
00610 }
00611
00612 QPopupMenu contextMenu;
00613 contextMenu.insertItem(QPixmap::fromMimeSource("chart.png"),
00614 "Plot", 0, 0, 0, 11);
00615 contextMenu.setItemEnabled(11, (ndraw>0));
00616
00617 contextMenu.insertItem(QPixmap::fromMimeSource("superimpose.png"),
00618 "Superimpose", 0, 0, 0, 12);
00619 contextMenu.setItemEnabled(12, (ndraw>1) && (nsuperimpose==ndraw));
00620
00621 contextMenu.insertItem(QPixmap::fromMimeSource("right.png"),
00622 "Fetch item(s)", 0, 0, 0, 18);
00623 contextMenu.setItemEnabled(18, (nfolders>0) || (nobjects>0));
00624
00625 contextMenu.insertItem(QPixmap::fromMimeSource("saveall.png"),
00626 "Save selected...", 0, 0, 0, 13);
00627 contextMenu.setItemEnabled(13, (nobjects>0) || ((nfolders==1) && (nitems==1)));
00628
00629
00630 if (nexport>0) {
00631
00632 QPopupMenu* expmenu = new QPopupMenu(&contextMenu, "Export menu");
00633
00634 expmenu->insertItem("ASCII", 0, 0, 0, 141);
00635 expmenu->insertItem("Radware", 0, 0, 0, 142);
00636
00637 contextMenu.insertItem(QPixmap::fromMimeSource("export.png"),
00638 "Export to", expmenu);
00639
00640 connect(expmenu, SIGNAL(activated(int)), this, SLOT(ContextMenuActivated(int)));
00641
00642 } else {
00643 contextMenu.insertItem(QPixmap::fromMimeSource("export.png"),
00644 "Export to", 0, 0, 0, 14);
00645 contextMenu.setItemEnabled(14, false);
00646 }
00647
00648 contextMenu.insertItem(QPixmap::fromMimeSource("info.png"),
00649 "Info...", 0, 0, 0, 15);
00650 contextMenu.setItemEnabled(15, (ninfo>0));
00651
00652 contextMenu.insertItem(QPixmap::fromMimeSource("control.png"),
00653 "Edit..", 0, 0, 0, 16);
00654 contextMenu.setItemEnabled(16, (nedits>0));
00655
00656 QString dellabel = "Delete item";
00657 QString delbutton = "delete.png";
00658 if ((nclose>0) && (ndelete==0)) {
00659 dellabel = "Close item";
00660 if (nclose>1) dellabel+="s";
00661 delbutton="close.png";
00662 } else
00663 if ((nclose==0) && (ndelete>0)) {
00664 dellabel = "Delete item";
00665 if (ndelete>1) dellabel+="s";
00666 } else
00667 if ((nclose>0) && (ndelete>0)) {
00668 dellabel = "Close/delete items";
00669 }
00670
00671 contextMenu.insertItem(QPixmap::fromMimeSource(delbutton),
00672 dellabel, 0, 0, 0, 17);
00673 contextMenu.setItemEnabled(17, (nclose>0) || (ndelete>0));
00674
00675 contextMenu.insertItem(QPixmap::fromMimeSource("copyws.png"),
00676 "Copy to Workspace", 0, 0, 0, 19);
00677 contextMenu.setItemEnabled(19, (nobjects>0) || ((nfolders==1) && (nitems==1)));
00678
00679 contextMenu.insertItem(QPixmap::fromMimeSource("editcopy.png"),
00680 "Copy to clipboard", 0, 0, 0, 20);
00681 contextMenu.setItemEnabled(20, (nobjects>0) || (nfolders>0));
00682
00683 if ((nremote>0) || (nanalysis>0)) {
00684
00685 contextMenu.insertSeparator();
00686
00687 contextMenu.insertItem(QPixmap::fromMimeSource("monitor.png"),
00688 "Monitor item(s)", 0, 0, 0, 21);
00689 contextMenu.setItemEnabled(21, ((nobjects>0) && (nremote>0) && (nmonitor<nremote)) || ((nfolders==1) && (nitems==1)));
00690
00691 contextMenu.insertItem(QPixmap::fromMimeSource("Stop.png"),
00692 "Stop item(s) monitoring", 0, 0, 0, 22);
00693 contextMenu.setItemEnabled(22, ((nobjects>0) && (nremote>0) && (nmonitor>0)) || ((nfolders==1) && (nitems==1)));
00694
00695 contextMenu.insertItem(QPixmap::fromMimeSource( "clear.png" ),
00696 "Clear (Reset to 0)", 0, 0, 0, 23);
00697 contextMenu.setItemEnabled(23, (nclear>0));
00698
00699 contextMenu.insertItem(QPixmap::fromMimeSource( "clear_nok.png" ),
00700 "Set Clear protection", 0, 0, 0, 24);
00701 contextMenu.setItemEnabled(24, (nclearprotoff>0));
00702
00703 contextMenu.insertItem(QPixmap::fromMimeSource( "clear_ok.png" ),
00704 "Unset Clear protection", 0, 0, 0, 25);
00705 contextMenu.setItemEnabled(25, (nclearproton>0));
00706
00707 contextMenu.insertItem(QPixmap::fromMimeSource( "delete.png" ),
00708 "Delete from analysis", 0, 0, 0, 26);
00709 contextMenu.setItemEnabled(26, (ndelprotoff>0));
00710
00711 contextMenu.insertItem(QPixmap::fromMimeSource( "refresh.png" ),
00712 "Refresh namelist", 0, 0, 0, 27);
00713 contextMenu.setItemEnabled(27, true);
00714 }
00715
00716 if ((nmemory>0) && (nmemory==nitems)) {
00717 contextMenu.insertSeparator();
00718
00719 contextMenu.insertItem(QPixmap::fromMimeSource("crefolder.png"),
00720 "Create folder", 0, 0, 0, 41);
00721 contextMenu.setItemEnabled(41, (nmemory==1) && (nfolders==1));
00722
00723 contextMenu.insertItem(QPixmap::fromMimeSource("rename.png"),
00724 "Rename object", 0, 0, 0, 42);
00725 contextMenu.setItemEnabled(42, (nmemory==1) && !istopmemory);
00726
00727 contextMenu.insertItem(QPixmap::fromMimeSource("editpaste.png"),
00728 "Paste from clipboard", 0, 0, 0, 43);
00729 contextMenu.setItemEnabled(43, br->IsClipboard() && (nmemory==1) && (nfolders==1));
00730 }
00731
00732 connect(&contextMenu, SIGNAL(activated(int)), this, SLOT(ContextMenuActivated(int)));
00733
00734 contextMenu.exec(pos);
00735 }
00736
00737 void TGo4Browser::ColumnToggled(int indx)
00738 {
00739 if ((indx<=0) || (indx>=NColumns)) return;
00740 fVisibleColumns[indx] = !fVisibleColumns[indx];
00741
00742 HeaderSizeChanged(0, 0, 0);
00743
00744 ShootUpdateTimer();
00745 }
00746
00747 void TGo4Browser::HeaderSizeChanged(int, int, int)
00748 {
00749 int ncolumn = 0;
00750 for(int indx=0;indx<NColumns;indx++) {
00751 int width = -1;
00752 if (fVisibleColumns[indx]) {
00753 width = ListView->columnWidth(ncolumn++);
00754 if (width==0) width = ColumnWidths[indx];
00755 }
00756 go4sett->setBrowserColumn(ColumnNames[indx], width);
00757 }
00758 }
00759
00760 void TGo4Browser::ContextMenuActivated(int id)
00761 {
00762 switch (id) {
00763 case 11: DisplaySelectedItems(); return;
00764 case 12: SuperImposeSelectedItems(); return;
00765 case 13: SaveSelectedItems(); return;
00766 case 141: ExportSelectedItems("ASCII format"); return;
00767 case 142: ExportSelectedItems("Radware format"); return;
00768 }
00769
00770 TGo4BrowserProxy* br = BrowserProxy();
00771
00772 TGo4AnalysisProxy* anrefresh = 0;
00773 TGo4HServProxy* hservrefresh = 0;
00774
00775 if (id==20) br->ClearClipboard();
00776
00777 if (id==19)
00778 QApplication::setOverrideCursor(Qt::WaitCursor);
00779
00780 QListViewItemIterator it(ListView);
00781 for ( ; it.current(); ++it )
00782 if (it.current()->isSelected()) {
00783 QString itemname = FullItemName(it.current());
00784 TGo4Slot* itemslot = br->ItemSlot(itemname.latin1());
00785 if (itemslot==0) continue;
00786 int cando = br->ItemCanDo(itemslot);
00787 int kind = br->ItemKind(itemslot);
00788
00789 switch(id) {
00790 case 15: {
00791 if (TGo4BrowserProxy::CanInfoItem(cando)) {
00792 ShowItemInfo(itemname.latin1());
00793 return;
00794 }
00795 break;
00796 }
00797
00798 case 16: {
00799 if (TGo4BrowserProxy::CanEditItem(cando)) {
00800 EditItem(itemname.latin1());
00801 return;
00802 }
00803 break;
00804 }
00805
00806 case 17: {
00807 br->DeleteDataSource(itemslot);
00808 break;
00809 }
00810
00811 case 18: {
00812 br->FetchItem(itemname.latin1());
00813 break;
00814 }
00815
00816 case 19: {
00817 br->ProduceExplicitCopy(itemname.latin1(), 0, go4sett->getFetchDataWhenCopy());
00818 break;
00819 }
00820
00821 case 20: {
00822 br->AddToClipboard(itemname.latin1());
00823 break;
00824 }
00825
00826 case 21:
00827 case 22: {
00828 br->SetItemMonitored(itemslot, id==21);
00829 ShootUpdateTimer();
00830 break;
00831 }
00832
00833 case 23: {
00834 TString objname;
00835 TGo4AnalysisProxy* an = br->DefineAnalysisObject(itemname.latin1(), objname);
00836 if (an!=0) {
00837 an->ClearAnalysisObject(objname.Data());
00838
00839 if (kind==TGo4Access::kndFolder) {
00840 TGo4Iter iter(itemslot, kTRUE);
00841 while (iter.next()) {
00842 TGo4Slot* subslot = iter.getslot();
00843 if (subslot->GetAssignedObject()!=0)
00844 subslot->Update(kFALSE);
00845 }
00846 } else
00847 if (itemslot->GetAssignedObject()!=0)
00848 itemslot->Update(kFALSE);
00849 }
00850 break;
00851 }
00852
00853 case 24:
00854 case 25: {
00855 TString objname;
00856 TGo4AnalysisProxy* an = br->DefineAnalysisObject(itemname.latin1(), objname);
00857 if (an!=0) {
00858 an->ChageObjectProtection(objname.Data(), (id == 24 ? "+C" : "-C"));
00859 anrefresh = an;
00860 }
00861 break;
00862 }
00863
00864 case 26: {
00865 TString objname;
00866 TGo4AnalysisProxy* an = br->DefineAnalysisObject(itemname.latin1(), objname);
00867 if (an!=0) {
00868 an->RemoveObjectFromAnalysis(objname.Data(), br->ItemClass(itemslot));
00869 anrefresh = an;
00870 }
00871 break;
00872 }
00873
00874 case 27: {
00875 TString objname;
00876 TGo4AnalysisProxy* an = br->DefineAnalysisObject(itemname.latin1(), objname);
00877 TGo4HServProxy* hserv = br->DefineHServerProxy(itemname.latin1());
00878 if (an!=0) anrefresh = an;
00879 if (hserv!=0) hservrefresh = hserv;
00880 break;
00881 }
00882
00883 case 41: {
00884 bool ok = false;
00885 QString folder =
00886 QInputDialog::getText("Create folder in workspace",
00887 "Input folder name",
00888 QLineEdit::Normal,
00889 QString::null,
00890 &ok);
00891 if (ok) br->CreateMemorySubfolder(itemname.latin1(), folder.latin1());
00892 break;
00893 }
00894
00895 case 42: {
00896 bool ok = false;
00897 QString newname =
00898 QInputDialog::getText("Rename item in workspace",
00899 "Input new item name",
00900 QLineEdit::Normal,
00901 QString::null,
00902 &ok);
00903 if (ok) br->RenameMemoryItem(itemname.latin1(), newname.latin1());
00904 break;
00905 }
00906
00907 case 43: {
00908 br->CopyClipboard(itemname.latin1(), go4sett->getFetchDataWhenCopy());
00909 br->ClearClipboard();
00910 break;
00911 }
00912 }
00913 }
00914
00915 if (anrefresh!=0)
00916 anrefresh->RefreshNamesList();
00917
00918 if (hservrefresh!=0)
00919 hservrefresh->RequestHistosList();
00920
00921 if (id==19)
00922 QApplication::restoreOverrideCursor();
00923 }
00924
00925 bool TGo4Browser::canDrawItem(QListViewItem* item)
00926 {
00927 if (item==0) return false;
00928 int cando = BrowserProxy()->ItemCanDo(FullItemName(item));
00929 return TGo4BrowserProxy::CanDrawItem(cando);
00930 }
00931
00932 void TGo4Browser::ShootUpdateTimer()
00933 {
00934 if (fbUpdateTimerActive) return;
00935
00936 fbUpdateTimerActive = true;
00937
00938 QTimer::singleShot(1, this, SLOT(updateListViewItems()));
00939 }
00940
00941 void TGo4Browser::SaveSelectedItems()
00942 {
00943 QFileDialog fd(this, "export", kTRUE );
00944 fd.setMode( QFileDialog::AnyFile);
00945 fd.setCaption("Save selected objects to file");
00946 fd.setFilters(QString("ROOT (*.root);;ROOT XML (*.xml)"));
00947 if (fd.exec() != QDialog::Accepted) return;
00948
00949 QString fname = fd.selectedFile();
00950 QString title;
00951
00952 if (fd.selectedFilter() == "ROOT (*.root)") {
00953 bool ok = false;
00954 title = QInputDialog::getText(
00955 "Save slected objects to file", "Provide file title",
00956 QLineEdit::Normal, QString::null, &ok);
00957 if (!ok) return;
00958 if (fname.find(".root", 0, FALSE)<0) fname+=".root";
00959 } else {
00960 if (fname.find(".xml", 0, FALSE)<0) fname+=".xml";
00961 }
00962
00963 ExportSelectedItems(fname.latin1(),
00964 QFileInfo(fname).dirPath(true).latin1(),
00965 fd.selectedFilter().latin1(),
00966 title.latin1());
00967 }
00968
00969 void TGo4Browser::ExportSelectedItems(const char* filtername)
00970 {
00971 QFileDialog fd(this, "export", kTRUE );
00972 fd.setMode(QFileDialog::DirectoryOnly);
00973 fd.setCaption(QString("Select directory to export to ") + filtername);
00974 if (fd.exec() != QDialog::Accepted) return;
00975
00976 ExportSelectedItems("null",
00977 fd.selectedFile().latin1(),
00978 filtername,
00979 "Export of selected items");
00980 }
00981
00982 void TGo4Browser::ExportSelectedItems(const char* filename, const char* filedir, const char* format, const char* description)
00983 {
00984 TObjArray items;
00985 QListViewItemIterator it(ListView);
00986 for ( ; it.current(); ++it )
00987 if (it.current()->isSelected()) {
00988 QString fullname = FullItemName(it.current());
00989 items.Add(new TObjString(fullname.latin1()));
00990 }
00991
00992 BrowserProxy()->ExportItemsTo(&items, go4sett->getFetchDataWhenSave(), filename, filedir, format, description);
00993
00994 items.Delete();
00995 }
00996
00997