<repo_name>Diogo-Ferreira/school-work-qt<file_sep>/build-Serie5exercice1-Desktop_Qt_5_5_0_GCC_64bit-Debug/moc_widget.cpp
/****************************************************************************
** Meta object code from reading C++ file 'widget.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.5.0)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/

#include "../Serie5exercice1/widget.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'widget.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.5.0. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif

QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_Convert_t {
    QByteArrayData data[6];
    char stringdata0[85];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
    Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
    qptrdiff(offsetof(qt_meta_stringdata_Convert_t, stringdata0) + ofs \
        - idx * sizeof(QByteArrayData)) \
    )
static const qt_meta_stringdata_Convert_t qt_meta_stringdata_Convert = {
    {
QT_MOC_LITERAL(0, 0, 7), // "Convert"
QT_MOC_LITERAL(1, 8, 19), // "onBtnComputeClicked"
QT_MOC_LITERAL(2, 28, 0), // ""
QT_MOC_LITERAL(3, 29, 16), // "onBtnQuitClicked"
QT_MOC_LITERAL(4, 46, 18), // "onBtnReInitClicked"
QT_MOC_LITERAL(5, 65, 19) // "onConversionChanged"

    },
    "Convert\0onBtnComputeClicked\0\0"
    "onBtnQuitClicked\0onBtnReInitClicked\0"
    "onConversionChanged"
};
#undef QT_MOC_LITERAL

static const uint qt_meta_data_Convert[] = {

 // content:
       7,       // revision
       0,       // classname
       0,    0, // classinfo
       4,   14, // methods
       0,    0, // properties
       0,    0, // enums/sets
       0,    0, // constructors
       0,       // flags
       0,       // signalCount

 // slots: name, argc, parameters, tag, flags
       1,    0,   34,    2, 0x0a /* Public */,
       3,    0,   35,    2, 0x0a /* Public */,
       4,    0,   36,    2, 0x0a /* Public */,
       5,    2,   37,    2, 0x0a /* Public */,

 // slots: parameters
    QMetaType::Void,
    QMetaType::Void,
    QMetaType::Void,
    QMetaType::Void, QMetaType::Int, QMetaType::Bool,    2,    2,

       0        // eod
};

void Convert::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
    if (_c == QMetaObject::InvokeMetaMethod) {
        Convert *_t = static_cast<Convert *>(_o);
        Q_UNUSED(_t)
        switch (_id) {
        case 0: _t->onBtnComputeClicked(); break;
        case 1: _t->onBtnQuitClicked(); break;
        case 2: _t->onBtnReInitClicked(); break;
        case 3: _t->onConversionChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        default: ;
        }
    }
}

const QMetaObject Convert::staticMetaObject = {
    { &QDialog::staticMetaObject, qt_meta_stringdata_Convert.data,
      qt_meta_data_Convert,  qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};


const QMetaObject *Convert::metaObject() const
{
    return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}

void *Convert::qt_metacast(const char *_clname)
{
    if (!_clname) return Q_NULLPTR;
    if (!strcmp(_clname, qt_meta_stringdata_Convert.stringdata0))
        return static_cast<void*>(const_cast< Convert*>(this));
    return QDialog::qt_metacast(_clname);
}

int Convert::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 4)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 4;
    } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
        if (_id < 4)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 4;
    }
    return _id;
}
QT_END_MOC_NAMESPACE
<file_sep>/serie7exercice3/picturezone.h
#ifndef PICTUREZONE_H
#define PICTUREZONE_H

#include <QWidget>
#include <QtWidgets>

class PictureZone : public QWidget
{
    Q_OBJECT
public:
    explicit PictureZone(QWidget *parent = 0);
    void updatePicture(QString);

private:
    void paintEvent(QPaintEvent *);
    QPixmap *picture;

public slots:

};

#endif // PICTUREZONE_H
<file_sep>/serie7exercice1/widget.cpp
#include "widget.h"

