ATLAS Offline Software
Classes | Public Slots | Signals | Public Member Functions | Protected Types | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
VP1TabManager Class Reference

#include <VP1TabManager.h>

Inheritance diagram for VP1TabManager:
Collaboration diagram for VP1TabManager:

Classes

class  Imp
 

Public Slots

void addNewTab (const QString &, const int &index=-1)
 
void renameTab (const QString &tabname, const QString &newtabname)
 
void removeTab (const QString &tabname)
 
void removeChannel (const QString &channeluniquename)
 
void moveChannelToTab (const QString &channeluniquename, const QString &tabname)
 
void cloneChannelToTab (const QString &channeluniquename, const QString &tabname)
 
void cloneTab (const QString &oldtabname, const QString &newtabname)
 
void removeAllTabs ()
 
void saveConfigurationToFile (const QString &filename, const bool &askonoverride=true)
 
void loadConfigurationFromFile (const QString &filename, const QMap< QString, QString > &availableplugins)
 
void showChannelFullScreen (IVP1ChannelWidget *)
 
void showCurrentChannelFullScreen ()
 
void showTabFullScreen (const QString &tabname)
 
void showCurrentTabFullScreen ()
 
void showNextTab ()
 
void showPreviousTab ()
 
void raiseTabBarContextMenu (int, const QPoint &)
 
void setSelectedDockWidget (VP1DockWidget *dw=0)
 
void setSelectedChannelWidget (IVP1ChannelWidget *cw=0)
 

Signals

void tabListChanged (QStringList)
 
void selectedChannelChanged (IVP1ChannelWidget *)
 
void visibleChannelsChanged (const QSet< IVP1ChannelWidget * > &vis, const QSet< IVP1ChannelWidget * > &soonvis, const double &soonvisbonus)
 

Public Member Functions

 VP1TabManager (QObject *parent, VP1TabWidget *, VP1ChannelManager *)
 
 ~VP1TabManager ()
 
bool hasTab (const QString &) const
 
bool showTab (const QString &)
 
bool showFirstChannelWithGivenBasename (const QString &basename)
 
QString suggestNewTabName (const QString &oldtabname) const
 
QString currentTab () const
 
QString currentChannelUniqueName () const
 
IVP1ChannelWidgetselectedChannelWidget () const
 
int nTabs () const
 
void dropOutOfFullScreen ()
 
QList< IVP1ChannelWidget * > allChannels () const
 
const QSet< IVP1ChannelWidget * > & visibleChannels () const
 
const QSet< IVP1ChannelWidget * > & soonVisibleChannels () const
 
bool isVisible (IVP1ChannelWidget *) const
 
void setTabCruiseMode (const bool &)
 
QStringList tabList ()
 
QString channelToTab (IVP1ChannelWidget *)
 
void launchStereoEditorCurrentTab ()
 
IVP1ChannelWidgetaddChannelToTab (const QString &channelbasename, const QString &tabname)
 
void removeChannelAfterQueueEmpties (const QString &)
 

Protected Types

typedef QPair< QByteArray, QMultiMap< QString, QByteArray > > ChanState
 

Protected Slots

void currentVisibleChanged ()
 
void executePendingChannelRemoval ()
 

Protected Member Functions

bool eventFilter (QObject *, QEvent *)
 
void serializeChannelState (IVP1ChannelWidget *, ChanState &state)
 
void unserializeChannelState (IVP1ChannelWidget *cw, ChanState tate)
 

Protected Attributes

Impm_d
 

Detailed Description

Definition at line 30 of file VP1TabManager.h.

Member Typedef Documentation

◆ ChanState

typedef QPair<QByteArray,QMultiMap<QString,QByteArray> > VP1TabManager::ChanState
protected

Definition at line 103 of file VP1TabManager.h.

Constructor & Destructor Documentation

◆ VP1TabManager()

VP1TabManager::VP1TabManager ( QObject *  parent,
VP1TabWidget tw,
VP1ChannelManager cm 
)

Definition at line 112 of file VP1TabManager.cxx.

113  : QObject(parent), m_d(new Imp(this,tw,cm)) {
114 
116  tw->setTabReorderingEnabled(true);
117  connect(tw->getVP1TabBar(),SIGNAL(contextMenu( int, const QPoint& )),
118  this,SLOT(raiseTabBarContextMenu(int,const QPoint &)));
119 
120  connect(tw,SIGNAL(currentChanged(int)),this,SLOT(currentVisibleChanged()));
121 }

◆ ~VP1TabManager()

VP1TabManager::~VP1TabManager ( )

Definition at line 126 of file VP1TabManager.cxx.

126  {
127  while (m_d->tabwidget->count()>0) {
128  removeTab( m_d->tabwidget->tabText(0) );
129  }
130  delete m_d;
131 }

Member Function Documentation

◆ addChannelToTab()

IVP1ChannelWidget * VP1TabManager::addChannelToTab ( const QString &  channelbasename,
const QString &  tabname 
)

Definition at line 470 of file VP1TabManager.cxx.

470  {
471 
472  #if defined BUILDVP1LIGHT
473  bool checkDisallowMultipleChannels = VP1QtUtils::expertSettingIsOn("general","ExpertSettings/VP1_DISALLOW_MULTIPLE_CHANNELS");
474  #else
475  bool checkDisallowMultipleChannels = VP1QtUtils::environmentVariableIsOn("VP1_DISALLOW_MULTIPLE_CHANNELS");
476  #endif
477 
478  if (m_d->channelwidget_2_dockwidget.size()&&checkDisallowMultipleChannels) {
479  QMessageBox::critical(0, "Error - Not allowed to open channel",
480  "The possibility to launch multiple channels has been disabled by the environment variable VP1_DISALLOW_MULTIPLE_CHANNELS."
481  " This was likely set since some badly written 3D drivers have been known to cause crashes when showing multiple 3D views."
482  "\n In order to launch a new channel you must thus first remove the already active channel."
483  "\n To disable this behaviour don't set VP1_DISALLOW_MULTIPLE_CHANNELS, or set it to \"0'.",QMessageBox::Ok,QMessageBox::Ok);
484  return 0;
485  }
486 
487  if (!m_d->checkTabnameExists(tabname)) return 0;
488  if (!m_d->checkChannelNameExists(channelbasename, false)) return 0;
489 
490  //Then we get the channel:
491  QString err;
492  IVP1ChannelWidget * cw = m_d->channelmanager->getChannel( channelbasename,err );
493  if (!err.isEmpty()) {
494  QMessageBox::critical(0, "Error - could not get channel: "+channelbasename,
495  "Could not get channel: "+channelbasename
496  +"\n\nReason: "+err,QMessageBox::Ok,QMessageBox::Ok);
497 
498  return 0;
499  }
500  assert(cw);
503  cw->setUpdatesEnabled(false);
504 
505  //Everything went well - go ahead and add the channel to the tab.
506  VP1DockWidget *dock = new VP1DockWidget(cw,this);
507  connect(dock,SIGNAL(topLevelChanged(bool)),this,SLOT(currentVisibleChanged()));
508  connect(dock,SIGNAL(wasSelected(VP1DockWidget*)),this,SLOT(setSelectedDockWidget(VP1DockWidget*)));
509 
510  QMainWindow * tab = m_d->name_2_tab[tabname];
511  tab->addDockWidget(Qt::TopDockWidgetArea, dock);
512 
515  assert(m_d->tab_2_channelwidgets.find(tab)!=m_d->tab_2_channelwidgets.end());
516  m_d->tab_2_channelwidgets[tab].insert(cw);
517  cw->setUpdatesEnabled(true);
520  return cw;
521 }

◆ addNewTab

void VP1TabManager::addNewTab ( const QString &  tabname,
const int &  index = -1 
)
slot

Definition at line 236 of file VP1TabManager.cxx.

237 {
238  if (!m_d->checkTabnameNotExists(tabname)) return;
241 
242  QMainWindow * t = new QMainWindow();
243  t->setDockNestingEnabled(true);
244  if (index==-1)
245  m_d->tabwidget->addTab(t,tabname);
246  else
247  m_d->tabwidget->insertTab(index,t,tabname);
248  //NB: Do not call: t->setParent(m_d->tabwidget);
249  m_d->name_2_tab[tabname]=t;
250  m_d->tab_2_channelwidgets[t] = std::set<IVP1ChannelWidget*>();
254 }

◆ allChannels()

QList< IVP1ChannelWidget * > VP1TabManager::allChannels ( ) const

Definition at line 1455 of file VP1TabManager.cxx.

1456 {
1457  QList<IVP1ChannelWidget*> l;
1459  for(it=m_d->channelwidget_2_dockwidget.begin();it!=itE;++it) {
1460  l <<it->first;
1461  }
1462  return l;
1463 }

◆ channelToTab()

