2 * file_browser.h - include file for fileBrowser
4 * Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
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"
40 class InstrumentTrack
;
41 class fileBrowserTreeWidget
;
47 class fileBrowser
: public SideBarWidget
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();
58 void filterItems( const QString
& _filter
);
59 void reloadTree( void );
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
;
82 class fileBrowserTreeWidget
: public QTreeWidget
86 fileBrowserTreeWidget( QWidget
* _parent
);
87 virtual ~fileBrowserTreeWidget();
91 virtual void contextMenuEvent( QContextMenuEvent
* _e
);
92 virtual void mousePressEvent( QMouseEvent
* _me
);
93 virtual void mouseMoveEvent( QMouseEvent
* _me
);
94 virtual void mouseReleaseEvent( QMouseEvent
* _me
);
98 void handleFile( fileItem
* _fi
, InstrumentTrack
* _it
);
99 void openInNewInstrumentTrack( trackContainer
* _tc
);
105 playHandle
* m_previewPlayHandle
;
108 fileItem
* m_contextMenuItem
;
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
126 directory( const QString
& _filename
, const QString
& _path
,
127 const QString
& _filter
);
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 ) ) +
145 inline void addDirectory( const QString
& _dir
)
147 m_directories
.push_back( _dir
);
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
;
169 class fileItem
: public QTreeWidgetItem
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() +
206 inline FileTypes
type( void ) const
211 inline FileHandling
handling( void ) const
213 return( m_handling
);
216 QString
extension( void );
217 static QString
extension( const QString
& _file
);
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
;
233 FileHandling m_handling
;