Completed viewing of recipes, beginning of browsing feature. #6

Merged
andrewlalis merged 1 commits from development into master 2018-03-11 08:35:34 +00:00
22 changed files with 891 additions and 361 deletions
Showing only changes of commit a34d46fa3d - Show all commits

View File

@ -29,7 +29,11 @@ SOURCES += model/recipe/instruction.cpp \
gui/newrecipedialog.cpp \
model/recipe/tags/taglistmodel.cpp \
gui/newDialogs/newingredientdialog.cpp \
gui/newDialogs/newtagdialog.cpp
gui/newDialogs/newtagdialog.cpp \
gui/newDialogs/newunitdialog.cpp \
utils/aspectratiopixmaplabel.cpp \
utils/stringutils.cpp \
openrecipedialog.cpp
HEADERS += model/recipe/instruction.h \
model/recipe/recipe.h \
@ -48,14 +52,20 @@ HEADERS += model/recipe/instruction.h \
gui/newrecipedialog.h \
model/recipe/tags/taglistmodel.h \
gui/newDialogs/newingredientdialog.h \
gui/newDialogs/newtagdialog.h
gui/newDialogs/newtagdialog.h \
gui/newDialogs/newunitdialog.h \
utils/aspectratiopixmaplabel.h \
utils/stringutils.h \
openrecipedialog.h
LIBS += -ldl \
FORMS += gui/mainwindow.ui \
gui/newrecipedialog.ui \
gui/newDialogs/newingredientdialog.ui \
gui/newDialogs/newtagdialog.ui
gui/newDialogs/newtagdialog.ui \
gui/newDialogs/newunitdialog.ui \
openrecipedialog.ui
DISTFILES += \
.gitignore

View File