QString VP1TabManager::channelToTab ( IVP1ChannelWidget cw)

Definition at line 1406 of file VP1TabManager.cxx.

1407 {
1408  QMainWindow * tab = m_d->channel2tab(cw);
1409  if (!tab)
1410  return "VP1TabManager::channelToTab ERROR: Unknown CW";
1411 
1412  std::map<QString,QMainWindow *>::const_iterator it, itE = m_d->name_2_tab.end();
1413  for ( it = m_d->name_2_tab.begin(); it!=itE; ++it ) {
1414  if (it->second == tab)
1415  return it->first;
1416  }
1417  return "";
1418 }

◆ cloneChannelToTab

void VP1TabManager::cloneChannelToTab ( const QString &  channeluniquename,
const QString &  tabname 
)
slot

Definition at line 719 of file VP1TabManager.cxx.

719  {
720  if (!m_d->checkTabnameExists(tabname)) return;
721  if (!m_d->checkChannelNameExists(channeluniquename, true)) return;
722  IVP1ChannelWidget* cw = m_d->channelmanager->uniqueName2Channel(channeluniquename);
723  assert(cw);
724  IVP1ChannelWidget * newcw = addChannelToTab(cw->name(),tabname);
725  if (newcw) {
726  ChanState state;
727  serializeChannelState(cw,state);
728  unserializeChannelState(newcw,state);
729  }
730 }

◆ cloneTab

void VP1TabManager::cloneTab ( const QString &  oldtabname,
const QString &  newtabname 
)
slot

Definition at line 733 of file VP1TabManager.cxx.

734 {
735  if (!m_d->checkTabnameExists(oldtabname)) return;
736  if (!m_d->checkTabnameNotExists(newtabname)) return;
737 
738  addNewTab(newtabname);
739 
740  assert(m_d->name_2_tab.find(newtabname)!=m_d->name_2_tab.end());
741 
742  QMainWindow * oldtab = m_d->name_2_tab[oldtabname];
743 
744  assert(m_d->tab_2_channelwidgets.find(oldtab)!=m_d->tab_2_channelwidgets.end());
745  std::set<IVP1ChannelWidget*>::const_iterator it = m_d->tab_2_channelwidgets[oldtab].begin();
746  std::set<IVP1ChannelWidget*>::const_iterator itE = m_d->tab_2_channelwidgets[oldtab].end();
747 
748  for (;it!=itE;++it) {
749  IVP1ChannelWidget * newcw = addChannelToTab((*it)->name(),newtabname);
750  if (newcw) {
751  ChanState state;
752  serializeChannelState(*it,state);
753  unserializeChannelState(newcw,state);
754  }
755  }
756 
757  QMainWindow * newtab = m_d->name_2_tab[newtabname];
758  QByteArray state = oldtab->saveState();
759  if (!newtab->restoreState(state))
760  QMessageBox::warning(0, "Warning - Problems cloning channel arrangement",
761  "Problems cloning channel arrangement.",QMessageBox::Ok,QMessageBox::Ok);
762 }

◆ currentChannelUniqueName()

QString VP1TabManager::currentChannelUniqueName ( ) const

Definition at line 386 of file VP1TabManager.cxx.

387 {
388  if(!m_d->selecteddockwidget)
389  return "";
390  else
392 }

◆ currentTab()

QString VP1TabManager::currentTab ( ) const

Definition at line 1036 of file VP1TabManager.cxx.

1036  {
1037  if (m_d->tabwidget->count()==0)
1038  return "";
1039  return m_d->tabwidget->tabText(m_d->tabwidget->currentIndex());
1040 }

◆ currentVisibleChanged

void VP1TabManager::currentVisibleChanged ( )
protectedslot

Definition at line 1248 of file VP1TabManager.cxx.

1248  {
1250  return;
1251 
1252  QSet<IVP1ChannelWidget*> visible;
1253  QSet<IVP1ChannelWidget*> soonvisible;
1254  double soonbonus(0.0);
1255 
1259 
1260  if (m_d->fullscreen_dockwidget) {
1261  //Thats an easy one:
1262  visible << m_d->fullscreen_dockwidget->channelWidget();
1263  } else if (m_d->fullscreen_tab) {
1264  //Add all channel widgets from this tab:
1268  for (it = m_d->tab_2_channelwidgets[m_d->fullscreen_tab].begin();it!=itE;++it) {
1269  visible << *it;
1270  }
1271  std::cout<<"fullscreen tab:"<<m_d->fullscreen_tab<<std::endl;
1272  } else {
1273  //Go through the tabs, if it is the current tab we add all dock
1274  //widgets, otherwise we add those that are floating:
1275  QWidget * currentTab = m_d->tabwidget->currentWidget();
1276  std::map<QMainWindow*,std::set<IVP1ChannelWidget*> >::iterator tabIt,tabItE = m_d->tab_2_channelwidgets.end();
1278  for (tabIt=m_d->tab_2_channelwidgets.begin();tabIt!=tabItE;++tabIt) {
1279  //Loop over channels;
1280  it = tabIt->second.begin();
1281  itE = tabIt->second.end();
1282  for (;it!=itE;++it) {
1283  if (currentTab==tabIt->first) {
1284  //Add all:
1285  visible << *it;
1286  } else {
1287  if (!m_d->fullscreen_tab) {
1288  //Add only if floating and not a fullscreen tab:
1290  if (m_d->channelwidget_2_dockwidget[*it]->isFloating())
1291  visible << *it;
1292  }
1293  }
1294  }
1295  }
1296  }
1297 
1301 
1302  if (m_d->fullscreen_dockwidget) {
1303  assert(!m_d->tabcruisemode);
1304  //Soon visible: All floating channels (not this one) and all channels in the present tab.
1305  soonbonus = 2000;//We are afterall quite sure here what will soon be visible.
1306  QWidget * currentTab = m_d->tabwidget->currentWidget();
1307  std::map<QMainWindow*,std::set<IVP1ChannelWidget*> >::iterator tabIt, tabItE = m_d->tab_2_channelwidgets.end();
1309  for (tabIt=m_d->tab_2_channelwidgets.begin();tabIt!=tabItE;++tabIt) {
1310  //Loop over channels;
1311  itE = tabIt->second.end();
1312  for (it=tabIt->second.begin();it!=itE;++it) {
1313  if (currentTab==tabIt->first) {
1314  //Add all except the fullscreen'ed one:
1316  soonvisible << *it;
1317  } else {
1318  //Add only if floating:
1320  if (m_d->channelwidget_2_dockwidget[*it]->isFloating())
1321  soonvisible << *it;
1322  }
1323  }
1324  }
1325  } else if (m_d->fullscreen_tab) {
1326  if (m_d->tabcruisemode&&m_d->tab_2_channelwidgets.size()>1) {
1327  //Everything in the next tab.
1328  soonbonus = 10000;//Very important that the stuff in the next tab gets a high priority!
1329  QMainWindow * nexttab = m_d->nextTab();
1330  assert(nexttab);
1331  std::cout<<"fullscreen tab:"<<m_d->fullscreen_tab<<std::endl;
1332  std::cout<<"nexttab:"<<nexttab<<std::endl;
1333  assert(m_d->tab_2_channelwidgets.find(nexttab)!=m_d->tab_2_channelwidgets.end());
1335  for(it=m_d->tab_2_channelwidgets[nexttab].begin();it!=itE;++it){
1336  soonvisible << *it;
1337  }
1338  } else {
1339  //All floating channels not in the present tab
1340  soonbonus = 1000;//We are rather sure here what will soon be visible.
1341  QWidget * currentTab = m_d->tabwidget->currentWidget();
1342  std::map<QMainWindow*,std::set<IVP1ChannelWidget*> >::iterator tabIt, tabItE = m_d->tab_2_channelwidgets.end();
1344  for (tabIt=m_d->tab_2_channelwidgets.begin();tabIt!=tabItE;++tabIt) {
1345  //Loop over channels;
1346  itE = tabIt->second.end();
1347  for (it=tabIt->second.begin();it!=itE;++it) {
1348  if (m_d->fullscreen_tab!=tabIt->first&&currentTab!=tabIt->first) {
1349  //Add only if floating:
1351  if (m_d->channelwidget_2_dockwidget[*it]->isFloating())
1352  soonvisible << *it;
1353  }
1354  }
1355  }
1356  }
1357  } else {
1358  //Add everything non-floating from the next tab.
1359  soonbonus = 200;//A weak guess (fixme: Stronger if tab cruise mode).
1360  if (m_d->tabwidget->count()>=2) {
1361  int nexttabindex = (m_d->tabwidget->currentIndex() + 1) % m_d->tabwidget->count();
1362  QMainWindow* tab = static_cast<QMainWindow*>(m_d->tabwidget->widget(nexttabindex));
1363  assert(tab);
1364  assert(m_d->tab_2_channelwidgets.find(tab)!=m_d->tab_2_channelwidgets.end());
1366  for (it=m_d->tab_2_channelwidgets[tab].begin();it!=itE;++it) {
1368  if (!m_d->channelwidget_2_dockwidget[*it]->isFloating())
1369  soonvisible << *it;
1370  }
1371  }
1372  }
1373 
1374 
1375  assert(soonbonus>0.0);
1376 
1377 #ifndef NDEBUG
1378  //There should be no intersection between visible and soon visible!
1379  QSet<IVP1ChannelWidget*> tmp = visible;
1380  tmp.intersect(soonvisible);
1381  assert(tmp.empty());
1382 #endif
1383 
1384  if (visible!=m_d->lastvisible||soonvisible!=m_d->lastsoonvisible) {
1385  m_d->lastvisible=visible;
1386  m_d->lastsoonvisible=soonvisible;
1387  visibleChannelsChanged(visible,soonvisible,soonbonus);
1388 
1389  //To ensure that we dont show controllers for channels that are
1390  //not visible:
1391  if (m_d->selecteddockwidget) {
1392  if (!visible.contains(m_d->selecteddockwidget->channelWidget()))
1394  }
1395 
1396  //To make sure we automatically select a channel if it is the only
1397  //one visible:
1398  if (visible.count()==1&&(!m_d->selecteddockwidget||*(visible.begin())!=m_d->selecteddockwidget->channelWidget())) {
1399  assert(m_d->channelwidget_2_dockwidget.find(*(visible.begin()))!=m_d->channelwidget_2_dockwidget.end());
1401  }
1402  }
1403 }

◆ dropOutOfFullScreen()

void VP1TabManager::dropOutOfFullScreen ( )

Definition at line 257 of file VP1TabManager.cxx.

258 {
260  return;
261 
264  qApp->removeEventFilter(this);
265  QWidget * focuswidget = qApp->focusWidget();
266 
267  if (m_d->fullscreen_dockwidget) {
270  m_d->fullscreen_channelwidget->showNormal();//fixme? Do inside dockwidget?
273  } else {
274  assert(m_d->fullscreen_tab);
275  QWidget * dummywidget=m_d->tabwidget->widget(m_d->fullscreen_tabindex);
278  delete dummywidget;
279  m_d->tabwidget->setCurrentIndex(m_d->fullscreen_tabindex);
280  //Make dockwidgets in the tab floatable again
282  std::set<IVP1ChannelWidget*>::const_iterator it = m_d->tab_2_channelwidgets[m_d->fullscreen_tab].begin();
283  std::set<IVP1ChannelWidget*>::const_iterator itE = m_d->tab_2_channelwidgets[m_d->fullscreen_tab].end();
284  for (;it!=itE;++it) {
287  dock->setFeatures(VP1DockWidget::DockWidgetMovable|VP1DockWidget::DockWidgetFloatable);
289  dock->setFloating(true);
290  }
291  m_d->fullscreen_tabname = "";
292  m_d->fullscreen_tabindex = -1;
293  m_d->fullscreen_tab = 0;
294  m_d->fullscreen_floatingdocks.clear();
295  }
296  if (focuswidget&&!focuswidget->hasFocus())
297  focuswidget->setFocus(Qt::OtherFocusReason);
300 }

◆ eventFilter()

bool VP1TabManager::eventFilter ( QObject *  ,
QEvent *  event 
)
protected

Definition at line 303 of file VP1TabManager.cxx.

303  {
304 
305  //When in fullscreen mode we monitor all events in the application
306  //to look for ESC (leave fullscreen) and to prevent any toplevel
307  //widgets from getting closed by e.g. the user pressing ALT+F4.
308 
309  if (event->type()==QEvent::Close) {
310  event->ignore();
311  return true;
312  }
313 
314  if (event->type()!=QEvent::KeyPress)
315  return false;
316 
317  QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
318  assert(keyEvent);
319  if (keyEvent->key()!=Qt::Key_Escape)
320  return false;
321 
323 
324  //Eat the event:
325  return true;
326 }

◆ executePendingChannelRemoval

void VP1TabManager::executePendingChannelRemoval ( )
protectedslot

Definition at line 1516 of file VP1TabManager.cxx.

1517 {
1518  if (m_d->channelWithPendingRemoval.isEmpty())
1519  return;
1522 }

◆ hasTab()

bool VP1TabManager::hasTab ( const QString &  tabname) const

Definition at line 1421 of file VP1TabManager.cxx.

1422 {
1423  return m_d->name_2_tab.find(tabname)!=m_d->name_2_tab.end();
1424 }

◆ isVisible()

bool VP1TabManager::isVisible ( IVP1ChannelWidget cw) const

Definition at line 1479 of file VP1TabManager.cxx.

1480 {
1481  return m_d->lastvisible.contains(cw);
1482 }

◆ launchStereoEditorCurrentTab()

void VP1TabManager::launchStereoEditorCurrentTab ( )

Definition at line 135 of file VP1TabManager.cxx.

135  {
136  VP1Msg::messageVerbose("VP1TabManager::launchStereoEditorCurrentTab()");
138  if (channel ) {
139  channel->launchStereoEditor();
140  }
141 }

◆ loadConfigurationFromFile

void VP1TabManager::loadConfigurationFromFile ( const QString &  filename,
const QMap< QString, QString > &  availableplugins 
)
slot

Definition at line 824 of file VP1TabManager.cxx.

