Updated SWH plugins and added missing hermes_filter plugin
[lmms/mlankhorst.git] / include / file_browser.h
blob3830f6eed34a8a2b60bc2ac017feedec49a956c3
1 /*
2 * file_browser.h - include file for fileBrowser
4 * Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 *
6 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
26 #ifndef _FILE_BROWSER_H
27 #define _FILE_BROWSER_H
29 #include <QtCore/QDir>
30 #include <QtCore/QMutex>
31 #include <QtGui/QTreeWidget>
34 #include "SideBarWidget.h"
37 class QLineEdit;
39 class fileItem;
40 class InstrumentTrack;
41 class fileBrowserTreeWidget;
42 class playHandle;
43 class trackContainer;
47 class fileBrowser : public SideBarWidget
49 Q_OBJECT
50 public:
51 fileBrowser( const QString & _directories, const QString & _filter,
52 const QString & _title, const QPixmap & _pm,
53 QWidget * _parent, bool _dirs_as_items = false );
54 virtual ~fileBrowser();
57 public slots:
58 void filterItems( const QString & _filter );
59 void reloadTree( void );
62 private:
63 bool filterItems( QTreeWidgetItem * _item, const QString & _filter );
64 virtual void keyPressEvent( QKeyEvent * _ke );
66 void addItems( const QString & _path );
68 fileBrowserTreeWidget * m_l;
70 QLineEdit * m_filterEdit;
72 QString m_directories;
73 QString m_filter;
75 bool m_dirsAsItems;
77 } ;
82 class fileBrowserTreeWidget : public QTreeWidget
84 Q_OBJECT
85 public:
86 fileBrowserTreeWidget( QWidget * _parent );
87 virtual ~fileBrowserTreeWidget();
90 protected:
91 virtual void contextMenuEvent( QContextMenuEvent * _e );
92 virtual void mousePressEvent( QMouseEvent * _me );
93 virtual void mouseMoveEvent( QMouseEvent * _me );
94 virtual void mouseReleaseEvent( QMouseEvent * _me );
97 private:
98 void handleFile( fileItem * _fi, InstrumentTrack * _it );
99 void openInNewInstrumentTrack( trackContainer * _tc );
102 bool m_mousePressed;
103 QPoint m_pressPos;
105 playHandle * m_previewPlayHandle;
106 QMutex m_pphMutex;
108 fileItem * m_contextMenuItem;
111 private slots:
112 void activateListItem( QTreeWidgetItem * _item, int _column );
113 void openInNewInstrumentTrackBBE( void );
114 void openInNewInstrumentTrackSE( void );
115 void sendToActiveInstrumentTrack( void );
116 void updateDirectory( QTreeWidgetItem * _item );
123 class directory : public QTreeWidgetItem
125 public:
126 directory( const QString & _filename, const QString & _path,
127 const QString & _filter );
129 void update( void );
131 inline QString fullName( QString _path = QString::null )
133 if( _path == QString::null )
135 _path = m_directories[0];
137 if( _path != QString::null )
139 _path += QDir::separator();
141 return( QDir::cleanPath( _path + text( 0 ) ) +
142 QDir::separator() );
145 inline void addDirectory( const QString & _dir )
147 m_directories.push_back( _dir );
151 private:
152 void initPixmaps( void );
154 bool addItems( const QString & _path );
157 static QPixmap * s_folderPixmap;
158 static QPixmap * s_folderOpenedPixmap;
159 static QPixmap * s_folderLockedPixmap;
161 QStringList m_directories;
162 QString m_filter;
169 class fileItem : public QTreeWidgetItem
171 public:
172 enum FileTypes
174 ProjectFile,
175 PresetFile,
176 SampleFile,
177 SoundFontFile,
178 PatchFile,
179 MidiFile,
180 FlpFile,
181 VstPluginFile,
182 UnknownFile,
183 NumFileTypes
186 enum FileHandling
188 NotSupported,
189 LoadAsProject,
190 LoadAsPreset,
191 LoadByPlugin,
192 ImportAsProject
196 fileItem( QTreeWidget * _parent, const QString & _name,
197 const QString & _path );
198 fileItem( const QString & _name, const QString & _path );
200 inline QString fullName( void ) const
202 return( QDir::cleanPath( m_path ) + QDir::separator() +
203 text( 0 ) );
206 inline FileTypes type( void ) const
208 return( m_type );
211 inline FileHandling handling( void ) const
213 return( m_handling );
216 QString extension( void );
217 static QString extension( const QString & _file );
220 private:
221 void initPixmaps( void );
222 void determineFileType( void );
224 static QPixmap * s_projectFilePixmap;
225 static QPixmap * s_presetFilePixmap;
226 static QPixmap * s_sampleFilePixmap;
227 static QPixmap * s_midiFilePixmap;
228 static QPixmap * s_flpFilePixmap;
229 static QPixmap * s_unknownFilePixmap;
231 QString m_path;
232 FileTypes m_type;
233 FileHandling m_handling;
238 #endif