Widget::Widget(QWidget *parent) : QGraphicsView(parent)
{
    qgScene = new QGraphicsScene(this);
    setScene(qgScene);
    QGraphicsEllipseItem *ellipse = new QGraphicsEllipseItem(10,10,500,300);
    QGraphicsTextItem *ellipseText = new QGraphicsTextItem("Add ellipse");
    ellipseText->setParentItem(ellipse);
    ellipseText->moveBy(ellipse->rect().width()+ 50,ellipse->rect().height()*0.5);
    ellipse->setSpanAngle(120 * 16);
    ellipse->setRotation(30 * 16);
    qgScene->addItem(ellipse);

}

Widget::~Widget()
{

}
<file_sep>/serie7exercice3/picturezone.cpp
#include "picturezone.h"

PictureZone::PictureZone(QWidget *parent) : QWidget(parent)
{

}

void PictureZone::updatePicture(QString absPath)
{
    picture = new QPixmap(absPath);
}

void PictureZone::paintEvent(QPaintEvent *)
{

    QPainter paint(this);
    if(picture != NULL)
    {
        paint.drawPixmap(0,0,width(),height(),*picture);
    }

}

<file_sep>/Serie5exercice1/widget.h
#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QtWidgets>

class Convert : public QDialog
{
    Q_OBJECT

public:
    Convert(QDialog *parent = 0);
    ~Convert();
private:
    //Widgets
    QButtonGroup *radGroup      ;
    QRadioButton *celToFaRadBtn ;
    QRadioButton *faToCelRadBtn ;
    QLineEdit    *tempInput     ;
    QPushButton  *reInitBtn     ;
    QPushButton  *quitBtn       ;
    QPushButton  *computeBtn    ;
    QLCDNumber   *computeOut    ;
    QLabel       *convLbl       ;

public slots:
    void onBtnComputeClicked();
    void onBtnQuitClicked();
    void onBtnReInitClicked();
    void onConversionChanged(int,bool);
};

#endif // WIDGET_H
<file_sep>/Serie5exercice1/widget.cpp
#include "widget.h"

Convert::Convert(QDialog *parent):QDialog(parent)
{
    setFixedWidth(320);
    setFixedHeight(150);
    radGroup      = new QButtonGroup(this);
    celToFaRadBtn = new QRadioButton("&Celsius -> Farenheit",this);
    faToCelRadBtn = new QRadioButton("&Farenheit -> Celsius",this);
    tempInput     = new QLineEdit("0",this);
    reInitBtn     = new QPushButton("&Ré-initialiser",this);
    quitBtn       = new QPushButton("&Quitter",this);
    computeBtn    = new QPushButton("C&alculer",this);
    computeOut    = new QLCDNumber(11,this);
    convLbl       = new QLabel("F°",this);

    radGroup->addButton(celToFaRadBtn);
    radGroup->addButton(faToCelRadBtn);
    faToCelRadBtn->setChecked(true);
    computeOut->display("--------");
    computeOut->setSegmentStyle(QLCDNumber::Flat);
    tempInput->setValidator( new QDoubleValidator(0, 100, 2, this) );


    QGridLayout *grid = new QGridLayout(this);
    grid->addWidget(celToFaRadBtn,0,0,1,2);
    grid->addWidget(faToCelRadBtn,1,0,1,2);
    grid->addWidget(tempInput,2,0);
    grid->addWidget(convLbl,2,1);
    grid->addWidget(computeOut,2,2);
    grid->addWidget(reInitBtn,3,0);
    grid->addWidget(quitBtn,3,1);
    grid->addWidget(computeBtn,3,2);
    setLayout(grid);


    connect(computeBtn,SIGNAL(clicked()),this,SLOT(onBtnComputeClicked()));
    connect(quitBtn,SIGNAL(clicked()),this,SLOT(onBtnQuitClicked()));
    connect(reInitBtn,SIGNAL(clicked()),this,SLOT(onBtnReInitClicked()));
    connect(radGroup,SIGNAL(buttonToggled(int,bool)),this,SLOT(onConversionChanged(int,bool)));
}

Convert::~Convert()
{

}

void Convert::onConversionChanged(int id,bool isChecked)
{
    if(isChecked && id == -2)
    {
        convLbl->setText("C°");
    }
    else if(isChecked && id == -3)
    {
        convLbl->setText("F°");
    }

}