824  {
825  if (filename.isEmpty()) {
826  QMessageBox::critical(0, "Error - Empty file name provided",
827  "Empty file name provided.",QMessageBox::Ok,QMessageBox::Ok);
828  return;
829  }
830  QFileInfo fi(filename);
831  if (!fi.exists()) {
832  QMessageBox::critical(0, "Error - file does not exists: "+filename,
833  "File does not exists: <i>"+filename+"</i>",QMessageBox::Ok,QMessageBox::Ok);
834  return;
835  }
836  if (!fi.isReadable()) {
837  QMessageBox::critical(0, "Error - file is not readable: "+filename,
838  "File is not readable: <i>"+filename+"</i>",QMessageBox::Ok,QMessageBox::Ok);
839  return;
840  }
841  //open file
842  QFile file(filename);
843  if (!file.open(QIODevice::ReadOnly)) {
844  QMessageBox::critical(0, "Error - problems opening file "+filename,
845  "Problems opening file: <i>"+filename+"</i>",QMessageBox::Ok,QMessageBox::Ok);
846  return;
847  }
848 
849  //Read:
850  QString head,foot;
851  QStringList pluginfiles;
852  QMap<QString,QMultiMap<QString,ChanState> > tab2channels;
853  QMap<QString,QByteArray> tab2arrangements;
854  QStringList tabs_orded;
855 
856  QByteArray byteArray64;
857  QDataStream infile(&file);
858  infile >> byteArray64;
859 
860  QByteArray byteArray = qUncompress(QByteArray::fromBase64(byteArray64));
861 
862  QBuffer buffer(&byteArray);
863  buffer.open(QIODevice::ReadOnly);
864  QDataStream in(&buffer);
865  in >> head;
866  in >> pluginfiles;
867  in >> tab2channels;
868  in >> tab2arrangements;
869  in >> tabs_orded;
870  in >> foot;
871  buffer.close();
872 
873  if (head!="This is an automatically generated config file for VP1. [cfg version 003]"
874  ||foot!="This is the end of the automatically generated config file for VP1."
875  ||tab2channels.count()!=tab2arrangements.count()) {
876  QMessageBox::critical(0, "Error - file not in correct format: "+filename,
877  "File not in correct format: <i>"+filename+"</i>",QMessageBox::Ok,QMessageBox::Ok);
878  return;
879  }
880 
881  QStringList pf_withproblem;
882  QStringList errormessage;
883 
884 #ifdef __APPLE__
885  QString sharedlibsuffix_correct = ".dylib";
886  QString sharedlibsuffix_wrong = ".so";
887 #else
888  QString sharedlibsuffix_correct = ".so";
889  QString sharedlibsuffix_wrong = ".dylib";
890 #endif
891 
892  for(QString pf : pluginfiles) {
893  if (pf.endsWith(sharedlibsuffix_wrong)) {
894  pf.replace(sharedlibsuffix_wrong, sharedlibsuffix_correct);
895  }
896 
897  if (!availableplugins.contains(pf)) {
898  pf_withproblem<<pf;
899  errormessage<<"Could not locate " + pf;
900  continue;
901  }
902  QString pfabsolute = availableplugins[pf];
903  QString err;
904  if (m_d->channelmanager->channelsInPluginFile(pfabsolute).empty())
905  err = m_d->channelmanager->loadPluginFile(pfabsolute);
906  if (!err.isEmpty()) {
907  pf_withproblem<<pfabsolute;
908  errormessage<<err;
909  }
910  }
911 
912  if (!pf_withproblem.empty()) {
913  assert(pf_withproblem.count()==errormessage.count());
914  QString tmp;
915  for (int i = 0; i<pf_withproblem.count();++i) {
916  tmp += pf_withproblem.value(i)+": "+errormessage.value(i)+"\n";
917  }
918  QMessageBox::warning(0, "Warning - could not load all plugins",
919  "Some or more plugins did not load properly:\n\n"+tmp,QMessageBox::Ok,QMessageBox::Ok);
920  }
921 
922  QString channelsFailureMsg;
923  QString tabArrangementFailureMsg;
924 
925  QString lastaddedtab;
926 
927  for (const QString& newtabname_infile : tabs_orded) {
928  //Check format:
929  if (!tab2channels.contains(newtabname_infile)||!tab2arrangements.contains(newtabname_infile)) {
930  QMessageBox::critical(0, "Error - file not in correct format: "+filename,
931  "File not in correct format: <i>"+filename+"</i>",QMessageBox::Ok,QMessageBox::Ok);
932  return;
933  }
934 
935  //We are about to add a new tab. If there is already one with
936  //that name we remove it if it is empty:
937  QMainWindow * existingtab = m_d->name2tab(newtabname_infile);
938  if (existingtab) {
939  if (m_d->tab_2_channelwidgets.find(existingtab)==m_d->tab_2_channelwidgets.end()
940  ||m_d->tab_2_channelwidgets[existingtab].empty())
941  removeTab(newtabname_infile);
942  }
943 
944  //Special case: If there are presently no loaded channels, and
945  //only one existing tab named 'My Tab', then we remove that one
946  if (m_d->channelwidget_2_dockwidget.empty()
947  &&m_d->name_2_tab.size()==1
948  &&m_d->name_2_tab.begin()->first=="My Tab")
949  removeTab("My Tab");
950 
951  QString newtabname = suggestNewTabName(newtabname_infile);
952  addNewTab(newtabname);
953  if (!m_d->checkTabnameExists(newtabname))
954  return;
955  lastaddedtab=newtabname;
956 
957  QMapIterator<QString,ChanState> it( tab2channels.value(newtabname_infile) );
958 
959  while (it.hasNext()) {
960  it.next();
961  //it.key(): Channel base name.
962  //it.value(): Channel state info.
963  if (!m_d->channelmanager->baseNameExists(it.key())) {
964  channelsFailureMsg += it.key()+" (tab "+newtabname+")"+"\n";
965  } else {
966  IVP1ChannelWidget * cw = addChannelToTab( it.key(), newtabname );
967  if (cw)
968  unserializeChannelState(cw,it.value());
969  else
970  channelsFailureMsg += it.key()+" (tab "+newtabname+")"+"\n";
971  }
972  }
973 
974  //Setup layout state:
975  assert(m_d->name_2_tab.find(newtabname)!=m_d->name_2_tab.end());
976  QMainWindow * tab = m_d->name_2_tab.find(newtabname)->second;
977  QByteArray state = tab2arrangements.value(newtabname_infile);
978 
979  if (!state.isEmpty()) {
980  if (!tab->restoreState(state,0/*version*/)) {
981  tabArrangementFailureMsg += newtabname+"\n";
982  }
983  }
984  }
985  if (!channelsFailureMsg.isEmpty()) {
986  QMessageBox::warning(0, "Warning - could not start all channels",
987  "Some or more channels were not available to start:\n\n"
988  +channelsFailureMsg,QMessageBox::Ok,QMessageBox::Ok);
989  }
990  if (!tabArrangementFailureMsg.isEmpty()) {
991  QMessageBox::warning(0, "Warning - could not arrange channels in all tabs",
992  "The arrangement of channels could not be properly determined withing the following tabs:\n\n"
993  +tabArrangementFailureMsg,QMessageBox::Ok,QMessageBox::Ok);
994  }
995  if (!lastaddedtab.isEmpty())
996  showTab(lastaddedtab);
997 }

◆ moveChannelToTab

void VP1TabManager::moveChannelToTab ( const QString &  channeluniquename,
const QString &  tabname 
)
slot

Definition at line 683 of file VP1TabManager.cxx.

683  {
684 
685  if (!m_d->checkTabnameExists(tabname)) return;
686  if (!m_d->checkChannelNameExists(channeluniquename, true)) return;
687 
688  QMainWindow * tab_new = m_d->name_2_tab[tabname];
689  assert(tab_new);
690  IVP1ChannelWidget* cw = m_d->channelmanager->uniqueName2Channel(channeluniquename);
691  assert(cw);
692 
694 
696  assert(dw);
697  QMainWindow * tab_old = m_d->channel2tab(cw);
698  assert(tab_old);
699 
700  if (tab_old==tab_new)//Fixme: Make warning here instead, and ensure that the interface does not allow this.
701  return;
702 
703  tab_old->removeDockWidget(dw);
704  dw->setParent(tab_new);
705  tab_new->addDockWidget(Qt::TopDockWidgetArea, dw);
706  dw->show();
707 
708  //Update tab_2_channelwidgets:
709  assert(m_d->tab_2_channelwidgets.find(tab_old)!=m_d->tab_2_channelwidgets.end());
710  assert(m_d->tab_2_channelwidgets.find(tab_new)!=m_d->tab_2_channelwidgets.end());
711  assert(m_d->tab_2_channelwidgets[tab_old].find(cw)!=m_d->tab_2_channelwidgets[tab_old].end());
712  assert(m_d->tab_2_channelwidgets[tab_new].find(cw)==m_d->tab_2_channelwidgets[tab_new].end());//dies!
713  m_d->tab_2_channelwidgets[tab_old].erase(m_d->tab_2_channelwidgets[tab_old].find(cw));
714  m_d->tab_2_channelwidgets[tab_new].insert(cw);
715 
716 }

◆ nTabs()

int VP1TabManager::nTabs ( ) const

Definition at line 1043 of file VP1TabManager.cxx.

1043  {
1044  return m_d->tabwidget->count();
1045 }

◆ raiseTabBarContextMenu

void VP1TabManager::raiseTabBarContextMenu ( int  i,
const QPoint &  p 
)
slot

Definition at line 1136 of file VP1TabManager.cxx.

1136  {
1137 
1138  QString tabname = m_d->tabwidget->tabText(i);
1139 
1140  QMenu menu(m_d->tabwidget);
1141 
1142  //Construct menu:
1143  // menu.addAction("Tab: "+tabname)->setEnabled(false);
1144  // menu.addSeparator ();
1145  QAction* pFullScreenAction = menu.addAction("Show &full Screen");
1146  menu.addSeparator();
1147  QAction* pRenameAction = menu.addAction("Re&name tab");
1148  QAction* pDeleteAction = menu.addAction("&Remove tab");
1149  menu.addSeparator ();
1150  QAction* pInsertNewAction = menu.addAction("&Insert new tab");
1151  QAction* pCloneAction = menu.addAction("&Clone tab");
1152  menu.addSeparator ();
1153  QAction* pAddChannelAction = menu.addAction("&Add channel");
1154  QAction* pRemoveChannelAction = menu.addAction("R&emove channel");
1155 
1156  QMenu menu_addchan(m_d->tabwidget);
1157  QStringList chnls = m_d->channelmanager->availableChannelList();
1158  if (chnls.empty()) {
1159  menu_addchan.addAction("No channels available")->setEnabled(false);
1160  } else {
1161  for (const QString& chnl : chnls) {
1162  QString iconloc = m_d->channelmanager->getIconLocation(chnl, true);
1163  QAction* pChnlAct;
1164  if (iconloc.isEmpty())
1165  pChnlAct = menu_addchan.addAction(chnl);
1166  else
1167  pChnlAct = menu_addchan.addAction(QIcon(iconloc),chnl);
1168  pChnlAct->setData("ADDCHAN");
1169  }
1170  }
1171  pAddChannelAction->setMenu(&menu_addchan);
1172  QStringList chnls_rem = m_d->channelsInTab(tabname);
1173  if (chnls_rem.empty())
1174  pFullScreenAction->setEnabled(false);
1175  QMenu menu_remchan(m_d->tabwidget);
1176  if (chnls_rem.empty()) {
1177  menu_remchan.addAction("No channels in tab")->setEnabled(false);
1178  } else {
1179  for (const QString& chnl : chnls_rem) {
1180  QString iconloc = m_d->channelmanager->getIconLocation(chnl, false);
1181  QAction* pChnlAct;
1182  if (iconloc.isEmpty())
1183  pChnlAct = menu_remchan.addAction(chnl);
1184  else
1185  pChnlAct = menu_remchan.addAction(QIcon(iconloc),chnl);
1186  pChnlAct->setData("REMCHAN");
1187  }
1188  }
1189  pRemoveChannelAction->setMenu(&menu_remchan);
1190 
1191 
1192  //Execute
1193  QAction * selAct = menu.exec(p);
1194  //
1195  if (!selAct)
1196  return;
1197  if (selAct==pFullScreenAction) {
1198  showTabFullScreen(tabname);
1199  return;
1200  }
1201  if (selAct==pRenameAction) {
1202  bool ok;
1203  QString text = QInputDialog::getText( 0, "Rename tab '"+tabname+"'","Rename tab '"+tabname+"' to:",
1204  QLineEdit::Normal, tabname, &ok );
1205  if (!ok||text==tabname)
1206  return;
1207  renameTab(tabname,text);
1208  return;
1209  }
1210  if (selAct==pDeleteAction) {
1211  removeTab( tabname );
1212  return;
1213  }
1214  if (selAct==pInsertNewAction) {
1215  bool ok;
1216  QString newtabname = QInputDialog::getText( 0, "New Tab Name","New tab name:",
1217  QLineEdit::Normal, suggestNewTabName("My Tab"), &ok );
1218  if (!ok||newtabname.isEmpty())
1219  return;
1220  addNewTab(newtabname,i+1);
1221  return;
1222  }
1223  if (selAct==pCloneAction) {
1224  bool ok;
1225  QString newtabname = QInputDialog::getText( 0, "Cloning '"+tabname+"'.","Cloning '"+tabname+"'. Name of new tab:",
1226  QLineEdit::Normal, suggestNewTabName(tabname), &ok );
1227  if (!ok||newtabname.isEmpty())
1228  return;
1229  cloneTab(tabname,newtabname);
1230  return;
1231  }
1232  if (selAct==pAddChannelAction) {
1233  return;
1234  }
1235  //Only option left is channels...
1236  if (selAct->data()=="ADDCHAN") {
1237  addChannelToTab( selAct->text(), tabname );
1238  return;
1239  }
1240  if (selAct->data()=="REMCHAN") {
1241  removeChannel( selAct->text() );
1242  return;
1243  }
1244  std::cout<<"ERROR in VP1TabManager::raiseTabBarContextMenu!!!!!"<<std::endl;
1245 }

