]> git.sesse.net Git - kdenlive/commitdiff
Make folders appear on top of the project tree:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 2 Nov 2009 14:27:53 +0000 (14:27 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 2 Nov 2009 14:27:53 +0000 (14:27 +0000)
http://kdenlive.org/mantis/view.php?id=945

svn path=/trunk/kdenlive/; revision=4088

src/folderprojectitem.cpp
src/folderprojectitem.h
src/projectitem.h
src/projectlistview.cpp
src/subprojectitem.h

index d1b1ce7fcc0b0bd9e0f8138f81ab044f27c70376..aa628c3105872f43470b183763c688546eceab5e 100644 (file)
@@ -19,7 +19,6 @@
 
 
 #include "folderprojectitem.h"
-#include "definitions.h"
 
 #include <KDebug>
 #include <KLocale>
index 2ed0631b9c813fa741db69f93e81afbc3217703e..ea9b5e6202f84e50006a906b446fec912689b0cc 100644 (file)
@@ -24,6 +24,9 @@
 #include <QTreeWidgetItem>
 #include <QTreeWidget>
 
+#include <KDebug>
+
+#include "definitions.h"
 
 /** \brief Represents a clip or a folder in the projecttree
  *
@@ -37,9 +40,18 @@ public:
     const QString groupName() const;
     void setGroupName(const QString name);
 
+    /** Make sure folders appear on top of the tree widget */
+    virtual bool operator<(const QTreeWidgetItem &other)const {
+       int column = treeWidget()->sortColumn();
+       if (other.type() == PROJECTFOLDERTYPE)
+         return text(column).toLower() < other.text(column).toLower();
+       else return true;
+    }
+
 private:
     QString m_groupName;
     QString m_clipId;
+
 };
 
 #endif
index 9817cd1fcfa2ffc994a26d7b3069764b62ac9281..0a8ab6e429f6410d98528ddd02a9e1410d21225d 100644 (file)
@@ -61,6 +61,13 @@ public:
     void clearProperty(const QString &key);
     QString getClipHash() const;
 
+    virtual bool operator<(const QTreeWidgetItem &other)const {
+       int column = treeWidget()->sortColumn();
+       if (other.type() != PROJECTFOLDERTYPE)
+         return text(column).toLower() < other.text(column).toLower();
+       else return false;
+    }
+
 private:
     CLIPTYPE m_clipType;
     QString m_clipId;
index 7ed3fa546b87dfa90c6b519650fa06b1ba093434..ce2f683322b2d4561d6dce6607dee2bf4b890d19 100644 (file)
@@ -43,23 +43,24 @@ ProjectListView::ProjectListView(QWidget *parent) :
     setDragEnabled(true);
     setAcceptDrops(true);
 
+
     setColumnCount(4);
     QStringList headers;
     headers << i18n("Thumbnail") << i18n("Filename") << i18n("Description") << i18n("Rating");
     setHeaderLabels(headers);
-    sortByColumn(1, Qt::AscendingOrder);
 
     QHeaderView* headerView = header();
     headerView->setContextMenuPolicy(Qt::CustomContextMenu);
     connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)),
             this, SLOT(configureColumns(const QPoint&)));
-
-    //connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(slotFocusOut(QTreeWidgetItem *, QTreeWidgetItem *)));
+    headerView->setClickable(true);
+    headerView->setSortIndicatorShown(true);
+    headerView->setMovable(false);
+    sortByColumn(1, Qt::AscendingOrder);
+    setSortingEnabled(true);
 
     if (!KdenliveSettings::showdescriptioncolumn()) hideColumn(2);
     if (!KdenliveSettings::showratingcolumn()) hideColumn(3);
-
-    setSortingEnabled(true);
 }
 
 ProjectListView::~ProjectListView()
index fc8e4a4fcc5a4a9496e32e288e342c81381c2bb2..e38846f58ef02a19e0fcb1ce91cf8d46c3685729 100644 (file)
@@ -45,6 +45,14 @@ public:
     DocClipBase *referencedClip();
     QPoint zone() const;
 
+    /** Make sure folders appear on top of the tree widget */
+    virtual bool operator<(const QTreeWidgetItem &other)const {
+       int column = treeWidget()->sortColumn();
+       if (other.type() != PROJECTFOLDERTYPE)
+         return text(column).toLower() < other.text(column).toLower();
+       else return false;
+    }
+
 private:
     int m_in;
     int m_out;