Browse Source

Update generated files.

Neal Wilson 10 years ago
parent
commit
223c48355e
10 changed files with 1765 additions and 1282 deletions
  1. 1
    1
      src/abouttypica.cpp
  2. 43
    0
      src/clock.cpp
  3. 29
    0
      src/clock.h
  4. 346
    0
      src/daterangeselector.cpp
  5. 37
    0
      src/daterangeselector.h
  6. 2
    2
      src/draglabel.cpp
  7. 2
    2
      src/draglabel.h
  8. 6
    6
      src/scale.cpp
  9. 2
    2
      src/scale.h
  10. 1297
    1269
      src/typica.cpp

+ 1
- 1
src/abouttypica.cpp View File

@@ -17,7 +17,7 @@ aboutFile.close();
17 17
 setCentralWidget(banner);
18 18
 }
19 19
 
20
-#line 5640 "./typica.w"
20
+#line 5641 "./typica.w"
21 21
 
22 22
 /*:223*/
23 23
 #line 36 "./abouttypica.w"

+ 43
- 0
src/clock.cpp View File

@@ -0,0 +1,43 @@
1
+/*244:*/
2
+#line 52 "./clock.w"
3
+
4
+#include "clock.h"
5
+
6
+/*245:*/
7
+#line 61 "./clock.w"
8
+
9
+Clock::Clock():QObject(NULL)
10
+{
11
+reference.start();
12
+}
13
+
14
+Clock::~Clock()
15
+{
16
+
17
+}
18
+
19
+/*:245*//*246:*/
20
+#line 79 "./clock.w"
21
+
22
+qint64 Clock::timestamp()
23
+{
24
+guard.lock();
25
+qint64 retval= reference.elapsed();
26
+guard.unlock();
27
+emit newTime(retval);
28
+return retval;
29
+}
30
+
31
+void Clock::setEpoch()
32
+{
33
+guard.lock();
34
+reference.restart();
35
+guard.unlock();
36
+emit newTime(0);
37
+}
38
+
39
+/*:246*/
40
+#line 55 "./clock.w"
41
+
42
+
43
+/*:244*/

+ 29
- 0
src/clock.h View File

@@ -0,0 +1,29 @@
1
+/*243:*/
2
+#line 24 "./clock.w"
3
+
4
+#include <QElapsedTimer> 
5
+#include <QMutex> 
6
+#include <QObject> 
7
+
8
+#ifndef ClockHeader
9
+#define ClockHeader
10
+
11
+class Clock:public QObject
12
+{
13
+Q_OBJECT
14
+public:
15
+Clock();
16
+~Clock();
17
+qint64 timestamp();
18
+public slots:
19
+void setEpoch();
20
+signals:
21
+void newTime(qint64 time);
22
+private:
23
+QElapsedTimer reference;
24
+QMutex guard;
25
+};
26
+
27
+#endif
28
+
29
+/*:243*/

+ 346
- 0
src/daterangeselector.cpp View File