◆ removeAllTabs

void VP1TabManager::removeAllTabs ( )
slot

Definition at line 590 of file VP1TabManager.cxx.

591 {
592  VP1Msg::messageDebug("VP1TabManager::removeAllTabs()");
593  for(const QString& tab : tabList() ) {
594  removeTab(tab);
595  }
596 }

◆ removeChannel

void VP1TabManager::removeChannel ( const QString &  channeluniquename)
slot

Definition at line 600 of file VP1TabManager.cxx.

600  {
601 
602  VP1Msg::messageDebug("VP1TabManager::removeChannel()");
603 
604  if (!m_d->checkChannelNameExists(channeluniquename, true)) return;
605 
606  IVP1ChannelWidget* cw = m_d->channelmanager->uniqueName2Channel(channeluniquename);
607  assert(cw);
608 
609  //Unselect if selected:
612 
613  QString bn = cw->name();
614  cw->setUpdatesEnabled(false);
615 
618 
619  //Update maps:
622 
623  //And remove dock from tab.
624  QMainWindow * tab = m_d->channel2tab(cw);
625  assert(tab);
626 
627 // int itab = m_d->tabwidget->indexOf(tab);
628 // assert(itab!=-1);
629 // QString tabname = m_d->tabwidget->tabText(itab);
630  // m_d->tabwidget->removeTab(itab);
631  tab->setUpdatesEnabled(false);
632  tab->removeDockWidget(dw);
633 
634 
635  //Update map:
636  assert(m_d->tab_2_channelwidgets[tab].find(cw)!=m_d->tab_2_channelwidgets[tab].end());
637  m_d->tab_2_channelwidgets[tab].erase(m_d->tab_2_channelwidgets[tab].find(cw));
638 
639  //delete channel
640  cw->hide();
641  dw->ensureCWHasNoParent();
642  [[maybe_unused]] //To avoid compile warning in opt mode.
643  bool ok=m_d->channelmanager->deleteChannel(cw->unique_name());
644  assert(ok);
645 
646  //delete dock widget
647  delete dw;
648 
649  tab->setUpdatesEnabled(true);
650  // m_d->tabwidget->insertTab(itab,tab,tabname);
651 
652  if (m_d->selecteddockwidget==dw) {
655  }
656 
658 }

◆ removeChannelAfterQueueEmpties()

void VP1TabManager::removeChannelAfterQueueEmpties ( const QString &  chnlun)

Definition at line 1509 of file VP1TabManager.cxx.

1510 {
1511  m_d->channelWithPendingRemoval = chnlun;
1512  QTimer::singleShot(0, this, SLOT(executePendingChannelRemoval()));
1513 }

◆ removeTab

void VP1TabManager::removeTab ( const QString &  tabname)
slot

Definition at line 549 of file VP1TabManager.cxx.

549  {
550 
551  if (!m_d->checkTabnameExists(tabname)) return;
552 
555 
556  assert(m_d->name_2_tab.find(tabname)!=m_d->name_2_tab.end());
557  QMainWindow * tab = m_d->name_2_tab[tabname];
558  assert(tab);
559  assert(m_d->tab_2_channelwidgets.find(tab)!=m_d->tab_2_channelwidgets.end());
560 
561  //First, we turn off updates on all channel widgets in the tab (this
562  //prevents some crashes due to poorly written channels):
563  std::set<IVP1ChannelWidget*>::const_iterator it = m_d->tab_2_channelwidgets[tab].begin();
564  std::set<IVP1ChannelWidget*>::const_iterator itE = m_d->tab_2_channelwidgets[tab].end();
565  for (;it!=itE;++it) {
566  (*it)->setUpdatesEnabled(false);//Fixme: do this on detach/reattach also?
567  (*it)->hide();
568  }
569 
570  while(m_d->tab_2_channelwidgets[tab].size()>0) {
571  IVP1ChannelWidget * channelwidget = *(m_d->tab_2_channelwidgets[tab].begin());
572  removeChannel(channelwidget->unique_name());
573  }
574 
575  //Remove the tab from the tabwidget (this does not actually delete the tab)
576  m_d->name_2_tab.erase(m_d->name_2_tab.find(tabname));
577  int i = m_d->tabwidget->indexOf(tab);
578  assert(i!=-1);
580 
581  delete tab;
582 
586 }

◆ renameTab

void VP1TabManager::renameTab ( const QString &  tabname,
const QString &  newtabname 
)
slot

Definition at line 524 of file VP1TabManager.cxx.

524  {
525  if (!m_d->checkTabnameExists(tabname)) return;
526  if (!m_d->checkTabnameNotExists(newtabname)) return;
527 
528  QMainWindow * tab = m_d->name_2_tab[tabname];
529 
530  m_d->name_2_tab.erase(m_d->name_2_tab.find(tabname));
531  m_d->name_2_tab[newtabname]=tab;
532  int tabindex = m_d->tabwidget->indexOf(tab);
533  assert(tabindex!=-1);
534  m_d->tabwidget->setTabText ( tabindex, newtabname );
536 }

◆ saveConfigurationToFile

void VP1TabManager::saveConfigurationToFile ( const QString &  filename,
const bool &  askonoverride = true 
)
slot

Definition at line 767 of file VP1TabManager.cxx.

767  {
768  if (filename.isEmpty()) {
769  QMessageBox::critical(0, "Error - Empty file name provided",
770  "Empty file name provided.",QMessageBox::Ok,QMessageBox::Ok);
771  return;
772  }
773  //If file exists, ask to overwrite.
774  QFileInfo fi(filename);
775  if (fi.exists()) {
776  if (!fi.isWritable()) {
777  QMessageBox::critical(0, "Error - could not save to file "+filename,
778  "Could not save to file: <i>"+filename+"</i>"
779  +"<br/><br/>Reason: File exists already and is write protected",QMessageBox::Ok,QMessageBox::Ok);
780  return;
781  }
782  if (askonoverride) {
783  int ret = QMessageBox::question(0, "File already exists: "+filename,
784  "The file <i>"+filename+"</i> already exists.\n"
785  "Override this file?",
786  QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel);
787  if (ret==QMessageBox::Cancel)
788  return;
789  }
790  }
791 
792  QFile file(filename);
793  if (!file.open(QIODevice::WriteOnly)) {
794  QMessageBox::critical(0, "Error - problems writing to file "+filename,
795  "Problems writing to file: <i>"+filename+"</i>",QMessageBox::Ok,QMessageBox::Ok);
796  return;
797  }
798 
799  //Serialise :
800  QMap<QString,QMultiMap<QString,ChanState> > tab2channels;
801  QMap<QString,QByteArray> tab2arrangements;
802  m_d->serializeTabAndChannelConfigInfo(tab2channels, tab2arrangements);
803 
804  //Put into bytearray:
805  QByteArray byteArray;
806  QBuffer buffer(&byteArray);
807  buffer.open(QIODevice::WriteOnly);
808  QDataStream out(&buffer);
809  out<<QString("This is an automatically generated config file for VP1. [cfg version 003]" );
811  out<<tab2channels;
812  out<<tab2arrangements;
813  out<<tabList();//For tab *order*
814  out<<QString("This is the end of the automatically generated config file for VP1." );
815  buffer.close();
816 
817  QDataStream outfile(&file);
818  outfile<<qCompress(byteArray).toBase64();
819 
820 
821 }

