Completed viewing of recipes, beginning of browsing feature. #6
			
				
			
		
		
		
	
							
								
								
									
										16
									
								
								RecipeDB.pro
								
								
								
								
							
							
						
						
									
										16
									
								
								RecipeDB.pro
								
								
								
								
							| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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: "Noto Sans CJK KR";</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,7 +306,103 @@ font: "Noto Sans CJK KR";</string>
 | 
			
		|||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item>
 | 
			
		||||
        <widget class="QWidget" name="displayPanelContent" native="true">
 | 
			
		||||
        <widget class="QWidget" name="allInfoPanel" native="true">
 | 
			
		||||
         <layout class="QVBoxLayout" name="verticalLayout_7">
 | 
			
		||||
          <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="QWidget" name="basicData" native="true">
 | 
			
		||||
            <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="styleSheet">
 | 
			
		||||
             <string notr="true">background-color: rgb(208, 204, 255);</string>
 | 
			
		||||
            </property>
 | 
			
		||||
            <layout class="QHBoxLayout" name="horizontalLayout_7">
 | 
			
		||||
             <property name="spacing">
 | 
			
		||||
              <number>2</number>
 | 
			
		||||
             </property>
 | 
			
		||||
             <property name="leftMargin">
 | 
			
		||||
              <number>2</number>
 | 
			
		||||
             </property>
 | 
			
		||||
             <property name="topMargin">
 | 
			
		||||
              <number>2</number>
 | 
			
		||||
             </property>
 | 
			
		||||
             <property name="rightMargin">
 | 
			
		||||
              <number>2</number>
 | 
			
		||||
             </property>
 | 
			
		||||
             <property name="bottomMargin">
 | 
			
		||||
              <number>2</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>
 | 
			
		||||
             <item>
 | 
			
		||||
              <widget class="QLabel" name="cookTimeLabel">
 | 
			
		||||
               <property name="enabled">
 | 
			
		||||
                <bool>true</bool>
 | 
			
		||||
               </property>
 | 
			
		||||
               <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>
 | 
			
		||||
             <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="QWidget" name="mainInfoPanel" native="true">
 | 
			
		||||
            <property name="sizePolicy">
 | 
			
		||||
             <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
 | 
			
		||||
              <horstretch>0</horstretch>
 | 
			
		||||
| 
						 | 
				
			
			@ -534,7 +517,7 @@ font: "Noto Sans CJK KR";</string>
 | 
			
		|||
                   <enum>Qt::ScrollBarAlwaysOff</enum>
 | 
			
		||||
                  </property>
 | 
			
		||||
                  <property name="selectionMode">
 | 
			
		||||
                <enum>QAbstractItemView::NoSelection</enum>
 | 
			
		||||
                   <enum>QAbstractItemView::ExtendedSelection</enum>
 | 
			
		||||
                  </property>
 | 
			
		||||
                  <property name="isWrapping" stdset="0">
 | 
			
		||||
                   <bool>true</bool>
 | 
			
		||||
| 
						 | 
				
			
			@ -661,8 +644,8 @@ p, li { white-space: pre-wrap; }
 | 
			
		|||
               </layout>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
          <item>
 | 
			
		||||
           <widget class="QWidget" name="imagePanelWidget" native="true">
 | 
			
		||||
             <item alignment="Qt::AlignTop">
 | 
			
		||||
              <widget class="QWidget" name="imageAndTags" native="true">
 | 
			
		||||
               <property name="sizePolicy">
 | 
			
		||||
                <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
 | 
			
		||||
                 <horstretch>0</horstretch>
 | 
			
		||||
| 
						 | 
				
			
			@ -679,6 +662,24 @@ p, li { white-space: pre-wrap; }
 | 
			
		|||
                <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>
 | 
			
		||||
| 
						 | 
				
			
			@ -695,7 +696,25 @@ p, li { white-space: pre-wrap; }
 | 
			
		|||
                    <number>0</number>
 | 
			
		||||
                   </property>
 | 
			
		||||
                   <item>
 | 
			
		||||
              <widget class="QLabel" name="imageLabel">
 | 
			
		||||
                    <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>
 | 
			
		||||
| 
						 | 
				
			
			@ -710,6 +729,73 @@ p, li { white-space: pre-wrap; }
 | 
			
		|||
                  </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>
 | 
			
		||||
           </widget>
 | 
			
		||||
          </item>
 | 
			
		||||
         </layout>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
| 
						 | 
				
			
			@ -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>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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>
 | 
			
		||||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,6 +28,4 @@ private:
 | 
			
		|||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
string toString(float val);
 | 
			
		||||
 | 
			
		||||
#endif // INGREDIENTLISTMODEL_H
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,3 +41,16 @@ void RecipeIngredient::setUnit(UnitOfMeasure newUnit){
 | 
			
		|||
void RecipeIngredient::setComment(string 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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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>
 | 
			
		||||
| 
						 | 
				
			
			@ -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());
 | 
			
		||||
	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(){
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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());
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
#ifndef STRINGUTILS_H
 | 
			
		||||
#define STRINGUTILS_H
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <cmath>
 | 
			
		||||
 | 
			
		||||
namespace StringUtils{
 | 
			
		||||
 | 
			
		||||
	std::string toString(float val);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif // STRINGUTILS_H
 | 
			
		||||
		Loading…
	
		Reference in New Issue