@ -242,7 +242,7 @@ QPushButton#browseButton:pressed{
<number>0</number>
</property>
<item>
<widget class="QWidget" name="basicInfoPanel" native="true">
<widget class="QWidget" name="titlePanel" native="true">
<property name="font">
<font>
<weight>50</weight>
@ -270,119 +270,6 @@ font: &quot;Noto Sans CJK KR&quot;;</string>
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignLeft">
<widget class="QWidget" name="basicInfoSubPanel" native="true">
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
</font>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QWidget" name="prepTimePanel" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="prepTimeLabel">
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Prep Time:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="cookTimePanel" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="cookTimeLabel">
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Cook Time:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="servingsPanel" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="servingsLabel">
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Servings:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="recipeNameLabel">
<property name="sizePolicy">
@ -419,14 +306,8 @@ font: &quot;Noto Sans CJK KR&quot;;</string>
</widget>
</item>
<item>
<widget class="QWidget" name="displayPanelContent" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<widget class="QWidget" name="allInfoPanel" native="true">
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="spacing">
<number>0</number>
</property>
@ -442,219 +323,78 @@ font: &quot;Noto Sans CJK KR&quot;;</string>
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignLeft">
<widget class="QWidget" name="ingredientsPanel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>16777215</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="ingredientsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="font">
<font>
<family>Noto Sans CJK KR Thin</family>
<pointsize>18</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(194, 196, 233);</string>
</property>
<property name="text">
<string>Ingredients</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="ingredientsListView">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>12</pointsize>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(232, 232, 232);</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="layoutMode">
<enum>QListView::SinglePass</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="instructionsPanel" native="true">
<widget class="QWidget" name="basicData" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
<width>0</width>
<height>40</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="styleSheet">
<string notr="true">background-color: rgb(208, 204, 255);</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="spacing">
<number>0</number>
<number>2</number>
</property>
<property name="leftMargin">
<number>0</number>
<number>2</number>
</property>
<property name="topMargin">
<number>0</number>
<number>2</number>
</property>
<property name="rightMargin">
<number>0</number>
<number>2</number>
</property>
<property name="bottomMargin">
<number>0</number>
<number>2</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="QLabel" name="instructionsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<item>
<widget class="QLabel" name="prepTimeLabel">
<property name="font">
<font>
<family>Noto Sans CJK KR Thin</family>
<pointsize>18</pointsize>
<family>Noto Sans CJK KR Light</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(218, 219, 234);</string>
</property>
<property name="text">
<string>Instructions</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<string>Prep Time:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="instructionsTextEdit">
<property name="font">
<font>
<family>Noto Sans CJK KR Medium</family>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(244, 244, 244);</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="autoFormatting">
<set>QTextEdit::AutoNone</set>
</property>
<property name="lineWrapMode">
<enum>QTextEdit::WidgetWidth</enum>
</property>
<property name="readOnly">
<widget class="QLabel" name="cookTimeLabel">
<property name="enabled">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans CJK KR Medium'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; color:#00ff40;&quot;&gt;This is some &lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:16pt; color:#a33c3e;&quot;&gt;colored text and &lt;/span&gt;&lt;a href=&quot;https://www.google.com&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; text-decoration: underline; color:#0000ff;&quot;&gt;link&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set>
<property name="text">
<string>Cook Time:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="servingsLabel">
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Servings:</string>
</property>
</widget>
</item>
@ -662,23 +402,14 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QWidget" name="imagePanelWidget" native="true">
<widget class="QWidget" name="mainInfoPanel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<layout class="QVBoxLayout" name="imagePanel">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
@ -694,17 +425,372 @@ p, li { white-space: pre-wrap; }
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignLeft">
<widget class="QWidget" name="ingredientsPanel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>16777215</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="ingredientsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="font">
<font>
<family>Noto Sans CJK KR Thin</family>
<pointsize>18</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(194, 196, 233);</string>
</property>
<property name="text">
<string>Ingredients</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="ingredientsListView">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>12</pointsize>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(232, 232, 232);</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="layoutMode">
<enum>QListView::SinglePass</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="imageLabel">
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/images/no_image.png</pixmap>
<widget class="QWidget" name="instructionsPanel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="scaledContents">
<bool>false</bool>
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="QLabel" name="instructionsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="font">
<font>
<family>Noto Sans CJK KR Thin</family>
<pointsize>18</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(218, 219, 234);</string>
</property>
<property name="text">
<string>Instructions</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="instructionsTextEdit">
<property name="font">
<font>
<family>Noto Sans CJK KR Medium</family>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(244, 244, 244);</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="autoFormatting">
<set>QTextEdit::AutoNone</set>
</property>
<property name="lineWrapMode">
<enum>QTextEdit::WidgetWidth</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans CJK KR Medium'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; color:#00ff40;&quot;&gt;This is some &lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:16pt; color:#a33c3e;&quot;&gt;colored text and &lt;/span&gt;&lt;a href=&quot;https://www.google.com&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; text-decoration: underline; color:#0000ff;&quot;&gt;link&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item alignment="Qt::AlignTop">
<widget class="QWidget" name="imageAndTags" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<layout class="QVBoxLayout" name="imagePanel">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="imagePanelWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="AspectRatioPixmapLabel" name="imageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>16777215</height>
</size>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/images/no_image.png</pixmap>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item alignment="Qt::AlignTop">
<widget class="QWidget" name="tagsPanel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(243, 243, 243);</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="tagsLabel">
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>16</pointsize>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="text">
<string>Tags</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="tagsListView">
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>12</pointsize>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
@ -720,6 +806,13 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>AspectRatioPixmapLabel</class>
<extends>QLabel</extends>
<header>utils/aspectratiopixmaplabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>

View File

@ -0,0 +1,33 @@
#include "newunitdialog.h"
#include "ui_newunitdialog.h"
NewUnitDialog::NewUnitDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::NewUnitDialog)
{
ui->setupUi(this);
ui->typeComboBox->clear();
ui->typeComboBox->setItemData(0, "Mass");
ui->typeComboBox->setItemData(1, "Volume");
ui->typeComboBox->setItemData(2, "Length");
ui->typeComboBox->setItemData(3, "Misc");
}
NewUnitDialog::~NewUnitDialog()
{
delete ui;
}
UnitOfMeasure NewUnitDialog::getUnit(){
return UnitOfMeasure(ui->unitNameEdit->text().toLower().toStdString(),
ui->pluralNameEdit->text().toLower().toStdString(),
ui->abbreviationEdit->text().toLower().toStdString(),
this->getSelectedType(),
ui->coefficientSpinBox->value());
}
int NewUnitDialog::getSelectedType(){
return ui->typeComboBox->currentIndex();
}

