Browse Source

Choose tab based on existence of scheduled batches

Neal Wilson 6 years ago
parent
commit
558e8daae1
3 changed files with 367 additions and 345 deletions
  1. 5
    1
      config/Windows/newbatch.xml
  2. 353
    344
      src/typica.cpp
  3. 9
    0
      src/typica.w

+ 5
- 1
config/Windows/newbatch.xml View File

149
             tabs.currentChanged.connect(function(index) {
149
             tabs.currentChanged.connect(function(index) {
150
                 pages.setCurrentIndex(index);
150
                 pages.setCurrentIndex(index);
151
             });
151
             });
152
-            tabs.setCurrentIndex(1);
153
             var batches = findChildObject(this, 'batches');
152
             var batches = findChildObject(this, 'batches');
154
             var filter = findChildObject(this, 'filter');
153
             var filter = findChildObject(this, 'filter');
155
             var filtervalue = findChildObject(this, 'filtervalue');
154
             var filtervalue = findChildObject(this, 'filtervalue');
177
                 updateSchedule();
176
                 updateSchedule();
178
             });
177
             });
179
             updateSchedule();
178
             updateSchedule();
179
+            if(batches.rows() > 0) {
180
+                tabs.setCurrentIndex(0);
181
+            } else {
182
+                tabs.setCurrentIndex(1);
183
+            }
180
             batches.setHeaderData(0, TTR("batchWindow", "ID"));
184
             batches.setHeaderData(0, TTR("batchWindow", "ID"));
181
             batches.setHeaderData(1, TTR("batchWindow", "Roasted Coffee"));
185
             batches.setHeaderData(1, TTR("batchWindow", "Roasted Coffee"));
182
             batches.setHeaderData(2, TTR("batchWindow", "Green Weight"));
186
             batches.setHeaderData(2, TTR("batchWindow", "Green Weight"));

+ 353
- 344
src/typica.cpp
File diff suppressed because it is too large
View File


+ 9
- 0
src/typica.w View File

14201
                                    QScriptEngine *engine);
14201
                                    QScriptEngine *engine);
14202
 QScriptValue SqlQueryView_setHeaderData(QScriptContext *context,
14202
 QScriptValue SqlQueryView_setHeaderData(QScriptContext *context,
14203
                                         QScriptEngine *engine);
14203
                                         QScriptEngine *engine);
14204
+QScriptValue SqlQueryView_rows(QScriptContext *context,
14205
+                               QScriptEngine *engine);
14204
 
14206
 
14205
 @ The script constructor is passed to the host environment.
14207
 @ The script constructor is passed to the host environment.
14206
 
14208
 
14226
     value.setProperty("setHeaderData",
14228
     value.setProperty("setHeaderData",
14227
                       engine->newFunction(SqlQueryView_setHeaderData));
14229
                       engine->newFunction(SqlQueryView_setHeaderData));
14228
     value.setProperty("setQuery", engine->newFunction(SqlQueryView_setQuery));
14230
     value.setProperty("setQuery", engine->newFunction(SqlQueryView_setQuery));
14231
+    value.setProperty("rows", engine->newFunction(SqlQueryView_rows));
14229
 }
14232
 }
14230
 
14233
 
14231
 @ The properties added are simplified wrappers around the class methods.
14234
 @ The properties added are simplified wrappers around the class methods.
14250
     return QScriptValue();
14253
     return QScriptValue();
14251
 }
14254
 }
14252
 
14255
 
14256
+QScriptValue SqlQueryView_rows(QScriptContext *context, QScriptEngine *)
14257
+{
14258
+    SqlQueryView *self = getself<SqlQueryView *>(context);
14259
+    return QScriptValue(self->model()->rowCount());
14260
+}
14261
+
14253
 @** Reporting.
14262
 @** Reporting.
14254
 
14263
 
14255
 \noindent \pn{} version 1.4 added a new type of menu which is designed to
14264
 \noindent \pn{} version 1.4 added a new type of menu which is designed to

Loading…
Cancel
Save