Merge lp:~par-hellstrom/forssim/loadAndRunTimestampsFromSQL into lp:forssim
- loadAndRunTimestampsFromSQL
- Merge into development
Proposed by
parhe
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~par-hellstrom/forssim/loadAndRunTimestampsFromSQL |
Merge into: | lp:forssim |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~par-hellstrom/forssim/loadAndRunTimestampsFromSQL |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Forsslund Systems | Pending | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
parhe (par-hellstrom) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'FsWisdom/ApplicationNode.cpp' |
2 | --- FsWisdom/ApplicationNode.cpp 2009-05-18 13:52:02 +0000 |
3 | +++ FsWisdom/ApplicationNode.cpp 2009-05-20 08:56:00 +0000 |
4 | @@ -290,6 +290,12 @@ |
5 | return username; |
6 | } |
7 | |
8 | +const QDir& ApplicationNode::getLogDirectory() |
9 | +{ |
10 | + return logDirectory; |
11 | +} |
12 | + |
13 | + |
14 | const QDir& ApplicationNode::getPreviousX3dFilePath() |
15 | { |
16 | return previousX3dFilePath; |
17 | |
18 | === modified file 'FsWisdom/ApplicationNode.h' |
19 | --- FsWisdom/ApplicationNode.h 2009-05-18 11:56:11 +0000 |
20 | +++ FsWisdom/ApplicationNode.h 2009-05-20 08:56:00 +0000 |
21 | @@ -116,6 +116,9 @@ |
22 | /// Get the username of the student |
23 | QString getUsername(); |
24 | |
25 | + /// Get the logdirectory of the student |
26 | + const QDir& getLogDirectory(); |
27 | + |
28 | /** |
29 | * get the previous x3d file the was launched via the "Launch x3d file" tab |
30 | * \return the full file path |
31 | |
32 | === modified file 'FsWisdom/SelectCaseWindow.cpp' |
33 | --- FsWisdom/SelectCaseWindow.cpp 2009-05-18 11:56:11 +0000 |
34 | +++ FsWisdom/SelectCaseWindow.cpp 2009-05-20 08:56:00 +0000 |
35 | @@ -3,7 +3,7 @@ |
36 | using namespace FS; |
37 | |
38 | SelectCaseWindow::SelectCaseWindow(ApplicationNode *applicationNode, QWidget *parent) |
39 | - : QMainWindow(parent) |
40 | +: QMainWindow(parent) |
41 | { |
42 | this->applicationNode = applicationNode; |
43 | ui.setupUi(this); |
44 | @@ -46,6 +46,11 @@ |
45 | QObject::connect(ui.launchCaseWithPlaybackPushButton, SIGNAL(clicked ()), this, SLOT(launchCaseWithPlayback())); |
46 | QObject::connect(ui.launchCaseWithoutPlaybackPushButton, SIGNAL(clicked ()), this, SLOT(launchCaseWithoutPlayback())); |
47 | |
48 | + |
49 | + QObject::connect(ui.caseListWidget, SIGNAL(itemSelectionChanged ()), this, SLOT(updateCaseListTimestampsWidget())); |
50 | + QObject::connect(ui.caseListTimestampsWidget, SIGNAL(itemSelectionChanged ()), this, SLOT(getCurrentTimestampForPlayback())); |
51 | + |
52 | + |
53 | //standardOutputToTextEdit.reset(new QDebugStream(std::cout, ui.standardOutputPlainTextEdit,QDir("stdout.txt"))); |
54 | //standardErrorToTextEdit.reset(new QDebugStream(std::cerr, ui.standardErrorPlainTextEdit,QDir("stderr.txt"))); |
55 | |
56 | @@ -172,3 +177,84 @@ |
57 | applicationNode->launchX3DWithStandardGuiWindow(x3dFilePath, isPlayback, forsCaseVersionId); |
58 | } |
59 | } |
60 | + |
61 | + |
62 | +void SelectCaseWindow::getCurrentTimestampForPlayback() |
63 | +{ |
64 | + //nått jadada |
65 | + //Download currentTimestamp |
66 | + cout<<"Getting the current timestampfile for do be downloaded"<<endl; |
67 | + |
68 | + QStringList stringList; |
69 | + |
70 | + int currentlySelectedRowIndex = ui.caseListTimestampsWidget->currentRow(); |
71 | + |
72 | + if(currentlySelectedRowIndex>=0) |
73 | + { |
74 | + QString selectedTimestamp = ui.caseListTimestampsWidget->item(currentlySelectedRowIndex)->text(); |
75 | + |
76 | + if(applicationNode->getForsDatabase().open()) |
77 | + { |
78 | + const Case& selectedCase = localCaseList->getCaseForSelectedRow(); |
79 | + |
80 | + QSqlQuery query; |
81 | + |
82 | + query.prepare("select timeStampFile from userCase join user on user.userId = userCase.userId join forsCaseVersion on userCase.forsCaseVersionId = forsCaseVersion.forsCaseVersionId join forsCase on forsCase.forsCaseId = forsCaseVersion.forsCaseId where forsCase.name = :caseName && user.name = :userName && userCase.dateAdded = :timestamp;"); |
83 | + query.bindValue(":userName",applicationNode->getUsername()); |
84 | + query.bindValue(":caseName",selectedCase.getName()); |
85 | + query.bindValue(":timestamp",selectedTimestamp); |
86 | + |
87 | + |
88 | + if(query.exec()) |
89 | + { |
90 | + query.next(); |
91 | + QByteArray byteArray = query.value(0).toByteArray(); |
92 | + |
93 | + QString timestampPath = applicationNode->getLogDirectory().path()+"/"+applicationNode->getUsername(); |
94 | + |
95 | + QFile file(timestampPath + QDir::separator() + "timeStamp.nrrd"); |
96 | + if (file.open(QIODevice::WriteOnly)) |
97 | + { |
98 | + file.write(byteArray); |
99 | + file.close(); |
100 | + std::cout << "File added to temp: " << QFileInfo(file).absoluteFilePath().toStdString() << std::endl; |
101 | + } |
102 | + else |
103 | + std::cout << "Failed to write to file: " << QFileInfo(file).absoluteFilePath().toStdString() << std::endl; |
104 | + } |
105 | + else |
106 | + std::cout << "Failed to read archive file from server: " << std::endl; |
107 | + |
108 | + } |
109 | + } |
110 | +} |
111 | + |
112 | + |
113 | + |
114 | +void SelectCaseWindow::updateCaseListTimestampsWidget() |
115 | +{ |
116 | + QStringList stringList; |
117 | + if(applicationNode->getForsDatabase().open()) |
118 | + { |
119 | + const Case& selectedCase = localCaseList->getCaseForSelectedRow(); |
120 | + |
121 | + QSqlQuery query; |
122 | + query.prepare("select dateAdded from userCase join user on user.userId = userCase.userId join forsCaseVersion on userCase.forsCaseVersionId = forsCaseVersion.forsCaseVersionId join forsCase on forsCase.forsCaseId = forsCaseVersion.forsCaseId where forsCase.name = :caseName && user.name = :userName;"); |
123 | + query.bindValue(":userName",applicationNode->getUsername()); |
124 | + query.bindValue(":caseName",selectedCase.getName()); |
125 | + |
126 | + query.exec(); |
127 | + while (query.next()) |
128 | + { |
129 | + stringList<< query.value(0).toString(); |
130 | + } |
131 | + } |
132 | + |
133 | + // display a sorted list of cases in the listWidget |
134 | + ui.caseListTimestampsWidget->clear(); |
135 | + ui.caseListTimestampsWidget->addItems(stringList); |
136 | + ui.caseListTimestampsWidget->setSortingEnabled(true); |
137 | + |
138 | + |
139 | + |
140 | +} |
141 | |
142 | === modified file 'FsWisdom/SelectCaseWindow.h' |
143 | --- FsWisdom/SelectCaseWindow.h 2009-05-18 11:56:11 +0000 |
144 | +++ FsWisdom/SelectCaseWindow.h 2009-05-20 08:56:00 +0000 |
145 | @@ -6,6 +6,7 @@ |
146 | #include "ApplicationNode.h" |
147 | #include "QDebugStream.h" |
148 | |
149 | + |
150 | #include "LocalCaseList.h" |
151 | #include "ServerCaseList.h" |
152 | |
153 | @@ -51,6 +52,11 @@ |
154 | void launchCaseWithPlayback(); |
155 | void launchCaseWithoutPlayback(); |
156 | |
157 | + void updateCaseListTimestampsWidget(); |
158 | + void getCurrentTimestampForPlayback(); |
159 | + |
160 | + |
161 | + |
162 | private: |
163 | Ui::SelectCaseWindowClass ui; |
164 | ApplicationNode* applicationNode; |
165 | |
166 | === modified file 'FsWisdom/SelectCaseWindow.ui' |
167 | --- FsWisdom/SelectCaseWindow.ui 2009-05-14 13:07:11 +0000 |
168 | +++ FsWisdom/SelectCaseWindow.ui 2009-05-20 08:56:00 +0000 |
169 | @@ -5,8 +5,8 @@ |
170 | <rect> |
171 | <x>0</x> |
172 | <y>0</y> |
173 | - <width>696</width> |
174 | - <height>827</height> |
175 | + <width>698</width> |
176 | + <height>831</height> |
177 | </rect> |
178 | </property> |
179 | <property name="sizePolicy" > |
180 | @@ -546,55 +546,72 @@ |
181 | <attribute name="title" > |
182 | <string>Launch Case</string> |
183 | </attribute> |
184 | - <layout class="QVBoxLayout" name="verticalLayout_11" > |
185 | - <item> |
186 | - <widget class="QListWidget" name="caseListWidget" /> |
187 | - </item> |
188 | - <item> |
189 | - <layout class="QHBoxLayout" name="horizontalLayout_12" > |
190 | - <property name="rightMargin" > |
191 | - <number>0</number> |
192 | - </property> |
193 | - <property name="bottomMargin" > |
194 | - <number>0</number> |
195 | - </property> |
196 | - <item> |
197 | - <spacer name="horizontalSpacer_12" > |
198 | - <property name="orientation" > |
199 | - <enum>Qt::Horizontal</enum> |
200 | - </property> |
201 | - <property name="sizeHint" stdset="0" > |
202 | - <size> |
203 | - <width>40</width> |
204 | - <height>20</height> |
205 | - </size> |
206 | - </property> |
207 | - </spacer> |
208 | - </item> |
209 | - <item> |
210 | - <widget class="QPushButton" name="addCasePushButton" > |
211 | - <property name="text" > |
212 | - <string>Add Local Case</string> |
213 | - </property> |
214 | - </widget> |
215 | - </item> |
216 | - <item> |
217 | - <widget class="QPushButton" name="launchCaseWithoutPlaybackPushButton" > |
218 | - <property name="text" > |
219 | - <string>Launch Case without Playback</string> |
220 | - </property> |
221 | - </widget> |
222 | - </item> |
223 | - <item> |
224 | - <widget class="QPushButton" name="launchCaseWithPlaybackPushButton" > |
225 | - <property name="text" > |
226 | - <string>Launch Case with Playback</string> |
227 | - </property> |
228 | - </widget> |
229 | - </item> |
230 | - </layout> |
231 | - </item> |
232 | - </layout> |
233 | + <widget class="QWidget" name="gridLayoutWidget_2" > |
234 | + <property name="geometry" > |
235 | + <rect> |
236 | + <x>10</x> |
237 | + <y>10</y> |
238 | + <width>651</width> |
239 | + <height>401</height> |
240 | + </rect> |
241 | + </property> |
242 | + <layout class="QGridLayout" name="gridLayout_2" > |
243 | + <item row="0" column="0" > |
244 | + <layout class="QGridLayout" name="gridLayout" > |
245 | + <item row="0" column="0" > |
246 | + <widget class="QListWidget" name="caseListWidget" /> |
247 | + </item> |
248 | + <item row="0" column="1" > |
249 | + <widget class="QListWidget" name="caseListTimestampsWidget" /> |
250 | + </item> |
251 | + </layout> |
252 | + </item> |
253 | + <item row="1" column="0" > |
254 | + <layout class="QHBoxLayout" name="horizontalLayout_12" > |
255 | + <property name="rightMargin" > |
256 | + <number>0</number> |
257 | + </property> |
258 | + <property name="bottomMargin" > |
259 | + <number>0</number> |
260 | + </property> |
261 | + <item> |
262 | + <widget class="QPushButton" name="addCasePushButton" > |
263 | + <property name="text" > |
264 | + <string>Add Local Case</string> |
265 | + </property> |
266 | + </widget> |
267 | + </item> |
268 | + <item> |
269 | + <widget class="QPushButton" name="launchCaseWithoutPlaybackPushButton" > |
270 | + <property name="text" > |
271 | + <string>Launch Case without Playback</string> |
272 | + </property> |
273 | + </widget> |
274 | + </item> |
275 | + <item> |
276 | + <spacer name="horizontalSpacer_12" > |
277 | + <property name="orientation" > |
278 | + <enum>Qt::Horizontal</enum> |
279 | + </property> |
280 | + <property name="sizeHint" stdset="0" > |
281 | + <size> |
282 | + <width>40</width> |
283 | + <height>20</height> |
284 | + </size> |
285 | + </property> |
286 | + </spacer> |
287 | + </item> |
288 | + <item> |
289 | + <widget class="QPushButton" name="launchCaseWithPlaybackPushButton" > |
290 | + <property name="text" > |
291 | + <string>Launch Case with Playback</string> |
292 | + </property> |
293 | + </widget> |
294 | + </item> |
295 | + </layout> |
296 | + </item> |
297 | + </layout> |
298 | + </widget> |
299 | </widget> |
300 | <widget class="QWidget" name="tab_6" > |
301 | <attribute name="title" > |
302 | @@ -698,19 +715,6 @@ |
303 | </widget> |
304 | </item> |
305 | <item> |
306 | - <spacer name="verticalSpacer_18" > |
307 | - <property name="orientation" > |
308 | - <enum>Qt::Vertical</enum> |
309 | - </property> |
310 | - <property name="sizeHint" stdset="0" > |
311 | - <size> |
312 | - <width>20</width> |
313 | - <height>40</height> |
314 | - </size> |
315 | - </property> |
316 | - </spacer> |
317 | - </item> |
318 | - <item> |
319 | <layout class="QHBoxLayout" name="horizontalLayout_9" > |
320 | <item> |
321 | <spacer name="horizontalSpacer_6" > |
322 | @@ -747,19 +751,6 @@ |
323 | </item> |
324 | </layout> |
325 | </item> |
326 | - <item> |
327 | - <spacer name="verticalSpacer_5" > |
328 | - <property name="orientation" > |
329 | - <enum>Qt::Vertical</enum> |
330 | - </property> |
331 | - <property name="sizeHint" stdset="0" > |
332 | - <size> |
333 | - <width>20</width> |
334 | - <height>40</height> |
335 | - </size> |
336 | - </property> |
337 | - </spacer> |
338 | - </item> |
339 | </layout> |
340 | </item> |
341 | </layout> |
Added functionality to download and run timestampfiles stored on the sql server.