View File

@ -0,0 +1,27 @@
#ifndef NEWUNITDIALOG_H
#define NEWUNITDIALOG_H
#include <QDialog>
#include "model/recipe/ingredients/unitofmeasure.h"
namespace Ui {
class NewUnitDialog;
}
class NewUnitDialog : public QDialog
{
Q_OBJECT
public:
explicit NewUnitDialog(QWidget *parent = 0);
~NewUnitDialog();
UnitOfMeasure getUnit();
private:
Ui::NewUnitDialog *ui;
int getSelectedType();
};
#endif // NEWUNITDIALOG_H

View File

@ -0,0 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NewUnitDialog</class>
<widget class="QDialog" name="NewUnitDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>240</width>
<height>350</height>
</rect>
</property>
<property name="windowTitle">
<string>New Unit</string>
</property>
<property name="windowIcon">
<iconset resource="../../images.qrc">
<normaloff>:/images/images/icon.png</normaloff>:/images/images/icon.png</iconset>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignTop">
<widget class="QWidget" name="contentPanel" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Unit Name</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="unitNameEdit"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Plural Name</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="pluralNameEdit"/>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Abbreviation</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="abbreviationEdit"/>
</item>
<item>
<widget class="QWidget" name="unitTypePanel" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="typeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="coefficientPanel" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Metric Coefficient</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="coefficientSpinBox">
<property name="maximum">
<double>1000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../images.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>NewUnitDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>NewUnitDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -144,6 +144,7 @@ void NewRecipeDialog::on_newTagButton_clicked(){
RecipeTag tag = d.getTag();
//Temporarily add this to the tags list, and it will be saved if the recipe is saved.
this->tags.push_back(tag);
this->tagsListModel.addTag(tag);
ui->tagsComboBox->clear();
for (unsigned int i = 0; i < this->tags.size(); i++){
QString s = QString::fromStdString(this->tags[i].getValue());
@ -166,3 +167,16 @@ void NewRecipeDialog::on_removeTagButton_clicked(){
this->populateTagsBox();
}
}
void NewRecipeDialog::on_newUnitButton_clicked(){
NewUnitDialog d(this);
d.show();
if (d.exec() == QDialog::Accepted){
UnitOfMeasure u = d.getUnit();
if (!this->recipeDB->storeUnitOfMeasure(u)){
QMessageBox::critical(this, "Error", "Unable to store new unit.");
} else {
this->populateUnitsBox();
}
}
}

View File

@ -13,6 +13,7 @@
#include "gui/newDialogs/newingredientdialog.h"
#include "gui/newDialogs/newtagdialog.h"
#include "gui/newDialogs/newunitdialog.h"
namespace Ui {
class NewRecipeDialog;
@ -54,6 +55,8 @@ class NewRecipeDialog : public QDialog
void on_removeTagButton_clicked();
void on_newUnitButton_clicked();
private:
Ui::NewRecipeDialog *ui;
RecipeDatabase *recipeDB;

View File

@ -155,7 +155,7 @@
<second>0</second>
<year>1999</year>
<month>12</month>
<day>27</day>
<day>26</day>
</datetime>
</property>
<property name="currentSection">
@ -662,6 +662,9 @@
</item>
<item>
<widget class="QWidget" name="imagePanel" native="true">
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<property name="spacing">
<number>0</number>
@ -679,7 +682,13 @@
<number>0</number>
</property>
<item>
<widget class="QLabel" name="imageDisplayLabel">
<widget class="AspectRatioPixmapLabel" name="imageDisplayLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>500</width>
@ -693,7 +702,7 @@
<pixmap resource="../images.qrc">:/images/images/no_image.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -816,6 +825,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>AspectRatioPixmapLabel</class>
<extends>QLabel</extends>
<header>utils/aspectratiopixmaplabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>

View File

@ -12,17 +12,7 @@ QVariant IngredientListModel::data(const QModelIndex &index, int role) const{
int row = index.row();
RecipeIngredient i = this->ingredients[row];
string displayStr;
if (std::ceil(i.getQuantity()) == i.getQuantity()){
//The quantity is an integer and should be casted.
displayStr += std::to_string((int)i.getQuantity());
} else {
float q = i.getQuantity();
displayStr += toString(q);
}
displayStr += " " + i.getUnit().getAbbreviation() + " " + i.getName();
string displayStr = i.toString();
switch(role){
case Qt::DisplayRole:
@ -61,17 +51,3 @@ void IngredientListModel::deleteIngredient(int index){
vector<RecipeIngredient> IngredientListModel::getIngredients(){
return this->ingredients;
}
string toString(float val){
float decimal = std::fmod(val, 1.0f);
int places = 1;
while (std::fmod(decimal * 10, 1.0f) > 0){
decimal *= 10;
places++;
}
char buffer[50];
string arg = "%."+std::to_string(places)+"f";
sprintf(buffer, arg.c_str(), val);
string s = buffer;
return s;
}

View File

@ -28,6 +28,4 @@ private:
};
string toString(float val);
#endif // INGREDIENTLISTMODEL_H

View File

@ -39,5 +39,18 @@ void RecipeIngredient::setUnit(UnitOfMeasure newUnit){
}
void RecipeIngredient::setComment(string newComment){
this->comment = newComment;
this->comment = newComment;
}
string RecipeIngredient::toString(){
string result;
if (std::ceil(this->getQuantity()) == this->getQuantity()){
result += std::to_string((int)this->getQuantity());
} else {
result += StringUtils::toString(this->getQuantity());
}
result += " " + this->getUnit().getAbbreviation() + " " + this->getName();
if (!this->getComment().empty()) result += " ~" + this->getComment();
return result;
}

View File

@ -2,9 +2,11 @@
#define RECIPEINGREDIENT_H
#include <string>
#include <cmath>
#include "model/recipe/ingredients/ingredient.h"
#include "model/recipe/ingredients/unitofmeasure.h"
#include "utils/stringutils.h"
using namespace std;
@ -30,6 +32,7 @@ public:
void setQuantity(float newQuantity);
void setUnit(UnitOfMeasure newUnit);
void setComment(string newComment);
string toString();
private:
float quantity;
UnitOfMeasure unit;

View File

@ -13,10 +13,10 @@ class UnitOfMeasure
{
public:
//Constants Declarations.
static const int MASS = 1;
static const int VOLUME = 2;
static const int LENGTH = 3;
static const int MISC = 4;
static const int MASS = 0;
static const int VOLUME = 1;
static const int LENGTH = 2;
static const int MISC = 3;
//Full constructor.
UnitOfMeasure(string name, string plural, string abbreviation, int type, double coef);

14
openrecipedialog.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "openrecipedialog.h"
#include "ui_openrecipedialog.h"
OpenRecipeDialog::OpenRecipeDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::OpenRecipeDialog)
{
ui->setupUi(this);
}
OpenRecipeDialog::~OpenRecipeDialog()
{
delete ui;
}

22
openrecipedialog.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef OPENRECIPEDIALOG_H
#define OPENRECIPEDIALOG_H
#include <QDialog>
namespace Ui {
class OpenRecipeDialog;
}
class OpenRecipeDialog : public QDialog
{
Q_OBJECT
public:
explicit OpenRecipeDialog(QWidget *parent = 0);
~OpenRecipeDialog();
private:
Ui::OpenRecipeDialog *ui;
};
#endif // OPENRECIPEDIALOG_H

19
openrecipedialog.ui Normal file
View File

@ -0,0 +1,19 @@
<?xml version='1.0'?>
<ui version="4.0">
<class>OpenRecipeDialog</class>
<widget name="OpenRecipeDialog" class="QDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -7,6 +7,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this);
ui->ingredientsListView->setModel(&this->ingredientModel);
ui->tagsListView->setModel(&this->tagsListModel);
}
MainWindow::MainWindow(RecipeDatabase *db, QWidget *parent) : MainWindow(parent){
@ -21,10 +22,15 @@ void MainWindow::loadFromRecipe(Recipe recipe){
setRecipeName(recipe.getName());
setInstruction(recipe.getInstruction());
setIngredients(recipe.getIngredients());
setImage(recipe.getImage());
if (recipe.getImage().isNull()){
setImage(QImage(QString(":/images/images/no_image.png")));
} else {
setImage(recipe.getImage());
}
setPrepTime(recipe.getPrepTime());
setCookTime(recipe.getCookTime());
setServings(recipe.getServings());
setTags(recipe.getTags());
}
void MainWindow::setRecipeName(string name){
@ -52,7 +58,11 @@ void MainWindow::setCookTime(QTime cookTime){
}
void MainWindow::setServings(float servings){
ui->servingsLabel->setText(QString("Servings: ")+QString::fromStdString(toString(servings)));
ui->servingsLabel->setText(QString("Servings: ")+QString::fromStdString(StringUtils::toString(servings)));
}
void MainWindow::setTags(vector<RecipeTag> tags){
this->tagsListModel.setTags(tags);
}
void MainWindow::on_newButton_clicked(){

View File

@ -8,6 +8,7 @@
#include "model/recipe/recipe.h"
#include "model/recipe/ingredients/ingredientlistmodel.h"
#include "gui/newrecipedialog.h"
#include "utils/stringutils.h"
using namespace std;
@ -33,6 +34,7 @@ public:
Ui::MainWindow *ui;
RecipeDatabase *recipeDB;
IngredientListModel ingredientModel;
TagListModel tagsListModel;
//Hidden manipulation methods.
void setRecipeName(string name);
@ -42,6 +44,7 @@ public:
void setPrepTime(QTime prepTime);
void setCookTime(QTime cookTime);
void setServings(float servings);
void setTags(vector<RecipeTag> tags);
};
#endif // MAINWINDOW_H

View File

@ -0,0 +1,36 @@
#include "aspectratiopixmaplabel.h"
AspectRatioPixmapLabel::AspectRatioPixmapLabel(QWidget *parent) :
QLabel(parent)
{
this->setMinimumSize(1,1);
setScaledContents(false);
}
void AspectRatioPixmapLabel::setPixmap ( const QPixmap & p)
{
pix = p;
QLabel::setPixmap(scaledPixmap());
}
int AspectRatioPixmapLabel::heightForWidth( int width ) const
{
return pix.isNull() ? this->height() : ((qreal)pix.height()*width)/pix.width();
}
QSize AspectRatioPixmapLabel::sizeHint() const
{
int w = this->width();
return QSize( w, heightForWidth(w) );
}
QPixmap AspectRatioPixmapLabel::scaledPixmap() const
{
return pix.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
void AspectRatioPixmapLabel::resizeEvent(QResizeEvent * e)
{
if(!pix.isNull())
QLabel::setPixmap(scaledPixmap());
}

View File

@ -0,0 +1,23 @@
#ifndef ASPECTRATIOPIXMAPLABEL_H
#define ASPECTRATIOPIXMAPLABEL_H
#include <QLabel>
#include <QPixmap>
#include <QResizeEvent>
class AspectRatioPixmapLabel : public QLabel
{
Q_OBJECT
public:
explicit AspectRatioPixmapLabel(QWidget *parent = 0);
virtual int heightForWidth( int width ) const;
virtual QSize sizeHint() const;
QPixmap scaledPixmap() const;
public slots:
void setPixmap ( const QPixmap & );
void resizeEvent(QResizeEvent *);
private:
QPixmap pix;
};
#endif // ASPECTRATIOPIXMAPLABEL_H

19
utils/stringutils.cpp Normal file
View File

@ -0,0 +1,19 @@
#include "stringutils.h"
namespace StringUtils{
std::string toString(float val){
float decimal = std::fmod(val, 1.0f);
int places = 1;
while (std::fmod(decimal * 10, 1.0f) > 0){
decimal *= 10;
places++;
}
char buffer[50];
std::string arg = "%."+std::to_string(places)+"f";
sprintf(buffer, arg.c_str(), val);
std::string s = buffer;
return s;
}
}

13
utils/stringutils.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef STRINGUTILS_H
#define STRINGUTILS_H
#include <string>
#include <cmath>
namespace StringUtils{
std::string toString(float val);
}
#endif // STRINGUTILS_H