◆ selectedChannelChanged

void VP1TabManager::selectedChannelChanged ( IVP1ChannelWidget )
signal

◆ selectedChannelWidget()

IVP1ChannelWidget * VP1TabManager::selectedChannelWidget ( ) const

Definition at line 465 of file VP1TabManager.cxx.

465  {
467 }

◆ serializeChannelState()

void VP1TabManager::serializeChannelState ( IVP1ChannelWidget cw,
ChanState state 
)
protected

Definition at line 1525 of file VP1TabManager.cxx.

1526 {
1527  QMultiMap<QString,QByteArray> sysstate;
1528  std::set<IVP1System*>::const_iterator it, itE = cw->systems().end();
1529  for (it=cw->systems().begin();it!=itE;++it) {
1530  unsigned nVP1Serialise = VP1Serialise::numberOfInstantiations();
1531  sysstate.insert((*it)->name(),(*it)->saveState());
1532  if (nVP1Serialise==VP1Serialise::numberOfInstantiations())
1533  VP1Msg::messageDebug("VP1TabManager WARNING: System "+(*it)->name()
1534  +" did not use VP1Serialise in implementation of saveState()");
1535  }
1536 
1537  state.first = cw->saveState();
1538  state.second = sysstate;
1539 }

◆ setSelectedChannelWidget

void VP1TabManager::setSelectedChannelWidget ( IVP1ChannelWidget cw = 0)
slot

Definition at line 347 of file VP1TabManager.cxx.

348 {
349  if (!cw) {
351  return;
352  }
355 }

◆ setSelectedDockWidget

void VP1TabManager::setSelectedDockWidget ( VP1DockWidget dw = 0)
slot

Definition at line 329 of file VP1TabManager.cxx.

329  {
330 
331  VP1Msg::messageDebug("VP1TabManager::setSelectedDockWidget()");
332 
333  if ( m_d->selecteddockwidget == dw )
334  return;
335 
336  if (m_d->selecteddockwidget)
338 
340  if (dw)
341  dw->setSelected();
342 
343  selectedChannelChanged( dw ? dw->channelWidget() : 0 );
344 }

◆ setTabCruiseMode()

void VP1TabManager::setTabCruiseMode ( const bool &  b)

Definition at line 1485 of file VP1TabManager.cxx.

1485  {
1486  if (m_d->tabcruisemode==b)
1487  return;
1490  m_d->tabcruisemode = b;
1491 // if (m_d->tabcruisemode) {
1492 // assert(!fullscreen_dockwidget);//We cant be in FS single-channel mode.
1493 // if (fullscreen_tab) {
1494 // //Dock all floating (in other tabs) immediately (fixme: only when they need to be shown!.
1495 // } else {
1496 // //normal mode
1497 // }
1498 // } else {
1499 // }
1500  //Soonvisible might have changed - so emit changes:
1503 }

◆ showChannelFullScreen

void VP1TabManager::showChannelFullScreen ( IVP1ChannelWidget cw)
slot

Definition at line 358 of file VP1TabManager.cxx.

358  {
360 
367  cw->hide();
368  dock->ensureCWHasNoParent();
369  cw->showFullScreen();
370  qApp->installEventFilter(this);
373 
374 
375 }

◆ showCurrentChannelFullScreen

void VP1TabManager::showCurrentChannelFullScreen ( )
slot

Definition at line 378 of file VP1TabManager.cxx.

379 {
380  if(!m_d->selecteddockwidget)
381  return;
383 }

◆ showCurrentTabFullScreen

void VP1TabManager::showCurrentTabFullScreen ( )
slot

Definition at line 455 of file VP1TabManager.cxx.

456 {
457  if (m_d->tabwidget->count()==0)
458  return;
459  showTabFullScreen(m_d->tabwidget->tabText(m_d->tabwidget->currentIndex()));
460 }

◆ showFirstChannelWithGivenBasename()

bool VP1TabManager::showFirstChannelWithGivenBasename ( const QString &  basename)

Definition at line 1427 of file VP1TabManager.cxx.

1427  {
1428 
1429  std::set<IVP1ChannelWidget*>::const_iterator it2,it2E;
1430 
1431  std::map<QMainWindow*,std::set<IVP1ChannelWidget*> >::const_iterator
1433  for (;it!=itE;++it) {
1434  it2=it->second.begin();
1435  it2E=it->second.end();
1436  for (;it2!=it2E;++it2) {
1437  if ((*it2)->name()==basename) {
1438  //Figure out the tabname:
1439  std::map<QString,QMainWindow *>::const_iterator it3,it3E;
1440  it3=m_d->name_2_tab.begin();it3E=m_d->name_2_tab.end();
1441  for (;it3!=it3E;++it3) {
1442  if (it3->second==it->first)
1443  return showTab(it3->first);
1444  }
1445  //Something is wrong.
1446  return false;
1447  }
1448  }
1449  }
1450  return false;
1451 }

◆ showNextTab

void VP1TabManager::showNextTab ( )
slot

Definition at line 1108 of file VP1TabManager.cxx.

1108  {
1109  if (m_d->tabwidget->count()<=1)
1110  return;
1111  assert(!m_d->fullscreen_channelwidget);
1112  if (m_d->fullscreen_tab) {
1116  showNextTab();
1119  }
1120  m_d->tabwidget->setCurrentIndex((m_d->tabwidget->currentIndex() + 1) % m_d->tabwidget->count());
1121 }

◆ showPreviousTab

void VP1TabManager::showPreviousTab ( )
slot

Definition at line 1124 of file VP1TabManager.cxx.

1124  {
1125  assert(!m_d->fullscreen_channelwidget);
1126  assert(!m_d->fullscreen_tab);//Fixme: as above.
1127  if (m_d->tabwidget->count()<=1)
1128  return;
1129  int newindex = m_d->tabwidget->currentIndex() - 1;
1130  if (newindex<0)
1131  newindex += m_d->tabwidget->count();
1132  m_d->tabwidget->setCurrentIndex( newindex % m_d->tabwidget->count());
1133 }

◆ showTab()

bool VP1TabManager::showTab ( const QString &  tabname)

Definition at line 1078 of file VP1TabManager.cxx.

1078  {
1079  int itarget(-1);
1080  for (int i = 0; i < m_d->tabwidget->count(); ++i) {
1081  if (m_d->tabwidget->tabText(i)==tabname) {
1082  itarget = i;
1083  break;
1084  }
1085  }
1086  if (itarget<0)
1087  return false;
1088  if (itarget==m_d->tabwidget->currentIndex())
1089  return true;
1090 
1093 
1094  bool fullscreentab = (m_d->fullscreen_tab!=0);
1097 
1098  m_d->tabwidget->setCurrentIndex(itarget);
1099  if (fullscreentab)
1103  return true;
1104 }

◆ showTabFullScreen

void VP1TabManager::showTabFullScreen ( const QString &  tabname)
slot

Definition at line 395 of file VP1TabManager.cxx.

396 {
397  int index = 0;
398  for (; index < m_d->tabwidget->count(); ++index) {
399  if (m_d->tabwidget->tabText(index)==tabname)
400  break;
401  }
402  if (index >= m_d->tabwidget->count())
403  return;
405  //Test that we are not already fs:
406  assert(m_d->fullscreen_tabname.isEmpty());
407  assert(m_d->fullscreen_tabindex==-1);
408  assert(!m_d->fullscreen_tab);
409  assert(m_d->fullscreen_floatingdocks.empty());
410 
413 
414  //Set tab info:
417  assert(m_d->name_2_tab.find(m_d->fullscreen_tabname)!=m_d->name_2_tab.end());
419  //Dock all dockwidgets in the tab that are currently floating, and make them unfloatable:
421  std::set<IVP1ChannelWidget*>::const_iterator it = m_d->tab_2_channelwidgets[m_d->fullscreen_tab].begin();
422  std::set<IVP1ChannelWidget*>::const_iterator itE = m_d->tab_2_channelwidgets[m_d->fullscreen_tab].end();
423  for (;it!=itE;++it) {
426  if (dock->isFloating()) {
427  m_d->fullscreen_floatingdocks.insert(dock);
428  dock->setFloating(false);
429  }
430  dock->setFeatures(VP1DockWidget::DockWidgetMovable);
431  }
432 
433  //Remove tab, put a dummy in its place, and go fullscreen:
435  m_d->fullscreen_tab->hide();
436  m_d->fullscreen_tab->setParent(0);
437  m_d->tabwidget->insertTab ( m_d->fullscreen_tabindex, new QWidget(), m_d->fullscreen_tabname );
438  m_d->fullscreen_tab->showFullScreen();
439  //Needs an extra update apparently, to get selection frame properly enlarged
442  for (;it!=itE;++it) {
445  dock->update();
446  }
447 
448  qApp->installEventFilter(this);
451 
452 }