void Convert::onBtnComputeClicked()
{
    if(celToFaRadBtn->isChecked())
        computeOut->display(QString::number(tempInput->text().toDouble() * 9/5 + 32)+ "F°");
    else
        computeOut->display(QString::number((tempInput->text().toDouble()-32) * 5/9 ) + "C°");
}

void Convert::onBtnQuitClicked()
{

}

void Convert::onBtnReInitClicked()
{

}
<file_sep>/1-LesFormes/mywidget.cpp
#include <QtWidgets>
#include "mywidget.h"

MyWidget::MyWidget(QWidget *parent) : QWidget(parent)
{
    pixmap = new QPixmap("Smiley.jpg");
    image = new QImage("Smiley.jpg");

    setWindowTitle("Les formes");
    setStyleSheet("background-color:white");
    resize(800, 650);
}

void MyWidget::paintEvent(QPaintEvent *)
{
    QPainter painter(this);

    // Peu performant : appelé à chaque rafraichissement !
    // painter.setBrush(Qt::white);
    // painter.setPen(Qt::white);
    // painter.drawRect(0, 0, width(), height());

    painter.setPen(Qt::blue);
    painter.drawText(100, 20, "Les différentes formes avec Qt");

    painter.setPen(Qt::black);
    painter.drawLine(0, 0, width(), height());

    // Dessiner une tranche de gâteau
    QRect rectangle(10, 40, 200, 100);
    // The startAngle and spanAngle must be specified in 1/16th of a degree,
    // i.e. a full circle equals 5760 (16 * 360).
    // Positive values for the angles mean counter-clockwise
    // while negative values mean the clockwise direction.
    // Zero degrees is at the 3 o'clock position.
    int startAngle = 30 * 16;
    int spanAngle = 120 * 16;
    painter.setBrush(Qt::blue);
    painter.drawPie(rectangle, startAngle, spanAngle);

    // Dessiner un rectangle
    painter.setBrush(Qt::red);
    painter.drawRect(10, 100, 200, 100);

    // Dessiner un polygone
    static const QPoint points[4] = {
        QPoint(110, 280),
        QPoint(120, 210),
        QPoint(180, 230),
        QPoint(190, 270)};
    painter.setBrush(Qt::yellow);
    painter.drawPolygon(points, 4);

    // Dessiner un QPixmap
    painter.drawPixmap(10, 280, 50, 50, *pixmap);

    // Dessiner un QImage
    QRect rectangle2(10, 350, 50, 50);
    painter.drawImage(rectangle2, *image);

    // Dessiner un rectangle arrondi
    painter.drawRoundedRect(10, 420, 200, 100, 20.0, 20.0);

    // Dessiner une ellipse
    painter.setBrush(Qt::green);
    painter.drawEllipse(10, 540, 100, 50);

    // Dessiner les textes
    painter.setPen(Qt::black);
    painter.drawText(300, 70, "drawPie");
    painter.drawText(300, 170, "drawRect");
    painter.drawText(300, 250, "drawPolygon");
    painter.drawText(300, 300, "drawPixmap");
    painter.drawText(300, 380, "drawImage");
    painter.drawText(300, 470, "drawRoundedRect");
    painter.drawText(300, 570, "drawEllipse");
    painter.drawText(530, 400, "drawLine");
}
<file_sep>/1-LesFormes/mywidget.h
#ifndef MYWIDGET_H
#define MYWIDGET_H

#include <QWidget>

class MyWidget : public QWidget
{
Q_OBJECT

protected:
    void paintEvent(QPaintEvent *);

public:
    MyWidget(QWidget *parent = 0);

private:
    QPixmap *pixmap;
    QImage *image;
};
#endif
<file_sep>/2-Dessin2D/mywidget.cpp
#include <QPainter>
#include <QPaintEvent>
#include <QPalette>
#include <QWidget>
#include <QDebug>

#include "mywidget.h"

MyWidget::MyWidget(QWidget *parent) : QWidget(parent)
{
    setWindowTitle("Disques");
    resize(400, 300);
    nbPaint = 0;
    dessinEnCours = false;
    // QPalette pal = QPalette(Qt::black, Qt::white);
    // setPalette(pal);
    setStyleSheet("background-color: #E1E1E1");
}

