1 /***************************************************************************
5 copyright : (C) 2003 Scott Wheeler <wheeler@kde.org>
6 : (C) 2004 Max Howell <max.howell@methylblue.com>
7 : (C) 2004 Mark Kretschmann <markey@web.de>
8 ***************************************************************************/
10 /***************************************************************************
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
17 ***************************************************************************/
19 #ifndef AMAROK_DIRECTORYLIST_H
20 #define AMAROK_DIRECTORYLIST_H
22 #include <KDirLister> //stack allocated
23 #include <KUrl> //stack allocated
24 #include <KVBox> //baseclass
26 #include <QCheckBox> //inlined functions
27 #include <q3listview.h> //baseclass
31 namespace CollectionFolder
{ class Item
; }
33 class QFixedListView
: public Q3ListView
34 // Reimplement sizeHint to have directorylist not being too big for "low" (1024x768 is not exactly low) resolutions
37 explicit QFixedListView ( QWidget
* parent
= 0, const char * name
= 0, Qt::WFlags f
= 0 )
38 :Q3ListView(parent
, name
, f
) {}
39 QSize
sizeHint() const
41 return QSize(400, 100);
46 class CollectionSetup
: public KVBox
48 friend class CollectionFolder::Item
;
51 static CollectionSetup
* instance() { return s_instance
; }
53 CollectionSetup( QWidget
* );
56 QStringList
dirs() const { return m_dirs
; }
57 bool recursive() const { return m_recursive
->isChecked(); }
58 bool monitor() const { return m_monitor
->isChecked(); }
61 static CollectionSetup
* s_instance
;
63 QFixedListView
*m_view
;
65 QCheckBox
*m_recursive
;
70 namespace CollectionFolder
{ //just to keep it out of the global namespace
72 class Item
: public QObject
, public Q3CheckListItem
76 Item( Q3ListView
*parent
);
77 Item( Q3ListViewItem
*parent
, const KUrl
&url
, bool full_disable
=false );
79 Q3CheckListItem
*parent() const { return static_cast<Q3CheckListItem
*>( Q3ListViewItem::parent() ); }
80 bool isFullyDisabled() const { return m_fullyDisabled
; }
81 bool isDisabled() const { return isFullyDisabled() || ( CollectionSetup::instance()->recursive() && parent() && parent()->isOn() ); }
82 QString
fullPath() const;
84 void setOpen( bool b
); // reimpl.
85 void stateChange( bool ); // reimpl.
86 void activate(); // reimpl.
87 void paintCell( QPainter
* p
, const QColorGroup
& cg
, int column
, int width
, int align
); // reimpl.
90 void newItems( const KFileItemList
& );
91 void completed() { if( childCount() == 0 ) { setExpandable( false ); repaint(); } }