summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo/modulesinfo.cpp
Unidiff
Diffstat (limited to 'noncore/settings/sysinfo/modulesinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/modulesinfo.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp
index e688a29..dfe48e1 100644
--- a/noncore/settings/sysinfo/modulesinfo.cpp
+++ b/noncore/settings/sysinfo/modulesinfo.cpp
@@ -20,29 +20,33 @@
20**********************************************************************/ 20**********************************************************************/
21 21
22#include "modulesinfo.h" 22#include "modulesinfo.h"
23#include "detail.h" 23#include "detail.h"
24 24
25/* OPIE */ 25/* OPIE */
26#include <opie2/olistview.h>
26#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
27 28
28/* QT */ 29/* QT */
30#include <qcombobox.h>
29#include <qfile.h> 31#include <qfile.h>
30#include <qlayout.h> 32#include <qlayout.h>
31#include <qmessagebox.h> 33#include <qmessagebox.h>
34#include <qpushbutton.h>
35#include <qtextview.h>
32#include <qtimer.h> 36#include <qtimer.h>
33#include <qwhatsthis.h> 37#include <qwhatsthis.h>
34 38
35ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) 39ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
36 : QWidget( parent, name, fl ) 40 : QWidget( parent, name, fl )
37{ 41{
38 QGridLayout *layout = new QGridLayout( this ); 42 QGridLayout *layout = new QGridLayout( this );
39 layout->setSpacing( 4 ); 43 layout->setSpacing( 4 );
40 layout->setMargin( 4 ); 44 layout->setMargin( 4 );
41 45
42 ModulesView = new QListView( this ); 46 ModulesView = new OListView( this );
43 int colnum = ModulesView->addColumn( tr( "Module" ) ); 47 int colnum = ModulesView->addColumn( tr( "Module" ) );
44 colnum = ModulesView->addColumn( tr( "Size" ) ); 48 colnum = ModulesView->addColumn( tr( "Size" ) );
45 ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); 49 ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
46 colnum = ModulesView->addColumn( tr( "Use#" ) ); 50 colnum = ModulesView->addColumn( tr( "Use#" ) );
47 ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); 51 ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
48 colnum = ModulesView->addColumn( tr( "Used by" ) ); 52 colnum = ModulesView->addColumn( tr( "Used by" ) );
@@ -51,14 +55,14 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
51 QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); 55 QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) );
52 56
53 // Test if we have /sbin/modinfo, and if so, allow module detail window 57 // Test if we have /sbin/modinfo, and if so, allow module detail window
54 if ( QFile::exists( "/sbin/modinfo" ) ) 58 if ( QFile::exists( "/sbin/modinfo" ) )
55 { 59 {
56 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); 60 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold );
57 connect( ModulesView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), 61 connect( ModulesView, SIGNAL( rightButtonPressed(OListViewItem*,const QPoint&,int) ),
58 this, SLOT( viewModules(QListViewItem*) ) ); 62 this, SLOT( viewModules(OListViewItem*) ) );
59 } 63 }
60 64
61 CommandCB = new QComboBox( FALSE, this ); 65 CommandCB = new QComboBox( FALSE, this );
62 CommandCB->insertItem( "modprobe -r" ); 66 CommandCB->insertItem( "modprobe -r" );
63 CommandCB->insertItem( "rmmod" ); 67 CommandCB->insertItem( "rmmod" );
64 // I can't think of other useful commands yet. Anyone? 68 // I can't think of other useful commands yet. Anyone?
@@ -90,26 +94,26 @@ void ModulesInfo::updateData()
90{ 94{
91 char modname[64]; 95 char modname[64];
92 char usage[200]; 96 char usage[200];
93 int modsize, usecount; 97 int modsize, usecount;
94 98
95 QString selectedmod; 99 QString selectedmod;
96 QListViewItem *curritem = ModulesView->currentItem(); 100 OListViewItem *curritem = static_cast<OListViewItem*>( ModulesView->currentItem() );
97 if ( curritem ) 101 if ( curritem )
98 { 102 {
99 selectedmod = curritem->text( 0 ); 103 selectedmod = curritem->text( 0 );
100 } 104 }
101 105
102 ModulesView->clear(); 106 ModulesView->clear();
103 107
104 FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); 108 FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r");
105 109
106 if ( procfile ) 110 if ( procfile )
107 { 111 {
108 QListViewItem *newitem; 112 OListViewItem *newitem;
109 QListViewItem *selecteditem = 0x0; 113 OListViewItem *selecteditem = 0x0;
110 while ( true ) 114 while ( true )
111 { 115 {
112 modname[0] = '\0'; 116 modname[0] = '\0';
113 usage[0] = '\0'; 117 usage[0] = '\0';
114 int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); 118 int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage );
115 119
@@ -118,13 +122,13 @@ void ModulesInfo::updateData()
118 122
119 QString qmodname = QString( modname ); 123 QString qmodname = QString( modname );
120 QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); 124 QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' );
121 QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); 125 QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' );
122 QString qusage = QString( usage ); 126 QString qusage = QString( usage );
123 127
124 newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); 128 newitem = new OListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage );
125 if ( qmodname == selectedmod ) 129 if ( qmodname == selectedmod )
126 { 130 {
127 selecteditem = newitem; 131 selecteditem = newitem;
128 } 132 }
129 } 133 }
130 ModulesView->setCurrentItem( selecteditem ); 134 ModulesView->setCurrentItem( selecteditem );
@@ -137,13 +141,13 @@ void ModulesInfo::slotSendClicked()
137{ 141{
138 if ( !ModulesView->currentItem() ) 142 if ( !ModulesView->currentItem() )
139 { 143 {
140 return; 144 return;
141 } 145 }
142 146
143 QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); 147 QString capstr = tr( "You really want to execute\n%1 for this module?" ).arg( CommandCB->currentText() );
144 148
145 QString modname = ModulesView->currentItem()->text( 0 ); 149 QString modname = ModulesView->currentItem()->text( 0 );
146 150
147 if ( QMessageBox::warning( this, modname, capstr, 151 if ( QMessageBox::warning( this, modname, capstr,
148 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) 152 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
149 { 153 {
@@ -156,13 +160,13 @@ void ModulesInfo::slotSendClicked()
156 if ( stream ) 160 if ( stream )
157 pclose( stream ); 161 pclose( stream );
158 } 162 }
159 163
160} 164}
161 165
162void ModulesInfo::viewModules( QListViewItem *modules ) 166void ModulesInfo::viewModules( OListViewItem *modules )
163{ 167{
164 QString modname = modules->text( 0 ); 168 QString modname = modules->text( 0 );
165 QString capstr = "Module: "; 169 QString capstr = "Module: ";
166 capstr.append( modname ); 170 capstr.append( modname );
167 ModulesDtl->setCaption( capstr ); 171 ModulesDtl->setCaption( capstr );
168 QString command = "/sbin/modinfo "; 172 QString command = "/sbin/modinfo ";