summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-06-01 21:19:21 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-06-01 21:19:21 -0500
commitb282a7bb897aef54980dc0996a842a2253f013da (patch)
treec2ec573c8c62db883c74790da00bbbfa92255b60
parentf04d5a36adcd7ed3849108fca0ee9e6899eccb1c (diff)
downloadtdelibs-b282a7bb897aef54980dc0996a842a2253f013da.tar.gz
tdelibs-b282a7bb897aef54980dc0996a842a2253f013da.zip
Reduce CPU usage of triggerless device polling routine
Fix TDEListView not emitting executed signal for part of entire highlighted item area
-rw-r--r--tdecore/tdehardwaredevices.cpp64
-rw-r--r--tdecore/tdehardwaredevices.h11
-rw-r--r--tdeui/kiconview.cpp2
-rw-r--r--tdeui/tdelistview.cpp78
-rw-r--r--tdeui/tdelistview.h2
5 files changed, 117 insertions, 40 deletions
diff --git a/tdecore/tdehardwaredevices.cpp b/tdecore/tdehardwaredevices.cpp
index 21c31bca4..7dc2de5e2 100644
--- a/tdecore/tdehardwaredevices.cpp
+++ b/tdecore/tdehardwaredevices.cpp
@@ -2386,10 +2386,16 @@ void TDEHardwareDevices::setTriggerlessHardwareUpdatesEnabled(bool enable) {
}
void TDEHardwareDevices::rescanDeviceInformation(TDEGenericDevice* hwdevice) {
+ rescanDeviceInformation(hwdevice, true);
+}
+
+void TDEHardwareDevices::rescanDeviceInformation(TDEGenericDevice* hwdevice, bool regenerateDeviceTree) {
struct udev_device *dev;
dev = udev_device_new_from_syspath(m_udevStruct, hwdevice->systemPath().ascii());
- classifyUnknownDevice(dev, hwdevice, false);
- updateParentDeviceInformation(hwdevice); // Update parent/child tables for this device
+ updateExistingDeviceInformation(hwdevice);
+ if (regenerateDeviceTree) {
+ updateParentDeviceInformation(hwdevice); // Update parent/child tables for this device
+ }
udev_device_unref(dev);
}
@@ -2874,7 +2880,7 @@ void TDEHardwareDevices::processStatelessDevices() {
TDEGenericHardwareList devList = listAllPhysicalDevices();
for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) {
if ((hwdevice->type() == TDEGenericDeviceType::RootSystem) || (hwdevice->type() == TDEGenericDeviceType::Network) || (hwdevice->type() == TDEGenericDeviceType::OtherSensor) || (hwdevice->type() == TDEGenericDeviceType::Event) || (hwdevice->type() == TDEGenericDeviceType::Battery) || (hwdevice->type() == TDEGenericDeviceType::PowerSupply)) {
- rescanDeviceInformation(hwdevice);
+ rescanDeviceInformation(hwdevice, false);
emit hardwareUpdated(hwdevice);
emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID());
}
@@ -4130,6 +4136,56 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
device = classifyUnknownDeviceByExternalRules(dev, device, false);
}
+ updateExistingDeviceInformation(device, dev);
+
+ if (temp_udev_device) {
+ udev_device_unref(dev);
+ }
+
+ return device;
+}
+
+void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* existingdevice, udev_device* dev) {
+ TQString devicename;
+ TQString devicetype;
+ TQString devicedriver;
+ TQString devicesubsystem;
+ TQString devicenode;
+ TQString systempath;
+ TQString devicevendorid;
+ TQString devicemodelid;
+ TQString devicevendoridenc;
+ TQString devicemodelidenc;
+ TQString devicesubvendorid;
+ TQString devicesubmodelid;
+ TQString devicetypestring;
+ TQString devicetypestring_alt;
+ TQString devicepciclass;
+ TDEGenericDevice* device = existingdevice;
+ bool temp_udev_device = !dev;
+
+ devicename = device->name();
+ devicetype = device->m_udevtype;
+ devicedriver = device->deviceDriver();
+ devicesubsystem = device->subsystem();
+ devicenode = device->deviceNode();
+ systempath = device->systemPath();
+ devicevendorid = device->vendorID();
+ devicemodelid = device->modelID();
+ devicevendoridenc = device->vendorEncoded();
+ devicemodelidenc = device->modelEncoded();
+ devicesubvendorid = device->subVendorID();
+ devicesubmodelid = device->subModelID();
+ devicetypestring = device->m_udevdevicetypestring;
+ devicetypestring_alt = device->udevdevicetypestring_alt;
+ devicepciclass = device->PCIClass();
+
+ if (!dev) {
+ TQString syspathudev = systempath;
+ syspathudev.truncate(syspathudev.length()-1); // Remove trailing slash
+ dev = udev_device_new_from_syspath(m_udevStruct, syspathudev.ascii());
+ }
+
if (device->type() == TDEGenericDeviceType::Disk) {
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(device);
if (sdevice->diskType() & TDEDiskDeviceType::Camera) {
@@ -5133,8 +5189,6 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
if (temp_udev_device) {
udev_device_unref(dev);
}
-
- return device;
}
void TDEHardwareDevices::updateBlacklists(TDEGenericDevice* hwdevice, udev_device* dev) {
diff --git a/tdecore/tdehardwaredevices.h b/tdecore/tdehardwaredevices.h
index 70c528a85..fcf60533d 100644
--- a/tdecore/tdehardwaredevices.h
+++ b/tdecore/tdehardwaredevices.h
@@ -2024,6 +2024,16 @@ class TDECORE_EXPORT TDEHardwareDevices : public TQObject
void rescanDeviceInformation(TDEGenericDevice* hwdevice);
/**
+ * Rescan a hardware device to look for changes
+ * WARNING: This method can be very expensive. Use with caution!
+ * The computational expense can be reduced somewhat if the device tree structure
+ * has not changed by calling this method with regenerateDeviceTree = FALSE.
+ * @param hwdevice TDEGenericDevice* with the device to rescan
+ * @param regenerateDeviceTree TRUE to update parent/child links in device tree
+ */
+ void rescanDeviceInformation(TDEGenericDevice* hwdevice, bool regenerateDeviceTree);
+
+ /**
* Enable or disable automatic state updates of triggerless hardware devices
* such as CPUs and network cards. When enabled, your application will use
* additional CPU resources to continually poll triggerless hardware devices.
@@ -2066,6 +2076,7 @@ class TDECORE_EXPORT TDEHardwareDevices : public TQObject
private:
TDEGenericDevice *classifyUnknownDevice(udev_device* dev, TDEGenericDevice* existingdevice=0, bool force_full_classification=true);
TDEGenericDevice *classifyUnknownDeviceByExternalRules(udev_device* dev, TDEGenericDevice* existingdevice=0, bool classifySubDevices=false);
+ void updateExistingDeviceInformation(TDEGenericDevice* existingdevice, udev_device* dev=NULL);
void updateParentDeviceInformation();
void updateParentDeviceInformation(TDEGenericDevice* hwdevice);
diff --git a/tdeui/kiconview.cpp b/tdeui/kiconview.cpp
index cd19f4030..31de273c7 100644
--- a/tdeui/kiconview.cpp
+++ b/tdeui/kiconview.cpp
@@ -247,7 +247,7 @@ void TDEIconView::emitExecute( TQIconViewItem *item, const TQPoint &pos )
m_pAutoSelect->stop();
- //Don�t emit executed if in SC mode and Shift or Ctrl are pressed
+ //Don't emit executed if in SC mode and Shift or Ctrl are pressed
if( !( m_bUseSingle && ((keybstate & ShiftButton) || (keybstate & ControlButton)) ) ) {
setSelected( item, false );
viewport()->unsetCursor();
diff --git a/tdeui/tdelistview.cpp b/tdeui/tdelistview.cpp
index 4750a7138..b4529722b 100644
--- a/tdeui/tdelistview.cpp
+++ b/tdeui/tdelistview.cpp
@@ -489,36 +489,45 @@ bool TDEListView::isExecuteArea( int x )
bool TDEListView::isExecuteArea( int x, TQListViewItem* item )
{
- if( allColumnsShowFocus() )
- return true;
- else {
- int offset = 0;
-
-
- int width = columnWidth( 0 );
-
- TQHeader* const thisHeader = header();
- const int pos = thisHeader->mapToIndex( 0 );
-
- for ( int index = 0; index < pos; ++index )
- offset += columnWidth( thisHeader->mapToSection( index ) );
-
- x += contentsX(); // in case of a horizontal scrollbar
-
- if ( item )
- {
- width = treeStepSize()*( item->depth() + ( rootIsDecorated() ? 1 : 0 ) );
- width += itemMargin();
- int ca = AlignHorizontal_Mask & columnAlignment( 0 );
- if ( ca == AlignLeft || ca == AlignAuto ) {
- width += item->width( fontMetrics(), this, 0 );
- if ( width > columnWidth( 0 ) )
- width = columnWidth( 0 );
+ if ( allColumnsShowFocus() ) {
+ return true;
+ }
+ else {
+ int offset = 0;
+ int width = columnWidth( 0 );
+
+ TQHeader* const thisHeader = header();
+ const int pos = thisHeader->mapToIndex( 0 );
+
+ for ( int index = 0; index < pos; ++index ) {
+ offset += columnWidth( thisHeader->mapToSection( index ) );
+ }
+
+ x += contentsX(); // in case of a horizontal scrollbar
+
+ // What was this supposed to do???
+ // Just use the column width, as at least one entire column is highlighted on row selection!
+#if 0
+ if ( item ) {
+ width = treeStepSize()*( item->depth() + ( rootIsDecorated() ? 1 : 0 ) );
+ width += itemMargin();
+ int ca = AlignHorizontal_Mask & columnAlignment( 0 );
+ if ( ca == AlignLeft || ca == AlignAuto ) {
+ width += item->width( fontMetrics(), this, 0 );
+ if ( width > columnWidth( 0 ) ) {
+ width = columnWidth( 0 );
+ }
+ }
+ }
+#endif
+ if ( item ) {
+ if (!allColumnsShowFocus()) {
+ offset += treeStepSize()*( item->depth() + ( rootIsDecorated() ? 1 : 0 ) );
+ }
+ }
+
+ return ( x > offset && x < ( offset + width ) );
}
- }
-
- return ( x > offset && x < ( offset + width ) );
- }
}
void TDEListView::slotOnItem( TQListViewItem *item )
@@ -883,8 +892,9 @@ void TDEListView::contentsMouseDoubleClickEvent ( TQMouseEvent *e )
// We don't want to call the parent method because it does setOpen,
// whereas we don't do it in single click mode... (David)
//TQListView::contentsMouseDoubleClickEvent( e );
- if ( !e || e->button() != Qt::LeftButton )
+ if ( !e || e->button() != Qt::LeftButton ) {
return;
+ }
TQPoint vp = contentsToViewport(e->pos());
TQListViewItem *item = itemAt( vp );
@@ -895,15 +905,17 @@ void TDEListView::contentsMouseDoubleClickEvent ( TQMouseEvent *e )
if( item ) {
emit doubleClicked( item, e->globalPos(), col );
- if( (e->button() == Qt::LeftButton) && !d->bUseSingle )
+ if( (e->button() == Qt::LeftButton) && !d->bUseSingle ) {
emitExecute( item, e->globalPos(), col );
+ }
}
}
void TDEListView::slotMouseButtonClicked( int btn, TQListViewItem *item, const TQPoint &pos, int c )
{
- if( (btn == Qt::LeftButton) && item )
+ if( (btn == Qt::LeftButton) && item ) {
emitExecute(item, pos, c);
+ }
}
void TDEListView::contentsDropEvent(TQDropEvent* e)
@@ -2365,7 +2377,7 @@ void TDEListViewItem::paintCell(TQPainter *p, const TQColorGroup &cg, int column
void TDEListView::selectAll( bool select )
{
- if ( selectionMode() == Multi || selectionMode() == Extended ) {
+ if ( ((SelectionModeExt)selectionMode() == Multi) || ((SelectionModeExt)selectionMode() == Extended) ) {
bool b = signalsBlocked();
blockSignals( TRUE );
bool anything = FALSE;
diff --git a/tdeui/tdelistview.h b/tdeui/tdelistview.h
index 995e2b678..bd0473304 100644
--- a/tdeui/tdelistview.h
+++ b/tdeui/tdelistview.h
@@ -37,7 +37,7 @@ class KLineEdit;
* There is a new signal executed(). It gets connected to either
* TQListView::clicked() or TQListView::doubleClicked() depending on the KDE
* wide Single Click/Double Click settings. It is strongly recommended that
- * you use this signal instead of the above mentioned. This way you don´t
+ * you use this signal instead of the above mentioned. This way you don't
* need to care about the current settings.
* If you want to get informed when the user selects something connect to the
* TQListView::selectionChanged() signal.