qse  0.5.4
Signals | Public Member Functions | Protected Attributes | Private Attributes | List of all members
QseDataSet Class Reference

#include <qsedataset.h>

Inheritance diagram for QseDataSet:
Inheritance graph

Signals

void operationCompleted ()
 
void message (const QString &msg)
 
void madeProgress (int level)
 
void dataCleared ()
 
void scanAdded (int n)
 
void dataChanged ()
 

Public Member Functions

 QseDataSet (const QString &name, QObject *parent=0)
 
 ~QseDataSet ()
 
void writeScan (int i, const QString &name)
 
void writeScans (const QString &name)
 
void removeScan (int i)
 
int scanCount () const
 
void clear ()
 
int maxColumnCount () const
 
QseScanscan (int n) const
 
QStringList header () const
 
void setHeader (const QStringList &hdr)
 
void appendHeader (const QString &hline)
 
QseScanappendScan ()
 
QString fileName () const
 
void setFileName (const QString &name)
 
void emitOperationCompleted ()
 
void emitDataChanged ()
 

Protected Attributes

QMutex m_Mutex
 

Private Attributes

QStringList m_Header
 
QList< QseScan * > m_Scans
 
QList< QseScan * > m_SpareScans
 
QString m_FileName
 

Detailed Description

Definition at line 14 of file qsedataset.h.

Constructor & Destructor Documentation

QseDataSet::QseDataSet ( const QString &  name,
QObject *  parent = 0 
)

Definition at line 9 of file qsedataset.cpp.

10  : QObject(parent),
11  m_Mutex(QMutex::Recursive)
12 {
13  setObjectName(name);
14 }
QMutex m_Mutex
Definition: qsedataset.h:62
QseDataSet::~QseDataSet ( )

Definition at line 16 of file qsedataset.cpp.

References m_Mutex, m_Scans, m_SpareScans, and scan().

17 {
18  QMutexLocker lock(&m_Mutex);
19 
20  QseScan *scan;
21 
22  foreach (scan, m_Scans) {
23  delete scan;
24  }
25 
26  foreach (scan, m_SpareScans) {
27  delete scan;
28  }
29 }
QseScan * scan(int n) const
Definition: qsedataset.cpp:70
QMutex m_Mutex
Definition: qsedataset.h:62
QList< QseScan * > m_SpareScans
Definition: qsedataset.h:57
QList< QseScan * > m_Scans
Definition: qsedataset.h:56

Member Function Documentation

void QseDataSet::appendHeader ( const QString &  hline)

Definition at line 137 of file qsedataset.cpp.

References m_Header, and m_Mutex.

Referenced by QseInputFile::nextInputLine().

138 {
139  QMutexLocker lock(&m_Mutex);
140 
141  m_Header.push_back(l);
142 }
QMutex m_Mutex
Definition: qsedataset.h:62
QStringList m_Header
Definition: qsedataset.h:55
QseScan * QseDataSet::appendScan ( )

Definition at line 100 of file qsedataset.cpp.

References clear(), dataChanged(), m_Mutex, m_Scans, m_SpareScans, scan(), scanAdded(), and scanCount().

Referenced by QseInputFile::nextInputLine().

101 {
102  QseScan *scan = NULL;
103 
104  {
105  QMutexLocker lock(&m_Mutex);
106 
107  if (m_SpareScans.size()) {
108  scan = m_SpareScans.takeLast();
109  scan -> clear();
110  } else {
111  scan = new QseScan("");
112  }
113 
114  m_Scans.append(scan);
115  }
116 
117 // printf("%s: Append scan %d\n", qPrintable(objectName()), scanCount()-1);
118 
119  emit scanAdded(scanCount()-1);
120  emit dataChanged();
121 
122  return scan;
123 }
int scanCount() const
Definition: qsedataset.cpp:31
QseScan * scan(int n) const
Definition: qsedataset.cpp:70
void dataChanged()
void clear()
Definition: qsedataset.cpp:52
QMutex m_Mutex
Definition: qsedataset.h:62
void scanAdded(int n)
QList< QseScan * > m_SpareScans
Definition: qsedataset.h:57
QList< QseScan * > m_Scans
Definition: qsedataset.h:56
void QseDataSet::clear ( )

Definition at line 52 of file qsedataset.cpp.

