Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 71 slide preview screen #97

Open
wants to merge 32 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3e00045
Created PresentationModel class.
Jul 22, 2016
16de79d
Changed implementation of presentation model.
Jul 26, 2016
b6a07b6
Created Slide Proxy model, tested it and created qml view to display it.
Jul 28, 2016
2a8548c
Created RoleProvider class and its interface.
Jul 28, 2016
9bf1416
Created Main Window page that displays slides. Fixed presentation mod…
Aug 2, 2016
836886c
Styled slide view a little.
Aug 3, 2016
fffd3bc
Merge branch 'development' into feature-71-SlidePreviewScreen
Aug 3, 2016
665d087
Added FontAwesome icons to slide preview.
Aug 3, 2016
8ccbace
Edited code according to code convention.
Aug 3, 2016
41d65e7
Removed TestScreen and placed slide preview screen on application win…
Aug 4, 2016
4361078
Added files for testing the model.
Aug 4, 2016
c51356e
Connected pandoc-slave module to project.
Aug 4, 2016
5822323
Added git commands to .yml file.
Aug 4, 2016
f1591cb
Added git commands to .yml file.
Aug 4, 2016
d546af9
Added git commands to .yml file.
Aug 4, 2016
3af7a74
Added git commands to .yml file.
Aug 4, 2016
24c953d
Added git commands to .yml file.
Aug 4, 2016
bb7cca5
Changed code according to review. Changed appveyor.yml
Aug 9, 2016
34cd66d
Changed appveyor.yml
Aug 9, 2016
055bdc3
Changed appveyor.yml
Aug 9, 2016
94cd48d
Changed appveyor.yml
Aug 9, 2016
ef6705c
Changed appveyor.yml
Aug 9, 2016
9cff8d2
Changed appveyor.yml
Aug 9, 2016
ea4fa25
Changed appveyor.yml
Aug 9, 2016
0d67480
Fixed crash on 2d slide.
Aug 9, 2016
f55d78c
Fixed invalid indexes issues and applied single return statement prin…
Aug 10, 2016
e0f0394
Changed files accorging to review.
Aug 10, 2016
ccb1d0e
Removed warnings about unused parameters.
Aug 10, 2016
b3940e9
Implemented copy constructor and copy-assignment operator for Slide.
Aug 10, 2016
129a300
Changed according to review.
Aug 10, 2016
27f1795
Added braces for default initialization.
Aug 19, 2016
876d703
Merge pull request #90 from PLLUG/feature-89-PandocSlaveSubmodule
Guitarheroua Aug 19, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "pandoc-slave"]
path = pandoc-slave
url = https://github.com/PLLUG/pandoc-slave.git
9 changes: 8 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
version: 0.0.1-{build}-{branch}

install:
- cmd: cd %APPVEYOR_BUILD_FOLDER%\pllug-presentation-system
- ps: Start-FileDownload 'https://www.qpm.io/download/v0.10.0/windows_386/qpm.exe'
pull_requests:
do_not_increment_build_number: true
environment:
QT_INSTALL_ROOT: C:\Qt\5.7\msvc2015_64
build_script:
- cmd: >-

%QT_INSTALL_ROOT%\bin\qtenv2.bat

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

cd %APPVEYOR_BUILD_FOLDER%\pllug-presentation-system

git submodule -q update --init

qpm install

qmake CONFIG+=release

nmake
Expand Down
1 change: 1 addition & 0 deletions pandoc-slave
Submodule pandoc-slave added at 691a50
30 changes: 29 additions & 1 deletion pllug-presentation-system/main.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QFile>
#include <memory>
#include <QList>
#include <QQmlContext>

#include "domdocumentdivider.h"
#include "htmlimport.h"
#include "presentationelement.h"
#include "presentationelementfactory.h"
#include "presentationmodel.h"
#include "slideproxymodel.h"

int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);

QFile htmlFile("D:/Qt_projects/SUMMERCAMP2016/pps2/pllug-presentation-system-2/tests/auto/resources/multiple_slides.html");
htmlFile.open(QFile::ReadOnly);
QByteArray input = htmlFile.readAll();
htmlFile.close();
std::shared_ptr<PresentationElementFactory> factoryPtr(new PresentationElementFactory());
HtmlImport importObject(factoryPtr);
QList<PresentationElement *> elements = importObject.import(input);
DomDocumentDivider divider;
std::unique_ptr<Presentation> presentation = divider.import(elements);

PresentationModel presentationModel;
presentationModel.setPresentation(presentation.release());
SlideProxyModel slideModel;
slideModel.setSourceModel(&presentationModel);
slideModel.setSlideNumber(0);

QQmlApplicationEngine engine;
engine.addImportPath(QStringLiteral("qrc:/"));
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
engine.rootContext()->setContextProperty("slideModel", &slideModel);
engine.rootContext()->setContextProperty("presentationModel", &presentationModel);
engine.load(QUrl(QLatin1String("qrc:/main.qml")));

return app.exec();
}
3 changes: 3 additions & 0 deletions pllug-presentation-system/pllug-presentation-system.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ QML_IMPORT_PATH =
include(deployment.pri)
include($$PWD/vendor/vendor.pri)

