Commit 992cf22c authored by Jakob Leben's avatar Jakob Leben

Qt: cleanups and organization

parent dee8d5f4
...@@ -51,9 +51,6 @@ QIcon PLModel::icons[ITEM_TYPE_NUMBER]; ...@@ -51,9 +51,6 @@ QIcon PLModel::icons[ITEM_TYPE_NUMBER];
* Playlist model implementation * Playlist model implementation
*************************************************************************/ *************************************************************************/
/*
This model is called two times, for the selector and the standard panel
*/
PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
intf_thread_t *_p_intf, /* main Qt p_intf */ intf_thread_t *_p_intf, /* main Qt p_intf */
playlist_item_t * p_root, playlist_item_t * p_root,
...@@ -81,7 +78,7 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */ ...@@ -81,7 +78,7 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
ADD_ICON( NODE, ":/type/node" ); ADD_ICON( NODE, ":/type/node" );
#undef ADD_ICON #undef ADD_ICON
rebuild( p_root, true ); rebuild( p_root );
CONNECT( THEMIM->getIM(), metaChanged( input_item_t *), CONNECT( THEMIM->getIM(), metaChanged( input_item_t *),
this, processInputItemUpdate( input_item_t *) ); this, processInputItemUpdate( input_item_t *) );
CONNECT( THEMIM, inputChanged( input_thread_t * ), CONNECT( THEMIM, inputChanged( input_thread_t * ),
...@@ -640,10 +637,10 @@ end: ...@@ -640,10 +637,10 @@ end:
void PLModel::rebuild() 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; playlist_item_t* p_item;
......
...@@ -97,7 +97,8 @@ public: ...@@ -97,7 +97,8 @@ public:
void search( const QString& search_text ); void search( const QString& search_text );
void sort( int column, Qt::SortOrder order ); void sort( int column, Qt::SortOrder order );
void sort( int i_root_id, 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 inline PLItem *getItem( QModelIndex index ) const
{ {
...@@ -106,30 +107,38 @@ public: ...@@ -106,30 +107,38 @@ public:
else return rootItem; 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 */ /* General */
PLItem *rootItem; PLItem *rootItem;
playlist_t *p_playlist; playlist_t *p_playlist;
intf_thread_t *p_intf; intf_thread_t *p_intf;
int i_depth;
static QIcon icons[ITEM_TYPE_NUMBER]; static QIcon icons[ITEM_TYPE_NUMBER];
/* Actions */ /* Shallow actions (do not affect core playlist) */
void recurseDelete( QList<PLItem*> children, QModelIndexList *fullList );
void updateTreeItem( PLItem * ); void updateTreeItem( PLItem * );
void removeItem ( PLItem * ); void removeItem ( PLItem * );
void removeItem( int ); void removeItem( int );
void recurseDelete( QList<PLItem*> children, QModelIndexList *fullList );
void takeItem( PLItem * ); //will not delete item void takeItem( PLItem * ); //will not delete item
void insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos ); void insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos );
void dropAppendCopy( QByteArray& data, PLItem *target ); /* ...of which the following will not update the views */
void dropMove( QByteArray& data, PLItem *target, int new_pos );
/* The following actions will not signal the view! */
void updateChildren( PLItem * ); void updateChildren( PLItem * );
void updateChildren( playlist_item_t *, 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 */ /* Popup */
int i_popup_item, i_popup_parent, i_popup_column; int i_popup_item, i_popup_parent, i_popup_column;
QModelIndexList current_selection; QModelIndexList current_selection;
...@@ -138,23 +147,15 @@ private: ...@@ -138,23 +147,15 @@ private:
PLItem *findById( PLItem *, int ); PLItem *findById( PLItem *, int );
PLItem *findByInput( PLItem *, int ); PLItem *findByInput( PLItem *, int );
PLItem *findInner( PLItem *, int , bool ); PLItem *findInner( PLItem *, int , bool );
int columnFromMeta( int meta_column ) const; int columnFromMeta( int meta_column ) const;
int columnToMeta( int column ) const; int columnToMeta( int column ) const;
bool canEdit() const; bool canEdit() const;
PLItem *p_cached_item; PLItem *p_cached_item;
PLItem *p_cached_item_bi; PLItem *p_cached_item_bi;
int i_cached_id; int i_cached_id;
int i_cached_input_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: private slots:
void popupPlay(); void popupPlay();
void popupDel(); void popupDel();
......
...@@ -460,7 +460,6 @@ void PLSelector::podcastAdd( PLSelItem* item ) ...@@ -460,7 +460,6 @@ void PLSelector::podcastAdd( PLSelItem* item )
void PLSelector::podcastRemove( 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?" ) ); QString question ( qtr( "Do you really want to unsubscribe from %1?" ) );
question = question.arg( item->text() ); question = question.arg( item->text() );
QMessageBox::StandardButton res = QMessageBox::StandardButton res =
...@@ -495,9 +494,6 @@ void PLSelector::drawBranches ( QPainter * painter, const QRect & rect, const QM ...@@ -495,9 +494,6 @@ void PLSelector::drawBranches ( QPainter * painter, const QRect & rect, const QM
QStyleOption option; QStyleOption option;
option.initFrom( this ); option.initFrom( this );
option.rect = rect.adjusted( rect.width() - indentation(), 0, 0, 0 ); 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 ) ? style()->drawPrimitive( isExpanded( index ) ?
QStyle::PE_IndicatorArrowDown : QStyle::PE_IndicatorArrowDown :
QStyle::PE_IndicatorArrowRight, &option, painter ); QStyle::PE_IndicatorArrowRight, &option, painter );
......
...@@ -69,14 +69,6 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -69,14 +69,6 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
currentRootId = -1; currentRootId = -1;
last_activated_id = -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 ); locationBar = new LocationBar( model );
layout->addWidget( locationBar, 0, 0 ); layout->addWidget( locationBar, 0, 0 );
CONNECT( model, rootChanged(), locationBar, setRootIndex() ); CONNECT( model, rootChanged(), locationBar, setRootIndex() );
...@@ -405,7 +397,6 @@ void StandardPLPanel::activate( const QModelIndex &index ) ...@@ -405,7 +397,6 @@ void StandardPLPanel::activate( const QModelIndex &index )
{ {
if( currentView == iconView ) { if( currentView == iconView ) {
iconView->setRootIndex( index ); iconView->setRootIndex( index );
//title->setText( index.data().toString() );
locationBar->setIndex( index ); locationBar->setIndex( index );
} }
} }
...@@ -414,7 +405,7 @@ void StandardPLPanel::activate( const QModelIndex &index ) ...@@ -414,7 +405,7 @@ void StandardPLPanel::activate( const QModelIndex &index )
playlist_Lock( THEPL ); playlist_Lock( THEPL );
playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index ) ); playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index ) );
p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG; 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 ); playlist_Unlock( THEPL );
model->activateItem( index ); model->activateItem( index );
} }
...@@ -517,11 +508,7 @@ void LocationButton::paintEvent ( QPaintEvent * event ) ...@@ -517,11 +508,7 @@ void LocationButton::paintEvent ( QPaintEvent * event )
{ {
QStyleOptionButton option; QStyleOptionButton option;
option.initFrom( this ); option.initFrom( this );
//option.rect = rect();
//option.features = QStyleOptionButton::Flat;
option.state |= QStyle::State_Enabled; option.state |= QStyle::State_Enabled;
//option.state |= isChecked() ? QStyle::State_On : QStyle::State_Off;
//if( isDown() ) option.state |= QStyle::State_Sunken;
QPainter p( this ); QPainter p( this );
if( underMouse() ) if( underMouse() )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment