GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4LoadedLibraries.cpp
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4LoadedLibraries.h"
15 
16 #include <QFileDialog>
17 #include <QDateTime>
18 
19 #include "TSystem.h"
20 #include "TString.h"
21 #include "TInterpreter.h"
22 #include "TObjArray.h"
23 
25  : QDialog( parent )
26 {
27  setObjectName("Go4LoadedLibraries");
28  setupUi(this);
29  QObject::connect(LoadLibBtn, &QPushButton::clicked, this, &TGo4LoadedLibraries::LoadNewLibrary);
30  QObject::connect(UnloadLibBtn, &QPushButton::clicked, this, &TGo4LoadedLibraries::UnloadLibrary);
31  QObject::connect(RefreshBtn, &QPushButton::clicked, this, &TGo4LoadedLibraries::RefreshLibs);
32 
33  RefreshLibs();
34  UnloadLibBtn->hide();
35 }
36 
38 {
39  QFileDialog fd(this, "Load Shared Library ", QString(), "Library (*.so)");
40  fd.setFileMode( QFileDialog::ExistingFiles);
41 
42  if ( fd.exec() != QDialog::Accepted ) return;
43 
44  QStringList list = fd.selectedFiles();
45  QStringList::Iterator it = list.begin();
46  while( it != list.end() ) {
47  gSystem->Load((*it).toLatin1().constData());
48  ++it;
49  }
50 
51  RefreshLibs();
52 }
53 
55 {
56  QTreeWidgetItemIterator it(LoadedLibsD);
57  while(*it) {
58  if ( (*it)->isSelected() )
59  gSystem->Unload((*it)->text(0).toLatin1().constData());
60  it++;
61  }
62 
63  RefreshLibs();
64 }
65 
67 {
68  LoadedLibsD->clear();
69 
70  TObjArray *libs = TString(gInterpreter->GetSharedLibs()).Tokenize(" ,\t\n");
71 
72  if (libs)
73  for (int n = 0; n <= libs->GetLast(); n++) {
74  QFileInfo fi(libs->At(n)->GetName());
75 
76  QStringList columns;
77 
78  columns << fi.fileName() << QString::number(fi.size()) << fi.lastModified().toString() << fi.owner() << fi.group();
79 
80  LoadedLibsD->addTopLevelItem(new QTreeWidgetItem(columns));
81  }
82 
83  delete libs;
84 
85  LoadedLibsS->clear();
86 
87  libs = TString(gSystem->GetLinkedLibs()).Tokenize(" ,\t\n");
88 
89  if (libs)
90  for (int n = 0; n <= libs->GetLast(); n++) {
91  QStringList columns;
92  columns << libs->At(n)->GetName();
93  LoadedLibsS->addTopLevelItem(new QTreeWidgetItem(columns));
94  }
95 
96  delete libs;
97 }
virtual void LoadNewLibrary()
TGo4LoadedLibraries(QWidget *parent=nullptr)
virtual void UnloadLibrary()