[Uml-devel] kdesdk/umbrello/umbrello

Carsten Pfeiffer carpdjih at mailbox.tu-berlin.de
Sun Apr 27 13:48:05 UTC 2003


CVS commit by pfeiffer: 

sort the listview items by type, so that diagrams are grouped together
and not mixed with e.g. classes


  M +17 -1     umllistviewitem.cpp   1.15
  M +6 -1      umllistviewitem.h   1.3


--- kdesdk/umbrello/umbrello/umllistviewitem.cpp  #1.14:1.15
@@ -73,5 +73,5 @@ UMLListViewItem::UMLListViewItem(UMLList
 UMLListViewItem::~UMLListViewItem() {}
 ////////////////////////////////////////////////////////////////////////////////////////////////////
-Uml::ListView_Type UMLListViewItem::getType() {
+Uml::ListView_Type UMLListViewItem::getType() const {
         return m_Data.getType();
 }
@@ -327,3 +327,19 @@ void UMLListViewItem::cancelRename(int c
 }
 
+// sort the listview items by type and alphabetically
+int UMLListViewItem::compare(QListViewItem *other, int col, bool ascending) const
+{
+        Uml::ListView_Type ourType = getType();
+        Uml::ListView_Type otherType = static_cast<UMLListViewItem*>( other )->getType();
+
+        if ( ourType == otherType )
+                return key( col, ascending ).compare( other->key( col, ascending) );
+
+        if ( ourType < otherType )
+                return -1;
+        if ( ourType > otherType )
+                return 1;
+
+        return 0;       
+}
 UMLListView* UMLListViewItem::s_pListView = 0;

--- kdesdk/umbrello/umbrello/umllistviewitem.h  #1.2:1.3
@@ -70,5 +70,5 @@ public:
          *      @return The type this instance represents.
          */
-        Uml::ListView_Type getType();
+        Uml::ListView_Type getType() const;
 
         /**
@@ -130,4 +130,9 @@ public:
          */
         void cancelRename( int col );
+
+        /**
+         *      Overrides the default sorting to sort by item type.
+         */
+        virtual int compare(QListViewItem *other, int col, bool ascending) const;
 
 protected:






More information about the umbrello-devel mailing list