# Pandoc-slave
include($$PWD/../pandoc-slave/pandoc-slave/pandoc-slave/pandoc-slave.pri)

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <QList>

class Presentation;
class QByteArray;
class PresentationElementFactory;
class PresentationElement;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ std::unique_ptr<Presentation> DomDocumentDivider::divideSlides(const QList<Slide
QList<Slide *> DomDocumentDivider::divideSlide(Slide *slide, int elementsNum) const
{
// TODO: Nothing done here yet, as we don't know how to divide a single slide
QList<Slide *> smallerSlides;
smallerSlides.push_back(slide);
return smallerSlides;
Q_UNUSED(elementsNum);
QList<Slide *> rSmallerSlides;
rSmallerSlides.push_back(slide);
return rSmallerSlides;
}
3 changes: 2 additions & 1 deletion pllug-presentation-system/presentation-data/htmlimport.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "htmlimport.h"
#include "abstractpresentationelementfactory.h"
#include "presentationElement.h"
#include "presentationelement.h"

#include <QDomDocument>
#include <QByteArray>
#include <QTextStream>

HtmlImport::HtmlImport(std::shared_ptr<AbstractPresentationElementFactory> presentationElementFactory)
: mPresentationElementFactory(presentationElementFactory)
{
Expand Down
13 changes: 13 additions & 0 deletions pllug-presentation-system/presentation-data/iroleprovider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef IROLEPROVIDER_H
#define IROLEPROVIDER_H

#include <QHash>
#include <QByteArray>

class IRoleProvider
{
public:
virtual QHash<int, QByteArray> roleNameByValue() const = 0;
};

#endif // IROLEPROVIDER_H
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ SOURCES += \
$$PWD/paragraph.cpp \
$$PWD/separator.cpp \
$$PWD/htmlimport.cpp \
$$PWD/presentationelementfactory.cpp
$$PWD/presentationelementfactory.cpp \
$$PWD/presentationmodel.cpp \
$$PWD/slideproxymodel.cpp \
$$PWD/roleprovider.cpp

HEADERS += \
$$PWD/presentation.h \
Expand All @@ -24,6 +27,10 @@ HEADERS += \
$$PWD/separator.h \
$$PWD/htmlimport.h \
$$PWD/abstractpresentationelementfactory.h \
$$PWD/presentationelementfactory.h
$$PWD/presentationelementfactory.h \
$$PWD/presentationmodel.h \
$$PWD/slideproxymodel.h \
$$PWD/iroleprovider.h \
$$PWD/roleprovider.h

INCLUDEPATH += $$PWD
14 changes: 12 additions & 2 deletions pllug-presentation-system/presentation-data/presentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <utility>
#include <algorithm>
#include <QtGlobal>

#include <QDebug>
/*!
* \brief Public constructor.
*/
Expand Down Expand Up @@ -62,6 +62,16 @@ void Presentation::appendSlide(std::unique_ptr<Slide> slide)

Slide *Presentation::slide(int index) const
{
return mSlideList[index];
Slide *rSlide {};
if(index >= 0 && index < mSlideList.count())
{
rSlide = mSlideList[index];
}
else
{
qWarning() << "Warning: Invalid slide index.";
rSlide = new Slide();
}
return rSlide;
}

2 changes: 1 addition & 1 deletion pllug-presentation-system/presentation-data/presentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define PRESENTATION_H

#include <memory>

#include <QVector>

#include "slide.h"
Expand All @@ -27,6 +26,7 @@ class Presentation
void appendSlide(std::unique_ptr<Slide> slide);

Slide *slide(int index) const;

private:
QVector<Slide *> mSlideList;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ PresentationElement::PresentationElement(const QString &html)
{
}

int PresentationElement::x() const
{
return 1;
}

int PresentationElement::y() const
{
return 1;
}

int PresentationElement::width() const
{
return 1;
}

int PresentationElement::height() const
{
return 1;
}

QString PresentationElement::toHtml() const
{
return mContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class PresentationElement
PresentationElement(const QString &html);
virtual ~PresentationElement() = 0;

int x() const;
int y() const;
int width() const;
int height() const;
QString toHtml() const;

protected:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
#include "presentationelementfactory.h"

#include <QString>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include "presentationelement.h"
#include "header.h"
#include "paragraph.h"
#include "separator.h"

#include <QString>
#include <QRegularExpression>
#include <QRegularExpressionMatch>

std::unique_ptr<PresentationElement> PresentationElementFactory::create(const QString &html) const
{
QRegularExpression re("(h[1-6]|hr|p)");
QRegularExpressionMatch match = re.match(html);
std::unique_ptr<PresentationElement> rElement(new Separator("<hr />"));
if(match.hasMatch())
{
QString tag = match.captured();
if(tag == "p")
{
return std::make_unique<Paragraph>(html);
rElement.reset(new Paragraph(html));
}
else if(tag[0] == 'h')
else if(tag == "hr")
{
if(tag[1] == 'r')
{
return std::make_unique<Separator>(html);
}
else
{
return std::make_unique<Header>(html);
}
rElement.reset(new Separator(html));
}
else
{
rElement.reset(new Header(html));
}
}
else
{
return nullptr;
}
return rElement;
}
Loading