void MyWidget::paintEvent(QPaintEvent *)
{
    QPainter paint(this);
    nbPaint++;
    paint.drawText(10, 20, QString("Nombre d'appels de paintEvent() : %1").arg(nbPaint));
    paint.drawText(10, 35, QString("Nombre de disques : %1").arg(listePoints.size()));

    qDebug() << nbPaint << ": " << point.rx() << ", " << point.ry();

    paint.setPen(Qt::red);
    paint.setBrush(Qt::red);

    foreach(QList<QPoint> l , listeEnsemblePoints)
    {
        for (int i=0; i < l.size()-1; i++)
        {
            paint.drawLine(l.at(i),l.at(i+1));
        }
    }
}

void MyWidget::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton)
    {
        dessinEnCours = true;
        point = event->pos();
        listePoints.append(point);
        listeEnsemblePoints.append(listePoints);
        update();
    }
}

void MyWidget::mouseMoveEvent(QMouseEvent *event)
{
    if ((event->buttons() & Qt::LeftButton))
    {
        point = event->pos();
        listeEnsemblePoints.last().append(point);
        update();
    }
}

void MyWidget::mouseReleaseEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton)
    {
        listePoints.clear();
        update();
    }
}
<file_sep>/serie7exercice3/mainwindow.cpp
#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
    fileMenu = menuBar()->addMenu(tr("&Fichier"));
    fileMenu->addAction(tr("&Ouvrir Dossier"), this, SLOT(openFolder()), tr("Ctrl+N"));
    showMenu = menuBar()->addMenu(tr("&Info"));
    showMenu->addAction(tr("&Ouvrir Dossier"), this, SLOT(currentPictureInfo()), tr("Ctrl+I"));

    currentPictureIndex = 0;

    pictures = new QStringList();

    picZone = new PictureZone(this);
    setDocumentMode(false);
    setCentralWidget(picZone);
    picZone->show();
}

MainWindow::~MainWindow()
{

}

void MainWindow::goToPicture(int index)
{
    picZone->updatePicture(pictures->at(index));
}

void MainWindow::openFolder()
{
    QDir qDirFiles(QFileDialog::getExistingDirectory(this, tr("Open Directory"),
                                                     QDir::homePath(),
                                                     QFileDialog::ShowDirsOnly));

    qDirFiles.setFilter(QDir::Files);
    QFileInfoList files = qDirFiles.entryInfoList();
    foreach (QFileInfo file, files){
        if(file.suffix().contains("jpg") || file.suffix().contains("png") || file.suffix().contains("jpeg"))
            pictures->append(file.absoluteFilePath());
    }

    picZone->updatePicture(pictures->at(currentPictureIndex));
}

void MainWindow::currentPictureInfo()
{
    qDebug() << pictures->at(currentPictureIndex) ;
}
<file_sep>/2-Dessin2D/stable.h
// Utilisation d'entêtes précompilées (PCH)
// Voir #http://qt-project.org/doc/qt-5/qmake-precompiledheaders.html


#ifndef STABLE_H
#define STABLE_H

#if defined __cplusplus
    #include <QApplication>
    #include <QPainter>
    #include <QPaintEvent>
    #include <QPalette>
    #include <QWidget>
#endif

#endif // STABLE_H
<file_sep>/serie7exercice3/mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtWidgets>
#include "picturezone.h"

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    QMenu *fileMenu;
    QMenu *showMenu;
    QStringList *pictures;
    int currentPictureIndex;
    PictureZone *picZone;
public slots:
    //Permet de changer d'image actuelle
    void goToPicture(int index);
    void openFolder();
    void currentPictureInfo();
};

#endif // MAINWINDOW_H
<file_sep>/2-Dessin2D/mywidget.h
#ifndef MYWIDGET_H
#define MYWIDGET_H

#include <QWidget>

class MyWidget : public QWidget
{
Q_OBJECT

protected:
    void paintEvent(QPaintEvent *);
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);

public:
    MyWidget(QWidget *parent = 0);

private:
    QList<QPoint> listePoints;
    QList<QList<QPoint> > listeEnsemblePoints;
    QPoint point;
    int nbPaint;
    bool dessinEnCours;
};

#endif