@@ -0,0 +1,346 @@
1
+/*603:*/
2
+#line 66 "./daterangeselector.w"
3
+
4
+#include <QCalendarWidget> 
5
+#include <QPushButton> 
6
+#include <QBoxLayout> 
7
+#include <QLabel> 
8
+#include <QToolButton> 
9
+#include <QApplication> 
10
+#include <QDesktopWidget> 
11
+
12
+#include "daterangeselector.h"
13
+
14
+/*604:*/
15
+#line 86 "./daterangeselector.w"
16
+
17
+class CustomDateRangePopup:public QWidget
18
+{
19
+Q_OBJECT
20
+public:
21
+CustomDateRangePopup(QWidget*parent= NULL);
22
+public slots:
23
+void applyRange();
24
+signals:
25
+void hidingPopup();
26
+protected:
27
+virtual void hideEvent(QHideEvent*event);
28
+private slots:
29
+void validateRange();
30
+private:
31
+QCalendarWidget*startDateSelector;
32
+QCalendarWidget*endDateSelector;
33
+QPushButton*applyButton;
34
+};
35
+
36
+/*:604*/
37
+#line 77 "./daterangeselector.w"
38
+
39
+/*605:*/
40
+#line 110 "./daterangeselector.w"
41
+
42
+CustomDateRangePopup::CustomDateRangePopup(QWidget*parent):
43
+QWidget(parent,Qt::Popup),startDateSelector(new QCalendarWidget),
44
+endDateSelector(new QCalendarWidget),applyButton(new QPushButton(tr("Apply")))
45
+{
46
+setAttribute(Qt::WA_WindowPropagation);
47
+
48
+QVBoxLayout*outerLayout= new QVBoxLayout;
49
+QHBoxLayout*calendarsLayout= new QHBoxLayout;
50
+QVBoxLayout*startDateLayout= new QVBoxLayout;
51
+QVBoxLayout*endDateLayout= new QVBoxLayout;
52
+QHBoxLayout*buttonLayout= new QHBoxLayout;
53
+QLabel*startDateLabel= new QLabel(tr("From"));
54
+QLabel*endDateLabel= new QLabel(tr("To"));
55
+startDateSelector->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
56
+endDateSelector->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
57
+DateRangeSelector*selector= qobject_cast<DateRangeSelector*> (parent);
58
+if(parent){
59
+QStringList range= selector->currentRange().toStringList();
60
+startDateSelector->setSelectedDate(QDate::fromString(range.first(),Qt::ISODate));
61
+endDateSelector->setSelectedDate(QDate::fromString(range.last(),Qt::ISODate));
62
+}
63
+connect(startDateSelector,SIGNAL(selectionChanged()),this,SLOT(validateRange()));
64
+connect(endDateSelector,SIGNAL(selectionChanged()),this,SLOT(validateRange()));
65
+
66
+startDateLayout->addWidget(startDateLabel);
67
+startDateLayout->addWidget(startDateSelector);
68
+endDateLayout->addWidget(endDateLabel);
69
+endDateLayout->addWidget(endDateSelector);
70
+
71
+connect(applyButton,SIGNAL(clicked()),this,SLOT(applyRange()));
72
+
73
+buttonLayout->addStretch();
74
+buttonLayout->addWidget(applyButton);
75
+
76
+calendarsLayout->addLayout(startDateLayout);
77
+calendarsLayout->addLayout(endDateLayout);
78
+outerLayout->addLayout(calendarsLayout);
79
+outerLayout->addLayout(buttonLayout);
80
+setLayout(outerLayout);
81
+}
82
+
83
+/*:605*//*606:*/
84
+#line 158 "./daterangeselector.w"
85
+
86
+void CustomDateRangePopup::hideEvent(QHideEvent*)
87
+{
88
+emit hidingPopup();
89
+}
90
+
91
+/*:606*//*607:*/
92
+#line 167 "./daterangeselector.w"
93
+
94
+void CustomDateRangePopup::applyRange()
95
+{
96
+DateRangeSelector*selector= qobject_cast<DateRangeSelector*> (parentWidget());
97
+if(selector)
98
+{
99
+selector->setCustomRange(QVariant(QStringList()<<
100
+startDateSelector->selectedDate().toString(Qt::ISODate)<<
101
+endDateSelector->selectedDate().toString(Qt::ISODate)));
102
+}
103
+hide();
104
+}
105
+
106
+/*:607*//*608:*/
107
+#line 184 "./daterangeselector.w"
108
+
109
+void CustomDateRangePopup::validateRange()
110
+{
111
+if(startDateSelector->selectedDate()> endDateSelector->selectedDate())
112
+{
113
+applyButton->setEnabled(false);
114
+}
115
+else
116
+{
117
+applyButton->setEnabled(true);
118
+}
119
+}
120
+
121
+/*:608*/
122
+#line 78 "./daterangeselector.w"
123
+
124
+/*609:*/
125
+#line 202 "./daterangeselector.w"
126
+
127
+DateRangeSelector::DateRangeSelector(QWidget*parent):
128
+QWidget(parent),quickSelector(new QComboBox(this)),
129
+customRangeSelector(NULL),lastIndex(0)
130
+{
131
+connect(quickSelector,SIGNAL(currentIndexChanged(int)),this,SLOT(updateRange(int)));
132
+
133
+QDate currentDate= QDate::currentDate();
134
+
135
+QHBoxLayout*layout= new QHBoxLayout;
136
+/*610:*/
137
+#line 231 "./daterangeselector.w"
138
+
139
+quickSelector->addItem("Yesterday",QVariant(QStringList()<<
140
+currentDate.addDays(-1).toString(Qt::ISODate)));
141
+quickSelector->addItem("Today",QVariant(QStringList()<<
142
+currentDate.toString(Qt::ISODate)));
143
+quickSelector->insertSeparator(quickSelector->count());
144
+quickSelector->addItem("This Week",QVariant(QStringList()<<
145
+(currentDate.dayOfWeek()%7?
146
+currentDate.addDays(-currentDate.dayOfWeek()).toString(Qt::ISODate):
147
+currentDate.toString(Qt::ISODate))<<
148
+currentDate.addDays(6-(currentDate.dayOfWeek()%7)).toString(Qt::ISODate)));
149
+quickSelector->addItem("This Week to Date",currentDate.dayOfWeek()%7?
150
+QVariant(QStringList()<<
151
+currentDate.addDays(-currentDate.dayOfWeek()).toString(Qt::ISODate)<<
152
+currentDate.toString(Qt::ISODate)):
153
+QVariant(QStringList()<<currentDate.toString(Qt::ISODate)));
154
+quickSelector->addItem("Last Week",QVariant(QStringList()<<
155
+currentDate.addDays(-(currentDate.dayOfWeek()%7)-7).toString(Qt::ISODate)<<
156
+currentDate.addDays(-(currentDate.dayOfWeek()%7)-1).toString(Qt::ISODate)));
157
+quickSelector->addItem("Last 7 Days",QVariant(QStringList()<<
158
+currentDate.addDays(-6).toString(Qt::ISODate)<<
159
+currentDate.toString(Qt::ISODate)));
160
+quickSelector->insertSeparator(quickSelector->count());
161
+quickSelector->addItem("This Month",QVariant(QStringList()<<
162
+QDate(currentDate.year(),currentDate.month(),1).toString(Qt::ISODate)<<
163
+QDate(currentDate.year(),currentDate.month(),
164
+currentDate.daysInMonth()).toString(Qt::ISODate)));
165
+quickSelector->addItem("This Month to Date",(currentDate.day()==1?
166
+(QVariant(QStringList()<<currentDate.toString(Qt::ISODate))):
167
+(QVariant(QStringList()<<
168
+QDate(currentDate.year(),currentDate.month(),1).toString(Qt::ISODate)<<
169
+currentDate.toString(Qt::ISODate)))));
170
+quickSelector->addItem("Last Four Weeks",QVariant(QStringList()<<
171
+currentDate.addDays(-27).toString(Qt::ISODate)<<
172
+currentDate.toString(Qt::ISODate)));
173
+quickSelector->addItem("Last 30 Days",QVariant(QStringList()<<
174
+currentDate.addDays(-29).toString(Qt::ISODate)<<
175
+currentDate.toString(Qt::ISODate)));
176
+quickSelector->insertSeparator(quickSelector->count());
177
+quickSelector->addItem("This Quarter",QVariant(QStringList()<<
178
+QDate(currentDate.year(),currentDate.month()-((currentDate.month()-1)%3),1).toString(Qt::ISODate)<<
179
+(currentDate.month()> 9?
180
+QDate(currentDate.year(),12,31).toString(Qt::ISODate):
181
+QDate(currentDate.year(),currentDate.month()-((currentDate.month()-1)%3)+3,1).addDays(-1).toString(Qt::ISODate))));
182
+quickSelector->addItem("This Quarter to Date",
183
+(currentDate.day()==1&&(currentDate.month()-1)%3==0)?
184
+QVariant(QStringList()<<currentDate.toString(Qt::ISODate)):
185
+QVariant(QStringList()<<
186
+QDate(currentDate.year(),currentDate.month()-((currentDate.month()-1)%3),1).toString(Qt::ISODate)<<
187
+currentDate.toString(Qt::ISODate)));
188
+quickSelector->addItem("Last Quarter",currentDate.month()<4?
189
+QVariant(QStringList()<<
190
+QDate(currentDate.year()-1,10,1).toString(Qt::ISODate)<<
191
+QDate(currentDate.year()-1,12,31).toString(Qt::ISODate)):
192
+QVariant(QStringList()<<
193
+QDate(currentDate.year(),currentDate.month()-((currentDate.month()-1)%3)-3,1).toString(Qt::ISODate)<<
194
+QDate(currentDate.year(),currentDate.month()-((currentDate.month()-1)%3),1).addDays(-1).toString(Qt::ISODate)));
195
+quickSelector->addItem("Last 90 Days",QVariant(QStringList()<<
196
+currentDate.addDays(-89).toString(Qt::ISODate)<<
197
+currentDate.toString(Qt::ISODate)));
198
+quickSelector->insertSeparator(quickSelector->count());
199
+quickSelector->addItem("This Year",QVariant(QStringList()<<
200
+QDate(currentDate.year(),1,1).toString(Qt::ISODate)<<
201
+QDate(currentDate.year(),12,31).toString(Qt::ISODate)));
202
+quickSelector->addItem("This Year to Date",(currentDate.dayOfYear()==1)?
203
+QVariant(QStringList()<<currentDate.toString(Qt::ISODate)):
204
+QVariant(QStringList()<<QDate(currentDate.year(),1,1).toString(Qt::ISODate)<<
205
+currentDate.toString(Qt::ISODate)));
206
+quickSelector->addItem("Last Year",QVariant(QStringList()<<
207
+QDate(currentDate.year()-1,1,1).toString(Qt::ISODate)<<
208
+QDate(currentDate.year()-1,12,31).toString(Qt::ISODate)));
209
+quickSelector->addItem("Last 365 Days",QVariant(QStringList()<<
210
+currentDate.addDays(-364).toString(Qt::ISODate)<<
211
+currentDate.toString(Qt::ISODate)));
212
+quickSelector->insertSeparator(quickSelector->count());
213
+quickSelector->addItem("Lifetime");
214
+quickSelector->addItem("Custom");
215
+
216
+/*:610*/
217
+#line 212 "./daterangeselector.w"
218
+
219
+QToolButton*customButton= new QToolButton;
220
+customButton->setIcon(QIcon::fromTheme("office-calendar",
221
+QIcon(":/resources/icons/tango/scalable/apps/office-calendar.svg")));
222
+layout->addWidget(quickSelector);
223
+layout->addWidget(customButton);
224
+setLayout(layout);
225
+
226
+connect(customButton,SIGNAL(clicked()),this,SLOT(toggleCustom()));
227
+}
228
+
229
+/*:609*//*611:*/
230
+#line 314 "./daterangeselector.w"
231
+
232
+void DateRangeSelector::updateRange(int index)
233
+{
234
+if(index!=lastIndex&&index==quickSelector->count()-1)
235
+{
236
+toggleCustom();
237
+}
238
+else
239
+{
240
+lastIndex= index;
241
+emit rangeUpdated(quickSelector->itemData(quickSelector->currentIndex()));
242
+}
243
+}
244
+
245
+/*:611*//*612:*/
246
+#line 331 "./daterangeselector.w"
247
+
248
+void DateRangeSelector::popupHidden()
249
+{
250
+customRangeSelector->deleteLater();
251
+customRangeSelector= NULL;
252
+quickSelector->setCurrentIndex(lastIndex);
253
+}
254
+
255
+/*:612*//*613:*/
256
+#line 342 "./daterangeselector.w"
257
+
258
+void DateRangeSelector::setCustomRange(QVariant range)
259
+{
260
+quickSelector->setItemData(quickSelector->count()-1,range);
261
+emit rangeUpdated(range);
262
+lastIndex= quickSelector->count()-1;
263
+quickSelector->setCurrentIndex(lastIndex);
264
+}
265
+
266
+/*:613*//*614:*/
267
+#line 357 "./daterangeselector.w"
268
+
269
+void DateRangeSelector::toggleCustom()
270
+{
271
+if(!customRangeSelector){
272
+customRangeSelector= new CustomDateRangePopup(this);
273
+QPoint pos= rect().bottomLeft();
274
+QPoint pos2= rect().topLeft();
275
+pos= mapToGlobal(pos);
276
+pos2= mapToGlobal(pos2);
277
+QSize size= customRangeSelector->sizeHint();
278
+QRect screen= QApplication::desktop()->availableGeometry(pos);
279
+if(pos.x()+size.width()> screen.right()){
280
+pos.setX(screen.right()-size.width());
281
+}
282
+pos.setX(qMax(pos.x(),screen.left()));
283
+if(pos.y()+size.height()> screen.bottom()){
284
+pos.setY(pos2.y()-size.height());
285
+}else if(pos.y()<screen.top()){
286
+pos.setY(screen.top());
287
+}
288
+if(pos.y()<screen.top()){
289
+pos.setY(screen.top());
290
+}
291
+if(pos.y()+size.height()> screen.bottom()){
292
+pos.setY(screen.bottom()-size.height());
293
+}
294
+customRangeSelector->move(pos);
295
+customRangeSelector->show();
296
+connect(customRangeSelector,SIGNAL(hidingPopup()),
297
+this,SLOT(popupHidden()));
298
+}
299
+else
300
+{
301
+customRangeSelector->close();
302
+customRangeSelector->deleteLater();
303
+customRangeSelector= NULL;
304
+}
305
+}
306
+
307
+/*:614*//*615:*/
308
+#line 399 "./daterangeselector.w"
309
+
310
+QVariant DateRangeSelector::currentRange()
311
+{
312
+return quickSelector->itemData(lastIndex);
313
+}
314
+
315
+/*:615*//*616:*/
316
+#line 407 "./daterangeselector.w"
317
+
318
+void DateRangeSelector::setCurrentIndex(int index)
319
+{
320
+quickSelector->setCurrentIndex(index);
321
+}
322
+
323
+/*:616*//*617:*/
324
+#line 422 "./daterangeselector.w"
325
+
326
+void DateRangeSelector::setLifetimeRange(QString startDate,QString endDate)
327
+{
328
+quickSelector->setItemData(quickSelector->count()-2,
329
+QVariant(QStringList()<<startDate<<endDate));
330
+}
331
+
332
+/*:617*//*618:*/
333
+#line 432 "./daterangeselector.w"
334
+
335
+void DateRangeSelector::removeIndex(int index)
336
+{
337
+quickSelector->removeItem(index);
338
+}
339
+
340
+/*:618*/
341
+#line 79 "./daterangeselector.w"
342
+
343
+
344
+#include "moc_daterangeselector.cpp"
345
+
346
+/*:603*/

+ 37
- 0
src/daterangeselector.h View File

@@ -0,0 +1,37 @@
1
+/*602:*/
2
+#line 30 "./daterangeselector.w"
3
+
4
+
5
+#include <QComboBox> 
6
+
7
+#ifndef TypicaDateRangeSelectorHeader
8
+#define TypicaDateRangeSelectorHeader
9
+
10
+class CustomDateRangePopup;
11
+
12
+class DateRangeSelector:public QWidget
13
+{
14
+Q_OBJECT
15
+public:
16
+DateRangeSelector(QWidget*parent= NULL);
17
+void setCustomRange(QVariant range);
18
+Q_INVOKABLE QVariant currentRange();
19
+public slots:
20
+void setCurrentIndex(int index);
21
+void setLifetimeRange(QString startDate,QString endDate);
22
+void removeIndex(int index);
23
+signals:
24
+void rangeUpdated(QVariant);
25
+private slots:
26
+void toggleCustom();
27
+void popupHidden();
28
+void updateRange(int index);
29
+private:
30
+QComboBox*quickSelector;
31
+CustomDateRangePopup*customRangeSelector;
32
+int lastIndex;
33
+};
34
+
35
+#endif
36
+
37
+/*:602*/

+ 2
- 2
src/draglabel.cpp View File

