Fix sorting of plugin scores in the QT plugin dialog.
authorDylan Yudaken <dyudaken@gmail.com>
Mon, 19 Oct 2009 22:04:54 +0000 (00:04 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 21 Oct 2009 21:14:48 +0000 (23:14 +0200)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/gui/qt4/dialogs/plugins.cpp
modules/gui/qt4/dialogs/plugins.hpp

index 9ab3e36..e071c18 100644 (file)
@@ -106,7 +106,7 @@ inline void PluginDialog::FillTree()
         if( qs_item.at(1).isEmpty() ) continue;
 #endif
 
         if( qs_item.at(1).isEmpty() ) continue;
 #endif
 
-        QTreeWidgetItem *item = new QTreeWidgetItem( qs_item );
+        QTreeWidgetItem *item = new PluginTreeItem( qs_item );
         treePlugins->addTopLevelItem( item );
     }
 }
         treePlugins->addTopLevelItem( item );
     }
 }
@@ -131,3 +131,10 @@ PluginDialog::~PluginDialog()
                              treePlugins->header()->saveState() );
 }
 
                              treePlugins->header()->saveState() );
 }
 
+bool PluginTreeItem::operator< ( const QTreeWidgetItem & other ) const
+{
+    int col = treeWidget()->sortColumn();
+    if( col == 2 )
+        return text( col ).toInt() < other.text( col ).toInt();
+    return text( col ) < other.text( col );
+}
index 1a243a8..1245e9c 100644 (file)
@@ -25,6 +25,8 @@
 #define QVLC_PLUGIN_DIALOG_H_ 1
 
 #include "util/qvlcframe.hpp"
 #define QVLC_PLUGIN_DIALOG_H_ 1
 
 #include "util/qvlcframe.hpp"
+#include <QTreeWidget>
+#include <QStringList>
 
 class QTreeWidget;
 class QLineEdit;
 
 class QTreeWidget;
 class QLineEdit;
@@ -57,5 +59,13 @@ private slots:
     void search( const QString& );
 };
 
     void search( const QString& );
 };
 
+class PluginTreeItem : public QTreeWidgetItem
+{
+public:
+    PluginTreeItem(QStringList &qs_item, int Type = QTreeWidgetItem::Type) : QTreeWidgetItem (qs_item, Type)
+    { }
+    virtual bool operator< ( const QTreeWidgetItem & other ) const;
+};
+
 #endif
 
 #endif