@@ -0,0 +1,131 | |||||
|
1 | #include "folderlistwidget.h" | |||
|
2 | #include <QDragEnterEvent> | |||
|
3 | #include <QMimeData> | |||
|
4 | #include <QDebug> | |||
|
5 | #include <QDrag> | |||
|
6 | #include <QApplication> | |||
|
7 | #include <QMap> | |||
|
8 | #include <QVariant> | |||
|
9 | #include <QDir> | |||
|
10 | ||||
|
11 | FolderListWidget::FolderListWidget(QWidget *parent) : QListWidget(parent) | |||
|
12 | { | |||
|
13 | this->setSelectionMode(QAbstractItemView::ExtendedSelection); | |||
|
14 | this->setAcceptDrops(true); | |||
|
15 | this->setDragEnabled(true); | |||
|
16 | this->setDragDropMode(QAbstractItemView::DragDrop); | |||
|
17 | this->setDefaultDropAction(Qt::MoveAction); | |||
|
18 | this->p_mainWin=NULL; | |||
|
19 | this->p_path=""; | |||
|
20 | } | |||
|
21 | ||||
|
22 | FolderListWidget::~FolderListWidget() | |||
|
23 | { | |||
|
24 | ||||
|
25 | } | |||
|
26 | ||||
|
27 | bool FolderListWidget::contains(const QString &name) | |||
|
28 | { | |||
|
29 | for(int i=0;i<this->count();i++) | |||
|
30 | { | |||
|
31 | if(this->item(i)->text()==name) | |||
|
32 | return true; | |||
|
33 | } | |||
|
34 | return false; | |||
|
35 | } | |||
|
36 | ||||
|
37 | bool FolderListWidget::isDraging(const QString &name) | |||
|
38 | { | |||
|
39 | for(int i=0;i<this->lastDragItems.count();i++) | |||
|
40 | { | |||
|
41 | if(lastDragItems.at(i)==name) | |||
|
42 | return true; | |||
|
43 | } | |||
|
44 | return false; | |||
|
45 | } | |||
|
46 | ||||
|
47 | void FolderListWidget::setMainWindow(MainWindow *mw) | |||
|
48 | { | |||
|
49 | this->p_mainWin = mw; | |||
|
50 | } | |||
|
51 | ||||
|
52 | void FolderListWidget::setPath(const QString &path) | |||
|
53 | { | |||
|
54 | this->p_path = path; | |||
|
55 | this->lastDragItems.clear(); | |||
|
56 | } | |||
|
57 | ||||
|
58 | void FolderListWidget::dragEnterEvent(QDragEnterEvent *event) | |||
|
59 | { | |||
|
60 | const QMimeData *mimeData = event->mimeData(); | |||
|
61 | QStringList mimeFormats = mimeData->formats(); | |||
|
62 | bool containsFile=false; | |||
|
63 | if(mimeFormats.count()) | |||
|
64 | { | |||
|
65 | QByteArray encoded = mimeData->data("application/x-qabstractitemmodeldatalist"); | |||
|
66 | QDataStream stream(&encoded, QIODevice::ReadOnly); | |||
|
67 | while (!stream.atEnd()) | |||
|
68 | { | |||
|
69 | int row, col; | |||
|
70 | QMap<int, QVariant> roleDataMap; | |||
|
71 | stream >> row >> col >> roleDataMap; | |||
|
72 | if(this->contains(roleDataMap[0].toString())) | |||
|
73 | containsFile = true; | |||
|
74 | } | |||
|
75 | } | |||
|
76 | if(!containsFile) | |||
|
77 | { | |||
|
78 | QListWidget::dragEnterEvent(event); | |||
|
79 | } | |||
|
80 | else | |||
|
81 | { | |||
|
82 | this->lastDragItems.clear(); | |||
|
83 | QList<QListWidgetItem*> selItems = this->selectedItems(); | |||
|
84 | for(int i=0;i<selItems.count();i++) | |||
|
85 | { | |||
|
86 | lastDragItems.append(selItems.at(i)->text()); | |||
|
87 | } | |||
|
88 | } | |||
|
89 | ||||
|
90 | } | |||
|
91 | ||||
|
92 | void FolderListWidget::dragMoveEvent(QDragMoveEvent *event) | |||
|
93 | { | |||
|
94 | QListWidget::dragMoveEvent(event); | |||
|
95 | } | |||
|
96 | ||||
|
97 | void FolderListWidget::dragLeaveEvent(QDragLeaveEvent *event) | |||
|
98 | { | |||
|
99 | QListWidget::dragLeaveEvent(event); | |||
|
100 | this->lastDragItems.clear(); | |||
|
101 | } | |||
|
102 | ||||
|
103 | void FolderListWidget::dropEvent(QDropEvent *event) | |||
|
104 | { | |||
|
105 | QByteArray encoded = event->mimeData()->data("application/x-qabstractitemmodeldatalist"); | |||
|
106 | QDataStream stream(&encoded, QIODevice::ReadOnly); | |||
|
107 | while (!stream.atEnd()) | |||
|
108 | { | |||
|
109 | int row, col; | |||
|
110 | QMap<int, QVariant> roleDataMap; | |||
|
111 | stream >> row >> col >> roleDataMap; | |||
|
112 | QString name=roleDataMap[0].toString(); | |||
|
113 | QString oldPath = p_mainWin->getFilePath(name); | |||
|
114 | if((oldPath!="") && (p_path!="")) | |||
|
115 | { | |||
|
116 | if(QFile::rename(oldPath+"/"+name,this->p_path+"/"+name)) | |||
|
117 | QListWidget::dropEvent(event); | |||
|
118 | emit askGlobalRescan(); | |||
|
119 | } | |||
|
120 | } | |||
|
121 | } | |||
|
122 | ||||
|
123 | void FolderListWidget::mousePressEvent(QMouseEvent *event) | |||
|
124 | { | |||
|
125 | QListWidget::mousePressEvent(event); | |||
|
126 | } | |||
|
127 | ||||
|
128 | void FolderListWidget::mouseMoveEvent(QMouseEvent *event) | |||
|
129 | { | |||
|
130 | QListWidget::mouseMoveEvent(event); | |||
|
131 | } |
@@ -0,0 +1,36 | |||||
|
1 | #ifndef FOLDERLISTWIDGET_H | |||
|
2 | #define FOLDERLISTWIDGET_H | |||
|
3 | ||||
|
4 | #include <QWidget> | |||
|
5 | #include <QListWidget> | |||
|
6 | #include <QPoint> | |||
|
7 | #include <mainwindow.h> | |||
|
8 | ||||
|
9 | class FolderListWidget : public QListWidget | |||
|
10 | { | |||
|
11 | Q_OBJECT | |||
|
12 | public: | |||
|
13 | explicit FolderListWidget(QWidget *parent = 0); | |||
|
14 | ~FolderListWidget(); | |||
|
15 | bool contains(const QString& name); | |||
|
16 | bool isDraging(const QString& name); | |||
|
17 | void setMainWindow(MainWindow* mw); | |||
|
18 | void setPath(const QString& path); | |||
|
19 | signals: | |||
|
20 | void askGlobalRescan(); | |||
|
21 | public slots: | |||
|
22 | protected: | |||
|
23 | void dragEnterEvent(QDragEnterEvent *event); | |||
|
24 | void dragMoveEvent(QDragMoveEvent *event); | |||
|
25 | void dragLeaveEvent(QDragLeaveEvent* event); | |||
|
26 | void dropEvent(QDropEvent *event); | |||
|
27 | void mousePressEvent(QMouseEvent *event); | |||
|
28 | void mouseMoveEvent(QMouseEvent *event); | |||
|
29 | ||||
|
30 | private: | |||
|
31 | QStringList lastDragItems; | |||
|
32 | MainWindow* p_mainWin; | |||
|
33 | QString p_path; | |||
|
34 | }; | |||
|
35 | ||||
|
36 | #endif // FOLDERLISTWIDGET_H |
@@ -23,7 +23,8 SOURCES += src/main.cpp\ | |||||
23 | src/themisdatafile.cpp \ |
|
23 | src/themisdatafile.cpp \ | |
24 | src/filedownloader.cpp \ |
|
24 | src/filedownloader.cpp \ | |
25 | src/folderview.cpp \ |
|
25 | src/folderview.cpp \ | |
26 | src/toolbarcontainer.cpp |
|
26 | src/toolbarcontainer.cpp \ | |
|
27 | src/folderlistwidget.cpp | |||
27 |
|
28 | |||
28 | HEADERS += src/mainwindow.h \ |
|
29 | HEADERS += src/mainwindow.h \ | |
29 | src/SocExplorerPlot.h \ |
|
30 | src/SocExplorerPlot.h \ | |
@@ -31,7 +32,8 HEADERS += src/mainwindow.h \ | |||||
31 | src/themisdatafile.h \ |
|
32 | src/themisdatafile.h \ | |
32 | src/filedownloader.h \ |
|
33 | src/filedownloader.h \ | |
33 | src/folderview.h \ |
|
34 | src/folderview.h \ | |
34 | src/toolbarcontainer.h |
|
35 | src/toolbarcontainer.h \ | |
|
36 | src/folderlistwidget.h | |||
35 |
|
37 | |||
36 | FORMS += src/mainwindow.ui \ |
|
38 | FORMS += src/mainwindow.ui \ | |
37 | src/folderview.ui |
|
39 | src/folderview.ui |
@@ -24,24 +24,25 | |||||
24 |
|
24 | |||
25 |
|
25 | |||
26 | SocExplorerPlot::SocExplorerPlot(QWidget *parent) : |
|
26 | SocExplorerPlot::SocExplorerPlot(QWidget *parent) : | |
27 |
|
|
27 | QWidget(parent) | |
28 | { |
|
28 | { | |
29 |
|
|
29 | this->m_plot = new QCustomPlot(this); | |
30 |
|
|
30 | this->m_plot->setInteractions(QCP::iRangeDrag | QCP::iSelectAxes | | |
31 |
|
|
31 | QCP::iSelectLegend | QCP::iSelectPlottables); | |
32 |
|
|
32 | this->m_plot->axisRect()->setRangeDrag(Qt::Horizontal|Qt::Vertical); | |
33 |
|
|
33 | this->m_plot->axisRect()->setRangeZoom(Qt::Horizontal|Qt::Vertical); | |
34 |
|
|
34 | this->m_mainlayout = new QGridLayout(this); | |
35 |
|
|
35 | this->setLayout(this->m_mainlayout); | |
36 |
|
|
36 | this->m_mainlayout->addWidget(this->m_plot); | |
37 |
|
|
37 | this->setMinimumSize(400,300); | |
38 |
|
|
38 | this->setFocusPolicy(Qt::WheelFocus); | |
39 |
|
|
39 | this->m_plot->setAttribute(Qt::WA_TransparentForMouseEvents); | |
40 |
|
|
40 | this->ctrl_hold = false; | |
41 |
|
|
41 | this->shift_hold = false; | |
42 |
|
|
42 | this->mouse_hold = false; | |
43 |
|
|
43 | this->m_plot->setNoAntialiasingOnDrag(true); | |
44 |
|
|
44 | this->show(); | |
|
45 | this->m_plot->legend->setVisible(true); | |||
45 |
|
46 | |||
46 | } |
|
47 | } | |
47 |
|
48 | |||
@@ -57,63 +58,63 void SocExplorerPlot::replot() | |||||
57 |
|
58 | |||
58 | void SocExplorerPlot::setTitle(QString title) |
|
59 | void SocExplorerPlot::setTitle(QString title) | |
59 | { |
|
60 | { | |
60 |
|
|
61 | Q_UNUSED(title) | |
61 |
|
|
62 | //this->m_plot->setTitle(title); | |
62 | /*! |
|
63 | /*! | |
63 | @todo Function borcken fixe this! |
|
64 | @todo Function borcken fixe this! | |
64 | */ |
|
65 | */ | |
65 |
|
|
66 | this->repaint(); | |
66 | } |
|
67 | } | |
67 |
|
68 | |||
68 | void SocExplorerPlot::setXaxisLabel(QString label) |
|
69 | void SocExplorerPlot::setXaxisLabel(QString label) | |
69 | { |
|
70 | { | |
70 |
|
|
71 | this->m_plot->xAxis->setLabel(label); | |
71 |
|
|
72 | this->repaint(); | |
72 | } |
|
73 | } | |
73 |
|
74 | |||
74 | void SocExplorerPlot::setYaxisLabel(QString label) |
|
75 | void SocExplorerPlot::setYaxisLabel(QString label) | |
75 | { |
|
76 | { | |
76 |
|
|
77 | this->m_plot->yAxis->setLabel(label); | |
77 |
|
|
78 | this->repaint(); | |
78 | } |
|
79 | } | |
79 |
|
80 | |||
80 | void SocExplorerPlot::setXaxisRange(double lower, double upper) |
|
81 | void SocExplorerPlot::setXaxisRange(double lower, double upper) | |
81 | { |
|
82 | { | |
82 |
|
|
83 | this->m_plot->xAxis->setRange(lower,upper); | |
83 | } |
|
84 | } | |
84 |
|
85 | |||
85 | void SocExplorerPlot::setYaxisRange(double lower, double upper) |
|
86 | void SocExplorerPlot::setYaxisRange(double lower, double upper) | |
86 | { |
|
87 | { | |
87 |
|
|
88 | this->m_plot->yAxis->setRange(lower,upper); | |
88 | } |
|
89 | } | |
89 |
|
90 | |||
90 |
|
91 | |||
91 | void SocExplorerPlot::rescaleAxis() |
|
92 | void SocExplorerPlot::rescaleAxis() | |
92 | { |
|
93 | { | |
93 |
|
|
94 | this->m_plot->rescaleAxes(); | |
94 |
|
|
95 | this->m_plot->replot(); | |
95 | } |
|
96 | } | |
96 |
|
97 | |||
97 | void SocExplorerPlot::setLegendFont(QFont font) |
|
98 | void SocExplorerPlot::setLegendFont(QFont font) | |
98 | { |
|
99 | { | |
99 |
|
|
100 | this->m_plot->legend->setFont(font); | |
100 |
|
|
101 | this->repaint(); | |
101 | } |
|
102 | } | |
102 |
|
103 | |||
103 | void SocExplorerPlot::setLegendSelectedFont(QFont font) |
|
104 | void SocExplorerPlot::setLegendSelectedFont(QFont font) | |
104 | { |
|
105 | { | |
105 |
|
|
106 | this->m_plot->legend->setSelectedFont(font); | |
106 |
|
|
107 | this->repaint(); | |
107 | } |
|
108 | } | |
108 |
|
109 | |||
109 | void SocExplorerPlot::setAdaptativeSampling(int graphIndex, bool enable) |
|
110 | void SocExplorerPlot::setAdaptativeSampling(int graphIndex, bool enable) | |
110 | { |
|
111 | { | |
111 |
|
|
112 | this->m_plot->graph(graphIndex)->setAdaptiveSampling(enable); | |
112 | } |
|
113 | } | |
113 |
|
114 | |||
114 | int SocExplorerPlot::addGraph() |
|
115 | int SocExplorerPlot::addGraph() | |
115 | { |
|
116 | { | |
116 |
|
|
117 | this->m_plot->addGraph(); | |
117 | return this->m_plot->graphCount() -1; |
|
118 | return this->m_plot->graphCount() -1; | |
118 | } |
|
119 | } | |
119 |
|
120 | |||
@@ -134,136 +135,136 void SocExplorerPlot::removeAllGraphs() | |||||
134 |
|
135 | |||
135 | void SocExplorerPlot::setGraphName(int graphIndex,QString name) |
|
136 | void SocExplorerPlot::setGraphName(int graphIndex,QString name) | |
136 | { |
|
137 | { | |
137 |
|
|
138 | if(graphIndex<this->m_plot->graphCount()) | |
138 | { |
|
139 | { | |
139 |
|
|
140 | this->m_plot->graph(graphIndex)->setName(name); | |
140 | } |
|
141 | } | |
141 | } |
|
142 | } | |
142 |
|
143 | |||
143 |
|
144 | |||
144 | void SocExplorerPlot::setGraphData(int graphIndex, QList<QVariant> x, QList<QVariant> y) |
|
145 | void SocExplorerPlot::setGraphData(int graphIndex, QList<QVariant> x, QList<QVariant> y) | |
145 | { |
|
146 | { | |
146 |
|
|
147 | if((graphIndex<this->m_plot->graphCount()) && (x.count()==y.count()) && (x.at(0).type()==QVariant::Double)) | |
147 | { |
|
148 | { | |
148 |
|
|
149 | QVector<double> _x(x.count()), _y(y.count()); | |
149 |
|
|
150 | for(int i=0;i<x.count();i++) | |
150 | { |
|
151 | { | |
151 |
|
|
152 | /*_x[i] = x.at(i).value<double>(); | |
152 | _y[i] = y.at(i).value<double>();*/ |
|
153 | _y[i] = y.at(i).value<double>();*/ | |
153 |
|
|
154 | _x[i] = x.at(i).toDouble(); | |
154 |
|
|
155 | _y[i] = y.at(i).toDouble(); | |
155 | } |
|
156 | } | |
156 |
|
|
157 | this->m_plot->graph(graphIndex)->setData(_x,_y); | |
157 | } |
|
158 | } | |
158 |
|
|
159 | else | |
159 |
|
|
160 | { | |
160 |
|
|
161 | if((graphIndex<this->m_plot->graphCount()) && (x.count()==y.count()) && (x.at(0).type()==QVariant::DateTime)) | |
161 | { |
|
162 | { | |
162 |
|
|
163 | QVector<double> _x(x.count()), _y(y.count()); | |
163 |
|
|
164 | for(int i=0;i<x.count();i++) | |
164 | { |
|
165 | { | |
165 |
|
|
166 | /*_x[i] = x.at(i).value<double>(); | |
166 | _y[i] = y.at(i).value<double>();*/ |
|
167 | _y[i] = y.at(i).value<double>();*/ | |
167 |
|
|
168 | _x[i] = x.at(i).toDateTime().toMSecsSinceEpoch(); | |
168 |
|
|
169 | _y[i] = y.at(i).toDouble(); | |
169 | } |
|
170 | } | |
170 |
|
|
171 | this->m_plot->graph(graphIndex)->setData(_x,_y); | |
171 |
|
|
172 | this->m_plot->xAxis->setTickLabelType(QCPAxis::ltDateTime); | |
172 |
|
|
173 | this->m_plot->xAxis->setDateTimeFormat("hh:mm:ss.zzz"); | |
173 |
|
174 | |||
174 | } |
|
175 | } | |
175 |
|
|
176 | } | |
176 |
|
|
177 | this->m_plot->replot(); | |
177 | } |
|
178 | } | |
178 |
|
179 | |||
179 | void SocExplorerPlot::setGraphData(int graphIndex, QCPDataMap *data, bool copy, bool replot) |
|
180 | void SocExplorerPlot::setGraphData(int graphIndex, QCPDataMap *data, bool copy, bool replot) | |
180 | { |
|
181 | { | |
181 | if((graphIndex<this->m_plot->graphCount()))// && (x.at(0).type()==QVariant::Double)) |
|
182 | if((graphIndex<this->m_plot->graphCount()))// && (x.at(0).type()==QVariant::Double)) | |
182 | { |
|
183 | { | |
183 | this->m_plot->graph(graphIndex)->setData(data,copy); |
|
184 | this->m_plot->graph(graphIndex)->setData(data,copy); | |
184 | } |
|
185 | } | |
185 | if(replot) |
|
186 | if(replot) | |
186 | this->m_plot->replot(); |
|
187 | this->m_plot->replot(); | |
187 | } |
|
188 | } | |
188 |
|
189 | |||
189 | void SocExplorerPlot::addGraphData(int graphIndex, QList<QVariant> x, QList<QVariant> y) |
|
190 | void SocExplorerPlot::addGraphData(int graphIndex, QList<QVariant> x, QList<QVariant> y) | |
190 | { |
|
191 | { | |
191 |
|
|
192 | if((graphIndex<this->m_plot->graphCount()) && (x.count()==y.count()))// && (x.at(0).type()==QVariant::Double)) | |
192 | { |
|
193 | { | |
193 |
|
|
194 | QVector<double> _x(x.count()), _y(y.count()); | |
194 |
|
|
195 | for(int i=0;i<x.count();i++) | |
195 | { |
|
196 | { | |
196 |
|
|
197 | /*_x[i] = x.at(i).value<double>(); | |
197 | _y[i] = y.at(i).value<double>();*/ |
|
198 | _y[i] = y.at(i).value<double>();*/ | |
198 |
|
|
199 | _x[i] = x.at(i).toDouble(); | |
199 |
|
|
200 | _y[i] = y.at(i).toDouble(); | |
200 | } |
|
201 | } | |
201 |
|
|
202 | this->m_plot->graph(graphIndex)->addData(_x,_y); | |
202 | } |
|
203 | } | |
203 |
|
|
204 | this->m_plot->replot(); | |
204 | } |
|
205 | } | |
205 |
|
206 | |||
206 | void SocExplorerPlot::addGraphData(int graphIndex, QVariant x, QVariant y) |
|
207 | void SocExplorerPlot::addGraphData(int graphIndex, QVariant x, QVariant y) | |
207 | { |
|
208 | { | |
208 |
|
|
209 | if(graphIndex<this->m_plot->graphCount())// && (x.at(0).type()==QVariant::Double)) | |
209 | { |
|
210 | { | |
210 |
|
|
211 | this->m_plot->graph(graphIndex)->addData(x.toDouble(),y.toDouble()); | |
211 | } |
|
212 | } | |
212 |
|
|
213 | this->m_plot->replot(); | |
213 | } |
|
214 | } | |
214 |
|
215 | |||
215 | void SocExplorerPlot::setGraphPen(int graphIndex,QPen pen) |
|
216 | void SocExplorerPlot::setGraphPen(int graphIndex,QPen pen) | |
216 | { |
|
217 | { | |
217 |
|
|
218 | if(graphIndex<this->m_plot->graphCount()) | |
218 | { |
|
219 | { | |
219 |
|
|
220 | this->m_plot->graph(graphIndex)->setPen(pen); | |
220 | } |
|
221 | } | |
221 | } |
|
222 | } | |
222 |
|
223 | |||
223 | QPen SocExplorerPlot::getGraphPen(int graphIndex) |
|
224 | QPen SocExplorerPlot::getGraphPen(int graphIndex) | |
224 | { |
|
225 | { | |
225 |
|
|
226 | if(graphIndex<this->m_plot->graphCount()) | |
226 | { |
|
227 | { | |
227 |
|
|
228 | return this->m_plot->graph(graphIndex)->pen(); | |
228 | } |
|
229 | } | |
229 |
|
|
230 | return this->m_plot->graph()->pen(); | |
230 | } |
|
231 | } | |
231 |
|
232 | |||
232 |
|
233 | |||
233 |
|
234 | |||
234 | void SocExplorerPlot::setGraphLineStyle(int graphIndex,QString lineStyle) |
|
235 | void SocExplorerPlot::setGraphLineStyle(int graphIndex,QString lineStyle) | |
235 | { |
|
236 | { | |
236 |
|
|
237 | if(graphIndex<this->m_plot->graphCount()) | |
237 | { |
|
238 | { | |
238 |
|
|
239 | if(!lineStyle.compare("none")) | |
239 | { |
|
240 | { | |
240 |
|
|
241 | this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsNone); | |
241 |
|
|
242 | return; | |
242 | } |
|
243 | } | |
243 |
|
|
244 | if(!lineStyle.compare("line")) | |
244 | { |
|
245 | { | |
245 |
|
|
246 | this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsLine); | |
246 |
|
|
247 | return; | |
247 | } |
|
248 | } | |
248 |
|
|
249 | if(!lineStyle.compare("stepleft")) | |
249 | { |
|
250 | { | |
250 |
|
|
251 | this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsStepLeft); | |
251 |
|
|
252 | return; | |
252 | } |
|
253 | } | |
253 |
|
|
254 | if(!lineStyle.compare("stepright")) | |
254 | { |
|
255 | { | |
255 |
|
|
256 | this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsStepRight); | |
256 |
|
|
257 | return; | |
257 | } |
|
258 | } | |
258 |
|
|
259 | if(!lineStyle.compare("stepcenter")) | |
259 | { |
|
260 | { | |
260 |
|
|
261 | this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsStepCenter); | |
261 |
|
|
262 | return; | |
262 | } |
|
263 | } | |
263 |
|
|
264 | if(!lineStyle.compare("impulse")) | |
264 | { |
|
265 | { | |
265 |
|
|
266 | this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsImpulse); | |
266 |
|
|
267 | return; | |
267 | } |
|
268 | } | |
268 |
|
269 | |||
269 |
|
270 | |||
@@ -272,90 +273,90 void SocExplorerPlot::setGraphLineStyle( | |||||
272 |
|
273 | |||
273 | void SocExplorerPlot::setGraphScatterStyle(int graphIndex,QString scatterStyle) |
|
274 | void SocExplorerPlot::setGraphScatterStyle(int graphIndex,QString scatterStyle) | |
274 | { |
|
275 | { | |
275 |
|
|
276 | if(graphIndex<this->m_plot->graphCount()) | |
276 | { |
|
277 | { | |
277 |
|
|
278 | if(!scatterStyle.compare("none")) | |
278 | { |
|
279 | { | |
279 |
|
|
280 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssNone); | |
280 |
|
|
281 | return; | |
281 | } |
|
282 | } | |
282 |
|
|
283 | if(!scatterStyle.compare("dot")) | |
283 | { |
|
284 | { | |
284 |
|
|
285 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssDot); | |
285 |
|
|
286 | return; | |
286 | } |
|
287 | } | |
287 |
|
|
288 | if(!scatterStyle.compare("cross")) | |
288 | { |
|
289 | { | |
289 |
|
|
290 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCross); | |
290 |
|
|
291 | return; | |
291 | } |
|
292 | } | |
292 |
|
|
293 | if(!scatterStyle.compare("plus")) | |
293 | { |
|
294 | { | |
294 |
|
|
295 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPlus); | |
295 |
|
|
296 | return; | |
296 | } |
|
297 | } | |
297 |
|
|
298 | if(!scatterStyle.compare("circle")) | |
298 | { |
|
299 | { | |
299 |
|
|
300 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCircle); | |
300 |
|
|
301 | return; | |
301 | } |
|
302 | } | |
302 |
|
|
303 | if(!scatterStyle.compare("disc")) | |
303 | { |
|
304 | { | |
304 |
|
|
305 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssDisc); | |
305 |
|
|
306 | return; | |
306 | } |
|
307 | } | |
307 |
|
|
308 | if(!scatterStyle.compare("square")) | |
308 | { |
|
309 | { | |
309 |
|
|
310 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssSquare); | |
310 |
|
|
311 | return; | |
311 | } |
|
312 | } | |
312 |
|
|
313 | if(!scatterStyle.compare("diamond")) | |
313 | { |
|
314 | { | |
314 |
|
|
315 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssDiamond); | |
315 |
|
|
316 | return; | |
316 | } |
|
317 | } | |
317 |
|
|
318 | if(!scatterStyle.compare("star")) | |
318 | { |
|
319 | { | |
319 |
|
|
320 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssStar); | |
320 |
|
|
321 | return; | |
321 | } |
|
322 | } | |
322 |
|
|
323 | if(!scatterStyle.compare("triangle")) | |
323 | { |
|
324 | { | |
324 |
|
|
325 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssTriangle); | |
325 |
|
|
326 | return; | |
326 | } |
|
327 | } | |
327 |
|
|
328 | if(!scatterStyle.compare("invertedtriangle")) | |
328 | { |
|
329 | { | |
329 |
|
|
330 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssTriangleInverted); | |
330 |
|
|
331 | return; | |
331 | } |
|
332 | } | |
332 |
|
|
333 | if(!scatterStyle.compare("crosssquare")) | |
333 | { |
|
334 | { | |
334 |
|
|
335 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCrossSquare); | |
335 |
|
|
336 | return; | |
336 | } |
|
337 | } | |
337 |
|
|
338 | if(!scatterStyle.compare("plussquare")) | |
338 | { |
|
339 | { | |
339 |
|
|
340 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPlusSquare); | |
340 |
|
|
341 | return; | |
341 | } |
|
342 | } | |
342 |
|
|
343 | if(!scatterStyle.compare("crosscircle")) | |
343 | { |
|
344 | { | |
344 |
|
|
345 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCrossCircle); | |
345 |
|
|
346 | return; | |
346 | } |
|
347 | } | |
347 |
|
|
348 | if(!scatterStyle.compare("pluscircle")) | |
348 | { |
|
349 | { | |
349 |
|
|
350 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPlusCircle); | |
350 |
|
|
351 | return; | |
351 | } |
|
352 | } | |
352 |
|
|
353 | if(!scatterStyle.compare("peace")) | |
353 | { |
|
354 | { | |
354 |
|
|
355 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPeace); | |
355 |
|
|
356 | return; | |
356 | } |
|
357 | } | |
357 |
|
358 | |||
358 |
|
|
359 | } | |
359 | } |
|
360 | } | |
360 |
|
361 | |||
361 | void SocExplorerPlot::setXaxisTickLabelType(QCPAxis::LabelType type) |
|
362 | void SocExplorerPlot::setXaxisTickLabelType(QCPAxis::LabelType type) | |
@@ -374,74 +375,107 void SocExplorerPlot::setXaxisDateTimeFo | |||||
374 |
|
375 | |||
375 | void SocExplorerPlot::keyPressEvent(QKeyEvent * event) |
|
376 | void SocExplorerPlot::keyPressEvent(QKeyEvent * event) | |
376 | { |
|
377 | { | |
377 |
|
|
378 | switch(event->key()) | |
378 | { |
|
379 | { | |
379 | case Qt::Key_Control: |
|
380 | case Qt::Key_Control: | |
380 |
|
|
381 | this->ctrl_hold = true; | |
381 |
|
|
382 | break; | |
382 | case Qt::Key_Shift: |
|
383 | case Qt::Key_Shift: | |
383 |
|
|
384 | this->shift_hold = true; | |
384 |
|
|
385 | break; | |
385 | case Qt::Key_M: |
|
386 | case Qt::Key_M: | |
386 |
|
|
387 | this->rescaleAxis(); | |
387 |
|
|
388 | break; | |
|
389 | case Qt::Key_Left: | |||
|
390 | if(!ctrl_hold) | |||
|
391 | { | |||
|
392 | move(-0.1,Qt::Horizontal); | |||
|
393 | } | |||
|
394 | else | |||
|
395 | { | |||
|
396 | zoom(2,this->width()/2,Qt::Horizontal); | |||
|
397 | } | |||
|
398 | break; | |||
|
399 | case Qt::Key_Right: | |||
|
400 | if(!ctrl_hold) | |||
|
401 | { | |||
|
402 | move(0.1,Qt::Horizontal); | |||
|
403 | } | |||
|
404 | else | |||
|
405 | { | |||
|
406 | zoom(0.5,this->width()/2,Qt::Horizontal); | |||
|
407 | } | |||
|
408 | break; | |||
|
409 | case Qt::Key_Up: | |||
|
410 | if(!ctrl_hold) | |||
|
411 | { | |||
|
412 | move(0.1,Qt::Vertical); | |||
|
413 | } | |||
|
414 | else | |||
|
415 | { | |||
|
416 | zoom(0.5,this->height()/2,Qt::Vertical); | |||
|
417 | } | |||
|
418 | break; | |||
|
419 | case Qt::Key_Down: | |||
|
420 | if(!ctrl_hold) | |||
|
421 | { | |||
|
422 | move(-0.1,Qt::Vertical); | |||
|
423 | } | |||
|
424 | else | |||
|
425 | { | |||
|
426 | zoom(2,this->height()/2,Qt::Vertical); | |||
|
427 | } | |||
|
428 | break; | |||
388 | default: |
|
429 | default: | |
389 |
|
|
430 | QWidget::keyPressEvent(event); | |
390 |
|
|
431 | break; | |
391 | } |
|
432 | } | |
392 | } |
|
433 | } | |
393 |
|
434 | |||
394 | void SocExplorerPlot::keyReleaseEvent(QKeyEvent * event) |
|
435 | void SocExplorerPlot::keyReleaseEvent(QKeyEvent * event) | |
395 | { |
|
436 | { | |
396 |
|
|
437 | switch(event->key()) | |
397 | { |
|
438 | { | |
398 | case Qt::Key_Control: |
|
439 | case Qt::Key_Control: | |
399 |
|
|
440 | event->accept(); | |
400 |
|
|
441 | this->ctrl_hold = false; | |
401 |
|
|
442 | break; | |
402 | case Qt::Key_Shift: |
|
443 | case Qt::Key_Shift: | |
403 |
|
|
444 | event->accept(); | |
404 |
|
|
445 | this->shift_hold = false; | |
405 |
|
|
446 | break; | |
406 | default: |
|
447 | default: | |
407 |
|
|
448 | QWidget::keyReleaseEvent(event); | |
408 |
|
|
449 | break; | |
409 | } |
|
450 | } | |
410 | } |
|
451 | } | |
411 |
|
452 | |||
412 | void SocExplorerPlot::wheelEvent(QWheelEvent * event) |
|
453 | void SocExplorerPlot::wheelEvent(QWheelEvent * event) | |
413 | { |
|
454 | { | |
414 |
|
|
455 | double factor; | |
415 |
|
|
456 | double wheelSteps = event->delta()/120.0; // a single step delta is +/-120 usually | |
416 |
|
|
457 | if(ctrl_hold) | |
417 | { |
|
|||
418 | if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical)) |
|
|||
419 | { |
|
|||
420 | factor = pow(this->m_plot->axisRect()->rangeZoomFactor(Qt::Vertical), wheelSteps); |
|
|||
421 | QCPAxis* axis = this->m_plot->axisRect()->rangeZoomAxis(Qt::Vertical); |
|
|||
422 | axis->scaleRange(factor, axis->pixelToCoord(event->pos().y())); |
|
|||
423 | } |
|
|||
424 | this->m_plot->replot(); |
|
|||
425 | QWidget::wheelEvent(event); |
|
|||
426 | return; |
|
|||
427 | } |
|
|||
428 | if(shift_hold) |
|
|||
429 | { |
|
458 | { | |
430 |
|
|
459 | if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical)) | |
431 | { |
|
460 | { | |
432 |
|
|
461 | factor = pow(this->m_plot->axisRect()->rangeZoomFactor(Qt::Vertical), wheelSteps); | |
433 | QCPAxis* axis = this->m_plot->axisRect()->rangeZoomAxis(Qt::Horizontal); |
|
462 | zoom(factor,event->pos().y(),Qt::Vertical); | |
434 | axis->scaleRange(factor, axis->pixelToCoord(event->pos().x())); |
|
|||
435 | } |
|
463 | } | |
436 | this->m_plot->replot(); |
|
464 | QWidget::wheelEvent(event); | |
437 | QWidget::wheelEvent(event); |
|
465 | return; | |
438 | return; |
|
|||
439 | } |
|
466 | } | |
440 | QCPAxis* Haxis = this->m_plot->axisRect()->rangeDragAxis(Qt::Horizontal); |
|
467 | if(shift_hold) | |
441 | double rg = (Haxis->range().upper - Haxis->range().lower)*(wheelSteps/10); |
|
468 | { | |
442 | Haxis->setRange(Haxis->range().lower+(rg), Haxis->range().upper+(rg)); |
|
469 | if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical)) | |
443 | this->m_plot->replot(); |
|
470 | { | |
444 | QWidget::wheelEvent(event); |
|
471 | factor = pow(this->m_plot->axisRect()->rangeZoomFactor(Qt::Horizontal), wheelSteps); | |
|
472 | zoom(factor,event->pos().x(),Qt::Horizontal); | |||
|
473 | } | |||
|
474 | QWidget::wheelEvent(event); | |||
|
475 | return; | |||
|
476 | } | |||
|
477 | move(wheelSteps/10,Qt::Horizontal); | |||
|
478 | QWidget::wheelEvent(event); | |||
445 | } |
|
479 | } | |
446 |
|
480 | |||
447 |
|
481 | |||
@@ -449,38 +483,54 void SocExplorerPlot::wheelEvent(QWheelE | |||||
449 |
|
483 | |||
450 | void SocExplorerPlot::mousePressEvent(QMouseEvent *event) |
|
484 | void SocExplorerPlot::mousePressEvent(QMouseEvent *event) | |
451 | { |
|
485 | { | |
452 |
|
|
486 | if(event->button()==Qt::LeftButton) | |
453 | { |
|
487 | { | |
454 |
|
|
488 | mDragStart = event->pos(); | |
455 |
|
|
489 | this->mouse_hold = true; | |
456 |
|
|
490 | DragStartHorzRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Horizontal)->range(); | |
457 |
|
|
491 | DragStartVertRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Vertical)->range(); | |
458 | } |
|
492 | } | |
459 |
|
|
493 | QWidget::mousePressEvent(event); | |
460 | } |
|
494 | } | |
461 |
|
495 | |||
462 | void SocExplorerPlot::mouseReleaseEvent(QMouseEvent *event) |
|
496 | void SocExplorerPlot::mouseReleaseEvent(QMouseEvent *event) | |
463 | { |
|
497 | { | |
464 |
|
|
498 | if(event->button()==Qt::LeftButton) | |
465 | { |
|
499 | { | |
466 |
|
|
500 | this->mouse_hold = false; | |
467 | } |
|
501 | } | |
468 |
|
|
502 | QWidget::mouseReleaseEvent(event); | |
|
503 | } | |||
|
504 | ||||
|
505 | void SocExplorerPlot::zoom(double factor, int center, Qt::Orientation orientation) | |||
|
506 | { | |||
|
507 | QCPAxis* axis = this->m_plot->axisRect()->rangeZoomAxis(orientation); | |||
|
508 | axis->scaleRange(factor, axis->pixelToCoord(center)); | |||
|
509 | this->m_plot->replot(); | |||
469 | } |
|
510 | } | |
470 |
|
511 | |||
|
512 | void SocExplorerPlot::move(double factor, Qt::Orientation orientation) | |||
|
513 | { | |||
|
514 | QCPAxis* axis = this->m_plot->axisRect()->rangeDragAxis(orientation); | |||
|
515 | double rg = (axis->range().upper - axis->range().lower)*(factor); | |||
|
516 | axis->setRange(axis->range().lower+(rg), axis->range().upper+(rg)); | |||
|
517 | this->m_plot->replot(); | |||
|
518 | } | |||
|
519 | ||||
|
520 | ||||
471 | void SocExplorerPlot::mouseMoveEvent(QMouseEvent *event) |
|
521 | void SocExplorerPlot::mouseMoveEvent(QMouseEvent *event) | |
472 | { |
|
522 | { | |
473 |
|
|
523 | if(mouse_hold) | |
474 | { |
|
524 | { | |
475 |
|
|
525 | QCPAxis* Haxis = this->m_plot->axisRect()->rangeDragAxis(Qt::Horizontal); | |
476 |
|
|
526 | QCPAxis* Vaxis = this->m_plot->axisRect()->rangeDragAxis(Qt::Vertical); | |
477 |
|
|
527 | double diff = Haxis->pixelToCoord(mDragStart.x()) - Haxis->pixelToCoord(event->pos().x()); | |
478 |
|
|
528 | Haxis->setRange(DragStartHorzRange.lower+diff, DragStartHorzRange.upper+diff); | |
479 |
|
|
529 | diff = Vaxis->pixelToCoord(mDragStart.y()) - Vaxis->pixelToCoord(event->pos().y()); | |
480 |
|
|
530 | Vaxis->setRange(DragStartVertRange.lower+diff, DragStartVertRange.upper+diff); | |
481 |
|
|
531 | this->m_plot->replot(); | |
482 | } |
|
532 | } | |
483 |
|
|
533 | QWidget::mouseMoveEvent(event); | |
484 | } |
|
534 | } | |
485 |
|
535 | |||
486 |
|
536 |
@@ -70,6 +70,8 protected: | |||||
70 | void mouseReleaseEvent(QMouseEvent *); |
|
70 | void mouseReleaseEvent(QMouseEvent *); | |
71 |
|
71 | |||
72 | private: |
|
72 | private: | |
|
73 | void zoom(double factor, int center, Qt::Orientation orientation); | |||
|
74 | void move(double factor, Qt::Orientation orientation); | |||
73 | QCustomPlot* m_plot; |
|
75 | QCustomPlot* m_plot; | |
74 | QGridLayout* m_mainlayout; |
|
76 | QGridLayout* m_mainlayout; | |
75 | bool ctrl_hold; |
|
77 | bool ctrl_hold; |
@@ -23,26 +23,26 | |||||
23 | #include "ui_folderview.h" |
|
23 | #include "ui_folderview.h" | |
24 | #include <QFileDialog> |
|
24 | #include <QFileDialog> | |
25 | #include <QLabel> |
|
25 | #include <QLabel> | |
|
26 | #include <QDebug> | |||
26 |
|
27 | |||
27 | FolderView::FolderView(QWidget *parent) : |
|
28 | p_FolderView::p_FolderView(QWidget *parent) : | |
28 |
Q |
|
29 | QWidget(parent), | |
29 | ui(new Ui::FolderView) |
|
30 | ui(new Ui::p_FolderView) | |
30 | { |
|
31 | { | |
31 | ui->setupUi(this); |
|
32 | ui->setupUi(this); | |
32 | this->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); |
|
|||
33 | this->setAllowedAreas(Qt::AllDockWidgetAreas); |
|
|||
34 | this->setWidget(this->ui->groupBox); |
|
|||
35 | connect(this->ui->setFolderQpb,SIGNAL(clicked()),this,SLOT(openFolder())); |
|
33 | connect(this->ui->setFolderQpb,SIGNAL(clicked()),this,SLOT(openFolder())); | |
36 | connect(this->ui->refreshQpb,SIGNAL(clicked()),this,SLOT(refreshFolder())); |
|
34 | connect(this->ui->refreshQpb,SIGNAL(clicked()),this,SLOT(refreshFolder())); | |
37 | connect(this->ui->listWidget,SIGNAL(itemActivated(QListWidgetItem*)),this,SLOT(itemActivated(QListWidgetItem*))); |
|
35 | connect(this->ui->listWidget,SIGNAL(itemActivated(QListWidgetItem*)),this,SLOT(itemActivated(QListWidgetItem*))); | |
|
36 | //this->ui->listWidget->installEventFilter(this); | |||
|
37 | connect(this->ui->listWidget,SIGNAL(askGlobalRescan()),this,SIGNAL(askGlobalRescan())); | |||
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | FolderView::~FolderView() |
|
40 | p_FolderView::~p_FolderView() | |
41 | { |
|
41 | { | |
42 | delete ui; |
|
42 | delete ui; | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | bool FolderView::contains(const QString &fileName) |
|
45 | bool p_FolderView::contains(const QString &fileName) | |
46 | { |
|
46 | { | |
47 | for(int i=0;i<this->ui->listWidget->count();i++) |
|
47 | for(int i=0;i<this->ui->listWidget->count();i++) | |
48 | { |
|
48 | { | |
@@ -54,16 +54,31 bool FolderView::contains(const QString | |||||
54 | return false; |
|
54 | return false; | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | void FolderView::openFolder() |
|
57 | bool p_FolderView::isDraging(const QString &name) | |
|
58 | { | |||
|
59 | return this->ui->listWidget->isDraging(name); | |||
|
60 | } | |||
|
61 | ||||
|
62 | void p_FolderView::setMainWindow(MainWindow *mw) | |||
58 | { |
|
63 | { | |
59 | currentFolder = QFileDialog::getExistingDirectory(this, tr("Open Directory"),NULL,QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); |
|
64 | this->ui->listWidget->setMainWindow(mw); | |
|
65 | } | |||
|
66 | ||||
|
67 | QString p_FolderView::currentFolder() | |||
|
68 | { | |||
|
69 | return p_currentFolder; | |||
|
70 | } | |||
|
71 | ||||
|
72 | void p_FolderView::openFolder() | |||
|
73 | { | |||
|
74 | p_currentFolder = QFileDialog::getExistingDirectory(this, tr("Open Directory"),NULL,QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); | |||
60 | refreshFolder(); |
|
75 | refreshFolder(); | |
61 | } |
|
76 | } | |
62 |
|
77 | |||
63 | void FolderView::refreshFolder() |
|
78 | void p_FolderView::refreshFolder() | |
64 | { |
|
79 | { | |
65 | QDir dir; |
|
80 | QDir dir; | |
66 | dir.setPath(currentFolder); |
|
81 | dir.setPath(p_currentFolder); | |
67 | this->ui->listWidget->clear(); |
|
82 | this->ui->listWidget->clear(); | |
68 | dir.setFilter(QDir::Files | QDir::NoSymLinks); |
|
83 | dir.setFilter(QDir::Files | QDir::NoSymLinks); | |
69 | dir.setSorting(QDir::Name); |
|
84 | dir.setSorting(QDir::Name); | |
@@ -75,15 +90,16 void FolderView::refreshFolder() | |||||
75 | this->ui->listWidget->addItem(list.at(i).fileName()); |
|
90 | this->ui->listWidget->addItem(list.at(i).fileName()); | |
76 | } |
|
91 | } | |
77 | } |
|
92 | } | |
78 |
this->ui-> |
|
93 | this->ui->listWidget->setPath(p_currentFolder); | |
|
94 | this->ui->groupBox->setTitle(p_currentFolder); | |||
79 | } |
|
95 | } | |
80 |
|
96 | |||
81 | void FolderView::itemActivated(QListWidgetItem *item) |
|
97 | void p_FolderView::itemActivated(QListWidgetItem *item) | |
82 | { |
|
98 | { | |
83 | emit itemActivated(currentFolder+'/'+item->text()); |
|
99 | emit itemActivated(p_currentFolder+'/'+item->text()); | |
84 | } |
|
100 | } | |
85 |
|
101 | |||
86 | void FolderView::changeEvent(QEvent *e) |
|
102 | void p_FolderView::changeEvent(QEvent *e) | |
87 | { |
|
103 | { | |
88 | QWidget::changeEvent(e); |
|
104 | QWidget::changeEvent(e); | |
89 | switch (e->type()) { |
|
105 | switch (e->type()) { | |
@@ -94,3 +110,56 void FolderView::changeEvent(QEvent *e) | |||||
94 | break; |
|
110 | break; | |
95 | } |
|
111 | } | |
96 | } |
|
112 | } | |
|
113 | ||||
|
114 | bool p_FolderView::eventFilter(QObject *object, QEvent *event) | |||
|
115 | { | |||
|
116 | if(object == this->ui->listWidget ) | |||
|
117 | { | |||
|
118 | qDebug()<<event->type(); | |||
|
119 | if(event->type() == QEvent::Drop) | |||
|
120 | { | |||
|
121 | QDropEvent *DropEvent = static_cast<QDropEvent *>(event); | |||
|
122 | qDebug()<< DropEvent->mimeData(); | |||
|
123 | } | |||
|
124 | } | |||
|
125 | return false; | |||
|
126 | } | |||
|
127 | ||||
|
128 | ||||
|
129 | FolderView::FolderView(MainWindow *parent) | |||
|
130 | :QDockWidget(parent) | |||
|
131 | { | |||
|
132 | this->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); | |||
|
133 | this->setAllowedAreas(Qt::AllDockWidgetAreas); | |||
|
134 | this->ui = new p_FolderView(this); | |||
|
135 | this->setWidget(this->ui); | |||
|
136 | connect(this->ui,SIGNAL(itemActivated(QString)),this,SIGNAL(itemActivated(QString))); | |||
|
137 | connect(this->ui,SIGNAL(askGlobalRescan()),this,SIGNAL(askGlobalRescan())); | |||
|
138 | this->ui->setMainWindow(parent); | |||
|
139 | } | |||
|
140 | ||||
|
141 | bool FolderView::contains(const QString &fileName) | |||
|
142 | { | |||
|
143 | return ui->contains(fileName); | |||
|
144 | } | |||
|
145 | ||||
|
146 | bool FolderView::isDraging(const QString &name) | |||
|
147 | { | |||
|
148 | return this->ui->isDraging(name); | |||
|
149 | } | |||
|
150 | ||||
|
151 | QString FolderView::currentFolder() | |||
|
152 | { | |||
|
153 | return this->ui->currentFolder(); | |||
|
154 | } | |||
|
155 | ||||
|
156 | void FolderView::openFolder() | |||
|
157 | { | |||
|
158 | this->ui->openFolder(); | |||
|
159 | } | |||
|
160 | ||||
|
161 | void FolderView::refreshFolder() | |||
|
162 | { | |||
|
163 | this->ui->refreshFolder(); | |||
|
164 | } | |||
|
165 |
@@ -25,32 +25,61 | |||||
25 | #include <QWidget> |
|
25 | #include <QWidget> | |
26 | #include <QDockWidget> |
|
26 | #include <QDockWidget> | |
27 | #include <QListWidget> |
|
27 | #include <QListWidget> | |
28 |
|
28 | #include <QEvent> | ||
|
29 | #include <QDropEvent> | |||
|
30 | class MainWindow; | |||
29 | namespace Ui { |
|
31 | namespace Ui { | |
30 | class FolderView; |
|
32 | class p_FolderView; | |
31 | } |
|
33 | } | |
32 |
|
34 | |||
|
35 | class p_FolderView; | |||
|
36 | ||||
33 | class FolderView : public QDockWidget |
|
37 | class FolderView : public QDockWidget | |
34 | { |
|
38 | { | |
35 | Q_OBJECT |
|
39 | Q_OBJECT | |
|
40 | public: | |||
|
41 | FolderView (MainWindow *parent = 0); | |||
|
42 | ~FolderView(){} | |||
|
43 | bool contains(const QString& fileName); | |||
|
44 | bool isDraging(const QString& name); | |||
|
45 | QString currentFolder(); | |||
|
46 | public slots: | |||
|
47 | void openFolder(); | |||
|
48 | void refreshFolder(); | |||
|
49 | signals: | |||
|
50 | void askGlobalRescan(); | |||
|
51 | void itemActivated(const QString& item); | |||
|
52 | private: | |||
|
53 | p_FolderView* ui; | |||
|
54 | }; | |||
|
55 | ||||
|
56 | ||||
|
57 | class p_FolderView : public QWidget | |||
|
58 | { | |||
|
59 | Q_OBJECT | |||
36 |
|
60 | |||
37 | public: |
|
61 | public: | |
38 | explicit FolderView(QWidget *parent = 0); |
|
62 | explicit p_FolderView(QWidget *parent = 0); | |
39 | ~FolderView(); |
|
63 | ~p_FolderView(); | |
40 | bool contains(const QString& fileName); |
|
64 | bool contains(const QString& fileName); | |
|
65 | bool isDraging(const QString& name); | |||
|
66 | void setMainWindow(MainWindow* mw); | |||
|
67 | QString currentFolder(); | |||
41 | public slots: |
|
68 | public slots: | |
42 | void openFolder(); |
|
69 | void openFolder(); | |
43 | void refreshFolder(); |
|
70 | void refreshFolder(); | |
44 | void itemActivated(QListWidgetItem * item); |
|
71 | void itemActivated(QListWidgetItem * item); | |
45 | signals: |
|
72 | signals: | |
|
73 | void askGlobalRescan(); | |||
46 | void itemActivated(const QString& item); |
|
74 | void itemActivated(const QString& item); | |
47 | protected: |
|
75 | protected: | |
48 | void changeEvent(QEvent *e); |
|
76 | void changeEvent(QEvent *e); | |
|
77 | bool eventFilter(QObject *object, QEvent *event); | |||
49 |
|
78 | |||
50 | private: |
|
79 | private: | |
51 | Ui::FolderView *ui; |
|
80 | Ui::p_FolderView *ui; | |
52 | QWidget* _Widget; |
|
81 | QWidget* _Widget; | |
53 | QString currentFolder; |
|
82 | QString p_currentFolder; | |
54 | }; |
|
83 | }; | |
55 |
|
84 | |||
56 | #endif // FOLDERVIEW_H |
|
85 | #endif // FOLDERVIEW_H |
@@ -1,7 +1,7 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>FolderView</class> |
|
3 | <class>p_FolderView</class> | |
4 | <widget class="QWidget" name="FolderView"> |
|
4 | <widget class="QWidget" name="p_FolderView"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
@@ -13,78 +13,87 | |||||
13 | <property name="windowTitle"> |
|
13 | <property name="windowTitle"> | |
14 | <string>Test</string> |
|
14 | <string>Test</string> | |
15 | </property> |
|
15 | </property> | |
16 |
< |
|
16 | <layout class="QGridLayout" name="gridLayout"> | |
17 | <property name="geometry"> |
|
17 | <item row="0" column="0"> | |
18 | <rect> |
|
18 | <widget class="QGroupBox" name="groupBox"> | |
19 | <x>9</x> |
|
19 | <property name="title"> | |
20 | <y>9</y> |
|
20 | <string>No Folder</string> | |
21 | <width>282</width> |
|
21 | </property> | |
22 | <height>268</height> |
|
22 | <layout class="QGridLayout" name="gridLayout_2"> | |
23 | </rect> |
|
23 | <item row="0" column="0" colspan="3"> | |
24 | </property> |
|
24 | <widget class="FolderListWidget" name="listWidget"> | |
25 |
<property name=" |
|
25 | <property name="acceptDrops"> | |
26 | <string>No Folder</string> |
|
26 | <bool>true</bool> | |
27 | </property> |
|
27 | </property> | |
28 | <layout class="QGridLayout" name="gridLayout_2"> |
|
28 | <property name="editTriggers"> | |
29 | <item row="0" column="0" colspan="3"> |
|
29 | <set>QAbstractItemView::NoEditTriggers</set> | |
30 | <widget class="QListWidget" name="listWidget"> |
|
30 | </property> | |
31 |
<property name=" |
|
31 | <property name="dragEnabled"> | |
32 | <set>QAbstractItemView::NoEditTriggers</set> |
|
32 | <bool>true</bool> | |
33 | </property> |
|
33 | </property> | |
34 |
<property name="drag |
|
34 | <property name="dragDropOverwriteMode"> | |
35 |
<bool> |
|
35 | <bool>false</bool> | |
36 | </property> |
|
36 | </property> | |
37 | <property name="dragDropMode"> |
|
37 | <property name="dragDropMode"> | |
38 | <enum>QAbstractItemView::DragDrop</enum> |
|
38 | <enum>QAbstractItemView::DragDrop</enum> | |
39 | </property> |
|
39 | </property> | |
40 | <property name="defaultDropAction"> |
|
40 | <property name="defaultDropAction"> | |
41 | <enum>Qt::MoveAction</enum> |
|
41 | <enum>Qt::MoveAction</enum> | |
42 | </property> |
|
42 | </property> | |
43 | </widget> |
|
43 | </widget> | |
44 | </item> |
|
44 | </item> | |
45 | <item row="1" column="1"> |
|
45 | <item row="1" column="1"> | |
46 | <widget class="QPushButton" name="setFolderQpb"> |
|
46 | <widget class="QPushButton" name="setFolderQpb"> | |
47 | <property name="text"> |
|
47 | <property name="text"> | |
48 | <string>Set Folder</string> |
|
48 | <string>Set Folder</string> | |
49 | </property> |
|
49 | </property> | |
50 | </widget> |
|
50 | </widget> | |
51 | </item> |
|
51 | </item> | |
52 | <item row="1" column="2"> |
|
52 | <item row="1" column="2"> | |
53 | <widget class="QPushButton" name="refreshQpb"> |
|
53 | <widget class="QPushButton" name="refreshQpb"> | |
54 | <property name="styleSheet"> |
|
54 | <property name="styleSheet"> | |
55 | <string notr="true"/> |
|
55 | <string notr="true"/> | |
56 | </property> |
|
56 | </property> | |
57 | <property name="text"> |
|
57 | <property name="text"> | |
58 | <string/> |
|
58 | <string/> | |
59 | </property> |
|
59 | </property> | |
60 | <property name="icon"> |
|
60 | <property name="icon"> | |
61 | <iconset resource="../resources/qlop.qrc"> |
|
61 | <iconset resource="../resources/qlop.qrc"> | |
62 | <normaloff>:/img/Gnome-view-refresh.svg</normaloff>:/img/Gnome-view-refresh.svg</iconset> |
|
62 | <normaloff>:/img/Gnome-view-refresh.svg</normaloff>:/img/Gnome-view-refresh.svg</iconset> | |
63 | </property> |
|
63 | </property> | |
64 | <property name="iconSize"> |
|
64 | <property name="iconSize"> | |
65 | <size> |
|
65 | <size> | |
66 | <width>24</width> |
|
66 | <width>24</width> | |
67 | <height>24</height> |
|
67 | <height>24</height> | |
68 | </size> |
|
68 | </size> | |
69 | </property> |
|
69 | </property> | |
70 | </widget> |
|
70 | </widget> | |
71 | </item> |
|
71 | </item> | |
72 | <item row="1" column="0"> |
|
72 | <item row="1" column="0"> | |
73 | <spacer name="horizontalSpacer"> |
|
73 | <spacer name="horizontalSpacer"> | |
74 | <property name="orientation"> |
|
74 | <property name="orientation"> | |
75 | <enum>Qt::Horizontal</enum> |
|
75 | <enum>Qt::Horizontal</enum> | |
76 | </property> |
|
76 | </property> | |
77 | <property name="sizeHint" stdset="0"> |
|
77 | <property name="sizeHint" stdset="0"> | |
78 | <size> |
|
78 | <size> | |
79 | <width>40</width> |
|
79 | <width>40</width> | |
80 | <height>20</height> |
|
80 | <height>20</height> | |
81 | </size> |
|
81 | </size> | |
82 | </property> |
|
82 | </property> | |
83 | </spacer> |
|
83 | </spacer> | |
84 | </item> |
|
84 | </item> | |
85 | </layout> |
|
85 | </layout> | |
86 | </widget> |
|
86 | </widget> | |
|
87 | </item> | |||
|
88 | </layout> | |||
87 | </widget> |
|
89 | </widget> | |
|
90 | <customwidgets> | |||
|
91 | <customwidget> | |||
|
92 | <class>FolderListWidget</class> | |||
|
93 | <extends>QListWidget</extends> | |||
|
94 | <header>folderlistwidget.h</header> | |||
|
95 | </customwidget> | |||
|
96 | </customwidgets> | |||
88 | <resources> |
|
97 | <resources> | |
89 | <include location="../resources/qlop.qrc"/> |
|
98 | <include location="../resources/qlop.qrc"/> | |
90 | </resources> |
|
99 | </resources> |
@@ -46,3 +46,5 int main(int argc, char *argv[]) | |||||
46 |
|
46 | |||
47 | return a.exec(); |
|
47 | return a.exec(); | |
48 | } |
|
48 | } | |
|
49 | ||||
|
50 |
@@ -55,6 +55,7 MainWindow::MainWindow(int OMP_THREADS, | |||||
55 | this->progressLayout = new QVBoxLayout(this->progressWidget); |
|
55 | this->progressLayout = new QVBoxLayout(this->progressWidget); | |
56 | this->progressWidget->setLayout(this->progressLayout); |
|
56 | this->progressWidget->setLayout(this->progressLayout); | |
57 | this->progressWidget->setWindowModality(Qt::WindowModal); |
|
57 | this->progressWidget->setWindowModality(Qt::WindowModal); | |
|
58 | progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); | |||
58 | for(int i=0;i<OMP_THREADS;i++) |
|
59 | for(int i=0;i<OMP_THREADS;i++) | |
59 | { |
|
60 | { | |
60 | this->progress.append(new QProgressBar(this->progressWidget)); |
|
61 | this->progress.append(new QProgressBar(this->progressWidget)); | |
@@ -63,6 +64,7 MainWindow::MainWindow(int OMP_THREADS, | |||||
63 | connect(&this->fileReader,SIGNAL(updateProgress(int,int)),this,SLOT(updateProgress(int,int))); |
|
64 | connect(&this->fileReader,SIGNAL(updateProgress(int,int)),this,SLOT(updateProgress(int,int))); | |
64 | this->progressLayout->addWidget(this->progress.last()); |
|
65 | this->progressLayout->addWidget(this->progress.last()); | |
65 | this->progressWidget->hide(); |
|
66 | this->progressWidget->hide(); | |
|
67 | this->progressThreadIds[i] = -1; | |||
66 | } |
|
68 | } | |
67 | this->progressWidget->setWindowTitle("Loading File"); |
|
69 | this->progressWidget->setWindowTitle("Loading File"); | |
68 | } |
|
70 | } | |
@@ -72,6 +74,16 MainWindow::~MainWindow() | |||||
72 | delete ui; |
|
74 | delete ui; | |
73 | } |
|
75 | } | |
74 |
|
76 | |||
|
77 | QString MainWindow::getFilePath(const QString &name) | |||
|
78 | { | |||
|
79 | for(int i=0;i<this->folderViews.count();i++) | |||
|
80 | { | |||
|
81 | if(folderViews.at(i)->isDraging(name)) | |||
|
82 | return folderViews.at(i)->currentFolder(); | |||
|
83 | } | |||
|
84 | return ""; | |||
|
85 | } | |||
|
86 | ||||
75 |
|
87 | |||
76 | void MainWindow::itemDoubleClicked(QListWidgetItem* item) |
|
88 | void MainWindow::itemDoubleClicked(QListWidgetItem* item) | |
77 | { |
|
89 | { | |
@@ -96,7 +108,14 void MainWindow::plotFile(const QString | |||||
96 |
|
108 | |||
97 | void MainWindow::dataReady(QCPDataMap *ch1, QCPDataMap *ch2, QCPDataMap *ch3) |
|
109 | void MainWindow::dataReady(QCPDataMap *ch1, QCPDataMap *ch2, QCPDataMap *ch3) | |
98 | { |
|
110 | { | |
|
111 | for(int i=0;i<OMP_THREADS;i++) | |||
|
112 | { | |||
|
113 | progressThreadIds[i]=-1; | |||
|
114 | } | |||
99 | this->progressWidget->hide(); |
|
115 | this->progressWidget->hide(); | |
|
116 | this->ui->Plot->setGraphName(0,"MAG_X"); | |||
|
117 | this->ui->Plot->setGraphName(1,"MAG_Y"); | |||
|
118 | this->ui->Plot->setGraphName(2,"MAG_Z"); | |||
100 | this->ui->Plot->setGraphData(0,ch1,false,false); |
|
119 | this->ui->Plot->setGraphData(0,ch1,false,false); | |
101 | this->ui->Plot->setGraphData(1,ch2,false,false); |
|
120 | this->ui->Plot->setGraphData(1,ch2,false,false); | |
102 | this->ui->Plot->setGraphData(2,ch3,false,false); |
|
121 | this->ui->Plot->setGraphData(2,ch3,false,false); | |
@@ -131,17 +150,36 void MainWindow::downloadData(const QDat | |||||
131 |
|
150 | |||
132 | void MainWindow::updateProgress(int threadId, int percentProgress) |
|
151 | void MainWindow::updateProgress(int threadId, int percentProgress) | |
133 | { |
|
152 | { | |
134 | if(threadId<progress.count()) |
|
153 | bool updated=false; | |
135 | this->progress.at(threadId)->setValue(percentProgress); |
|
154 | for(int i=0;i<OMP_THREADS;i++) | |
|
155 | { | |||
|
156 | if(progressThreadIds[i]==threadId) | |||
|
157 | { | |||
|
158 | this->progress.at(threadId)->setValue(percentProgress); | |||
|
159 | updated=true; | |||
|
160 | } | |||
|
161 | } | |||
|
162 | if(Q_UNLIKELY(updated==false)) | |||
|
163 | { | |||
|
164 | for(int i=0;i<OMP_THREADS;i++) | |||
|
165 | { | |||
|
166 | if(progressThreadIds[i]==-1) | |||
|
167 | { | |||
|
168 | progressThreadIds[i] = threadId; | |||
|
169 | updateProgress(threadId,percentProgress); | |||
|
170 | } | |||
|
171 | } | |||
|
172 | } | |||
136 | } |
|
173 | } | |
137 |
|
174 | |||
138 | void MainWindow::addFolderView() |
|
175 | void MainWindow::addFolderView() | |
139 | { |
|
176 | { | |
140 | this->folderViews.append(new FolderView()); |
|
177 | this->folderViews.append(new FolderView(this)); | |
141 | this->ui->folderViews->addDockWidget(Qt::TopDockWidgetArea,this->folderViews.last()); |
|
178 | this->ui->folderViews->addDockWidget(Qt::TopDockWidgetArea,this->folderViews.last()); | |
142 |
this->folderViews.last()->setWindowTitle( " |
|
179 | this->folderViews.last()->setWindowTitle( QString("Folder View %1").arg(this->folderViews.length())); | |
143 | this->folderViews.last()->setAllowedAreas(Qt::AllDockWidgetAreas); |
|
180 | this->folderViews.last()->setAllowedAreas(Qt::AllDockWidgetAreas); | |
144 | connect(this->folderViews.last(),SIGNAL(itemActivated(QString)),this,SLOT(plotFile(QString))); |
|
181 | connect(this->folderViews.last(),SIGNAL(itemActivated(QString)),this,SLOT(plotFile(QString))); | |
|
182 | ||||
145 | } |
|
183 | } | |
146 |
|
184 | |||
147 | void MainWindow::fileDownloadComplete() |
|
185 | void MainWindow::fileDownloadComplete() | |
@@ -169,6 +207,14 void MainWindow::fileDownloadComplete() | |||||
169 | } |
|
207 | } | |
170 | } |
|
208 | } | |
171 |
|
209 | |||
|
210 | void MainWindow::askGlobalRescan() | |||
|
211 | { | |||
|
212 | for(int i=0;i<this->folderViews.count();i++) | |||
|
213 | { | |||
|
214 | this->folderViews.at(i)->refreshFolder(); | |||
|
215 | } | |||
|
216 | } | |||
|
217 | ||||
172 | void MainWindow::changeEvent(QEvent *e) |
|
218 | void MainWindow::changeEvent(QEvent *e) | |
173 | { |
|
219 | { | |
174 | QMainWindow::changeEvent(e); |
|
220 | QMainWindow::changeEvent(e); |
@@ -44,7 +44,7 class MainWindow : public QMainWindow | |||||
44 | public: |
|
44 | public: | |
45 | explicit MainWindow(int OMP_THREADS,QWidget *parent = 0); |
|
45 | explicit MainWindow(int OMP_THREADS,QWidget *parent = 0); | |
46 | ~MainWindow(); |
|
46 | ~MainWindow(); | |
47 |
|
47 | QString getFilePath(const QString& name); | ||
48 | public slots: |
|
48 | public slots: | |
49 | void itemDoubleClicked(QListWidgetItem *item); |
|
49 | void itemDoubleClicked(QListWidgetItem *item); | |
50 | void plotFile(const QString& File); |
|
50 | void plotFile(const QString& File); | |
@@ -53,6 +53,7 public slots: | |||||
53 | void updateProgress(int threadId,int percentProgress); |
|
53 | void updateProgress(int threadId,int percentProgress); | |
54 | void addFolderView(); |
|
54 | void addFolderView(); | |
55 | void fileDownloadComplete(); |
|
55 | void fileDownloadComplete(); | |
|
56 | void askGlobalRescan(); | |||
56 | protected: |
|
57 | protected: | |
57 | void changeEvent(QEvent *e); |
|
58 | void changeEvent(QEvent *e); | |
58 |
|
59 | |||
@@ -62,6 +63,7 private: | |||||
62 | QList<FileDownloader*> pendingDownloads; |
|
63 | QList<FileDownloader*> pendingDownloads; | |
63 | ThemisDataFile fileReader; |
|
64 | ThemisDataFile fileReader; | |
64 | QList<QProgressBar*> progress; |
|
65 | QList<QProgressBar*> progress; | |
|
66 | int* progressThreadIds; | |||
65 | QWidget* progressWidget; |
|
67 | QWidget* progressWidget; | |
66 | QVBoxLayout*progressLayout; |
|
68 | QVBoxLayout*progressLayout; | |
67 | int OMP_THREADS; |
|
69 | int OMP_THREADS; |
@@ -28,10 +28,10 | |||||
28 | #include <omp.h> |
|
28 | #include <omp.h> | |
29 | #include <QTimer> |
|
29 | #include <QTimer> | |
30 | #include <QElapsedTimer> |
|
30 | #include <QElapsedTimer> | |
|
31 | #include <time.h> | |||
31 |
|
32 | |||
32 | ThemisDataFile::ThemisDataFile(QObject *parent) : QThread(parent) |
|
33 | ThemisDataFile::ThemisDataFile(QObject *parent) : QThread(parent) | |
33 | { |
|
34 | { | |
34 | // this->moveToThread(this); |
|
|||
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | ThemisDataFile::~ThemisDataFile() |
|
37 | ThemisDataFile::~ThemisDataFile() | |
@@ -48,29 +48,32 void ThemisDataFile::parseFile(const QSt | |||||
48 | inline double __decodeVal(int ofset,unsigned char* data) |
|
48 | inline double __decodeVal(int ofset,unsigned char* data) | |
49 | { |
|
49 | { | |
50 | if(data[ofset]=='-') |
|
50 | if(data[ofset]=='-') | |
51 | return -1.0 * ((10.0 * (data[ofset+1] & 0x0F)) |
|
51 | return -0.001 * (double)( | |
52 |
|
|
52 | (10000 * (int)(data[ofset+1] & 0x0F)) | |
53 |
+ (0 |
|
53 | + (1000 * (int)(data[ofset+2] & 0x0F)) | |
54 |
+ (0 |
|
54 | + (100 * (int)(data[ofset+4] & 0x0F)) | |
55 |
+ ( |
|
55 | + (10 * (int)(data[ofset+5] & 0x0F)) | |
|
56 | + ( (int)(data[ofset+6] & 0x0F)) | |||
56 | ); |
|
57 | ); | |
57 | else |
|
58 | else | |
58 | { |
|
59 | { | |
59 | if(data[ofset+1]=='-') |
|
60 | if(data[ofset+1]=='-') | |
60 | { |
|
61 | { | |
61 |
return - |
|
62 | return -0.001 * (double)( | |
62 |
|
|
63 | (1000 * (int)(data[ofset+2] & 0x0F)) | |
63 |
+ (0 |
|
64 | + (100 * (int)(data[ofset+4] & 0x0F)) | |
64 |
+ ( |
|
65 | + (10 * (int)(data[ofset+5] & 0x0F)) | |
|
66 | + ( (int)(data[ofset+6] & 0x0F)) | |||
65 | ); |
|
67 | ); | |
66 | } |
|
68 | } | |
67 | else |
|
69 | else | |
68 | { |
|
70 | { | |
69 |
return |
|
71 | return 0.001 * (double)( | |
70 |
|
|
72 | (10000 * (int)(data[ofset+1] & 0x0F)) | |
71 |
+ (0 |
|
73 | + (1000 * (int)(data[ofset+2] & 0x0F)) | |
72 |
+ (0 |
|
74 | + (100 * (int)(data[ofset+4] & 0x0F)) | |
73 |
+ ( |
|
75 | + (10 * (int)(data[ofset+5] & 0x0F)) | |
|
76 | + ( (int)(data[ofset+6] & 0x0F)) | |||
74 | ); |
|
77 | ); | |
75 | } |
|
78 | } | |
76 | } |
|
79 | } | |
@@ -93,7 +96,35 inline QTime __decodeTime(int ofset,unsi | |||||
93 | return QTime(h,m,s,ms); |
|
96 | return QTime(h,m,s,ms); | |
94 | } |
|
97 | } | |
95 |
|
98 | |||
|
99 | double __decodeTimeFromEpochMs(int ofset,unsigned char* data) | |||
|
100 | { | |||
|
101 | struct tm t; | |||
|
102 | time_t t_of_day; | |||
|
103 | t.tm_year=(1000*(data[ofset] & 0x0F)) + (100*(data[ofset+1] & 0x0F)) + (10*(data[ofset+2] & 0x0F)) + ((data[ofset+3] & 0x0F)) -1900; | |||
|
104 | t.tm_mon=(10*(data[ofset+5] & 0x0F)) + ((data[ofset+6] & 0x0F)); | |||
|
105 | t.tm_mday=(10*(data[ofset+8] & 0x0F)) + ((data[ofset+9] & 0x0F)); | |||
|
106 | t.tm_hour=(10*(data[ofset+11] & 0x0F)) + ((data[ofset+12] & 0x0F)); | |||
|
107 | t.tm_min=(10*(data[ofset+14] & 0x0F)) + ((data[ofset+15] & 0x0F)); | |||
|
108 | t.tm_sec=(10*(data[ofset+17] & 0x0F)) + ((data[ofset+18] & 0x0F)); | |||
|
109 | int ms=(100*(data[ofset+20] & 0x0F)) + (10*(data[ofset+21] & 0x0F)) + ((data[ofset+22] & 0x0F)); | |||
|
110 | t_of_day = mktime(&t); | |||
|
111 | return (t_of_day*1000.0)+ms; | |||
|
112 | } | |||
96 |
|
113 | |||
|
114 | double __decodeTimeFromEpoch(int ofset,unsigned char* data) | |||
|
115 | { | |||
|
116 | struct tm t; | |||
|
117 | time_t t_of_day; | |||
|
118 | t.tm_year=(1000*(data[ofset] & 0x0F)) + (100*(data[ofset+1] & 0x0F)) + (10*(data[ofset+2] & 0x0F)) + ((data[ofset+3] & 0x0F)) -1900; | |||
|
119 | t.tm_mon=(10*(data[ofset+5] & 0x0F)) + ((data[ofset+6] & 0x0F)); | |||
|
120 | t.tm_mday=(10*(data[ofset+8] & 0x0F)) + ((data[ofset+9] & 0x0F)); | |||
|
121 | t.tm_hour=(10*(data[ofset+11] & 0x0F)) + ((data[ofset+12] & 0x0F)); | |||
|
122 | t.tm_min=(10*(data[ofset+14] & 0x0F)) + ((data[ofset+15] & 0x0F)); | |||
|
123 | t.tm_sec=(10*(data[ofset+17] & 0x0F)) + ((data[ofset+18] & 0x0F)); | |||
|
124 | int ms=(100*(data[ofset+20] & 0x0F)) + (10*(data[ofset+21] & 0x0F)) + ((data[ofset+22] & 0x0F)); | |||
|
125 | t_of_day = mktime(&t); | |||
|
126 | return t_of_day+(ms*0.001); | |||
|
127 | } | |||
97 | void ThemisDataFile::run() |
|
128 | void ThemisDataFile::run() | |
98 | { |
|
129 | { | |
99 | FILE* dataFile; |
|
130 | FILE* dataFile; | |
@@ -106,9 +137,6 void ThemisDataFile::run() | |||||
106 | double _x=0.0; |
|
137 | double _x=0.0; | |
107 | char* line; |
|
138 | char* line; | |
108 | QCPData data1,data2,data3; |
|
139 | QCPData data1,data2,data3; | |
109 | // QCPData data12,data22,data32; |
|
|||
110 | // QCPData data13,data23,data33; |
|
|||
111 | // QCPData data14,data24,data34; |
|
|||
112 | if(dataFile != NULL) |
|
140 | if(dataFile != NULL) | |
113 | { |
|
141 | { | |
114 | fseek(dataFile, 0L, SEEK_END); |
|
142 | fseek(dataFile, 0L, SEEK_END); | |
@@ -138,13 +166,7 void ThemisDataFile::run() | |||||
138 | #pragma omp for |
|
166 | #pragma omp for | |
139 | for(int i=0;i<(FileSize/(58));i++) |
|
167 | for(int i=0;i<(FileSize/(58));i++) | |
140 | { |
|
168 | { | |
141 | line[(i*58)+23]='\0'; |
|
169 | _x=__decodeTimeFromEpoch((i*58),(unsigned char*)line); | |
142 | line[(i*58)+56]='\0'; |
|
|||
143 | //_x= QDateTime::fromString(line+(i*58),"yyyy-MM-ddThh:mm:ss.zzz").toMSecsSinceEpoch(); |
|
|||
144 | // sscanf(line+(i*58)+24,"%lf %lf %lf",&_y1,&_y2,&_y3); |
|
|||
145 | date.setDate(__decodeDate((i*58),(unsigned char*)line)); |
|
|||
146 | date.setTime(__decodeTime(((i*58)+11),(unsigned char*)line)); |
|
|||
147 | _x= date.toMSecsSinceEpoch(); |
|
|||
148 | data1.key=_x; |
|
170 | data1.key=_x; | |
149 | data2.key=_x; |
|
171 | data2.key=_x; | |
150 | data3.key=_x; |
|
172 | data3.key=_x; |
General Comments 0
You need to be logged in to leave comments.
Login now