00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4LoadedLibrariesSlots.h"
00017
00018 #include "TSystem.h"
00019 #include "TInterpreter.h"
00020
00021 #include "qfiledialog.h"
00022 #include "qstring.h"
00023 #include "qlistview.h"
00024
00025 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00026 #include "TGo4LoadedLibraries.h"
00027
00028 void TGo4LoadedLibrariesSlots::SetGUI(TGo4LoadedLibraries * GUI)
00029 {
00030 fxTGo4LoadedLibraries=GUI;
00031 fxTGo4GUIRegistry->GuiIsChanged(this, GUI);
00032 }
00033
00034 TGo4LoadedLibrariesSlots::TGo4LoadedLibrariesSlots(const char * name, const char * title, TGo4LoadedLibraries * p)
00035 : TGo4SlotsBaseClass(name, title),fxTGo4LoadedLibraries(p)
00036 {
00037 fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00038 fxTGo4GUIRegistry->RegisterSlotClass(this,0, p);
00039 }
00040
00041
00042 void TGo4LoadedLibrariesSlots::LoadNewLibrary()
00043 {
00044
00045 QFileDialog fd( fxTGo4LoadedLibraries, "Load Library", TRUE );
00046 fd.setMode( QFileDialog::ExistingFiles);
00047 fd.setName( "Load Shared Library ");
00048 fd.setFilter( "Library (*.so)" );
00049
00050 if ( fd.exec() != QDialog::Accepted ) return;
00051
00052 QStringList list = fd.selectedFiles();
00053 QStringList::Iterator it = list.begin();
00054 while( it != list.end() ) {
00055 gSystem->Load((*it).data());
00056 ++it;
00057 }
00058 RefreshLibs();
00059 }
00060
00061 void TGo4LoadedLibrariesSlots::UnloadLibrary()
00062 {
00063
00064 QPtrList <QListViewItem> *lst = new QPtrList <QListViewItem>;
00065 lst->setAutoDelete( TRUE );
00066
00067 if(fxTGo4LoadedLibraries->LoadedLibsD->isMultiSelection()){
00068 QListViewItemIterator it(fxTGo4LoadedLibraries->LoadedLibsD);
00069
00070 for ( ; it.current(); ++it ) {
00071 if ( it.current()->isSelected() ){
00072 gSystem->Unload(it.current()->text(0).data());
00073 lst->append( it.current() );
00074 }
00075 }
00076 }
00077
00078 delete lst;
00079
00080 }
00081
00082
00083 void TGo4LoadedLibrariesSlots::RefreshLibs()
00084 {
00085 char seps[]=" ,\t\n";
00086 char buffer[16];
00087
00088
00089 fxTGo4LoadedLibraries->LoadedLibsD->clear();
00090 QString T = gInterpreter->GetSharedLibs();
00091
00092 char* tokbuf = 0;
00093 char *token = strtok_r((char *)T.data(), seps, &tokbuf);
00094
00095 while(token!=NULL) {
00096 QFileInfo fi(token);
00097 snprintf(buffer,15,"%d",fi.size());
00098 new QListViewItem(fxTGo4LoadedLibraries->LoadedLibsD,token,QString(buffer),
00099 fi.lastModified().toString(), fi.owner(), fi.group() );
00100 token = strtok_r(NULL, seps, &tokbuf);
00101 }
00102
00103 fxTGo4LoadedLibraries->LoadedLibsS->clear();
00104 QString T1 = gSystem->GetLinkedLibs() ;
00105
00106 token =strtok_r((char *)T1.data(), seps, &tokbuf);
00107
00108 while(token!=NULL) {
00109 new QListViewItem(fxTGo4LoadedLibraries->LoadedLibsS,token);
00110 token = strtok_r(NULL, seps, &tokbuf);
00111 }
00112 }
00113
00114
00115