Commit 486527f1 authored by Thomas Boquet's avatar Thomas Boquet

handling cellSelected signal for preview

parent a37958d3
......@@ -20,11 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "ListViewController.h"
#include <QPushButton>
#include "ListViewController.h"
#include "MediaCellView.h"
#include <QPushButton>
#include "Library.h"
ListViewController::ListViewController( StackViewController* nav ) : m_nav( nav )
{
......@@ -61,3 +61,8 @@ void ListViewController::addCell( QWidget* cell )
{
m_layout->addWidget( cell );
}
void ListViewController::cellSelected( const QUuid& uuid )
{
emit selectedClipChanged( Library::getInstance()->getClip( uuid ) );
}
......@@ -27,15 +27,19 @@
#include <QListView>
#include <QAbstractItemModel>
#include <QScrollArea>
#include <QUuid>
#include "ViewController.h"
#include "StackViewController.h"
#include "Clip.h"
class ListViewController : public ViewController
{
Q_OBJECT
public:
ListViewController() {}
ListViewController( StackViewController* nav );
~ListViewController();
......@@ -49,6 +53,12 @@ private:
QWidget* m_container;
QVBoxLayout* m_layout;
StackViewController* m_nav;
public slots:
void cellSelected( const QUuid& );
signals:
void selectedClipChanged( Clip* );
};
#endif // LISTVIEWCONTROLLER_H
......@@ -7,6 +7,7 @@ MediaCellView::MediaCellView( const QUuid& uuid, QWidget *parent ) :
QWidget( parent ), m_ui( new Ui::MediaCellView ), m_uuid( uuid )
{
m_ui->setupUi( this );
setFocusPolicy( Qt::ClickFocus );
}
MediaCellView::~MediaCellView()
......@@ -50,10 +51,18 @@ const QUuid& MediaCellView::uuid() const
void MediaCellView::mouseDoubleClickEvent( QMouseEvent* event )
{
if ( event->buttons() | Qt::LeftButton == Qt::LeftButton )
if ( ( event->buttons() | Qt::LeftButton ) == Qt::LeftButton )
{
ClipProperty* mp = new ClipProperty( Library::getInstance()->getClip( m_uuid ), this );
mp->setModal( true );
mp->show();
}
}
void MediaCellView::mousePressEvent( QMouseEvent* event )
{
if ( ( event->buttons() | Qt::LeftButton ) == Qt::LeftButton )
{
emit cellSelected( m_uuid );
}
}
......@@ -32,6 +32,12 @@ private:
protected:
void mouseDoubleClickEvent( QMouseEvent* );
void mousePressEvent( QMouseEvent* );
signals:
void cellSelected( const QUuid& uuid );
};
#endif // MEDIACELLVIEW_H
......@@ -2,13 +2,18 @@
MediaLibraryWidget::MediaLibraryWidget( QWidget* parent ) : QWidget( parent )
{
StackViewController* nav = new StackViewController( this );
MediaListViewController* list = new MediaListViewController( nav );
m_nav = new StackViewController( this );
MediaListViewController* list = new MediaListViewController( m_nav );
nav->pushViewController( list );
m_nav->pushViewController( list );
}
MediaLibraryWidget::~MediaLibraryWidget()
{
}
const ViewController* MediaLibraryWidget::getCurrentViewController()
{
return m_nav->getCurrentViewController();
}
......@@ -14,6 +14,8 @@ public:
MediaLibraryWidget( QWidget* parent = 0 );
virtual ~MediaLibraryWidget();
const ViewController* getCurrentViewController();
private:
StackViewController* m_nav;
};
......
#include "MediaListViewController.h"
MediaListViewController::MediaListViewController( StackViewController* nav ) :
ListViewController( nav )
ListViewController( nav ), m_nav( nav )
{
connect(Library::getInstance(), SIGNAL( newMediaLoaded( Media* ) ), this, SLOT( newMediaLoaded( Media* ) ) );
}
......@@ -15,6 +15,9 @@ void MediaListViewController::newMediaLoaded( Media* media )
{
MediaCellView* cell = new MediaCellView( media->getUuid() );
connect( cell, SIGNAL ( cellSelected( QUuid ) ),
this, SLOT ( cellSelected( QUuid ) ) );
cell->setThumbnail( media->getSnapshot() );
cell->setTitle( media->getFileName() );
addCell(cell);
......
......@@ -7,7 +7,7 @@
#include "Library.h"
#include "Media.h"
class MediaListViewController : public QObject, public ListViewController
class MediaListViewController : public ListViewController
{
Q_OBJECT
......@@ -15,6 +15,9 @@ public:
MediaListViewController( StackViewController* nav );
virtual ~MediaListViewController();
private:
StackViewController* m_nav;
public slots:
void newMediaLoaded( Media* );
};
......
......@@ -74,3 +74,8 @@ void StackViewController::previous()
{
popViewController();
}
const ViewController* StackViewController::getCurrentViewController() const
{
return m_current;
}
......@@ -19,10 +19,10 @@ public:
StackViewController( QWidget* parent = 0 );
~StackViewController();
void pushViewController( ViewController* viewController,
bool animated = false );
void popViewController( bool animated = false );
void pushViewController( ViewController* viewController,
bool animated = false );
void popViewController( bool animated = false );
const ViewController* getCurrentViewController() const;
private:
StackViewNavController* m_nav;
......
#ifndef VIEWCONTROLLER_H
#define VIEWCONTROLLER_H
#include <QWidget>
#include <QObject>
class ViewController
class ViewController : public QObject
{
Q_OBJECT
public:
ViewController() {}
//ViewController() {}
virtual ~ViewController() {}
......
......@@ -154,6 +154,12 @@ void MainWindow::setupLibrary()
connect( libraryWidget->getVideoListWidget(), SIGNAL( selectedClipChanged( Clip* ) ),
m_clipPreview->getGenericRenderer(), SLOT( setClip( Clip* ) ) );
connect( mediaLibraryWidget->getCurrentViewController(),
SIGNAL( selectedClipChanged( Clip* ) ),
m_clipPreview->getGenericRenderer(),
SLOT( setClip( Clip* ) ) );
connect( Library::getInstance(), SIGNAL( mediaRemoved( const QUuid& ) ),
m_clipPreview->getGenericRenderer(), SLOT( mediaUnloaded( QUuid ) ) );
connect( libraryWidget->getVideoListWidget(), SIGNAL( itemDoubleClicked( QListWidgetItem* ) ),
......
......@@ -131,7 +131,8 @@ HEADERS += src/GUI/MainWindow.h \
src/GUI/Library/ListViewController.h \
src/GUI/Library/MediaCellView.h \
src/GUI/Library/MediaLibraryWidget.h \
src/GUI/Library/MediaListViewController.h
src/GUI/Library/MediaListViewController.h \
src/GUI/Library/ViewController.h
FORMS += src/GUI/ui/MainWindow.ui \
src/GUI/ui/PreviewWidget.ui \
src/GUI/ui/LanguagePreferences.ui \
......
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