1 /***************************************************************************
2 * copyright : (C) 2007 Ian Monroe <ian@monroe.nu> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License version 2 *
6 * as published by the Free Software Foundation. *
7 ***************************************************************************/
10 #include "MainWindow.h"
11 #include "PlaylistGraphicsView.h"
12 #include "PlaylistHeader.h"
13 #include "PlaylistModel.h"
14 //#include "PlaylistView.h"
15 #include "PlaylistWidget.h"
16 #include "TheInstances.h"
18 #include <QHBoxLayout>
20 #include <QStackedWidget>
27 using namespace Playlist
;
30 Widget::Widget( QWidget
* parent
)
34 QVBoxLayout
* layout
= new QVBoxLayout( this );
35 layout
->setContentsMargins(0,0,0,0);
37 QWidget
* layoutHolder
= new QWidget( this );
39 QVBoxLayout
* mainPlaylistlayout
= new QVBoxLayout( layoutHolder
);
40 mainPlaylistlayout
->setContentsMargins(0,0,0,0);
43 Playlist::HeaderWidget
* header
= new Playlist::HeaderWidget( layoutHolder
);
45 Playlist::Model
* playModel
= The::playlistModel();
47 playModel
->testData();
49 Playlist::GraphicsView
* playView
= The::playlistView();
50 playView
->setModel( playModel
);
52 QTreeView
* clasicalPlaylistView
= new QTreeView( this );
53 clasicalPlaylistView
->setRootIsDecorated( false );
54 clasicalPlaylistView
->setAlternatingRowColors ( true );
55 clasicalPlaylistView
->setSelectionMode( QAbstractItemView::ExtendedSelection
);
56 clasicalPlaylistView
->setModel( playModel
);
59 mainPlaylistlayout
->setSpacing( 0 );
60 mainPlaylistlayout
->addWidget( header
);
61 mainPlaylistlayout
->addWidget( playView
);
63 m_stackedWidget
= new QStackedWidget( this );
64 m_stackedWidget
->addWidget( layoutHolder
);
65 m_stackedWidget
->addWidget( clasicalPlaylistView
);
67 m_stackedWidget
->setCurrentIndex( 0 );
69 layout
->setSpacing( 0 );
70 layout
->addWidget( m_stackedWidget
);
72 KActionCollection
* const ac
= App::instance()->mainWindow()->actionCollection();
74 KAction
* action
= new KAction( KIcon( Amarok::icon( "download" ) ), i18nc( "switch view", "&View" ), this );
75 connect( action
, SIGNAL( triggered( bool ) ), this, SLOT( switchView() ) );
76 ac
->addAction( "playlist_switch", action
);
78 KToolBar
*plBar
= App::instance()->mainWindow()->findChild
<KToolBar
*> ( "PlaylistToolBar" );
81 plBar
->addSeparator();
82 plBar
->addAction( ac
->action( "playlist_switch") );
83 debug() << "PlaylistToolBar found! :-)";
86 debug() << "PlaylistToolBar not found";
90 void Widget::switchView()
92 m_stackedWidget
->setCurrentIndex( ( m_stackedWidget
->currentIndex() + 1 ) % 2 );
97 #include "PlaylistWidget.moc"