@@ -1,4 +1,4 @@
1
-/*842:*/
1
+/*863:*/
2 2
 #line 33 "./scales.w"
3 3
 
4 4
 #include "draglabel.h"
@@ -26,4 +26,4 @@ drag->exec();
26 26
 }
27 27
 }
28 28
 
29
-/*:842*/
29
+/*:863*/

+ 2
- 2
src/draglabel.h View File

@@ -1,4 +1,4 @@
1
-/*841:*/
1
+/*862:*/
2 2
 #line 13 "./scales.w"
3 3
 
4 4
 #ifndef TypicaDragLabelInclude
@@ -17,4 +17,4 @@ void mousePressEvent(QMouseEvent*event);
17 17
 
18 18
 #endif
19 19
 
20
-/*:841*/
20
+/*:862*/

+ 6
- 6
src/scale.cpp View File

@@ -1,4 +1,4 @@
1
-/*848:*/
1
+/*869:*/
2 2
 #line 131 "./scales.w"
3 3
 
4 4
 #include "scale.h"
@@ -10,7 +10,7 @@ QextSerialPort(port,QextSerialPort::EventDriven)
10 10
 connect(this,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
11 11
 }
12 12
 
13
-/*:848*//*849:*/
13
+/*:869*//*870:*/
14 14
 #line 149 "./scales.w"
15 15
 
16 16
 void SerialScale::dataAvailable()
@@ -24,7 +24,7 @@ responseBuffer.clear();
24 24
 }
25 25
 else
26 26
 {
27
-/*850:*/
27
+/*871:*/
28 28
 #line 189 "./scales.w"
29 29
 
30 30
 QStringList responseParts= QString(responseBuffer.simplified()).split(' ');
@@ -53,7 +53,7 @@ unit= Units::Ounce;
53 53
 }
54 54
 emit newMeasurement(weight,unit);
55 55
 
56
-/*:850*/
56
+/*:871*/
57 57
 #line 161 "./scales.w"
58 58
 
59 59
 responseBuffer.clear();
@@ -61,7 +61,7 @@ responseBuffer.clear();
61 61
 }
62 62
 }
63 63
 
64
-/*:849*//*851:*/
64
+/*:870*//*872:*/
65 65
 #line 220 "./scales.w"
66 66
 
67 67
 void SerialScale::tare()
@@ -74,4 +74,4 @@ void SerialScale::weigh()
74 74
 write("!KP\x0D");
75 75
 }
76 76
 
77
-/*:851*/
77
+/*:872*/

+ 2
- 2
src/scale.h View File

@@ -1,4 +1,4 @@
1
-/*847:*/
1
+/*868:*/
2 2
 #line 103 "./scales.w"
3 3
 
4 4
 #ifndef TypicaScaleInclude
@@ -25,4 +25,4 @@ QByteArray responseBuffer;
25 25
 
26 26
 #endif
27 27
 
28
-/*:847*/
28
+/*:868*/

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


Loading…
Cancel
Save