[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-01 21:53:37
Message-ID: 1246485217.785969.29904.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 990168 by mrnjavac:

A new temporary testing GUI for playlist sorting.

 M  +53 -13    PlaylistSortWidget.cpp  
 M  +9 -4      PlaylistSortWidget.h  
 M  +2 -2      proxymodels/SortProxy.cpp  
 M  +1 -1      proxymodels/SortProxy.h  


--- trunk/extragear/multimedia/amarok/src/playlist/PlaylistSortWidget.cpp \
#990167:990168 @@ -23,23 +23,41 @@
 namespace Playlist
 {
 
-SortWidget::SortWidget( QWidget *parent ) : KHBox( parent )
+SortWidget::SortWidget( QWidget *parent ) : QWidget( parent )
 {
     DEBUG_BLOCK
-    m_sortCombo = new KComboBox( this );
-    KPushButton *btnSort = new KPushButton( "Just sort it!", this );
+    QHBoxLayout *mainLayout = new QHBoxLayout( this );
+    setLayout( mainLayout );
+    m_comboLayout = new QHBoxLayout( this );
+    mainLayout->addLayout( m_comboLayout );
+    m_sortableCategories.append( internalColumnNames );
+    for( QStringList::iterator i = m_sortableCategories.begin(); \
i!=m_sortableCategories.end(); ) +    {
+        if( *i == QString( "Placeholder" ) || *i == QString( "Bpm" )
+            || *i == QString( "Cover image" ) || *i == QString( "Divider" )
+            || *i == QString( "Last played" ) || *i == QString( "Mood" )
+            || *i == QString( "Source" ) || *i == QString( "SourceEmblem" )
+            || *i == QString( "Title (with track number)" ) || *i == QString( "Type" \
) ) +            i = m_sortableCategories.erase( i );
+        else
+            ++i;
+    }
 
-    m_sortCombo->addItem( "ArtistA/AlbumD/TrackD" );
-    m_schemeList.append( new SortScheme() );
-    m_schemeList.last()->addLevel( SortLevel( Artist, Qt::AscendingOrder ) );
-    m_schemeList.last()->addLevel( SortLevel( Album, Qt::DescendingOrder ) );
-    m_schemeList.last()->addLevel( SortLevel( TrackNumber, Qt::DescendingOrder ) );
+    KPushButton *btnPushLevel = new KPushButton( KIcon( "list-add" ), "", this );
+    mainLayout->addWidget( btnPushLevel );
+    btnPushLevel->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
+    btnPushLevel->resize( btnPushLevel->height(), btnPushLevel->height() );
+    KPushButton *btnPopLevel = new KPushButton( KIcon( "edit-delete" ), "", this );
+    mainLayout->addWidget( btnPopLevel );
+    btnPopLevel->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
+    btnPopLevel->resize( btnPopLevel->height(), btnPopLevel->height() );
 
-    m_sortCombo->addItem( "ArtistD/TitleA" );
-    m_schemeList.append( new SortScheme() );
-    m_schemeList.last()->addLevel( SortLevel( Artist, Qt::DescendingOrder ) );
-    m_schemeList.last()->addLevel( SortLevel( Title, Qt::AscendingOrder ) );
+    mainLayout->addStretch();
+    KPushButton *btnSort = new KPushButton( "Just sort it!", this );
+    mainLayout->addWidget( btnSort );
 
+    connect(btnPushLevel, SIGNAL( clicked() ), this, SLOT( pushLevel() ) );
+    connect(btnPopLevel, SIGNAL( clicked() ), this, SLOT( popLevel() ) );
     connect(btnSort, SIGNAL( clicked() ), this, SLOT( applySortingScheme() ) );
 }
 
@@ -47,8 +65,30 @@
 SortWidget::applySortingScheme()
 {
     DEBUG_BLOCK
-    SortProxy::instance()->updateSortMap( m_schemeList[ m_sortCombo->currentIndex() \
]  ); +    SortScheme scheme = SortScheme();
+    for( QList< KComboBox * >::const_iterator i = m_comboList.begin(); \
i!=m_comboList.end(); ++i ) +    {
+        scheme.addLevel( SortLevel( internalColumnNames.indexOf( (*i)->currentText() \
), Qt::DescendingOrder ) ); +    }
+    SortProxy::instance()->updateSortMap( scheme );
 }
 
+void
+SortWidget::pushLevel()
+{
+    m_comboList.append( new KComboBox( this ) );
+    m_comboLayout->addWidget( m_comboList.back() );
+    m_comboList.back()->addItems( m_sortableCategories );
+}
 
+void
+SortWidget::popLevel()
+{
+    if( !m_comboList.isEmpty() )
+    {
+        m_comboLayout->removeWidget( m_comboList.back() );
+        delete m_comboList.takeLast();
+    }
+}
+
 }   //namespace Playlist
--- trunk/extragear/multimedia/amarok/src/playlist/PlaylistSortWidget.h \
#990167:990168 @@ -20,25 +20,30 @@
 #include "playlist/proxymodels/SortProxy.h"
 
 #include <KComboBox>
-#include <KHBox>
 
+#include <QHBoxLayout>
+
 namespace Playlist
 {
 /**
  * A ribbon interface that allows the user to define multiple sorting levels for the \
                playlist.
  * @author To Mrnjavac <teo.mrnjavac@gmail.com>
  */
-class SortWidget : public KHBox
+class SortWidget : public QWidget
 {
     Q_OBJECT
     public:
         SortWidget( QWidget* parent = 0 );
+    public slots:
+        void pushLevel();
+        void popLevel();
 
     private slots:
         void applySortingScheme();
     private:
-        KComboBox* m_sortCombo;
-        QList< SortScheme *> m_schemeList;
+        QHBoxLayout *m_comboLayout;
+        QList< KComboBox * > m_comboList;
+        QStringList m_sortableCategories;
 };
 
 }   //namespace Playlist
--- trunk/extragear/multimedia/amarok/src/playlist/proxymodels/SortProxy.cpp \
#990167:990168 @@ -67,10 +67,10 @@
 }
 
 void
-SortProxy::updateSortMap( SortScheme *scheme)
+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 \
#990167:990168 @@ -73,7 +73,7 @@
      * Applies a sorting scheme to the playlist.
      * @param scheme the sorting scheme that will be applied.
      */
-    void updateSortMap( SortScheme *scheme );
+    void updateSortMap( SortScheme scheme );
 
 private:
     /**


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

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