瀏覽代碼

Add option to specify recommended maximum batch size on roaster configuration

Neal Wilson 9 年之前
父節點
當前提交
8c7c14cc7d
共有 1 個檔案被更改,包括 53 行新增2 行删除
  1. 53
    2
      src/typica.w

+ 53
- 2
src/typica.w 查看文件

@@ -16085,6 +16085,9 @@ class RoasterConfWidget : public BasicDeviceConfigurationWidget
16085 16085
                                             const QModelIndex &index);
16086 16086
     @[private slots@]:@/
16087 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 16093
 @ Aside from the ID number used to identify the roaster in the database we also
@@ -16166,7 +16169,26 @@ RoasterConfWidget::RoasterConfWidget(DeviceTreeModel *model, const QModelIndex &
16166 16169
     idLayout->addWidget(idLabel);
16167 16170
     QSpinBox *id = new QSpinBox;
16168 16171
     idLayout->addWidget(id);
16172
+    idLayout->addStretch();
16169 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 16192
     @<Get device configuration data for current node@>@;
16171 16193
     for(int i = 0; i < configData.size(); i++)
16172 16194
     {
@@ -16174,11 +16196,25 @@ RoasterConfWidget::RoasterConfWidget(DeviceTreeModel *model, const QModelIndex &
16174 16196
         if(node.attribute("name") == "databaseid")
16175 16197
         {
16176 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 16213
     updateRoasterId(id->value());
16181 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 16218
     setLayout(layout);
16183 16219
 }
16184 16220
 
@@ -16195,7 +16231,7 @@ QDomElement referenceElement =
16195 16231
 QDomNodeList configData = referenceElement.elementsByTagName("attribute");
16196 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 16235
 configuration document. The |updateAttribute()| method in the base class
16200 16236
 makes this trivial.
16201 16237
 
@@ -16205,6 +16241,21 @@ void RoasterConfWidget::updateRoasterId(int id)
16205 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 16259
 @ Finally we must register the configuration widget so that it can be
16209 16260
 instantiated at the appropriate time.
16210 16261
 

Loading…
取消
儲存