Commit 831c6b73 authored by Christophe Courtaut's avatar Christophe Courtaut

[GUI] Added FileBrowser Widget

parent d02ed257
/*****************************************************************************
* FileBrowser.cpp: FileBrowser Widget
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Christophe Courtaut <christophe.courtaut@gmail.com>
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "FileBrowser.h"
#include <QStringList>
#include <QtDebug>
FileBrowser::FileBrowser( QWidget* parent ) : QWidget( parent )
{
m_ui.setupUi( this );
m_DirsModel = new QDirModel();
m_FilesModel = new QDirModel();
QStringList filters;
filters << "*.mp3" << "*.oga" << "*.flac" << "*.aac" << "*.wav";
filters << "*.mov" << "*.avi" << "*.mkv" << "*.mpg" << "*.mpeg" << "*.wmv" << "*.mp4";
filters << "*.gif" << "*.png" << "*.jpg";
m_FilesModel->setFilter( QDir::Dirs | QDir::Files | QDir::Readable | QDir::NoDotAndDotDot );
m_FilesModel->sort( 2, Qt::AscendingOrder );
m_FilesModel->sort( 0, Qt::AscendingOrder );
m_FilesModel->setNameFilters( filters );
m_ui.listViewBrowser->setModel( m_FilesModel );
m_ui.listViewBrowser->setRootIndex( m_FilesModel->index( QDir::homePath() ) );
m_DirsModel->setFilter( ( QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Readable ) );
m_ui.treeViewBrowser->setModel( m_DirsModel );
m_ui.treeViewBrowser->setRootIndex( m_DirsModel->index( QDir::rootPath() ) );
m_ui.treeViewBrowser->setCurrentIndex( m_DirsModel->index( QDir::homePath() ) );
m_ui.treeViewBrowser->setExpanded( m_ui.treeViewBrowser->currentIndex() , true );
m_ui.treeViewBrowser->setColumnHidden( 1, true );
m_ui.treeViewBrowser->setColumnHidden( 2, true );
m_ui.treeViewBrowser->setColumnHidden( 3, true );
//m_ui.listViewBrowser->setSelectionModel( m_ui.treeViewBrowser->selectionModel() );
}
void FileBrowser::on_treeViewBrowser_clicked( QModelIndex index )
{
if ( m_DirsModel->isDir( index ) )
{
m_ui.listViewBrowser->setRootIndex( m_FilesModel->index( m_DirsModel->filePath( index ) ) );
}
}
void FileBrowser::on_listViewBrowser_doubleClicked(QModelIndex index)
{
if ( m_FilesModel->isDir( index ) )
{
m_ui.listViewBrowser->setRootIndex( index );
m_ui.treeViewBrowser->setCurrentIndex( m_DirsModel->index( m_FilesModel->filePath( index ) ) );
}
}
/*****************************************************************************
* FileBrowser.h: FileBrowser Widget
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Christophe Courtaut <christophe.courtaut@gmail.com>
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef FILEBROWSER_H
#define FILEBROWSER_H
#include <QWidget>
#include <QDirModel>
#include "ui_FileBrowser.h"
class FileBrowser : public QWidget
{
Q_OBJECT
public:
FileBrowser( QWidget* parent = NULL );
private:
Ui::FileBrowser m_ui;
QDirModel* m_DirsModel;
QDirModel* m_FilesModel;
private slots:
void on_listViewBrowser_doubleClicked(QModelIndex index);
void on_treeViewBrowser_clicked( QModelIndex index );
};
#endif /* !FILEBROWSER_H */
......@@ -33,6 +33,7 @@
#include "Timeline.h"
#include "About.h"
#include "Transcode.h"
#include "FileBrowser.h"
MainWindow::MainWindow( QWidget *parent ) :
QMainWindow( parent )
......@@ -131,9 +132,16 @@ void MainWindow::m_initializeDockWidgets( void )
m_timeline->show();
setCentralWidget( m_timeline );
DockWidgetManager *dockManager = DockWidgetManager::instance();
// dockManager->addDockedWidget( new FileBrowser( this ),
// tr( "FileBrowser" ),
// Qt::AllDockWidgetAreas,
// QDockWidget::AllDockWidgetFeatures,
// Qt::TopDockWidgetArea);
setupLibrary();
DockWidgetManager *dockManager = DockWidgetManager::instance();
dockManager->addDockedWidget( new PreviewWidget( this ),
tr( "Preview" ),
Qt::AllDockWidgetAreas,
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FileBrowser</class>
<widget class="QWidget" name="FileBrowser">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>629</width>
<height>400</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTreeView" name="treeViewBrowser">
<property name="headerHidden">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="listViewBrowser"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -35,7 +35,8 @@ SOURCES += src/main.cpp \
src/Library.cpp \
src/gui/GraphicsMovieItem.cpp \
src/gui/AbstractGraphicsMediaItem.cpp \
src/Media.cpp
src/Media.cpp \
src/gui/FileBrowser.cpp
HEADERS += src/gui/MainWindow.h \
src/gui/DockWidgetManager.h \
src/gui/LibraryWidget.h \
......@@ -63,14 +64,16 @@ HEADERS += src/gui/MainWindow.h \
src/Library.h \
src/gui/AbstractGraphicsMediaItem.h \
src/gui/GraphicsMovieItem.h \
src/Media.h
src/Media.h \
src/gui/FileBrowser.h
FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/PreviewWidget.ui \
src/gui/ui/Preferences.ui \
src/gui/ui/Timeline.ui \
src/gui/ui/LibraryWidget.ui \
src/gui/ui/About.ui \
src/gui/ui/Transcode.ui
src/gui/ui/Transcode.ui \
src/gui/ui/FileBrowser.ui
FORMS +=
TRANSLATIONS = ts/vlmc_es.ts \
ts/vlmc_fr.ts \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment