]> git.sesse.net Git - vlc/commitdiff
Qt: cleanups and organization
authorJakob Leben <jleben@videolan.org>
Wed, 10 Feb 2010 10:07:12 +0000 (11:07 +0100)
committerJakob Leben <jleben@videolan.org>
Wed, 10 Feb 2010 10:07:40 +0000 (11:07 +0100)
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.hpp
modules/gui/qt4/components/playlist/selector.cpp
modules/gui/qt4/components/playlist/standardpanel.cpp

index 742c58cc9388d3b65efdce263adf7fad183652af..ec72f89b0a608a6365ccc30ef0f9b7b031c405e7 100644 (file)
@@ -51,9 +51,6 @@ QIcon PLModel::icons[ITEM_TYPE_NUMBER];
  * Playlist model implementation
  *************************************************************************/
 
-/*
-  This model is called two times, for the selector and the standard panel
-*/
 PLModel::PLModel( playlist_t *_p_playlist,  /* THEPL */
                   intf_thread_t *_p_intf,   /* main Qt p_intf */
                   playlist_item_t * p_root,
@@ -81,7 +78,7 @@ PLModel::PLModel( playlist_t *_p_playlist,  /* THEPL */
     ADD_ICON( NODE, ":/type/node" );
 #undef ADD_ICON
 
-    rebuild( p_root, true );
+    rebuild( p_root );
     CONNECT( THEMIM->getIM(), metaChanged( input_item_t *),
             this, processInputItemUpdate( input_item_t *) );
     CONNECT( THEMIM, inputChanged( input_thread_t * ),
@@ -640,10 +637,10 @@ end:
 
 void PLModel::rebuild()
 {
-    rebuild( NULL, false );
+    rebuild( NULL );
 }
 
-void PLModel::rebuild( playlist_item_t *p_root, bool b_first )
+void PLModel::rebuild( playlist_item_t *p_root )
 {
     playlist_item_t* p_item;
 
index 19f704b1e4ab345365820c832d30877c6cf54cff..5cc5c1259a32d6d86acedcee752ee84988afd732 100644 (file)
@@ -97,7 +97,8 @@ public:
     void search( const QString& search_text );
     void sort( int column, Qt::SortOrder order );
     void sort( int i_root_id, int column, Qt::SortOrder order );
-    void rebuild(); void rebuild( playlist_item_t *, bool b_first = false );
+    void rebuild();
+    void rebuild( playlist_item_t * );
 
     inline PLItem *getItem( QModelIndex index ) const
     {
@@ -106,30 +107,38 @@ public:
         else return rootItem;
     }
 
-private:
+signals:
+    void currentChanged( const QModelIndex& );
+    void rootChanged();
+
+public slots:
+    void activateItem( const QModelIndex &index );
+    void activateItem( playlist_item_t *p_item );
 
+private:
     /* General */
     PLItem *rootItem;
 
     playlist_t *p_playlist;
     intf_thread_t *p_intf;
-    int i_depth;
 
     static QIcon icons[ITEM_TYPE_NUMBER];
 
-    /* Actions */
-    void recurseDelete( QList<PLItem*> children, QModelIndexList *fullList );
+    /* Shallow actions (do not affect core playlist) */
     void updateTreeItem( PLItem * );
     void removeItem ( PLItem * );
     void removeItem( int );
+    void recurseDelete( QList<PLItem*> children, QModelIndexList *fullList );
     void takeItem( PLItem * ); //will not delete item
     void insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos );
-    void dropAppendCopy( QByteArray& data, PLItem *target );
-    void dropMove( QByteArray& data, PLItem *target, int new_pos );
-    /* The following actions will not signal the view! */
+    /* ...of which  the following will not update the views */
     void updateChildren( PLItem * );
     void updateChildren( playlist_item_t *, PLItem * );
 
+    /* Deep actions (affect core playlist) */
+    void dropAppendCopy( QByteArray& data, PLItem *target );
+    void dropMove( QByteArray& data, PLItem *target, int new_pos );
+
     /* Popup */
     int i_popup_item, i_popup_parent, i_popup_column;
     QModelIndexList current_selection;
@@ -138,23 +147,15 @@ private:
     PLItem *findById( PLItem *, int );
     PLItem *findByInput( PLItem *, int );
     PLItem *findInner( PLItem *, int , bool );
-
     int columnFromMeta( int meta_column ) const;
     int columnToMeta( int column ) const;
     bool canEdit() const;
+
     PLItem *p_cached_item;
     PLItem *p_cached_item_bi;
     int i_cached_id;
     int i_cached_input_id;
 
-signals:
-    void currentChanged( const QModelIndex& );
-    void rootChanged();
-
-public slots:
-    void activateItem( const QModelIndex &index );
-    void activateItem( playlist_item_t *p_item );
-
 private slots:
     void popupPlay();
     void popupDel();
index f0ce539b8c066b061867f95323d704b7dbeff699..30e93a0b901eefdbebcce2acdc5a8627ee50af19 100644 (file)
@@ -460,7 +460,6 @@ void PLSelector::podcastAdd( PLSelItem* item )
 
 void PLSelector::podcastRemove( PLSelItem* item )
 {
-    //FIXME will translators know to leave that %1 somewhere inside?
     QString question ( qtr( "Do you really want to unsubscribe from %1?" ) );
     question = question.arg( item->text() );
     QMessageBox::StandardButton res =
@@ -495,9 +494,6 @@ void PLSelector::drawBranches ( QPainter * painter, const QRect & rect, const QM
     QStyleOption option;
     option.initFrom( this );
     option.rect = rect.adjusted( rect.width() - indentation(), 0, 0, 0 );
-
-    /*option.state = QStyle::State_Children;
-    if( isExpanded( index ) ) option.state |=  QStyle::State_Open;*/
     style()->drawPrimitive( isExpanded( index ) ?
                             QStyle::PE_IndicatorArrowDown :
                             QStyle::PE_IndicatorArrowRight, &option, painter );
index 4401931cb157f7a1f18fd5eaed5f31a587b4053f..504b041e4da8c0fd84dd30312024a36412ffa98c 100644 (file)
@@ -69,14 +69,6 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     currentRootId = -1;
     last_activated_id = -1;
 
-    /* Title label */
-    /*title = new QLabel;
-    QFont titleFont;
-    titleFont.setPointSize( titleFont.pointSize() + 6 );
-    titleFont.setFamily( "Verdana" );
-    title->setFont( titleFont );
-    layout->addWidget( title, 0, 0 );*/
-
     locationBar = new LocationBar( model );
     layout->addWidget( locationBar, 0, 0 );
     CONNECT( model, rootChanged(), locationBar, setRootIndex() );
@@ -405,7 +397,6 @@ void StandardPLPanel::activate( const QModelIndex &index )
     {
         if( currentView == iconView ) {
             iconView->setRootIndex( index );
-            //title->setText( index.data().toString() );
             locationBar->setIndex( index );
         }
     }
@@ -414,7 +405,7 @@ void StandardPLPanel::activate( const QModelIndex &index )
         playlist_Lock( THEPL );
         playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index ) );
         p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
-        last_activated_id = p_item->p_input->i_id;//model->getItem( index )->inputItem()->i_id;
+        last_activated_id = p_item->p_input->i_id;
         playlist_Unlock( THEPL );
         model->activateItem( index );
     }
@@ -517,11 +508,7 @@ void LocationButton::paintEvent ( QPaintEvent * event )
 {
     QStyleOptionButton option;
     option.initFrom( this );
-    //option.rect = rect();
-    //option.features = QStyleOptionButton::Flat;
     option.state |= QStyle::State_Enabled;
-    //option.state |= isChecked() ? QStyle::State_On : QStyle::State_Off;
-    //if( isDown() ) option.state |= QStyle::State_Sunken;
     QPainter p( this );
 
     if( underMouse() )