◆ soonVisibleChannels()

const QSet< IVP1ChannelWidget * > & VP1TabManager::soonVisibleChannels ( ) const

Definition at line 1472 of file VP1TabManager.cxx.

1473 {
1474  return m_d->lastsoonvisible;
1475 }

◆ suggestNewTabName()

QString VP1TabManager::suggestNewTabName ( const QString &  oldtabname) const

Definition at line 1027 of file VP1TabManager.cxx.

1027  {
1028  QString newtabname=oldtabname;
1029  int i = 1;
1030  while (m_d->name_2_tab.find(newtabname)!=m_d->name_2_tab.end())
1031  newtabname=oldtabname+" "+QString::number(++i);
1032  return newtabname;
1033 }

◆ tabList()

QStringList VP1TabManager::tabList ( )

Definition at line 539 of file VP1TabManager.cxx.

539  {
540  QStringList l;
541  for (int i = 0; i < m_d->tabwidget->count(); ++i) {
542  l<<m_d->tabwidget->tabText(i);
543  }
544  return l;
545 }

◆ tabListChanged

void VP1TabManager::tabListChanged ( QStringList  )
signal

◆ unserializeChannelState()

void VP1TabManager::unserializeChannelState ( IVP1ChannelWidget cw,
ChanState  tate 
)
protected

Definition at line 1542 of file VP1TabManager.cxx.

1543 {
1544  if(!state.first.isEmpty())
1545  cw->restoreFromState(state.first);
1546 
1547  QList<QString> storedSystems = state.second.keys();
1548 
1549  std::set<IVP1System*>::const_iterator itsys, itsysE = cw->systems().end();
1550  for (itsys=cw->systems().begin();itsys!=itsysE;++itsys) {
1551  QString name = (*itsys)->name();
1552  //Look for the first entry with this system name in the list. If it is there - use it and remove it:
1553  QMultiMap<QString,QByteArray>::iterator it_state = state.second.find(name);
1554  if (it_state != state.second.end()) {
1555  storedSystems.removeAll(name);
1556 // //Lets make sure that we advance it_state to the LAST of the elements with the same key:
1557 // QMultiMap<QString,QByteArray>::iterator it_state_tmp = it_state;
1558 // while ( it_state_tmp != state.second.end() && it_state_tmp.key() == (*itsys)->name() ) {
1559 // it_state=it_state_tmp;
1560 // ++it_state_tmp;
1561 // }
1562  //Fixme ^^^: The above has not been tested on any channel which
1563  //actually has multiple similar systems. So might be buggy.
1564 
1565  //Use it and remove it from array:
1566  if (!it_state.value().isEmpty()) {
1567  unsigned nVP1Deserialise = VP1Deserialise::numberOfInstantiations();
1568  (*itsys)->restoreFromState(it_state.value());
1569  if (nVP1Deserialise==VP1Deserialise::numberOfInstantiations())
1570  VP1Msg::messageDebug("VP1TabManager WARNING: System "+(*itsys)->name()
1571  +" did not use VP1Deserialise in implementation of restoreFromState()");
1572  }
1573  //state.second.erase(it_state);
1574  } else {
1575  std::cout<<"VP1TabManager::unserializeChannelState Warning: Did not find state data for system "<<name.toStdString()<<std::endl;
1576  }
1577  }
1578  for (const QString& name : storedSystems)
1579  std::cout<<"VP1TabManager::unserializeChannelState Warning: Did not use stored configuration for system "<<name.toStdString()<<std::endl;
1580 }

◆ visibleChannels()

const QSet< IVP1ChannelWidget * > & VP1TabManager::visibleChannels ( ) const

Definition at line 1467 of file VP1TabManager.cxx.

1468 {
1469  return m_d->lastvisible;
1470 }

◆ visibleChannelsChanged

void VP1TabManager::visibleChannelsChanged ( const QSet< IVP1ChannelWidget * > &  vis,
const QSet< IVP1ChannelWidget * > &  soonvis,
const double &  soonvisbonus 
)
signal

Member Data Documentation

◆ m_d

Imp* VP1TabManager::m_d
protected

