Branch: master

01d88b28 2014-11-26 20:51:59 Michele Calgaro
Added support for handbookDocPath(). This relates to bug 1850.
M tdeui/tdecmodule.cpp
M tdeui/tdecmodule.h
M tdeutils/kcmultidialog.cpp
M tdeutils/tdecmoduleproxy.cpp
M tdeutils/tdecmoduleproxy.h
diff --git a/tdeui/tdecmodule.cpp b/tdeui/tdecmodule.cpp
index 1c71827..48a72b6 100644
--- a/tdeui/tdecmodule.cpp
+++ b/tdeui/tdecmodule.cpp
@@ -208,6 +208,11 @@
     return d->_quickHelp;
 }
 
+TQString TDECModule::handbookDocPath() const
+{
+    return TQString::null;
+}
+
 TQString TDECModule::handbookSection() const
 {
     return TQString::null;
diff --git a/tdeui/tdecmodule.h b/tdeui/tdecmodule.h
index b4d7f6d..186ee66 100644
--- a/tdeui/tdecmodule.h
+++ b/tdeui/tdecmodule.h
@@ -178,6 +178,16 @@
   virtual TQString quickHelp() const;
 
   /**
+   * If the handbook's docPath string of the currently displayed content
+   * (for example in tabbed control center modules) differs from the docPath string
+   * of the currently displaying container, this method returns the relevant docPath string
+   *
+   * @returns a TQString containing the relevant handbook's docPath string or TQString::null 
+   *          if no specific docPath string is required (i.e. the container docPath is sufficient)
+   */
+  virtual TQString handbookDocPath() const;
+  
+  /**
    * If a specific handbook section is relevant to the currently displayed content
    * (for example tabbed control center modules) this method returns the relevant section name
    *
diff --git a/tdeutils/kcmultidialog.cpp b/tdeutils/kcmultidialog.cpp
index 0ba07fe..cbdffaa 100644
--- a/tdeutils/kcmultidialog.cpp
+++ b/tdeutils/kcmultidialog.cpp
@@ -189,10 +189,14 @@
     for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it ) {
         if( pageIndex( ( TQWidget * )( *it ).kcm->parent() ) == curPageIndex )
         {
-            docPath = ( *it ).kcm->moduleInfo().docPath();
-            TDECModuleProxy * m = ( *it ).kcm;
+            TDECModuleProxy *m = (*it).kcm;
+            
+            docPath = m->handbookDocPath();
+            if (docPath == TQString::null)
+              docPath = m->moduleInfo().docPath();
+                        
             TQString section = m->handbookSection();
-            if (section != "") {
+            if (section != TQString::null) {
                 docPath = TQString( "%1#%2" ).arg( docPath ).arg( section );
             }
             break;
diff --git a/tdeutils/tdecmoduleproxy.cpp b/tdeutils/tdecmoduleproxy.cpp
index 75da38e..d074b8c 100644
--- a/tdeutils/tdecmoduleproxy.cpp
+++ b/tdeutils/tdecmoduleproxy.cpp
@@ -598,6 +598,18 @@
 	}
 }
 
+TQString TDECModuleProxy::handbookDocPath() const
+{
+	if( !d->rootMode ) {
+		return realModule() ? realModule()->handbookDocPath() : TQString::null;
+	}
+	else {
+	/* This needs fixing, perhaps cache a handbookSection() copy
+	 * while in root mode? */
+		return TQString::null;
+	}
+}
+
 TQString TDECModuleProxy::handbookSection() const
 {
 	if( !d->rootMode ) {
diff --git a/tdeutils/tdecmoduleproxy.h b/tdeutils/tdecmoduleproxy.h
index 3d2b1ca..f5b5701 100644
--- a/tdeutils/tdecmoduleproxy.h
+++ b/tdeutils/tdecmoduleproxy.h
@@ -158,6 +158,11 @@
 	const TDEAboutData * aboutData() const;
 
 	/**
+	 * @return the module's handbookDocPath()
+	 */
+	TQString handbookDocPath() const;
+
+	/**
 	 * @return the module's handbookSection()
 	 */
 	TQString handbookSection() const;
777f25f2 2014-11-26 20:52:10 Michele Calgaro
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tdelibs
M tdecore/tdehw/tdehardwaredevices.cpp
M tdecore/tdehw/tdestoragedevice.cpp
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp
index 8905b60..fd8ee3b 100644
--- a/tdecore/tdehw/tdehardwaredevices.cpp
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -402,8 +402,8 @@
 			TDEGenericDevice *hwdevice;
 			for (hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next()) {
 				if (hwdevice->systemPath() == systempath) {
-					emit hardwareRemoved(hwdevice);
-					emit hardwareEvent(TDEHardwareEvent::HardwareRemoved, hwdevice->uniqueID());
+					// Temporarily disable auto-deletion to ensure object validity when calling the Removed events below
+					m_deviceList.setAutoDelete(false);
 
 					// If the device is a storage device and has a slave, update it as well
 					if (hwdevice->type() == TDEGenericDeviceType::Disk) {
@@ -423,6 +423,13 @@
 						m_deviceList.remove(hwdevice);
 					}
 
+					emit hardwareRemoved(hwdevice);
+					emit hardwareEvent(TDEHardwareEvent::HardwareRemoved, hwdevice->uniqueID());
+
+					// Reenable auto-deletion and delete the removed device object
+					m_deviceList.setAutoDelete(true);
+					delete hwdevice;
+
 					break;
 				}
 			}
diff --git a/tdecore/tdehw/tdestoragedevice.cpp b/tdecore/tdehw/tdestoragedevice.cpp
index 9491a66..70258e4 100644
--- a/tdecore/tdehw/tdestoragedevice.cpp
+++ b/tdecore/tdehw/tdestoragedevice.cpp
@@ -25,6 +25,7 @@
 #include <sys/ioctl.h>
 #include <linux/cdrom.h>
 
+#include <tqregexp.h>
 #include <tqpixmap.h>
 #include <tqfile.h>
 
@@ -489,13 +490,26 @@
 	m_slaveDevices = sd;
 }
 
+TQString decodeHexEncoding(TQString str) {
+	TQRegExp hexEncRegExp("\\\\x[0-9A-Fa-f]{1,2}");
+	hexEncRegExp.setMinimal(false);
+	hexEncRegExp.setCaseSensitive(true);
+	int s = -1;
+
+	while((s = hexEncRegExp.search(str, s+1))>=0){
+		str.replace(s, hexEncRegExp.cap(0).length(), TQChar((char)strtol(hexEncRegExp.cap(0).mid(2).ascii(), NULL, 16)));
+	}
+
+	return str;
+}
+
 TQString TDEStorageDevice::friendlyName() {
 	// Return the actual storage device name
 	TQString devicevendorid = vendorEncoded();
 	TQString devicemodelid = modelEncoded();
 
-	devicevendorid.replace("\\x20", " ");
-	devicemodelid.replace("\\x20", " ");
+	devicevendorid = decodeHexEncoding(devicevendorid);
+	devicemodelid = decodeHexEncoding(devicemodelid);
 
 	devicevendorid = devicevendorid.stripWhiteSpace();
 	devicemodelid = devicemodelid.stripWhiteSpace();
@@ -637,7 +651,7 @@
 		ret = DesktopIcon("tape_unmount", size);
 	}
 	if (isDiskOfType(TDEDiskDeviceType::Camera)) {
-		ret = DesktopIcon("camera_unmount");
+		ret = DesktopIcon("camera_unmount", size);
 	}
 
 	if (isDiskOfType(TDEDiskDeviceType::HDD)) {