Improvements made to recipe objects.
This commit is contained in:
parent
db91d81ec3
commit
3b42d1f418
|
@ -19,7 +19,8 @@ SOURCES += SQLite/sqlite3.c \
|
|||
model/recipe/recipeingredient.cpp \
|
||||
userInterface/mainwindow.cpp \
|
||||
main.cpp \
|
||||
model/database/database.cpp
|
||||
model/database/database.cpp \
|
||||
model/recipe/ingredientlistmodel.cpp
|
||||
|
||||
HEADERS += SQLite/sqlite3.h \
|
||||
SQLite/sqlite3ext.h \
|
||||
|
@ -28,12 +29,12 @@ HEADERS += SQLite/sqlite3.h \
|
|||
model/recipe/recipe.h \
|
||||
model/recipe/recipeingredient.h \
|
||||
userInterface/mainwindow.h \
|
||||
model/database/database.h
|
||||
model/database/database.h \
|
||||
model/recipe/ingredientlistmodel.h
|
||||
|
||||
FORMS += gui/mainwindow.ui
|
||||
|
||||
DISTFILES += \
|
||||
.gitignore
|
||||
|
||||
RESOURCES += \
|
||||
gui/menubuttonstylesheet.qrc
|
||||
RESOURCES +=
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
|
@ -11,7 +14,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
@ -26,177 +29,473 @@
|
|||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<widget class="QWidget" name="mainWidget">
|
||||
<widget class="QWidget" name="menuBarWidget" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>150</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(0, 0, 104)</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="title">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-1</y>
|
||||
<width>151</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Sans Pro Light</family>
|
||||
<pointsize>24</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Recipe DB</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>53</y>
|
||||
<width>151</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="menuButtonLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="newRecipeButton">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Sans Pro Light</family>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);
|
||||
color: rgb(0, 0, 104);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="openRecipeButton">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Sans Pro Light</family>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);
|
||||
color: rgb(0, 0, 104);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="browseButton">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Sans Pro Light</family>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);
|
||||
color: rgb(0, 0, 104);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>149</x>
|
||||
<y>-1</y>
|
||||
<width>861</width>
|
||||
<height>511</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: qlineargradient(spread:pad, x1:0, y1:0.466, x2:1, y2:0.534, stop:0 rgba(0, 55, 104, 255), stop:1 rgba(0, 0, 0, 255));</string>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>false</bool>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>859</width>
|
||||
<height>509</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="QWidget" name="menuPanelWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(210, 222, 255);</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="menuPanel">
|
||||
<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="QWidget" name="menuPanelButtons" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<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="QPushButton" name="newButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Sans Pro Light</family>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(83, 75, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignTop">
|
||||
<widget class="QPushButton" name="openButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Sans Pro Light</family>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(112, 105, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignTop">
|
||||
<widget class="QPushButton" name="browseButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Sans Pro Light</family>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(137, 131, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="displayPanelWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="displayPanel">
|
||||
<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="recipeNameLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Sans Pro Light</family>
|
||||
<pointsize>24</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(219, 216, 216);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Recipe Name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</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">
|
||||
<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::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>Source Sans Pro Light</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="listView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Sans Pro Light</family>
|
||||
<pointsize>16</pointsize>
|
||||
</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="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">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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>Source Sans Pro Light</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="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="lineWrapMode">
|
||||
<enum>QTextEdit::WidgetWidth</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#00ff40;">This is some </span><span style=" font-size:16pt; color:#a33c3e;">colored text and </span><a href="https://www.google.com"><span style=" font-size:8pt; text-decoration: underline; color:#0000ff;">link</span></a></p></body></html></string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QWidget" name="imagePanelWidget" 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>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>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
|
|
71
main.cpp
71
main.cpp
|
@ -1,17 +1,7 @@
|
|||
#include "userInterface/mainwindow.h"
|
||||
#include <QApplication>
|
||||
#include <iostream>
|
||||
#include "SQLite/sqlite3.h"
|
||||
|
||||
static int callback(void* data, int rows, char** argv, char** azColName){
|
||||
int i;
|
||||
fprintf(stderr, "%s: ", (const char*)data);
|
||||
for(i=0; i<rows; i++){
|
||||
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
#include "model/database/database.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -19,64 +9,7 @@ int main(int argc, char *argv[])
|
|||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
sqlite3* db; //Database object.
|
||||
char* zErrMsg = 0; //Error message object.
|
||||
int rc; //Return code from sqlite3 calls.
|
||||
char* sql; //SQL text code is stored here.
|
||||
const char* data = "Callback function called";
|
||||
|
||||
rc = sqlite3_open("test.db", &db);
|
||||
|
||||
if (rc){
|
||||
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
|
||||
return(0);
|
||||
} else {
|
||||
fprintf(stdout, "Opened database successfully\n");
|
||||
}
|
||||
|
||||
//Create sample SQL statement.
|
||||
sql = "DROP TABLE ingredients;"
|
||||
"CREATE TABLE ingredients(" \
|
||||
"id int PRIMARY KEY NOT NULL," \
|
||||
"name varchar NOT NULL," \
|
||||
"foodGroup varchar NOT NULL);";
|
||||
|
||||
//Execute statement.
|
||||
rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
|
||||
|
||||
if (rc != SQLITE_OK){
|
||||
fprintf(stderr, "SQL error: %s\n", zErrMsg);
|
||||
sqlite3_free(zErrMsg);
|
||||
} else {
|
||||
fprintf(stdout, "Table created successfully.\n");
|
||||
}
|
||||
|
||||
//Create some fake data.
|
||||
sql = "INSERT INTO ingredients (id, name, foodGroup) VALUES (1, 'flour', 'grains');" \
|
||||
"INSERT INTO ingredients (id, name, foodGroup) VALUES (2, 'pasta', 'grains');";
|
||||
|
||||
rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
|
||||
|
||||
if (rc != SQLITE_OK){
|
||||
fprintf(stderr, "SQL error: %s\n", zErrMsg);
|
||||
sqlite3_free(zErrMsg);
|
||||
} else {
|
||||
fprintf(stdout, "Records created successfully.\n");
|
||||
}
|
||||
|
||||
//Select data.
|
||||
sql = "SELECT * FROM ingredients;";
|
||||
|
||||
rc = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg);
|
||||
|
||||
if (rc != SQLITE_OK){
|
||||
fprintf(stderr, "SQL error: %s\n", zErrMsg);
|
||||
sqlite3_free(zErrMsg);
|
||||
} else {
|
||||
fprintf(stdout, "Select done successfully.\n");
|
||||
}
|
||||
|
||||
sqlite3_close(db);
|
||||
Database db("test.db");
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,46 @@
|
|||
#include "model/database/database.h"
|
||||
|
||||
Database::Database(){
|
||||
Database::Database(string filename){
|
||||
this->filename = filename;
|
||||
openConnection();
|
||||
if (tableExists("ingredients")){
|
||||
printf("Ingredients table already exists.\n");
|
||||
} else {
|
||||
printf("Couldn't find the ingredients table.\n");
|
||||
}
|
||||
}
|
||||
|
||||
Database::~Database(){
|
||||
closeConnection();
|
||||
}
|
||||
|
||||
void Database::openConnection(){
|
||||
this->returnCode = sqlite3_open(this->filename.c_str(), &this->db);
|
||||
if (this->returnCode){
|
||||
if (this->returnCode || this->db == NULL){
|
||||
this->dbIsOpen = false;
|
||||
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
this->dbIsOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Database::closeConnection(){
|
||||
this->returnCode = sqlite3_close(this->db);
|
||||
this->dbIsOpen = false;
|
||||
}
|
||||
|
||||
bool Database::tableExists(string tableName){
|
||||
if (this->dbIsOpen){
|
||||
this->sql = "SELECT name FROM sqlite_master WHERE type='table' AND name='"+tableName+"';";
|
||||
const char* str = this->sql.c_str();
|
||||
this->returnCode = sqlite3_exec(this->db, str, NULL, 0, &this->errorMsg);
|
||||
if (this->returnCode == SQLITE_ERROR){
|
||||
fprintf(stderr, "Unable to select name from master table list: %s\n", this->errorMsg);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -13,17 +13,26 @@ class Database
|
|||
{
|
||||
public:
|
||||
Database(string filename);
|
||||
~Database();
|
||||
|
||||
void insertIngredient(Ingredient);
|
||||
vector<Ingredient> getIngredients();
|
||||
|
||||
private:
|
||||
//SQL Instance variables.
|
||||
string filename;
|
||||
sqlite3* db;
|
||||
bool dbIsOpen;
|
||||
int returnCode;
|
||||
string sql;
|
||||
char* errorMsg;
|
||||
|
||||
void openConnection();
|
||||
void closeConnection();
|
||||
//Guarantees that all tables from the schema exist.
|
||||
void ensureTablesExist();
|
||||
|
||||
//Utility methods.
|
||||
bool tableExists(string tableName);
|
||||
};
|
||||
|
||||
#endif // DATABASE_H
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#include "model/recipe/ingredientlistmodel.h"
|
||||
|
||||
IngredientListModel::IngredientListModel(){
|
||||
this->ingredients = vector<Ingredient>();
|
||||
}
|
||||
|
||||
int IngredientListModel::rowCount(const QModelIndex &parent){
|
||||
return this->ingredients.size();
|
||||
}
|
||||
|
||||
QVariant IngredientListModel::data(const QModelIndex &index, int role){
|
||||
|
||||
}
|
||||
|
||||
void IngredientListModel::setIngredients(vector<Ingredient> ingredients){
|
||||
this->ingredients = ingredients;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef INGREDIENTLISTMODEL_H
|
||||
#define INGREDIENTLISTMODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include "model/recipe/ingredient.h"
|
||||
|
||||
class IngredientListModel : public QAbstractListModel
|
||||
{
|
||||
public:
|
||||
IngredientListModel();
|
||||
|
||||
//Overridden methods.
|
||||
int rowCount(const QModelIndex &parent = QModelIndex());
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole);
|
||||
|
||||
//Custom methods to handle ingredient data.
|
||||
void setIngredients(vector<Ingredient> ingredients);
|
||||
|
||||
private:
|
||||
vector<Ingredient> ingredients;
|
||||
};
|
||||
|
||||
#endif // INGREDIENTLISTMODEL_H
|
|
@ -1,6 +1,25 @@
|
|||
#include "headers/recipe.h"
|
||||
|
||||
Recipe::Recipe()
|
||||
{
|
||||
#include "model/recipe/recipe.h"
|
||||
|
||||
Recipe::Recipe(){
|
||||
this->name = "NULL";
|
||||
this->ingredients = vector<Ingredient>();
|
||||
this->instructions = vector<Instruction>();
|
||||
}
|
||||
|
||||
Recipe::Recipe(string name, vector<Ingredient> ingredients, vector<Instruction> instructions){
|
||||
this->name = name;
|
||||
this->ingredients = ingredients;
|
||||
this->instructions = instructions;
|
||||
}
|
||||
|
||||
string Recipe::getName(){
|
||||
return this->name;
|
||||
}
|
||||
|
||||
vector<Ingredient> Recipe::getIngredients(){
|
||||
return this->ingredients;
|
||||
}
|
||||
|
||||
vector<Instruction> Recipe::getInstructions(){
|
||||
return this->instructions;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include <string>
|
||||
#include <hash_map>
|
||||
|
||||
#include "headers/ingredient.h"
|
||||
#include "headers/instruction.h"
|
||||
#include "model/recipe/ingredient.h"
|
||||
#include "model/recipe/instruction.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -14,13 +14,17 @@ class Recipe
|
|||
{
|
||||
public:
|
||||
Recipe();
|
||||
Recipe(string name, vector<Ingredient> ingredients, vector<Instruction> instructions);
|
||||
|
||||
string getName();
|
||||
vector<Ingredient> getIngredients();
|
||||
vector<Instruction> getInstructions();
|
||||
private:
|
||||
string name;
|
||||
vector<string> tags;
|
||||
vector<Ingredient> ingredients;
|
||||
vector<Instruction> instructions;
|
||||
|
||||
};
|
||||
|
||||
#endif // RECIPE_H
|
||||
|
|
|
@ -3,12 +3,28 @@
|
|||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui(new Ui::MainWindow){
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
MainWindow::~MainWindow(){
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::loadFromRecipe(Recipe recipe){
|
||||
setRecipeName(recipe.getName());
|
||||
setInstructions(recipe.getInstructions());
|
||||
setIngredients(recipe.getIngredients());
|
||||
}
|
||||
|
||||
void MainWindow::setRecipeName(string name){
|
||||
ui->recipeNameLabel->setText(QString::fromStdString(name));
|
||||
}
|
||||
|
||||
void MainWindow::setInstructions(vector<Instruction> instructions){
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::setIngredients(vector<Ingredient> ingredients){
|
||||
ui->listView
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <string>
|
||||
|
||||
#include "model/recipe/recipe.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
|
@ -15,8 +20,15 @@ public:
|
|||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
//Loads all data from a recipe into the GUI components.
|
||||
void loadFromRecipe(Recipe recipe);
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
//Hidden manipulation methods.
|
||||
void setRecipeName(string name);
|
||||
void setInstructions(vector<Instruction> instructions);
|
||||
void setIngredients(vector<Ingredient> ingredients);
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
Loading…
Reference in New Issue