Branch: master

54578ce0 2014-10-02 08:41:28 Timothy Pearson
Add mimeTypePtrFast method to KFileItem
This relates to Bug 699
Clean up a couple of minor build warnings
Classify usbmisc devices
M tdecore/tdehw/tdehardwaredevices.cpp
M tdeio/tdefile/tdefiledetailview.cpp
M tdeio/tdefile/tdefileiconview.cpp
M tdeio/tdeio/tdefileitem.cpp
M tdeio/tdeio/tdefileitem.h
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp
index 194bf6c..3ae7479 100644
--- a/tdecore/tdehw/tdehardwaredevices.cpp
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -2243,6 +2243,7 @@
 		// Last ditch attempt at classification
 		// Likely inaccurate and sweeping
 		if ((devicesubsystem == "usb")
+			|| (devicesubsystem == "usbmisc")
 			|| (devicesubsystem == "usb_device")
 			|| (devicesubsystem == "usbmon")) {
 				// Get USB interface class for further classification
diff --git a/tdeio/tdefile/tdefiledetailview.cpp b/tdeio/tdefile/tdefiledetailview.cpp
index e267bdb..2f7166e 100644
--- a/tdeio/tdefile/tdefiledetailview.cpp
+++ b/tdeio/tdefile/tdefiledetailview.cpp
@@ -360,13 +360,13 @@
 
     switch( col ) {
         case COL_NAME:
-            sortSpec = (sort & ~TQDir::SortByMask | TQDir::Name);
+            sortSpec = ((sort & ~TQDir::SortByMask) | TQDir::Name);
             break;
         case COL_SIZE:
-            sortSpec = (sort & ~TQDir::SortByMask | TQDir::Size);
+            sortSpec = ((sort & ~TQDir::SortByMask) | TQDir::Size);
             break;
         case COL_DATE:
-            sortSpec = (sort & ~TQDir::SortByMask | TQDir::Time);
+            sortSpec = ((sort & ~TQDir::SortByMask) | TQDir::Time);
             break;
 
         // the following columns have no equivalent in TQDir, so we set it
diff --git a/tdeio/tdefile/tdefileiconview.cpp b/tdeio/tdefile/tdefileiconview.cpp
index 92bbeba..d4be8a5 100644
--- a/tdeio/tdefile/tdefileiconview.cpp
+++ b/tdeio/tdefile/tdefileiconview.cpp
@@ -611,7 +611,7 @@
 void KFileIconView::gotPreview( const KFileItem *item, const TQPixmap& pix )
 {
     KFileIconViewItem *it = viewItem( item );
-    if ( it )
+    if ( it ) {
         if( item->overlays() & TDEIcon::HiddenOverlay )
         {
             TQPixmap p( pix );
@@ -619,8 +619,10 @@
             TDEIconEffect::semiTransparent( p );
             it->setPixmap( p );
         }
-        else
+        else {
             it->setPixmap( pix );
+        }
+    }
 }
 
 bool KFileIconView::canPreview( const KFileItem *item ) const
diff --git a/tdeio/tdeio/tdefileitem.cpp b/tdeio/tdeio/tdefileitem.cpp
index 98013f1..8ef5072 100644
--- a/tdeio/tdeio/tdefileitem.cpp
+++ b/tdeio/tdeio/tdefileitem.cpp
@@ -556,27 +556,32 @@
 
 TQString KFileItem::mimetypeFast() const
 {
-  if (isMimeTypeKnown()) {
-    return mimetype();
-  }
-  else {
-    return m_pMimeType->name();
-  }
+	if (isMimeTypeKnown()) {
+		return mimetype();
+	}
+	else {
+		return m_pMimeType->name();
+	}
+}
+
+KMimeType::Ptr KFileItem::mimeTypePtrFast()
+{
+	return m_pMimeType;
 }
 
 KMimeType::Ptr KFileItem::determineMimeType()
 {
-  if ( !m_pMimeType || !m_bMimeTypeKnown )
-  {
-    bool isLocalURL;
-    KURL url = mostLocalURL(isLocalURL);
+	if ( !m_pMimeType || !m_bMimeTypeKnown )
+	{
+		bool isLocalURL;
+		KURL url = mostLocalURL(isLocalURL);
 
-    m_pMimeType = KMimeType::findByURL( url, m_fileMode, isLocalURL );
-    //kdDebug() << "finding mimetype for " << url.url() << " : " << m_pMimeType->name() << endl;
-    m_bMimeTypeKnown = true;
-  }
+		m_pMimeType = KMimeType::findByURL( url, m_fileMode, isLocalURL );
+		//kdDebug() << "finding mimetype for " << url.url() << " : " << m_pMimeType->name() << endl;
+		m_bMimeTypeKnown = true;
+	}
 
-  return m_pMimeType;
+	return m_pMimeType;
 }
 
 bool KFileItem::isMimeTypeKnown() const
diff --git a/tdeio/tdeio/tdefileitem.h b/tdeio/tdeio/tdefileitem.h
index b6c1b0b..b0dd9b4 100644
--- a/tdeio/tdeio/tdefileitem.h
+++ b/tdeio/tdeio/tdefileitem.h
@@ -336,6 +336,14 @@
 
   /**
    * Returns the mimetype of the file item.
+   * If @p _determineMimeTypeOnDemand was used in the constructor, this will return
+   * the mimetype as fast as possible at the expense of accuracy.
+   * @return the fast mime type
+   */
+  KMimeType::Ptr mimeTypePtrFast();
+
+  /**
+   * Returns the mimetype of the file item.
    * If _determineMimeTypeOnDemand was used in the constructor, this will determine
    * the mimetype first.
    * @return the mime type