# HG changeset patch # User Chris Cannam # Date 1279299099 0 # Node ID 11a664058dd85c71b4b3b167000d027c4aaf3547 # Parent 35499d48a5d1070a9789f322704452664c536d0e * 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. diff -r 35499d48a5d1 -r 11a664058dd8 data/fileio/CSVFormat.cpp --- a/data/fileio/CSVFormat.cpp Thu Jul 15 15:27:21 2010 +0000 +++ b/data/fileio/CSVFormat.cpp Fri Jul 16 16:51:39 2010 +0000 @@ -250,6 +250,37 @@ if (m_columnPurposes[i] == ColumnValue) ++valueCount; } + if (valueCount == 2 && timingColumnCount == 1) { + // If we have exactly two apparent value columns and only one + // timing column, but one value column is integral and the + // other is not, guess that whichever one matches the integral + // status of the time column is either duration or end time + if (m_timingType == ExplicitTiming) { + int a = -1, b = -1; + for (int i = 0; i < m_columnCount; ++i) { + if (m_columnPurposes[i] == ColumnValue) { + if (a == -1) a = i; + else b = i; + } + } + if ((m_columnQualities[a] & ColumnIntegral) != + (m_columnQualities[b] & ColumnIntegral)) { + int timecol = a; + if ((m_columnQualities[a] & ColumnIntegral) != + (m_columnQualities[0] & ColumnIntegral)) { + timecol = b; + } + if (m_columnQualities[timecol] & ColumnIncreasing) { + // This shouldn't happen; should have been settled above + m_columnPurposes[timecol] = ColumnEndTime; + } else { + m_columnPurposes[timecol] = ColumnDuration; + } + --valueCount; + } + } + } + if (valueCount == 0) { m_modelType = OneDimensionalModel; } else if (valueCount == 1) { diff -r 35499d48a5d1 -r 11a664058dd8 data/fileio/CSVFormat.h --- a/data/fileio/CSVFormat.h Thu Jul 15 15:27:21 2010 +0000 +++ b/data/fileio/CSVFormat.h Fri Jul 16 16:51:39 2010 +0000 @@ -95,9 +95,12 @@ QString getSeparator() const { return m_separator; } size_t getSampleRate() const { return m_sampleRate; } size_t getWindowSize() const { return m_windowSize; } + int getColumnCount() const { return m_columnCount; } QString::SplitBehavior getSplitBehaviour() const { return m_behaviour; } QList getColumnPurposes() const { return m_columnPurposes; } + + ColumnPurpose getColumnPurpose(int i) { return m_columnPurposes[i]; } void setModelType(ModelType t) { m_modelType = t; } void setTimingType(TimingType t) { m_timingType = t; } @@ -106,10 +109,13 @@ void setSeparator(QString s) { m_separator = s; } void setSampleRate(size_t r) { m_sampleRate = r; } void setWindowSize(size_t s) { m_windowSize = s; } + void setColumnCount(int c) { m_columnCount = c; } void setSplitBehaviour(QString::SplitBehavior b) { m_behaviour = b; } void setColumnPurposes(QList cl) { m_columnPurposes = cl; } + void setColumnPurpose(int i, ColumnPurpose p) { m_columnPurposes[i] = p; } + // read-only; only valid if format has been guessed: QList getColumnQualities() const { return m_columnQualities; }