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.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp
index 3d127a8..8def0d6 100644
--- a/noncore/settings/sysinfo/modulesinfo.cpp
+++ b/noncore/settings/sysinfo/modulesinfo.cpp
@@ -27,49 +27,49 @@
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlistview.h> 28#include <qlistview.h>
29#include <qmessagebox.h> 29#include <qmessagebox.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qwhatsthis.h> 33#include <qwhatsthis.h>
34 34
35#include "modulesinfo.h" 35#include "modulesinfo.h"
36#include "detail.h" 36#include "detail.h"
37 37
38ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) 38ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
39 : QWidget( parent, name, fl ) 39 : QWidget( parent, name, fl )
40{ 40{
41 QGridLayout *layout = new QGridLayout( this ); 41 QGridLayout *layout = new QGridLayout( this );
42 layout->setSpacing( 4 ); 42 layout->setSpacing( 4 );
43 layout->setMargin( 4 ); 43 layout->setMargin( 4 );
44 44
45 ModulesView = new QListView( this ); 45 ModulesView = new QListView( this );
46 int colnum = ModulesView->addColumn( tr( "Module" ) ); 46 int colnum = ModulesView->addColumn( tr( "Module" ) );
47 colnum = ModulesView->addColumn( tr( "Size" ) ); 47 colnum = ModulesView->addColumn( tr( "Size" ) );
48 ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); 48 ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
49 colnum = ModulesView->addColumn( tr( "Use#" ) ); 49 colnum = ModulesView->addColumn( tr( "Use#" ) );
50 ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); 50 ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
51 colnum = ModulesView->addColumn( tr( "Used By" ) ); 51 colnum = ModulesView->addColumn( tr( "Used by" ) );
52 ModulesView->setAllColumnsShowFocus( TRUE ); 52 ModulesView->setAllColumnsShowFocus( TRUE );
53 layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); 53 layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 );
54 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." ) ); 54 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 55
56 // Test if we have /sbin/modinfo, and if so, allow module detail window 56 // Test if we have /sbin/modinfo, and if so, allow module detail window
57 if ( QFile::exists( "/sbin/modinfo" ) ) 57 if ( QFile::exists( "/sbin/modinfo" ) )
58 { 58 {
59 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); 59 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold );
60 connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), 60 connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
61 this, SLOT( viewModules( QListViewItem * ) ) ); 61 this, SLOT( viewModules( QListViewItem * ) ) );
62 } 62 }
63 63
64 CommandCB = new QComboBox( FALSE, this ); 64 CommandCB = new QComboBox( FALSE, this );
65 CommandCB->insertItem( "modprobe -r" ); 65 CommandCB->insertItem( "modprobe -r" );
66 CommandCB->insertItem( "rmmod" ); 66 CommandCB->insertItem( "rmmod" );
67 // I can't think of other useful commands yet. Anyone? 67 // I can't think of other useful commands yet. Anyone?
68 layout->addWidget( CommandCB, 1, 0 ); 68 layout->addWidget( CommandCB, 1, 0 );
69 QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); 69 QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) );
70 70
71 QPushButton *btn = new QPushButton( this ); 71 QPushButton *btn = new QPushButton( this );
72 btn->setMinimumSize( QSize( 50, 24 ) ); 72 btn->setMinimumSize( QSize( 50, 24 ) );
73 btn->setMaximumSize( QSize( 50, 24 ) ); 73 btn->setMaximumSize( QSize( 50, 24 ) );
74 btn->setText( tr( "Send" ) ); 74 btn->setText( tr( "Send" ) );
75 connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); 75 connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) );
@@ -120,51 +120,49 @@ void ModulesInfo::updateData()
120 QString qmodname = QString( modname ); 120 QString qmodname = QString( modname );
121 QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); 121 QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' );
122 QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); 122 QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' );
123 QString qusage = QString( usage ); 123 QString qusage = QString( usage );
124 124
125 newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); 125 newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage );
126 if ( qmodname == selectedmod ) 126 if ( qmodname == selectedmod )
127 { 127 {
128 selecteditem = newitem; 128 selecteditem = newitem;
129 } 129 }
130 } 130 }
131 ModulesView->setCurrentItem( selecteditem ); 131 ModulesView->setCurrentItem( selecteditem );
132 132
133 fclose( procfile ); 133 fclose( procfile );
134 } 134 }
135} 135}
136 136
137void ModulesInfo::slotSendClicked() 137void ModulesInfo::slotSendClicked()
138{ 138{
139 if ( !ModulesView->currentItem() ) 139 if ( !ModulesView->currentItem() )
140 { 140 {
141 return; 141 return;
142 } 142 }
143 143
144 QString capstr = tr( "You really want to execute\n" ); 144 QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() );
145 capstr.append( CommandCB->currentText() );
146 capstr.append( "\nfor this module?" );
147 145
148 QString modname = ModulesView->currentItem()->text( 0 ); 146 QString modname = ModulesView->currentItem()->text( 0 );
149 147
150 if ( QMessageBox::warning( this, modname, capstr, 148 if ( QMessageBox::warning( this, modname, capstr,
151 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) 149 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
152 { 150 {
153 QString command = "/sbin/"; 151 QString command = "/sbin/";
154 command.append( CommandCB->currentText() ); 152 command.append( CommandCB->currentText() );
155 command.append( " " ); 153 command.append( " " );
156 command.append( modname ); 154 command.append( modname );
157 155
158 FILE* stream = popen( command, "r" ); 156 FILE* stream = popen( command, "r" );
159 if ( stream ) 157 if ( stream )
160 pclose( stream ); 158 pclose( stream );
161 } 159 }
162 160
163} 161}
164 162
165void ModulesInfo::viewModules( QListViewItem *modules ) 163void ModulesInfo::viewModules( QListViewItem *modules )
166{ 164{
167 QString modname = modules->text( 0 ); 165 QString modname = modules->text( 0 );
168 QString capstr = "Module: "; 166 QString capstr = "Module: ";
169 capstr.append( modname ); 167 capstr.append( modname );
170 ModulesDtl->setCaption( capstr ); 168 ModulesDtl->setCaption( capstr );