Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
LabPlot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Education
LabPlot
Commits
e0cadaac
Commit
e0cadaac
authored
Apr 18, 2013
by
Alexander Semke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. Moved column related enums from globals.h to AbstractColumn.h.
2. Reduced the dependence on globals.h/cpp.
parent
e6da21f9
Changes
38
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
472 additions
and
532 deletions
+472
-532
src/backend/core/AbstractColumn.cpp
src/backend/core/AbstractColumn.cpp
+10
-10
src/backend/core/AbstractColumn.h
src/backend/core/AbstractColumn.h
+26
-6
src/backend/core/AbstractSimpleFilter.cpp
src/backend/core/AbstractSimpleFilter.cpp
+11
-12
src/backend/core/AbstractSimpleFilter.h
src/backend/core/AbstractSimpleFilter.h
+5
-5
src/backend/core/Folder.cpp
src/backend/core/Folder.cpp
+1
-1
src/backend/core/column/Column.cpp
src/backend/core/column/Column.cpp
+53
-36
src/backend/core/column/Column.h
src/backend/core/column/Column.h
+16
-14
src/backend/core/column/ColumnPrivate.cpp
src/backend/core/column/ColumnPrivate.cpp
+121
-121
src/backend/core/column/ColumnPrivate.h
src/backend/core/column/ColumnPrivate.h
+10
-10
src/backend/core/column/columncommands.cpp
src/backend/core/column/columncommands.cpp
+28
-28
src/backend/core/column/columncommands.h
src/backend/core/column/columncommands.h
+7
-7
src/backend/core/datatypes/DateTime2DoubleFilter.h
src/backend/core/datatypes/DateTime2DoubleFilter.h
+3
-3
src/backend/core/datatypes/DateTime2StringFilter.cpp
src/backend/core/datatypes/DateTime2StringFilter.cpp
+4
-4
src/backend/core/datatypes/DateTime2StringFilter.h
src/backend/core/datatypes/DateTime2StringFilter.h
+2
-2
src/backend/core/datatypes/DayOfWeek2DoubleFilter.h
src/backend/core/datatypes/DayOfWeek2DoubleFilter.h
+3
-3
src/backend/core/datatypes/Double2DateTimeFilter.h
src/backend/core/datatypes/Double2DateTimeFilter.h
+3
-3
src/backend/core/datatypes/Double2DayOfWeekFilter.h
src/backend/core/datatypes/Double2DayOfWeekFilter.h
+3
-3
src/backend/core/datatypes/Double2MonthFilter.h
src/backend/core/datatypes/Double2MonthFilter.h
+3
-3
src/backend/core/datatypes/Double2StringFilter.h
src/backend/core/datatypes/Double2StringFilter.h
+3
-3
src/backend/core/datatypes/Month2DoubleFilter.h
src/backend/core/datatypes/Month2DoubleFilter.h
+3
-3
src/backend/core/datatypes/String2DateTimeFilter.cpp
src/backend/core/datatypes/String2DateTimeFilter.cpp
+4
-4
src/backend/core/datatypes/String2DateTimeFilter.h
src/backend/core/datatypes/String2DateTimeFilter.h
+1
-1
src/backend/core/datatypes/String2DayOfWeekFilter.h
src/backend/core/datatypes/String2DayOfWeekFilter.h
+3
-3
src/backend/core/datatypes/String2DoubleFilter.h
src/backend/core/datatypes/String2DoubleFilter.h
+3
-3
src/backend/core/datatypes/String2MonthFilter.h
src/backend/core/datatypes/String2MonthFilter.h
+3
-3
src/backend/core/globals.cpp
src/backend/core/globals.cpp
+0
-73
src/backend/core/globals.h
src/backend/core/globals.h
+0
-24
src/backend/datasources/filters/AsciiFilter.cpp
src/backend/datasources/filters/AsciiFilter.cpp
+6
-6
src/backend/spreadsheet/Spreadsheet.cpp
src/backend/spreadsheet/Spreadsheet.cpp
+25
-25
src/backend/spreadsheet/Spreadsheet.h
src/backend/spreadsheet/Spreadsheet.h
+2
-2
src/backend/spreadsheet/SpreadsheetModel.cpp
src/backend/spreadsheet/SpreadsheetModel.cpp
+13
-13
src/backend/worksheet/plots/cartesian/XYCurve.cpp
src/backend/worksheet/plots/cartesian/XYCurve.cpp
+19
-19
src/commonfrontend/spreadsheet/SpreadsheetView.cpp
src/commonfrontend/spreadsheet/SpreadsheetView.cpp
+24
-24
src/commonfrontend/spreadsheet/SpreadsheetView.h
src/commonfrontend/spreadsheet/SpreadsheetView.h
+4
-4
src/kdefrontend/dockwidgets/ColumnDock.cpp
src/kdefrontend/dockwidgets/ColumnDock.cpp
+32
-33
src/kdefrontend/dockwidgets/ColumnDock.h
src/kdefrontend/dockwidgets/ColumnDock.h
+1
-1
src/kdefrontend/dockwidgets/XYCurveDock.cpp
src/kdefrontend/dockwidgets/XYCurveDock.cpp
+15
-15
src/kdefrontend/dockwidgets/XYCurveDock.h
src/kdefrontend/dockwidgets/XYCurveDock.h
+2
-2
No files found.
src/backend/core/AbstractColumn.cpp
View file @
e0cadaac
/***************************************************************************
File : AbstractColumn.cpp
Project :
SciDAVis
Project :
AbstractColumn
Description : Interface definition for data with column logic
--------------------------------------------------------------------
Copyright : (C) 2007,2008 Tilman Benkert (thzs*gmx.net)
...
...
@@ -95,7 +95,7 @@ AbstractColumn::AbstractColumn(const QString &name) : AbstractAspect(name),
*/
/**
* \fn
SciDAVis
::ColumnMode AbstractColumn::columnMode() const
* \fn
AbstractColumn
::ColumnMode AbstractColumn::columnMode() const
* \brief Return the column mode
*
* This function is most used by tables but can also be used
...
...
@@ -109,7 +109,7 @@ AbstractColumn::AbstractColumn(const QString &name) : AbstractAspect(name),
* This sets the column mode and, if
* necessary, converts it to another datatype.
*/
void
AbstractColumn
::
setColumnMode
(
SciDAVis
::
ColumnMode
)
{}
void
AbstractColumn
::
setColumnMode
(
AbstractColumn
::
ColumnMode
)
{}
/**
* \brief Copy another column of the same type
...
...
@@ -185,14 +185,14 @@ void AbstractColumn::handleRowRemoval(int first, int count) {
}
/**
* \fn
SciDAVis
::PlotDesignation AbstractColumn::plotDesignation() const
* \fn
AbstractColumn
::PlotDesignation AbstractColumn::plotDesignation() const
* \brief Return the column plot designation
*/
/**
* \brief Set the column plot designation
*/
void
AbstractColumn
::
setPlotDesignation
(
SciDAVis
::
PlotDesignation
pd
)
{
void
AbstractColumn
::
setPlotDesignation
(
AbstractColumn
::
PlotDesignation
pd
)
{
Q_UNUSED
(
pd
)
}
...
...
@@ -206,13 +206,13 @@ void AbstractColumn::clear() {}
*/
bool
AbstractColumn
::
isValid
(
int
row
)
const
{
switch
(
columnMode
())
{
case
SciDAVis
::
Numeric
:
case
AbstractColumn
::
Numeric
:
return
!
isnan
(
valueAt
(
row
));
case
SciDAVis
::
Text
:
case
AbstractColumn
::
Text
:
return
!
textAt
(
row
).
isNull
();
case
SciDAVis
::
DateTime
:
case
SciDAVis
::
Month
:
case
SciDAVis
::
Day
:
case
AbstractColumn
::
DateTime
:
case
AbstractColumn
::
Month
:
case
AbstractColumn
::
Day
:
return
dateTimeAt
(
row
).
isValid
();
}
...
...
src/backend/core/AbstractColumn.h
View file @
e0cadaac
/***************************************************************************
File : AbstractColumn.h
Project :
SciDAVis
Project :
AbstractColumn
Description : Interface definition for data with column logic
--------------------------------------------------------------------
Copyright : (C) 2013 by Alexander Semke (alexander.semke*web.de)
Copyright : (C) 2007,2008 Tilman Benkert (thzs*gmx.net)
(replace * with @ in the email addresses)
...
...
@@ -30,7 +31,6 @@
#ifndef ABSTRACTCOLUMN_H
#define ABSTRACTCOLUMN_H
#include "backend/core/globals.h"
#include "backend/core/AbstractAspect.h"
class
AbstractSimpleFilter
;
...
...
@@ -45,18 +45,38 @@ template<class T> class Interval;
class
AbstractColumn
:
public
AbstractAspect
{
Q_OBJECT
Q_ENUMS
(
PlotDesignation
)
Q_ENUMS
(
ColumnMode
)
public:
enum
PlotDesignation
{
noDesignation
=
0
,
X
=
1
,
Y
=
2
,
Z
=
3
,
xErr
=
4
,
yErr
=
5
};
enum
ColumnMode
{
Numeric
=
0
,
Text
=
1
,
Month
=
4
,
Day
=
5
,
DateTime
=
6
// 2 and 3 are skipped to avoid problems with old obsolete values
};
class
Private
;
AbstractColumn
(
const
QString
&
name
);
virtual
~
AbstractColumn
()
{
aboutToBeDestroyed
(
this
);}
virtual
bool
isReadOnly
()
const
{
return
true
;
};
virtual
SciDAVis
::
ColumnMode
columnMode
()
const
=
0
;
virtual
void
setColumnMode
(
SciDAVis
::
ColumnMode
m
ode
);
virtual
SciDAVis
::
PlotDesignation
plotDesignation
()
const
=
0
;
virtual
void
setPlotDesignation
(
SciDAVis
::
PlotDesignation
pd
);
virtual
ColumnMode
columnMode
()
const
=
0
;
virtual
void
setColumnMode
(
AbstractColumn
::
ColumnM
ode
);
virtual
PlotDesignation
plotDesignation
()
const
=
0
;
virtual
void
setPlotDesignation
(
AbstractColumn
::
PlotDesignation
);
virtual
bool
copy
(
const
AbstractColumn
*
source
);
virtual
bool
copy
(
const
AbstractColumn
*
source
,
int
source_start
,
int
dest_start
,
int
num_rows
);
...
...
src/backend/core/AbstractSimpleFilter.cpp
View file @
e0cadaac
/***************************************************************************
File : AbstractSimpleFilter.cpp
Project :
SciDAVis
Project :
AbstractColumn
--------------------------------------------------------------------
Copyright : (C) 2007,2008 by Knut Franke, Tilman Benkert
Email (use @ for *) : knut.franke*gmx.de, thzs*gmx.net
...
...
@@ -29,7 +29,6 @@
***************************************************************************/
#include "AbstractSimpleFilter.h"
#include "globals.h"
#include <QtCore/QString>
#include <QtCore/QDateTime>
...
...
@@ -66,10 +65,10 @@
* 03 {
* 04 protected:
* 05 virtual bool inputAcceptable(int, AbstractColumn *source) {
* 06 return (source->columnMode() ==
SciDAVis
::Numeric);
* 06 return (source->columnMode() ==
AbstractColumn
::Numeric);
* 07 }
* 08 public:
* 09 virtual
SciDAVis::ColumnMode columnMode() const { return SciDAVis
::Numeric; }
* 09 virtual
AbstractColumn::ColumnMode columnMode() const { return AbstractColumn
::Numeric; }
* 10
* 11 virtual double valueAt(int row) const {
* 12 if (!m_inputs.value(0)) return 0.0;
...
...
@@ -89,7 +88,7 @@
* fully-functional filter!
*
* Equivalently, you can write 1:1-filters for QString or QDateTime inputs by checking for
*
SciDAVis::TypeQString or SciDAVis
::TypeQDateTime in line 6. You would then use
*
AbstractColumn::TypeQString or AbstractColumn
::TypeQDateTime in line 6. You would then use
* AbstractColumn::textAt(row) or AbstractColumn::dateTimeAt(row) in line 13 to access the input data.
* For QString output, you need to implement AbstractColumn::textAt(row).
* For QDateTime output, you have to implement three methods:
...
...
@@ -110,10 +109,10 @@
* 03 {
* 04 protected:
* 05 virtual bool inputAcceptable(int, AbstractColumn *source) {
* 06 return (source->columnMode() ==
SciDAVis
::Numeric);
* 06 return (source->columnMode() ==
AbstractColumn
::Numeric);
* 07 }
* 08 public:
* 09 virtual
SciDAVis::ColumnMode columnMode() const { return SciDAVis
::Numeric; }
* 09 virtual
AbstractColumn::ColumnMode columnMode() const { return AbstractColumn
::Numeric; }
* \endcode
* Even rows (including row 0) get dropped, odd rows are renumbered:
* \code
...
...
@@ -152,10 +151,10 @@ int AbstractSimpleFilter::outputCount() const {
/**
* \brief Copy plot designation of input port 0.
*/
SciDAVis
::
PlotDesignation
AbstractSimpleFilter
::
plotDesignation
()
const
{
AbstractColumn
::
PlotDesignation
AbstractSimpleFilter
::
plotDesignation
()
const
{
return
m_inputs
.
value
(
0
)
?
m_inputs
.
at
(
0
)
->
plotDesignation
()
:
SciDAVis
::
noDesignation
;
AbstractColumn
::
noDesignation
;
}
/**
...
...
@@ -165,11 +164,11 @@ SciDAVis::PlotDesignation AbstractSimpleFilter::plotDesignation() const {
* by plots. The column mode specifies how to interpret
* the values in the column additional to the data type.
*/
SciDAVis
::
ColumnMode
AbstractSimpleFilter
::
columnMode
()
const
{
AbstractColumn
::
ColumnMode
AbstractSimpleFilter
::
columnMode
()
const
{
// calling this function while m_input is empty is a sign of very bad code
// nevertheless it will return some rather meaningless value to
// avoid crashes
return
m_inputs
.
value
(
0
)
?
m_inputs
.
at
(
0
)
->
columnMode
()
:
SciDAVis
::
Text
;
return
m_inputs
.
value
(
0
)
?
m_inputs
.
at
(
0
)
->
columnMode
()
:
AbstractColumn
::
Text
;
}
/**
...
...
@@ -395,7 +394,7 @@ bool AbstractSimpleFilter::load(XmlStreamReader * reader)
//! \class SimpleFilterColumn
////////////////////////////////////////////////////////////////////////////////////////////////////
SciDAVis
::
ColumnMode
SimpleFilterColumn
::
columnMode
()
const
{
AbstractColumn
::
ColumnMode
SimpleFilterColumn
::
columnMode
()
const
{
return
m_owner
->
columnMode
();
}
...
...
src/backend/core/AbstractSimpleFilter.h
View file @
e0cadaac
/***************************************************************************
File : AbstractSimpleFilter.h
Project :
SciDAVis
Project :
AbstractColumn
--------------------------------------------------------------------
Copyright : (C) 2007 by Knut Franke, Tilman Benkert
Email (use @ for *) : knut.franke*gmx.de, thzs*gmx.net
...
...
@@ -47,8 +47,8 @@ class AbstractSimpleFilter : public AbstractFilter
virtual
int
outputCount
()
const
;
virtual
AbstractColumn
*
output
(
int
port
);
virtual
const
AbstractColumn
*
output
(
int
port
)
const
;
virtual
SciDAVis
::
PlotDesignation
plotDesignation
()
const
;
virtual
SciDAVis
::
ColumnMode
columnMode
()
const
;
virtual
AbstractColumn
::
PlotDesignation
plotDesignation
()
const
;
virtual
AbstractColumn
::
ColumnMode
columnMode
()
const
;
virtual
QString
textAt
(
int
row
)
const
;
virtual
QDate
dateAt
(
int
row
)
const
;
virtual
QTime
timeAt
(
int
row
)
const
;
...
...
@@ -85,9 +85,9 @@ class SimpleFilterColumn : public AbstractColumn
public:
SimpleFilterColumn
(
AbstractSimpleFilter
*
owner
)
:
AbstractColumn
(
owner
->
name
()),
m_owner
(
owner
)
{}
virtual
SciDAVis
::
ColumnMode
columnMode
()
const
;
virtual
AbstractColumn
::
ColumnMode
columnMode
()
const
;
virtual
int
rowCount
()
const
{
return
m_owner
->
rowCount
();
}
virtual
SciDAVis
::
PlotDesignation
plotDesignation
()
const
{
return
m_owner
->
plotDesignation
();
}
virtual
AbstractColumn
::
PlotDesignation
plotDesignation
()
const
{
return
m_owner
->
plotDesignation
();
}
virtual
QString
textAt
(
int
row
)
const
;
virtual
QDate
dateAt
(
int
row
)
const
;
virtual
QTime
timeAt
(
int
row
)
const
;
...
...
src/backend/core/Folder.cpp
View file @
e0cadaac
...
...
@@ -175,7 +175,7 @@ bool Folder::readChildAspectElement(XmlStreamReader * reader)
}
else
if
(
element_name
==
"column"
)
{
Column
*
column
=
new
Column
(
""
,
SciDAVis
::
Text
);
Column
*
column
=
new
Column
(
""
,
AbstractColumn
::
Text
);
if
(
!
column
->
load
(
reader
))
{
delete
column
;
...
...
src/backend/core/column/Column.cpp
View file @
e0cadaac
/***************************************************************************
File : Column.cpp
Project :
SciDAVis
Project :
AbstractColumn
Description : Aspect that manages a column
--------------------------------------------------------------------
Copyright : (C) 2007-2009 Tilman Benkert (thzs*gmx.net)
...
...
@@ -36,8 +36,10 @@
#include "backend/core/datatypes/DateTime2StringFilter.h"
#include <QIcon>
#include <QXmlStreamWriter>
#include <QtDebug>
//
#include <QtDebug>
#include <QVariant>
// #include <QMetaObject>
#include <QMetaEnum>
/**
* \class Column
...
...
@@ -61,7 +63,7 @@
* \param name the column name (= aspect name)
* \param mode initial column mode
*/
Column
::
Column
(
const
QString
&
name
,
SciDAVis
::
ColumnMode
mode
)
Column
::
Column
(
const
QString
&
name
,
AbstractColumn
::
ColumnMode
mode
)
:
AbstractColumn
(
name
),
m_column_private
(
new
Private
(
this
,
mode
)
)
{
init
();
...
...
@@ -74,7 +76,7 @@ Column::Column(const QString& name, SciDAVis::ColumnMode mode)
* \param data initial data vector
*/
Column
::
Column
(
const
QString
&
name
,
QVector
<
double
>
data
)
:
AbstractColumn
(
name
),
m_column_private
(
new
Private
(
this
,
SciDAVis
::
Numeric
,
new
QVector
<
double
>
(
data
))
)
:
AbstractColumn
(
name
),
m_column_private
(
new
Private
(
this
,
AbstractColumn
::
Numeric
,
new
QVector
<
double
>
(
data
))
)
{
init
();
}
...
...
@@ -86,7 +88,7 @@ Column::Column(const QString& name, QVector<double> data)
* \param data initial data vector
*/
Column
::
Column
(
const
QString
&
name
,
QStringList
data
)
:
AbstractColumn
(
name
),
m_column_private
(
new
Private
(
this
,
SciDAVis
::
Text
,
new
QStringList
(
data
)))
:
AbstractColumn
(
name
),
m_column_private
(
new
Private
(
this
,
AbstractColumn
::
Text
,
new
QStringList
(
data
)))
{
init
();
}
...
...
@@ -98,7 +100,7 @@ Column::Column(const QString& name, QStringList data)
* \param data initial data vector
*/
Column
::
Column
(
const
QString
&
name
,
QList
<
QDateTime
>
data
)
:
AbstractColumn
(
name
),
m_column_private
(
new
Private
(
this
,
SciDAVis
::
DateTime
,
new
QList
<
QDateTime
>
(
data
))
)
:
AbstractColumn
(
name
),
m_column_private
(
new
Private
(
this
,
AbstractColumn
::
DateTime
,
new
QList
<
QDateTime
>
(
data
))
)
{
init
();
}
...
...
@@ -132,7 +134,7 @@ Column::~Column() {
* This sets the column mode and, if
* necessary, converts it to another datatype.
*/
void
Column
::
setColumnMode
(
SciDAVis
::
ColumnMode
mode
)
void
Column
::
setColumnMode
(
AbstractColumn
::
ColumnMode
mode
)
{
if
(
mode
==
columnMode
())
return
;
beginMacro
(
QObject
::
tr
(
"%1: change column type"
).
arg
(
name
()));
...
...
@@ -211,7 +213,7 @@ void Column::handleRowRemoval(int first, int count)
/**
* \brief Set the column plot designation
*/
void
Column
::
setPlotDesignation
(
SciDAVis
::
PlotDesignation
pd
)
void
Column
::
setPlotDesignation
(
AbstractColumn
::
PlotDesignation
pd
)
{
if
(
pd
!=
plotDesignation
())
exec
(
new
ColumnSetPlotDesignationCmd
(
m_column_private
,
pd
));
...
...
@@ -428,13 +430,13 @@ double Column::valueAt(int row) const
QIcon
Column
::
icon
()
const
{
switch
(
columnMode
())
{
case
SciDAVis
::
Numeric
:
case
AbstractColumn
::
Numeric
:
return
QIcon
(
QPixmap
(
":/numerictype.png"
));
case
SciDAVis
::
Text
:
case
AbstractColumn
::
Text
:
return
QIcon
(
QPixmap
(
":/texttype.png"
));
case
SciDAVis
::
DateTime
:
case
SciDAVis
::
Month
:
case
SciDAVis
::
Day
:
case
AbstractColumn
::
DateTime
:
case
AbstractColumn
::
Month
:
case
AbstractColumn
::
Day
:
return
QIcon
(
QPixmap
(
":/datetype.png"
));
}
return
QIcon
();
...
...
@@ -452,8 +454,8 @@ void Column::save(QXmlStreamWriter * writer) const
{
writer
->
writeStartElement
(
"column"
);
writeBasicAttributes
(
writer
);
writer
->
writeAttribute
(
"mode"
,
SciDAVis
::
enumValueToString
(
columnMode
(),
"ColumnMode"
));
writer
->
writeAttribute
(
"plot_designation"
,
SciDAVis
::
enumValueToString
(
plotDesignation
(),
"PlotDesignation"
));
writer
->
writeAttribute
(
"mode"
,
enumValueToString
(
columnMode
(),
"ColumnMode"
));
writer
->
writeAttribute
(
"plot_designation"
,
enumValueToString
(
plotDesignation
(),
"PlotDesignation"
));
writer
->
writeAttribute
(
"width"
,
QString
::
number
(
width
()));
writeCommentElement
(
writer
);
writer
->
writeStartElement
(
"input_filter"
);
...
...
@@ -474,7 +476,7 @@ void Column::save(QXmlStreamWriter * writer) const
}
int
i
;
switch
(
columnMode
())
{
case
SciDAVis
::
Numeric
:
case
AbstractColumn
::
Numeric
:
{
const
char
*
data
=
reinterpret_cast
<
const
char
*>
(
static_cast
<
QVector
<
double
>*
>
(
m_column_private
->
dataPointer
())
->
constData
());
...
...
@@ -482,7 +484,7 @@ void Column::save(QXmlStreamWriter * writer) const
writer
->
writeCharacters
(
QByteArray
::
fromRawData
(
data
,
size
).
toBase64
());
break
;
}
case
SciDAVis
::
Text
:
case
AbstractColumn
::
Text
:
for
(
i
=
0
;
i
<
rowCount
();
i
++
)
{
writer
->
writeStartElement
(
"row"
);
...
...
@@ -492,9 +494,9 @@ void Column::save(QXmlStreamWriter * writer) const
}
break
;
case
SciDAVis
::
DateTime
:
case
SciDAVis
::
Month
:
case
SciDAVis
::
Day
:
case
AbstractColumn
::
DateTime
:
case
AbstractColumn
::
Month
:
case
AbstractColumn
::
Day
:
for
(
i
=
0
;
i
<
rowCount
();
i
++
)
{
writer
->
writeStartElement
(
"row"
);
...
...
@@ -538,25 +540,25 @@ bool Column::load(XmlStreamReader * reader)
reader
->
raiseError
(
tr
(
"column mode missing"
));
return
false
;
}
int
mode_code
=
SciDAVis
::
enumStringToValue
(
str
,
"ColumnMode"
);
int
mode_code
=
enumStringToValue
(
str
,
"ColumnMode"
);
if
(
mode_code
==
-
1
)
{
reader
->
raiseError
(
tr
(
"column mode invalid"
));
return
false
;
}
setColumnMode
((
SciDAVis
::
ColumnMode
)
mode_code
);
setColumnMode
((
AbstractColumn
::
ColumnMode
)
mode_code
);
// read plot designation
str
=
attribs
.
value
(
reader
->
namespaceUri
().
toString
(),
"plot_designation"
).
toString
();
int
pd_code
=
SciDAVis
::
enumStringToValue
(
str
,
"PlotDesignation"
);
int
pd_code
=
enumStringToValue
(
str
,
"PlotDesignation"
);
if
(
str
.
isEmpty
())
setPlotDesignation
(
SciDAVis
::
noDesignation
);
setPlotDesignation
(
AbstractColumn
::
noDesignation
);
else
if
(
pd_code
==
-
1
)
{
reader
->
raiseError
(
tr
(
"column plot designation invalid"
));
return
false
;
}
else
setPlotDesignation
((
SciDAVis
::
PlotDesignation
)
pd_code
);
setPlotDesignation
((
AbstractColumn
::
PlotDesignation
)
pd_code
);
bool
ok
;
int
width
=
attribs
.
value
(
reader
->
namespaceUri
().
toString
(),
"width"
).
toString
().
toInt
(
&
ok
);
if
(
ok
)
...
...
@@ -602,7 +604,7 @@ bool Column::load(XmlStreamReader * reader)
return
false
;
}
QString
content
=
reader
->
text
().
toString
().
trimmed
();
if
(
!
content
.
isEmpty
()
&&
columnMode
()
==
SciDAVis
::
Numeric
)
{
if
(
!
content
.
isEmpty
()
&&
columnMode
()
==
AbstractColumn
::
Numeric
)
{
QByteArray
bytes
=
QByteArray
::
fromBase64
(
content
.
toAscii
());
QVector
<
double
>
*
data
=
new
QVector
<
double
>
(
bytes
.
size
()
/
sizeof
(
double
));
memcpy
(
data
->
data
(),
bytes
.
data
(),
(
bytes
.
size
()
/
sizeof
(
double
))
*
sizeof
(
double
));
...
...
@@ -683,7 +685,7 @@ bool Column::XmlReadRow(XmlStreamReader * reader)
str
=
reader
->
readElementText
();
switch
(
columnMode
())
{
case
SciDAVis
::
Numeric
:
case
AbstractColumn
::
Numeric
:
{
double
value
=
str
.
toDouble
(
&
ok
);
if
(
!
ok
)
{
...
...
@@ -693,13 +695,13 @@ bool Column::XmlReadRow(XmlStreamReader * reader)
setValueAt
(
index
,
value
);
break
;
}
case
SciDAVis
::
Text
:
case
AbstractColumn
::
Text
:
setTextAt
(
index
,
str
);
break
;
case
SciDAVis
::
DateTime
:
case
SciDAVis
::
Month
:
case
SciDAVis
::
Day
:
case
AbstractColumn
::
DateTime
:
case
AbstractColumn
::
Month
:
case
AbstractColumn
::
Day
:
QDateTime
date_time
=
QDateTime
::
fromString
(
str
,
"yyyy-dd-MM hh:mm:ss:zzz"
);
setDateTimeAt
(
index
,
date_time
);
break
;
...
...
@@ -726,7 +728,7 @@ bool Column::isReadOnly() const {
* by plots. The column mode specifies how to interpret
* the values in the column additional to the data type.
*/
SciDAVis
::
ColumnMode
Column
::
columnMode
()
const
AbstractColumn
::
ColumnMode
Column
::
columnMode
()
const
{
return
m_column_private
->
columnMode
();
}
...
...
@@ -746,7 +748,7 @@ int Column::rowCount() const
/**
* \brief Return the column plot designation
*/
SciDAVis
::
PlotDesignation
Column
::
plotDesignation
()
const
AbstractColumn
::
PlotDesignation
Column
::
plotDesignation
()
const
{
return
m_column_private
->
plotDesignation
();
}
...
...
@@ -796,7 +798,7 @@ QList< Interval<int> > Column::formulaIntervals() const
void
Column
::
handleFormatChange
()
{
if
(
columnMode
()
==
SciDAVis
::
DateTime
)
{
if
(
columnMode
()
==
AbstractColumn
::
DateTime
)
{
String2DateTimeFilter
*
input_filter
=
static_cast
<
String2DateTimeFilter
*>
(
m_column_private
->
inputFilter
());
DateTime2StringFilter
*
output_filter
=
static_cast
<
DateTime2StringFilter
*>
(
m_column_private
->
outputFilter
());
input_filter
->
setFormat
(
output_filter
->
format
());
...
...
@@ -806,6 +808,21 @@ void Column::handleFormatChange()
emit
aspectDescriptionChanged
(
this
);
// the icon for the type changed
}
QString
Column
::
enumValueToString
(
int
key
,
const
QString
&
enum_name
)
{
int
index
=
staticMetaObject
.
indexOfEnumerator
(
enum_name
.
toAscii
());
if
(
index
==
-
1
)
return
QString
(
"invalid"
);
QMetaEnum
meta_enum
=
staticMetaObject
.
enumerator
(
index
);
return
QString
(
meta_enum
.
valueToKey
(
key
));
}
int
Column
::
enumStringToValue
(
const
QString
&
string
,
const
QString
&
enum_name
)
{
int
index
=
staticMetaObject
.
indexOfEnumerator
(
enum_name
.
toAscii
());
if
(
index
==
-
1
)
return
-
1
;
QMetaEnum
meta_enum
=
staticMetaObject
.
enumerator
(
index
);
return
meta_enum
.
keyToValue
(
string
.
toAscii
());
}
/**
* \class ColumnStringIO
* \brief String-IO interface of Column.
...
...
@@ -828,7 +845,7 @@ QString ColumnStringIO::textAt(int row) const
}
bool
ColumnStringIO
::
copy
(
const
AbstractColumn
*
other
)
{
if
(
other
->
columnMode
()
!=
SciDAVis
::
Text
)
return
false
;
if
(
other
->
columnMode
()
!=
AbstractColumn
::
Text
)
return
false
;
m_owner
->
m_column_private
->
inputFilter
()
->
input
(
0
,
other
);
m_owner
->
copy
(
m_owner
->
m_column_private
->
inputFilter
()
->
output
(
0
));
m_owner
->
m_column_private
->
inputFilter
()
->
input
(
0
,
this
);
...
...
@@ -836,7 +853,7 @@ bool ColumnStringIO::copy(const AbstractColumn *other) {
}
bool
ColumnStringIO
::
copy
(
const
AbstractColumn
*
source
,
int
source_start
,
int
dest_start
,
int
num_rows
)
{
if
(
source
->
columnMode
()
!=
SciDAVis
::
Text
)
return
false
;
if
(
source
->
columnMode
()
!=
AbstractColumn
::
Text
)
return
false
;
m_owner
->
m_column_private
->
inputFilter
()
->
input
(
0
,
source
);
m_owner
->
copy
(
m_owner
->
m_column_private
->
inputFilter
()
->
output
(
0
),
source_start
,
dest_start
,
num_rows
);
m_owner
->
m_column_private
->
inputFilter
()
->
input
(
0
,
this
);
...
...
src/backend/core/column/Column.h
View file @
e0cadaac
/***************************************************************************
File : Column.h
Project :
SciDAVis
Project :
AbstractColumn
Description : Aspect that manages a column
--------------------------------------------------------------------
Copyright : (C) 2007-2009 Tilman Benkert (thzs*gmx.net)
...
...
@@ -45,7 +45,7 @@ class Column : public AbstractColumn
class
Private
;
friend
class
Private
;
Column
(
const
QString
&
name
,
SciDAVis
::
ColumnMode
mode
);
Column
(
const
QString
&
name
,
AbstractColumn
::
ColumnMode
mode
);
Column
(
const
QString
&
name
,
QVector
<
double
>
data
);
Column
(
const
QString
&
name
,
QStringList
data
);
Column
(
const
QString
&
name
,
QList
<
QDateTime
>
data
);
...
...
@@ -55,13 +55,13 @@ class Column : public AbstractColumn
virtual
QIcon
icon
()
const
;
bool
isReadOnly
()
const
;
SciDAVis
::
ColumnMode
columnMode
()
const
;
void
setColumnMode
(
SciDAVis
::
ColumnMode
mode
);
AbstractColumn
::
ColumnMode
columnMode
()
const
;
void
setColumnMode
(
AbstractColumn
::
ColumnMode
mode
);
bool
copy
(
const
AbstractColumn
*
other
);
bool
copy
(
const
AbstractColumn
*
source
,
int
source_start
,
int
dest_start
,
int
num_rows
);
int
rowCount
()
const
;
SciDAVis
::
PlotDesignation
plotDesignation
()
const
;
void
setPlotDesignation
(
SciDAVis
::
PlotDesignation
pd
);
AbstractColumn
::
PlotDesignation
plotDesignation
()
const
;
void
setPlotDesignation
(
AbstractColumn
::
PlotDesignation
pd
);
int
width
()
const
;
void
setWidth
(
int
value
);
void
clear
();
...
...
@@ -99,6 +99,14 @@ class Column : public AbstractColumn
void
handleRowInsertion
(
int
before
,
int
count
);
void
handleRowRemoval
(
int
first
,
int
count
);
static
QString
enumValueToString
(
int
key
,
const
QString
&
enum_name
);
static
int
enumStringToValue
(
const
QString
&
string
,
const
QString
&
enum_name
);
Private
*
m_column_private
;
ColumnStringIO
*
m_string_io
;
friend
class
ColumnStringIO
;
signals:
void
widthAboutToChange
(
const
Column
*
);
...
...
@@ -106,12 +114,6 @@ class Column : public AbstractColumn
private
slots
:
void
handleFormatChange
();
private:
Private
*
m_column_private
;
ColumnStringIO
*
m_string_io
;
friend
class
ColumnStringIO
;
};
class
ColumnStringIO
:
public
AbstractColumn
...
...
@@ -120,8 +122,8 @@ class ColumnStringIO : public AbstractColumn
public:
ColumnStringIO
(
Column
*
owner
)
:
AbstractColumn
(
tr
(
"as string"
)),
m_owner
(
owner
),
m_setting
(
false
)
{}
virtual
SciDAVis
::
ColumnMode
columnMode
()
const
{
return
SciDAVis
::
Text
;
}
virtual
SciDAVis
::
PlotDesignation
plotDesignation
()
const
{
return
m_owner
->
plotDesignation
();
}
virtual
AbstractColumn
::
ColumnMode
columnMode
()
const
{
return
AbstractColumn
::
Text
;
}
virtual
AbstractColumn
::
PlotDesignation
plotDesignation
()
const
{
return
m_owner
->
plotDesignation
();
}
virtual
int
rowCount
()
const
{
return
m_owner
->
rowCount
();
}
virtual
QString
textAt
(
int
row
)
const
;
virtual
void
setTextAt
(
int
row
,
const
QString
&
value
);
...
...
src/backend/core/column/ColumnPrivate.cpp
View file @
e0cadaac
This diff is collapsed.
Click to expand it.
src/backend/core/column/ColumnPrivate.h
View file @
e0cadaac
/***************************************************************************
File : ColumnPrivate.h
Project :
SciDAVis
Project :
AbstractColumn
Description : Private data class of Column
--------------------------------------------------------------------
Copyright : (C) 2007,2008 Tilman Benkert (thzs*gmx.net)
...
...
@@ -39,14 +39,14 @@ class QString;
class
Column
::
Private
{
public:
Private
(
Column
*
owner
,
SciDAVis
::
ColumnMode
mode
);
Private
(
Column
*
owner
,
AbstractColumn
::
ColumnMode
mode
);
~
Private
();
Private
(
Column
*
owner
,
SciDAVis
::
ColumnMode
mode
,
void
*
data
);
Private
(
Column
*
owner
,
AbstractColumn
::
ColumnMode
mode
,
void
*
data
);
Column
*
owner
()
{
return
m_owner
;
}
SciDAVis
::
ColumnMode
columnMode
()
const
;
void
setColumnMode
(
SciDAVis
::
ColumnMode
mode
);
AbstractColumn
::
ColumnMode
columnMode
()
const
;
void
setColumnMode
(
AbstractColumn
::
ColumnMode
mode
);