Commit e3dd088a authored by Thomas Boquet's avatar Thomas Boquet
Browse files

forgot some files sorry.

parent 56674f4c
#include "ListViewController.h"
#include "MediaCellView.h"
#include <QPushButton>
ListViewController::ListViewController( StackViewController* nav ) : m_nav( nav )
{
m_title = new QString( "Media List 42" );
m_scrollArea = new QScrollArea();
m_layout = new QVBoxLayout();
m_container = new QWidget();
m_layout->setAlignment( Qt::AlignTop );
m_layout->setSpacing( 0 );
m_container->setLayout( m_layout );
m_scrollArea->setWidget( m_container );
m_scrollArea->setWidgetResizable( true );
}
ListViewController::~ListViewController()
{
}
// ViewController method implementation
const QString& ListViewController::title() const
{
return *m_title;
}
QWidget* ListViewController::view() const
{
return m_scrollArea;
}
void ListViewController::addCell( QWidget* cell )
{
m_layout->addWidget( cell );
}
#ifndef LISTVIEWCONTROLLER_H
#define LISTVIEWCONTROLLER_H
#include <QWidget>
#include <QListView>
#include <QAbstractItemModel>
#include <QScrollArea>
#include "ViewController.h"
#include "StackViewController.h"
class ListViewController : public ViewController
{
public:
ListViewController( StackViewController* nav );
~ListViewController();
QWidget* view() const;
const QString& title() const;
void addCell( QWidget* cell );
private:
QString* m_title;
QScrollArea* m_scrollArea;
QWidget* m_container;
QVBoxLayout* m_layout;
StackViewController* m_nav;
};
#endif // LISTVIEWCONTROLLER_H
#include "MediaCellView.h"
#include "ui_MediaCellView.h"
MediaCellView::MediaCellView( const QUuid& uuid, QWidget *parent ) :
QWidget( parent ), m_ui( new Ui::MediaCellView ), m_uuid( uuid )
{
m_ui->setupUi( this );
}
MediaCellView::~MediaCellView()
{
delete m_ui;
}
void MediaCellView::changeEvent( QEvent *e )
{
QWidget::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
m_ui->retranslateUi( this );
break;
default:
break;
}
}
void MediaCellView::setTitle( const QString& title )
{
m_ui->title->setText( title );
}
void MediaCellView::setThumbnail( const QPixmap& pixmap )
{
m_ui->thumbnail->setScaledContents( true );
m_ui->thumbnail->setPixmap( pixmap );
}
QString MediaCellView::title() const
{
return m_ui->title->text();
}
const QUuid& MediaCellView::uuid() const
{
return m_uuid;
}
#ifndef MEDIACELLVIEW_H
#define MEDIACELLVIEW_H
#include <QWidget>
#include <QUuid>
namespace Ui
{
class MediaCellView;
}
class MediaCellView : public QWidget
{
Q_OBJECT
public:
MediaCellView( const QUuid& uuid, QWidget *parent = 0 );
~MediaCellView();
void setTitle( const QString& title );
void setThumbnail( const QPixmap& pixmap );
QString title() const;
const QUuid& uuid() const;
protected:
void changeEvent( QEvent *e );
private:
Ui::MediaCellView *m_ui;
const QUuid m_uuid;
};
#endif // MEDIACELLVIEW_H
#include "MediaLibraryWidget.h"
MediaLibraryWidget::MediaLibraryWidget( QWidget* parent ) : QWidget( parent )
{
StackViewController* nav = new StackViewController( this );
MediaListViewController* list = new MediaListViewController( nav );
nav->pushViewController( list );
}
MediaLibraryWidget::~MediaLibraryWidget()
{
}
#ifndef MEDIALIBRARYWIDGET_H
#define MEDIALIBRARYWIDGET_H
#include <QWidget>
#include "StackViewController.h"
#include "MediaListViewController.h"
class MediaLibraryWidget : public QWidget
{
Q_OBJECT
public:
MediaLibraryWidget( QWidget* parent = 0 );
virtual ~MediaLibraryWidget();
private:
StackViewController* m_nav;
};
#endif // MEDIALIBRARYWIDGET_H
#include "MediaListViewController.h"
MediaListViewController::MediaListViewController( StackViewController* nav ) :
ListViewController( nav )
{
connect(Library::getInstance(), SIGNAL( newMediaLoaded( Media* ) ), this, SLOT( newMediaLoaded( Media* ) ) );
}
MediaListViewController::~MediaListViewController()
{
}
void MediaListViewController::newMediaLoaded( Media* media )
{
MediaCellView* cell = new MediaCellView( media->getUuid() );
cell->setThumbnail( media->getSnapshot() );
cell->setTitle( media->getFileName() );
addCell(cell);
}
#ifndef MEDIALISTVIEWCONTROLLER_H
#define MEDIALISTVIEWCONTROLLER_H
#include "StackViewController.h"
#include "ListViewController.h"
#include "MediaCellView.h"
#include "Library.h"
#include "Media.h"
class MediaListViewController : public QObject, public ListViewController
{
Q_OBJECT
public:
MediaListViewController( StackViewController* nav );
virtual ~MediaListViewController();
public slots:
void newMediaLoaded( Media* );
};
#endif // MEDIALISTVIEWCONTROLLER_H
#include "StackViewController.h"
StackViewController::StackViewController( QWidget* parent ) :
QWidget( parent ), m_current( 0 )
{
m_nav = new StackViewNavController( this );
m_footer = new QLabel( "Footer" );
m_layout = new QVBoxLayout;
m_controllerStack = new QStack<ViewController*>();
m_footer->setAlignment( Qt::AlignCenter );
QObject::connect( m_nav->previousButton(), SIGNAL( clicked() ),
this, SLOT( previous() ) );
m_layout->addWidget( m_nav );
m_layout->addWidget( m_footer );
parent->setLayout( m_layout );
}
StackViewController::~StackViewController()
{
delete m_nav;
delete m_footer;
delete m_layout;
delete m_controllerStack;
}
void StackViewController::pushViewController( ViewController* viewController,
bool animated )
{
animated = false;
if ( m_current )
{
m_layout->removeWidget( m_current->view() );
m_current->view()->hide();
m_controllerStack->push( m_current );
m_nav->previousButton()->setHidden( false );
m_nav->previousButton()->setText( "< " + m_current->title() );
}
m_current = viewController;
m_nav->setTitle( m_current->title() );
m_layout->insertWidget( 1, m_current->view() );
}
void StackViewController::popViewController( bool animated )
{
animated = false;
if ( !m_controllerStack->size() )
return ;
m_layout->removeWidget( m_current->view() );
m_current->view()->hide();
m_current = m_controllerStack->pop();
m_nav->setTitle( m_current->title() );
m_layout->insertWidget( 1, m_current->view() );
m_current->view()->setHidden( false );
if ( !m_controllerStack->size() )
m_nav->previousButton()->setHidden( true );
else
{
m_nav->previousButton()->setText( "< " +
m_controllerStack->value( m_controllerStack->size() - 1 )->title() );
}
}
void StackViewController::previous()
{
popViewController();
}
#ifndef STACKVIEWCONTROLLER_H
#define STACKVIEWCONTROLLER_H
#include <QWidget>
#include <QPushButton>
#include <QHBoxLayout>
#include <QLabel>
#include <QDebug>
#include <QStack>
#include "StackViewNavController.h"
#include "ViewController.h"
class StackViewController : public QWidget
{
Q_OBJECT
public:
StackViewController( QWidget* parent = 0 );
~StackViewController();
void pushViewController( ViewController* viewController,
bool animated = false );
void popViewController( bool animated = false );
private:
StackViewNavController* m_nav;
QLabel* m_footer;
QVBoxLayout* m_layout;
ViewController* m_current;
QStack<ViewController*>* m_controllerStack;
public slots:
void previous();
};
#endif // STACKVIEWCONTROLLER_H
#include "StackViewNavController.h"
#include "ui_StackViewNavController.h"
StackViewNavController::StackViewNavController( QWidget *parent ) :
QWidget( parent ),
m_ui(new Ui::StackViewNavController)
{
m_ui->setupUi(this);
m_ui->previousButton->setHidden(true);
}
StackViewNavController::~StackViewNavController()
{
delete m_ui;
}
void StackViewNavController::changeEvent( QEvent *e )
{
QWidget::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
m_ui->retranslateUi( this );
break;
default:
break;
}
}
void StackViewNavController::setTitle( const QString& title )
{
m_ui->title->setText( title );
}
QPushButton* StackViewNavController::previousButton() const
{
return m_ui->previousButton;
}
#ifndef STACKVIEWNAVCONTROLLER_H
#define STACKVIEWNAVCONTROLLER_H
#include <QWidget>
#include <QPushButton>
namespace Ui
{
class StackViewNavController;
}
class StackViewNavController : public QWidget
{
Q_OBJECT
public:
StackViewNavController( QWidget *parent = 0 );
~StackViewNavController();
void setTitle( const QString& title );
QPushButton* previousButton() const;
protected:
void changeEvent( QEvent *e );
private:
Ui::StackViewNavController *m_ui;
};
#endif // STACKVIEWNAVCONTROLLER_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StackViewNavController</class>
<widget class="QWidget" name="StackViewNavController">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>46</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="previousButton">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="title">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#ifndef VIEWCONTROLLER_H
#define VIEWCONTROLLER_H
#include <QWidget>
class ViewController
{
public:
ViewController() {}
virtual ~ViewController() {}
virtual QWidget* view() const = 0;
virtual const QString &title() const = 0;
};
#endif // VIEWCONTROLLER_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MediaCellView</class>
<widget class="QWidget" name="MediaCellView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>274</width>
<height>81</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="thumbnail">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>48</width>
<height>48</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>48</width>
<height>48</height>
</size>
</property>
<property name="baseSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="title">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Media Title</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout">