]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/ml_configuration.hpp
Qt: toolbar editor: make it easier for small narrow screens
[vlc] / modules / gui / qt4 / dialogs / ml_configuration.hpp
1 /*****************************************************************************
2  * ml_configuration.hpp: SQL ML's configuration dialog (folder view)
3  *****************************************************************************
4  * Copyright (C) 2008-2010 the VideoLAN Team and AUTHORS
5  * $Id$
6  *
7  * Authors: Antoine Lejeune <phytos@videolan.org>
8  *          Jean-Philippe André <jpeg@videolan.org>
9  *          Rémi Duraffort <ivoire@videolan.org>
10  *          Adrien Maglo <magsoft@videolan.org>
11  *
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.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27
28 #ifndef _MEDIA_LIBRARY_CONFIG_H
29 #define _MEDIA_LIBRARY_CONFIG_H
30
31 #ifdef HAVE_CONFIG_H
32 # include <config.h>
33 #endif
34
35 #ifdef SQL_MEDIA_LIBRARY
36
37 #include <vlc_common.h>
38 #include <vlc_media_library.h>
39
40 #include "util/qvlcframe.hpp"
41
42 #include <QDirModel>
43 #include <QCheckBox>
44 #include <QDialogButtonBox>
45 #include <QPushButton>
46
47 /** Classes in this header */
48 class MLDirModel;
49 class MLConfDialog;
50
51 /** *************************************************************************
52  * \brief Model representing the filesystem and whose items are checkable
53  ****************************************************************************/
54 class MLDirModel : public QDirModel
55 {
56     Q_OBJECT;
57
58 public:
59     MLDirModel( const QStringList &nameFilters, QDir::Filters filters,
60                 QDir::SortFlags sort, QObject *parent = 0 )
61                 : QDirModel( nameFilters, filters, sort, parent ) {};
62
63     virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
64     virtual QVariant data( const QModelIndex &index, int role ) const;
65     virtual bool setData( const QModelIndex &index, const QVariant &value,
66                           int role = Qt::EditRole );
67     int columnCount( const QModelIndex &parent = QModelIndex() ) const;
68     void reset( bool, vlc_array_t *);
69
70     QStringList monitoredDirs;
71
72 private:
73     bool b_recursive;
74     QMap<QString, Qt::CheckState> itemCheckState;
75     intf_thread_t *p_intf;
76     media_library_t* p_ml;
77
78 public slots:
79     void setRecursivity( bool );
80 };
81
82 /** *************************************************************************
83  * \brief Configuration dialog for the media library
84  ****************************************************************************/
85 class MLConfDialog : public QVLCDialog
86 {
87     Q_OBJECT;
88 public:
89     MLConfDialog( QWidget *, intf_thread_t * );
90
91 private:
92     void init();
93
94     vlc_array_t *p_monitored_dirs;
95     media_library_t *p_ml;
96     intf_thread_t *p_intf;
97
98     MLDirModel *model;
99     QCheckBox *recursivity;
100     QCheckBox *synchronous;
101
102     static MLConfDialog *instance;
103
104 private slots:
105     void save();
106     void cancel();
107     void reset();
108     void close() { save(); };
109 };
110
111 #endif
112 #endif
113