Definition at line 100 of file VP1TabManager.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.changerun.bn
bn
Definition: changerun.py:79
VP1TabManager::Imp::channelsInTab
QStringList channelsInTab(QMainWindow *tab)
Definition: VP1TabManager.cxx:209
VP1TabManager::showNextTab
void showNextTab()
Definition: VP1TabManager.cxx:1108
VP1TabManager::showTabFullScreen
void showTabFullScreen(const QString &tabname)
Definition: VP1TabManager.cxx:395
VP1TabWidget::tabText
QString tabText(int) const
Definition: VP1TabWidget.cxx:291
VP1TabManager::Imp::checkTabnameNotExists
bool checkTabnameNotExists(const QString &tabname) const
Definition: VP1TabManager.cxx:170
VP1TabWidget::getVP1TabBar
VP1TabBar * getVP1TabBar()
Definition: VP1TabWidget.cxx:75
run.infile
string infile
Definition: run.py:13
VP1TabWidget::setTabText
void setTabText(int, const QString &)
Definition: VP1TabWidget.cxx:303
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
VP1TabManager::Imp::tabcruisemode
bool tabcruisemode
Definition: VP1TabManager.cxx:103
VP1TabManager::selectedChannelChanged
void selectedChannelChanged(IVP1ChannelWidget *)
index
Definition: index.py:1
VP1TabManager::serializeChannelState
void serializeChannelState(IVP1ChannelWidget *, ChanState &state)
Definition: VP1TabManager.cxx:1525
VP1ChannelManager::getIconLocation
QString getIconLocation(const QString &channelname, const bool &isbasename=true)
Definition: VP1ChannelManager.cxx:588
VP1TabManager::showTab
bool showTab(const QString &)
Definition: VP1TabManager.cxx:1078
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
python.TriggerConfig.menu
menu
Definition: TriggerConfig.py:842
skel.it
it
Definition: skel.GENtoEVGEN.py:396
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
VP1TabManager::currentVisibleChanged
void currentVisibleChanged()
Definition: VP1TabManager.cxx:1248
VP1TabManager::Imp::fullscreen_floatingdocks
std::set< VP1DockWidget * > fullscreen_floatingdocks
Definition: VP1TabManager.cxx:95
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
VP1ChannelManager::availableChannelList
QStringList availableChannelList()
Definition: VP1ChannelManager.cxx:498
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
IVP1ChannelWidget::unique_name
const QString unique_name() const
Definition: IVP1ChannelWidget.cxx:175
VP1TabManager::tabListChanged
void tabListChanged(QStringList)
VP1TabManager::ChanState
QPair< QByteArray, QMultiMap< QString, QByteArray > > ChanState
Definition: VP1TabManager.h:103
VP1TabManager::Imp::tab_2_channelwidgets
std::map< QMainWindow *, std::set< IVP1ChannelWidget * > > tab_2_channelwidgets
Definition: VP1TabManager.cxx:73
TruthTest.itE
itE
Definition: TruthTest.py:25
VP1ChannelManager::serializePluginInfo
QStringList serializePluginInfo() const
Definition: VP1ChannelManager.cxx:523
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
VP1TabManager::suggestNewTabName
QString suggestNewTabName(const QString &oldtabname) const
Definition: VP1TabManager.cxx:1027
VP1TabManager::Imp::selecteddockwidget
VP1DockWidget * selecteddockwidget
Definition: VP1TabManager.cxx:87
menu
make the sidebar many part of the config
Definition: hcg.cxx:551
VP1TabManager::renameTab
void renameTab(const QString &tabname, const QString &newtabname)
Definition: VP1TabManager.cxx:524
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:178
VP1DockWidget
Definition: VP1DockWidget.h:24
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
VP1TabManager::addChannelToTab
IVP1ChannelWidget * addChannelToTab(const QString &channelbasename, const QString &tabname)
Definition: VP1TabManager.cxx:470
VP1TabManager::tabList
QStringList tabList()
Definition: VP1TabManager.cxx:539
VP1Serialise::numberOfInstantiations
static unsigned numberOfInstantiations()
Definition: VP1Serialise.cxx:75
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
VP1TabManager::Imp::fullscreen_channelwidget
IVP1ChannelWidget * fullscreen_channelwidget
Definition: VP1TabManager.cxx:90
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:182
VP1ChannelManager::channelsInPluginFile
QStringList channelsInPluginFile(QString filename) const
Definition: VP1ChannelManager.cxx:358
VP1QtUtils::environmentVariableIsOn
static bool environmentVariableIsOn(const QString &name)
Definition: VP1QtUtils.cxx:127
lumiFormat.i
int i
Definition: lumiFormat.py:85
VP1TabManager::Imp::fullscreen_tabname
QString fullscreen_tabname
Definition: VP1TabManager.cxx:92
IVP13DStandardChannelWidget
Definition: IVP13DStandardChannelWidget.h:24
VP1TabManager::Imp::nextTab
QMainWindow * nextTab()
Definition: VP1TabManager.cxx:1048
file
TFile * file
Definition: tile_monitor.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VP1TabWidget::removeTab
virtual void removeTab(int index)
Definition: VP1TabWidget.cxx:473
IVP1ChannelWidget::systems
const std::set< IVP1System * > & systems()
Definition: IVP1ChannelWidget.cxx:231
VP1TabManager::Imp::name2tab
QMainWindow * name2tab(const QString &tabname)
Definition: VP1TabManager.cxx:673
VP1TabManager::Imp::lastvisible
QSet< IVP1ChannelWidget * > lastvisible
Definition: VP1TabManager.cxx:84
VP1QtUtils::expertSettingIsOn
static bool expertSettingIsOn(const QString &type, const QString &name)
Definition: VP1QtUtils.cxx:60
VP1TabManager::Imp::tabwidget
VP1TabWidget * tabwidget
Definition: VP1TabManager.cxx:63
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
VP1ChannelManager::loadPluginFile
QString loadPluginFile(QString filename)
Definition: VP1ChannelManager.cxx:229
VP1TabManager::selectedChannelWidget
IVP1ChannelWidget * selectedChannelWidget() const
Definition: VP1TabManager.cxx:465
VP1TabManager::showCurrentTabFullScreen
void showCurrentTabFullScreen()
Definition: VP1TabManager.cxx:455
VP1TabWidget::setTabReorderingEnabled
void setTabReorderingEnabled(bool enable)
Definition: VP1TabWidget.cxx:245
IVP1ChannelWidget
Definition: IVP1ChannelWidget.h:34
VP1TabManager::Imp::name_2_tab
std::map< QString, QMainWindow * > name_2_tab
Definition: VP1TabManager.cxx:71
VP1TabManager::addNewTab
void addNewTab(const QString &, const int &index=-1)
Definition: VP1TabManager.cxx:236
VP1TabManager::Imp::fullscreen_dockwidget
VP1DockWidget * fullscreen_dockwidget
Definition: VP1TabManager.cxx:89
head
std::string head(std::string s, const std::string &pattern)
head of a string
Definition: computils.cxx:311
VP1DockWidget::setSelected
void setSelected()
Definition: VP1DockWidget.cxx:223
VP1Deserialise::numberOfInstantiations
static unsigned numberOfInstantiations()
Definition: VP1Deserialise.cxx:90
VP1TabManager::Imp::channelWithPendingRemoval
QString channelWithPendingRemoval
Definition: VP1TabManager.cxx:108
IVP1ChannelWidget::restoreFromState
virtual void restoreFromState(QByteArray)
Definition: IVP1ChannelWidget.cxx:326
VP1DockWidget::ensureCWHasNoParent
void ensureCWHasNoParent()
Definition: VP1DockWidget.cxx:164
VP1TabManager::Imp::fullscreen_tab
QMainWindow * fullscreen_tab
Definition: VP1TabManager.cxx:94
IVP1ChannelWidget::saveState
virtual QByteArray saveState()
Definition: IVP1ChannelWidget.cxx:320
VP1DockWidget::setUnselected
void setUnselected()
Definition: VP1DockWidget.cxx:236
VP1TabManager::unserializeChannelState
void unserializeChannelState(IVP1ChannelWidget *cw, ChanState tate)
Definition: VP1TabManager.cxx:1542
python.selection.number
number
Definition: selection.py:20
VP1TabManager::showChannelFullScreen
void showChannelFullScreen(IVP1ChannelWidget *)
Definition: VP1TabManager.cxx:358
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
VP1TabManager::Imp::serializeTabAndChannelConfigInfo
QMap< QString, QStringList > serializeTabAndChannelConfigInfo() const
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VP1TabManager::currentTab
QString currentTab() const
Definition: VP1TabManager.cxx:1036
VP1TabManager::dropOutOfFullScreen
void dropOutOfFullScreen()
Definition: VP1TabManager.cxx:257
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
VP1ChannelManager::deleteChannel
bool deleteChannel(QString channeluniquename)
Definition: VP1ChannelManager.cxx:132
VP1ChannelManager::uniqueName2Channel
IVP1ChannelWidget * uniqueName2Channel(QString uniquename) const
Definition: VP1ChannelManager.cxx:455
VP1TabManager::Imp::fullscreen_tabindex
int fullscreen_tabindex
Definition: VP1TabManager.cxx:93
VP1TabManager::removeChannel
void removeChannel(const QString &channeluniquename)
Definition: VP1TabManager.cxx:600
VP1TabManager::Imp::checkChannelNameExists
bool checkChannelNameExists(const QString &channelbasename, const bool &isuniquename, const bool &checkfornonexistance=false) const
Definition: VP1TabManager.cxx:192
DeMoScan.index
string index
Definition: DeMoScan.py:364
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition: VP1Msg.cxx:39
VP1TabManager::removeTab
void removeTab(const QString &tabname)
Definition: VP1TabManager.cxx:549
python.output.AtlRunQueryRoot.pf
pf
Definition: AtlRunQueryRoot.py:988
VP1TabManager::Imp::lastsoonvisible
QSet< IVP1ChannelWidget * > lastsoonvisible
Definition: VP1TabManager.cxx:85
VP1TabManager::m_d
Imp * m_d
Definition: VP1TabManager.h:99
VP1DockWidget::channelWidget
IVP1ChannelWidget * channelWidget() const
Definition: VP1DockWidget.cxx:249
VP1TabManager::Imp::channelmanager
VP1ChannelManager * channelmanager
Definition: VP1TabManager.cxx:64
VP1ChannelManager::getChannel
IVP1ChannelWidget * getChannel(const QString &channelbasename, QString &err)
Definition: VP1ChannelManager.cxx:403
VP1TabManager::Imp::checkTabnameExists
bool checkTabnameExists(const QString &tabname) const
Definition: VP1TabManager.cxx:158
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
VP1TabManager::setSelectedDockWidget
void setSelectedDockWidget(VP1DockWidget *dw=0)
Definition: VP1TabManager.cxx:329
VP1TabManager::raiseTabBarContextMenu
void raiseTabBarContextMenu(int, const QPoint &)
Definition: VP1TabManager.cxx:1136
VP1TabManager::Imp::dontEmitVisibilityChanges
bool dontEmitVisibilityChanges
Definition: VP1TabManager.cxx:83
checkFileSG.fi
fi
Definition: checkFileSG.py:65
IVP1ChannelWidget::name
const QString & name() const
Definition: IVP1ChannelWidget.cxx:180
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
VP1TabManager::Imp::channel2tab
QMainWindow * channel2tab(IVP1ChannelWidget *cw)
Definition: VP1TabManager.cxx:661
VP1ChannelManager::baseNameExists
bool baseNameExists(QString) const
Definition: VP1ChannelManager.cxx:467
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42
VP1TabManager::visibleChannelsChanged
void visibleChannelsChanged(const QSet< IVP1ChannelWidget * > &vis, const QSet< IVP1ChannelWidget * > &soonvis, const double &soonvisbonus)
VP1TabManager::Imp::channelwidget_2_dockwidget
std::map< IVP1ChannelWidget *, VP1DockWidget * > channelwidget_2_dockwidget
Definition: VP1TabManager.cxx:72
VP1TabManager::executePendingChannelRemoval
void executePendingChannelRemoval()
Definition: VP1TabManager.cxx:1516
VP1DockWidget::ensureCWHasParent
void ensureCWHasParent()
Definition: VP1DockWidget.cxx:177
VP1TabManager::cloneTab
void cloneTab(const QString &oldtabname, const QString &newtabname)
Definition: VP1TabManager.cxx:733
beamspotman.basename
basename
Definition: beamspotman.py:640