summaryrefslogtreecommitdiffstats
path: root/src/directorylist.h
blob: 0c8498899abe4a199e51df947124d3bc2b333574 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/***************************************************************************
                         directorylist.h
                            -------------------
   begin                : Tue Feb 4 2003
   copyright            : (C) 2003 Scott Wheeler <wheeler@kde.org>
                        : (C) 2004 Max Howell <max.howell@methylblue.com>
                        : (C) 2004 Mark Kretschmann <markey@web.de>
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _DIRECTORYLIST_H
#define _DIRECTORYLIST_H

#include <tqcheckbox.h>  //inlined functions
#include <tqlistview.h>  //baseclass
#include <tqvbox.h>      //baseclass
#include <tqstringlist.h>

#include <kdirlister.h> //stack allocated
#include <kurl.h>       //stack allocated


namespace Collection { class Item; }


class CollectionSetup : public TQVBox
{
Q_OBJECT
    friend class Collection::Item;

public:
    static CollectionSetup* instance() { return s_instance; }

    CollectionSetup( TQWidget* ,bool );

    TQStringList dirs() const { return m_dirs; }
    bool recursive() const { return m_recursive; }
//     bool monitor() const { return m_monitor->isChecked(); }
//     bool importPlaylists() const { return m_playlists->isChecked(); }
    TQStringList m_dirs;
    TQMap<TQString,int> m_refcount;

    TQStringList pruneSelectedDirs();
    void writeConfig( const char* optGroup, const char* optName );

signals:
    void dirsSelected(TQStringList& dirs);

public slots:

    void slotRecursiveToggled(bool on);

private:
    static CollectionSetup* s_instance;

    TQListView *m_view;
    bool m_recursive;
    TQCheckBox *m_monitor;
    TQCheckBox *m_playlists;
};


namespace Collection { //just to keep it out of the global namespace

class Item : public TQObject, public TQCheckListItem
{
Q_OBJECT
public:
    Item( TQListView *parent, const TQString &name, const TQString &path, const TQString &icon=TQString::null );
    Item( TQListViewItem *parent, const KURL &url );

    TQCheckListItem *parent() const { return (TQCheckListItem*)TQListViewItem::parent(); }
    bool isDisabled() const { return CollectionSetup::instance()->recursive() && parent() && parent()->isOn(); }
    TQString fullPath() const;

    void setOpen( bool b ); // reimpl.
    void stateChange( bool ); // reimpl.
    void activate(); // reimpl.
    void paintCell( TQPainter * p, const TQColorGroup & cg, int column, int width, int align ); // reimpl.

public slots:
    void newItems( const KFileItemList& );
    void completed() { if( childCount() == 0 ) { setExpandable( false ); repaint(); } }

private:
    KDirLister m_lister;
    KURL       m_url;
    bool       m_listed;
};


class DeviceItem : public TQObject, public TQCheckListItem
{
   Q_OBJECT
   public:
      DeviceItem( TQListView *parent );
      DeviceItem( TQListViewItem *parent, const TQString &name, const KURL &url );

      TQCheckListItem *parent() const { return (TQCheckListItem*)TQListViewItem::parent(); }
      bool isDisabled() const { return CollectionSetup::instance()->recursive() && parent() && parent()->isOn(); }
      TQString fullPath() const;

      void setOpen( bool b ); // reimpl.
      void stateChange( bool ); // reimpl.
      void activate(); // reimpl.
      void paintCell( TQPainter * p, const TQColorGroup & cg, int column, int width, int align ); // reimpl.
      TQString getMountPoint(const TQString & device);
   public slots:
      void newItems( const KFileItemList& );
      void completed() { if( childCount() == 0 ) { setExpandable( false ); repaint(); } }
   private:
      void mountDevice(const TQString & device);
      KDirLister m_lister;
      KURL       m_url;
      bool       m_listed;
};
} //namespace



#endif