References dataChanged(), dataCleared(), m_Header, m_Mutex, m_Scans, m_SpareScans, and scanCount().

Referenced by appendScan().

53 {
54  int sz = scanCount();
55 
56  {
57  QMutexLocker lock(&m_Mutex);
58 
59  for (int i = sz-1; i>=0; i--) {
60  m_SpareScans.append(m_Scans.takeLast());
61  }
62 
63  m_Header.clear();
64  }
65 
66  emit dataCleared();
67  emit dataChanged();
68 }
int scanCount() const
Definition: qsedataset.cpp:31
void dataChanged()
QMutex m_Mutex
Definition: qsedataset.h:62
QStringList m_Header
Definition: qsedataset.h:55
QList< QseScan * > m_SpareScans
Definition: qsedataset.h:57
QList< QseScan * > m_Scans
Definition: qsedataset.h:56
void dataCleared()
void QseDataSet::dataChanged ( )
signal
void QseDataSet::dataCleared ( )
signal

Referenced by clear().

void QseDataSet::emitDataChanged ( )

Definition at line 45 of file qsedataset.cpp.

References dataChanged().

46 {
47  printf("QseDataSet::emitDataChanged()\n");
48 
49  emit dataChanged();
50 }
void dataChanged()
void QseDataSet::emitOperationCompleted ( )

Definition at line 38 of file qsedataset.cpp.

References operationCompleted().

Referenced by QseFileReader::timerRoutine().

39 {
40 // printf("QseDataSet::emitOperationCompleted()\n");
41 
42  emit operationCompleted();
43 }
void operationCompleted()
QString QseDataSet::fileName ( ) const

Definition at line 186 of file qsedataset.cpp.

References m_FileName.

Referenced by QseDataExport::QseDataExport(), and QseDataExport::substituteFilenamePatterns().

187 {
188  return m_FileName;
189 }
QString m_FileName
Definition: qsedataset.h:59
QStringList QseDataSet::header ( ) const

Definition at line 125 of file qsedataset.cpp.

References m_Header, and m_Mutex.

Referenced by QseDataExport::updatePreview().

126 {
127  QMutexLocker lock(&m_Mutex);
128 
129  return m_Header;
130 }
QMutex m_Mutex
Definition: qsedataset.h:62
QStringList m_Header
Definition: qsedataset.h:55
void QseDataSet::madeProgress ( int  level)
signal
int QseDataSet::maxColumnCount ( ) const

Definition at line 82 of file qsedataset.cpp.

References QseScan::columnCount(), m_Mutex, m_Scans, and scan().

Referenced by QseDataSetModel::columnCount().

83 {
84  QMutexLocker lock(&m_Mutex);
85 
86  int max=0;
87  QseScan* scan;
88 
89  foreach (scan, m_Scans) {
90  if (scan) {
91  if (scan->columnCount()>max) {
92  max = scan->columnCount();
93  }
94  }
95  }
96 
97  return max;
98 }
QseScan * scan(int n) const
Definition: qsedataset.cpp:70
QMutex m_Mutex
Definition: qsedataset.h:62
int columnCount() const
Definition: qsescan.cpp:45
QList< QseScan * > m_Scans
Definition: qsedataset.h:56
void QseDataSet::message ( const QString &  msg)
signal
void QseDataSet::operationCompleted ( )
signal
void QseDataSet::removeScan ( int  i)

Definition at line 170 of file qsedataset.cpp.

References dataChanged(), m_Mutex, m_Scans, m_SpareScans, and scanCount().

171 {
172  if (i >= 0 && i < scanCount()) {
173  {
174  QMutexLocker lock(&m_Mutex);
175  QseScan *s = m_Scans.takeAt(i);
176 
177  if (s) {
178  m_SpareScans.append(s);
179  }
180  }
181 
182  emit dataChanged();
183  }
184 }
int scanCount() const
Definition: qsedataset.cpp:31
void dataChanged()
QMutex m_Mutex
Definition: qsedataset.h:62
QList< QseScan * > m_SpareScans
Definition: qsedataset.h:57
QList< QseScan * > m_Scans
Definition: qsedataset.h:56
QseScan * QseDataSet::scan ( int  n) const

Definition at line 70 of file qsedataset.cpp.

