comparison data/fileio/CSVFormat.cpp @ 630:11a664058dd8

* Start revamping the CSV import dialog so as to show a "purpose" for each column. These are estimated from the file now, but changing them does not actually do anything yet.
author Chris Cannam
date Fri, 16 Jul 2010 16:51:39 +0000
parents 35499d48a5d1
children 3a5ee4b6c9ad
comparison
equal deleted inserted replaced
629:35499d48a5d1 630:11a664058dd8
248 int valueCount = 0; 248 int valueCount = 0;
249 for (int i = 0; i < m_columnCount; ++i) { 249 for (int i = 0; i < m_columnCount; ++i) {
250 if (m_columnPurposes[i] == ColumnValue) ++valueCount; 250 if (m_columnPurposes[i] == ColumnValue) ++valueCount;
251 } 251 }
252 252
253 if (valueCount == 2 && timingColumnCount == 1) {
254 // If we have exactly two apparent value columns and only one
255 // timing column, but one value column is integral and the
256 // other is not, guess that whichever one matches the integral
257 // status of the time column is either duration or end time
258 if (m_timingType == ExplicitTiming) {
259 int a = -1, b = -1;
260 for (int i = 0; i < m_columnCount; ++i) {
261 if (m_columnPurposes[i] == ColumnValue) {
262 if (a == -1) a = i;
263 else b = i;
264 }
265 }
266 if ((m_columnQualities[a] & ColumnIntegral) !=
267 (m_columnQualities[b] & ColumnIntegral)) {
268 int timecol = a;
269 if ((m_columnQualities[a] & ColumnIntegral) !=
270 (m_columnQualities[0] & ColumnIntegral)) {
271 timecol = b;
272 }
273 if (m_columnQualities[timecol] & ColumnIncreasing) {
274 // This shouldn't happen; should have been settled above
275 m_columnPurposes[timecol] = ColumnEndTime;
276 } else {
277 m_columnPurposes[timecol] = ColumnDuration;
278 }
279 --valueCount;
280 }
281 }
282 }
283
253 if (valueCount == 0) { 284 if (valueCount == 0) {
254 m_modelType = OneDimensionalModel; 285 m_modelType = OneDimensionalModel;
255 } else if (valueCount == 1) { 286 } else if (valueCount == 1) {
256 m_modelType = TwoDimensionalModel; 287 m_modelType = TwoDimensionalModel;
257 } else { 288 } else {