[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/amarok/src/playlist
From:       Teo Mrnjavac <teo.mrnjavac () gmail ! com>
Date:       2009-07-02 1:19:16
Message-ID: 1246497556.183330.18473.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 990222 by mrnjavac:

As SortScheme (m_scheme) wraps thinly around a QStack<> * which works on the heap \
anyway, no need to allocate the m_scheme itself on the heap. Also, fix crash when \
sorting on an empty SortScheme.

 M  +7 -4      PlaylistSortWidget.cpp  
 M  +2 -0      PlaylistSortWidget.h  
 M  +4 -4      proxymodels/SortAlgorithms.cpp  
 M  +2 -2      proxymodels/SortAlgorithms.h  
 M  +1 -1      proxymodels/SortProxy.cpp  
 M  +1 -1      proxymodels/SortProxy.h  


--- trunk/extragear/multimedia/amarok/src/playlist/PlaylistSortWidget.cpp \
#990221:990222 @@ -18,7 +18,6 @@
 
 #include "Debug.h"
 
-#include <KPushButton>
 
 namespace Playlist
 {
@@ -53,12 +52,13 @@
     btnPopLevel->resize( btnPopLevel->height(), btnPopLevel->height() );
 
     mainLayout->addStretch();
-    KPushButton *btnSort = new KPushButton( "Just sort it!", this );
-    mainLayout->addWidget( btnSort );
+    m_btnSort = new KPushButton( "Just sort it!", this );
+    mainLayout->addWidget( m_btnSort );
+    m_btnSort->setEnabled( false );
 
     connect(btnPushLevel, SIGNAL( clicked() ), this, SLOT( pushLevel() ) );
     connect(btnPopLevel, SIGNAL( clicked() ), this, SLOT( popLevel() ) );
-    connect(btnSort, SIGNAL( clicked() ), this, SLOT( applySortingScheme() ) );
+    connect(m_btnSort, SIGNAL( clicked() ), this, SLOT( applySortingScheme() ) );
 }
 
 void
@@ -79,6 +79,7 @@
     m_comboList.append( new KComboBox( this ) );
     m_comboLayout->addWidget( m_comboList.back() );
     m_comboList.back()->addItems( m_sortableCategories );
+    m_btnSort->setEnabled( true );
 }
 
 void
@@ -88,6 +89,8 @@
     {
         m_comboLayout->removeWidget( m_comboList.back() );
         delete m_comboList.takeLast();
+        if( m_comboList.isEmpty() )
+            m_btnSort->setEnabled( false );
     }
 }
 
--- trunk/extragear/multimedia/amarok/src/playlist/PlaylistSortWidget.h \
#990221:990222 @@ -20,6 +20,7 @@
 #include "playlist/proxymodels/SortProxy.h"
 
 #include <KComboBox>
+#include <KPushButton>
 
 #include <QHBoxLayout>
 
@@ -44,6 +45,7 @@
         QHBoxLayout *m_comboLayout;
         QList< KComboBox * > m_comboList;
         QStringList m_sortableCategories;
+        KPushButton *m_btnSort;
 };
 
 }   //namespace Playlist
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/SortAlgorithms.cpp \
#990221:990222 @@ -25,12 +25,12 @@
 multilevelLessThan::operator()( int rowA, int rowB)
 {
     quint8 verdict;  //0 = false  1 = true  2 = nextIteration
-    for( int i = 0; i < m_scheme->length(); i++ )
+    for( int i = 0; i < m_scheme.length(); i++ )
     {
-        int currentCategory = m_scheme->level( i ).category();  //see enum Column in \
PlaylistDefines.h +        int currentCategory = m_scheme.level( i ).category();  \
                //see enum Column in PlaylistDefines.h
         QVariant dataA = m_sourceProxy->index( rowA, currentCategory ).data();  \
                //FIXME: are you sure you need to do comparisons on sourceProxy \
                indexes?
         QVariant dataB = m_sourceProxy->index( rowB, currentCategory ).data();  //or \
                better, are you sure those rowA and rowB don't need a rowToSource \
                around them?
-        if( m_scheme->level( i ).isString() )
+        if( m_scheme.level( i ).isString() )
         {
             if( dataA.toString() < dataB.toString() )
                 verdict = 1;
@@ -50,7 +50,7 @@
         }
         if( verdict != 2 )
         {
-            if( m_scheme->level( i ).order() == Qt::AscendingOrder )
+            if( m_scheme.level( i ).order() == Qt::AscendingOrder )
                 verdict = verdict ? 0 : 1;
             break;
         }
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/SortAlgorithms.h \
#990221:990222 @@ -38,7 +38,7 @@
      * @param sourceProxy a pointer to the FilteProxy instance.
      * @param scheme the sorting scheme that needs to be applied.
      */
-    multilevelLessThan( QAbstractItemModel *sourceProxy, SortScheme *scheme )
+    multilevelLessThan( QAbstractItemModel *sourceProxy, const SortScheme &scheme )
         : m_sourceProxy( sourceProxy )
         , m_scheme( scheme )
     {}
@@ -54,7 +54,7 @@
 
     private:
         QAbstractItemModel *m_sourceProxy;     //! The proxy or model which holds \
                the rows that need to be sorted.
-        SortScheme *m_scheme;           //! The current sorting scheme.
+        SortScheme m_scheme;           //! The current sorting scheme.
 };
 
 }   //namespace Playlist
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/SortProxy.cpp \
#990221:990222 @@ -70,7 +70,7 @@
 SortProxy::updateSortMap( SortScheme scheme)
 {
     emit layoutAboutToBeChanged();  //NOTE to self: do I need this or sort() takes \
                care of it?
-    *m_scheme = scheme;
+    m_scheme = scheme;
     sort( 0 );  //0 is a dummy column
     emit layoutChanged();
 }
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/SortProxy.h \
#990221:990222 @@ -88,7 +88,7 @@
 
     static SortProxy *s_instance;       //! Instance member.
 
-    SortScheme *m_scheme;               //! The current sorting scheme.
+    SortScheme m_scheme;               //! The current sorting scheme.
 };
 
 }   //namespace Playlist


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic