Browse Source

Add option to specify recommended maximum batch size on roaster configuration

Neal Wilson 9 years ago
parent
commit
8c7c14cc7d
1 changed files with 53 additions and 2 deletions
  1. 53
    2
      src/typica.w

+ 53
- 2
src/typica.w View File

16085
                                             const QModelIndex &index);
16085
                                             const QModelIndex &index);
16086
     @[private slots@]:@/
16086
     @[private slots@]:@/
16087
         void updateRoasterId(int id);
16087
         void updateRoasterId(int id);
16088
+        void updateCapacityCheck(int value);
16089
+        void updateCapacity(const QString &value);
16090
+        void updateCapacityUnit(const QString &value);
16088
 };
16091
 };
16089
 
16092
 
16090
 @ Aside from the ID number used to identify the roaster in the database we also
16093
 @ Aside from the ID number used to identify the roaster in the database we also
16166
     idLayout->addWidget(idLabel);
16169
     idLayout->addWidget(idLabel);
16167
     QSpinBox *id = new QSpinBox;
16170
     QSpinBox *id = new QSpinBox;
16168
     idLayout->addWidget(id);
16171
     idLayout->addWidget(id);
16172
+    idLayout->addStretch();
16169
     layout->addLayout(idLayout);
16173
     layout->addLayout(idLayout);
16174
+    QHBoxLayout *capacityLayout = new QHBoxLayout;
16175
+    QCheckBox *capacityCheckEnabled = new QCheckBox(tr("Maximum batch size:"));
16176
+    QDoubleSpinBox *capacity = new QDoubleSpinBox;
16177
+    capacity->setMinimum(0.0);
16178
+    capacity->setDecimals(3);
16179
+    capacity->setMaximum(999999.999);
16180
+    QComboBox *capacityUnit = new QComboBox;
16181
+    capacityUnit->addItem("g");
16182
+    capacityUnit->addItem("Kg");
16183
+    capacityUnit->addItem("oz");
16184
+    capacityUnit->addItem("Lb");
16185
+    capacityUnit->setCurrentIndex(3);
16186
+    capacityLayout->addWidget(capacityCheckEnabled);
16187
+    capacityLayout->addWidget(capacity);
16188
+    capacityLayout->addWidget(capacityUnit);
16189
+    capacityLayout->addStretch();
16190
+    layout->addLayout(capacityLayout);
16191
+    layout->addStretch();
16170
     @<Get device configuration data for current node@>@;
16192
     @<Get device configuration data for current node@>@;
16171
     for(int i = 0; i < configData.size(); i++)
16193
     for(int i = 0; i < configData.size(); i++)
16172
     {
16194
     {
16174
         if(node.attribute("name") == "databaseid")
16196
         if(node.attribute("name") == "databaseid")
16175
         {
16197
         {
16176
             id->setValue(node.attribute("value").toInt());
16198
             id->setValue(node.attribute("value").toInt());
16177
-            break;
16199
+        }
16200
+        else if(node.attribute("name") == "checkcapacity")
16201
+        {
16202
+            capacityCheckEnabled->setChecked(node.attribute("value") == "true");
16203
+        }
16204
+        else if(node.attribute("name") == "capacity")
16205
+        {
16206
+            capacity->setValue(node.attribute("value").toDouble());
16207
+        }
16208
+        else if(node.attribute("name") == "capacityunit")
16209
+        {
16210
+            capacityUnit->setCurrentIndex(capacityUnit->findText(node.attribute("value")));
16178
         }
16211
         }
16179
     }
16212
     }
16180
     updateRoasterId(id->value());
16213
     updateRoasterId(id->value());
16181
     connect(id, SIGNAL(valueChanged(int)), this, SLOT(updateRoasterId(int)));
16214
     connect(id, SIGNAL(valueChanged(int)), this, SLOT(updateRoasterId(int)));
16215
+    connect(capacityCheckEnabled, SIGNAL(stateChanged(int)), this, SLOT(updateCapacityCheck(int)));
16216
+    connect(capacity, SIGNAL(valueChanged(QString)), this, SLOT(updateCapacity(QString)));
16217
+    connect(capacityUnit, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateCapacityUnit(QString)));
16182
     setLayout(layout);
16218
     setLayout(layout);
16183
 }
16219
 }
16184
 
16220
 
16195
 QDomNodeList configData = referenceElement.elementsByTagName("attribute");
16231
 QDomNodeList configData = referenceElement.elementsByTagName("attribute");
16196
 QDomElement node;
16232
 QDomElement node;
16197
 
16233
 
16198
-@ We need to propagate changes to the ID number field to the device
16234
+@ We need to propagate changes to the configuration fields to the device
16199
 configuration document. The |updateAttribute()| method in the base class
16235
 configuration document. The |updateAttribute()| method in the base class
16200
 makes this trivial.
16236
 makes this trivial.
16201
 
16237
 
16205
     updateAttribute("databaseid", QString("%1").arg(id));
16241
     updateAttribute("databaseid", QString("%1").arg(id));
16206
 }
16242
 }
16207
 
16243
 
16244
+void RoasterConfWidget::updateCapacityCheck(int value)
16245
+{
16246
+    updateAttribute("checkcapacity", value == Qt::Checked ? "true" : "false");
16247
+}
16248
+
16249
+void RoasterConfWidget::updateCapacity(const QString &value)
16250
+{
16251
+    updateAttribute("capacity", value);
16252
+}
16253
+
16254
+void RoasterConfWidget::updateCapacityUnit(const QString &value)
16255
+{
16256
+    updateAttribute("capacityunit", value);
16257
+}
16258
+
16208
 @ Finally we must register the configuration widget so that it can be
16259
 @ Finally we must register the configuration widget so that it can be
16209
 instantiated at the appropriate time.
16260
 instantiated at the appropriate time.
16210
 
16261
 

Loading…
Cancel
Save