References m_Mutex, m_Scans, and scanCount().

Referenced by appendScan(), QseController::currentScan(), QseDataSetModel::data(), QseGraphScansModel::data(), QseNormalizer::matchesScan(), QseNormalizer::matchesScanPattern(), maxColumnCount(), QseNormalizer::normalizeScan(), QseDataExport::QseDataExport(), QseDataReference::QseDataReference(), QseController::scan(), QseDataExport::substituteFilenamePatterns(), writeScan(), and ~QseDataSet().

71 {
72  int ns = scanCount();
73 
74  if (n >= 0 && n < ns) {
75  QMutexLocker lock(&m_Mutex);
76  return m_Scans.at(n);
77  } else {
78  return NULL;
79  }
80 }
int scanCount() const
Definition: qsedataset.cpp:31
QMutex m_Mutex
Definition: qsedataset.h:62
QList< QseScan * > m_Scans
Definition: qsedataset.h:56
void QseDataSet::scanAdded ( int  n)
signal

Referenced by appendScan().

int QseDataSet::scanCount ( ) const

Definition at line 31 of file qsedataset.cpp.

References m_Mutex, and m_Scans.

Referenced by appendScan(), clear(), QseInputFile::nextInputLine(), QseDataExport::QseDataExport(), removeScan(), scan(), and writeScans().

32 {
33  QMutexLocker lock(&m_Mutex);
34 
35  return m_Scans.size();
36 }
QMutex m_Mutex
Definition: qsedataset.h:62
QList< QseScan * > m_Scans
Definition: qsedataset.h:56
void QseDataSet::setFileName ( const QString &  name)

Definition at line 191 of file qsedataset.cpp.

References m_FileName.

Referenced by QseInputFile::nextDataFile().

192 {
193  m_FileName = nam;
194 }
QString m_FileName
Definition: qsedataset.h:59
void QseDataSet::setHeader ( const QStringList &  hdr)

Definition at line 132 of file qsedataset.cpp.

References m_Header.

133 {
134  m_Header = hdr;
135 }
QStringList m_Header
Definition: qsedataset.h:55
void QseDataSet::writeScan ( int  i,
const QString &  name 
)

Definition at line 151 of file qsedataset.cpp.

References message(), and scan().

Referenced by writeScans().

152 {
153  QFileInfo fileInfo(name);
154 
155  QDir dir = fileInfo.dir();
156  QString base = fileInfo.completeBaseName();
157  QString extn = fileInfo.suffix();
158 
159  QFileInfo ofile(dir, base+"-"+QString().setNum(i)+"."+extn);
160 
161  QseScan *s = scan(i);
162 
163  if (s) {
164  s -> writeScan(ofile.filePath());
165 
166  emit message (QString("Scan %1 saved as %2").arg(i).arg(ofile.filePath()));
167  }
168 }
QseScan * scan(int n) const
Definition: qsedataset.cpp:70
void message(const QString &msg)
void writeScan(int i, const QString &name)
Definition: qsedataset.cpp:151
void QseDataSet::writeScans ( const QString &  name)

Definition at line 144 of file qsedataset.cpp.

References scanCount(), and writeScan().

145 {
146  for (int i=0; i<scanCount(); i++) {
147  writeScan(i, name);
148  }
149 }
int scanCount() const
Definition: qsedataset.cpp:31
void writeScan(int i, const QString &name)
Definition: qsedataset.cpp:151

Member Data Documentation

QString QseDataSet::m_FileName
private

Definition at line 59 of file qsedataset.h.

Referenced by fileName(), and setFileName().

QStringList QseDataSet::m_Header
private

Definition at line 55 of file qsedataset.h.

Referenced by appendHeader(), clear(), header(), and setHeader().

QMutex QseDataSet::m_Mutex
mutableprotected
QList<QseScan*> QseDataSet::m_Scans
private

Definition at line 56 of file qsedataset.h.

Referenced by appendScan(), clear(), maxColumnCount(), removeScan(), scan(), scanCount(), and ~QseDataSet().

QList<QseScan*> QseDataSet::m_SpareScans
private

Definition at line 57 of file qsedataset.h.

Referenced by appendScan(), clear(), removeScan(), and ~QseDataSet().


The documentation for this class was generated from the following files: