@@ -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 | 23 | src/themisdatafile.cpp \ |
|
24 | 24 | src/filedownloader.cpp \ |
|
25 | 25 | src/folderview.cpp \ |
|
26 | src/toolbarcontainer.cpp | |
|
26 | src/toolbarcontainer.cpp \ | |
|
27 | src/folderlistwidget.cpp | |
|
27 | 28 | |
|
28 | 29 | HEADERS += src/mainwindow.h \ |
|
29 | 30 | src/SocExplorerPlot.h \ |
@@ -31,7 +32,8 HEADERS += src/mainwindow.h \ | |||
|
31 | 32 | src/themisdatafile.h \ |
|
32 | 33 | src/filedownloader.h \ |
|
33 | 34 | src/folderview.h \ |
|
34 | src/toolbarcontainer.h | |
|
35 | src/toolbarcontainer.h \ | |
|
36 | src/folderlistwidget.h | |
|
35 | 37 | |
|
36 | 38 | FORMS += src/mainwindow.ui \ |
|
37 | 39 | src/folderview.ui |
@@ -24,24 +24,25 | |||
|
24 | 24 | |
|
25 | 25 | |
|
26 | 26 | SocExplorerPlot::SocExplorerPlot(QWidget *parent) : |
|
27 |
|
|
|
27 | QWidget(parent) | |
|
28 | 28 | { |
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
29 | this->m_plot = new QCustomPlot(this); | |
|
30 | this->m_plot->setInteractions(QCP::iRangeDrag | QCP::iSelectAxes | | |
|
31 | QCP::iSelectLegend | QCP::iSelectPlottables); | |
|
32 | this->m_plot->axisRect()->setRangeDrag(Qt::Horizontal|Qt::Vertical); | |
|
33 | this->m_plot->axisRect()->setRangeZoom(Qt::Horizontal|Qt::Vertical); | |
|
34 | this->m_mainlayout = new QGridLayout(this); | |
|
35 | this->setLayout(this->m_mainlayout); | |
|
36 | this->m_mainlayout->addWidget(this->m_plot); | |
|
37 | this->setMinimumSize(400,300); | |
|
38 | this->setFocusPolicy(Qt::WheelFocus); | |
|
39 | this->m_plot->setAttribute(Qt::WA_TransparentForMouseEvents); | |
|
40 | this->ctrl_hold = false; | |
|
41 | this->shift_hold = false; | |
|
42 | this->mouse_hold = false; | |
|
43 | this->m_plot->setNoAntialiasingOnDrag(true); | |
|
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 | 59 | void SocExplorerPlot::setTitle(QString title) |
|
59 | 60 | { |
|
60 |
|
|
|
61 |
|
|
|
62 | /*! | |
|
61 | Q_UNUSED(title) | |
|
62 | //this->m_plot->setTitle(title); | |
|
63 | /*! | |
|
63 | 64 | @todo Function borcken fixe this! |
|
64 | 65 | */ |
|
65 |
|
|
|
66 | this->repaint(); | |
|
66 | 67 | } |
|
67 | 68 | |
|
68 | 69 | void SocExplorerPlot::setXaxisLabel(QString label) |
|
69 | 70 | { |
|
70 |
|
|
|
71 |
|
|
|
71 | this->m_plot->xAxis->setLabel(label); | |
|
72 | this->repaint(); | |
|
72 | 73 | } |
|
73 | 74 | |
|
74 | 75 | void SocExplorerPlot::setYaxisLabel(QString label) |
|
75 | 76 | { |
|
76 |
|
|
|
77 |
|
|
|
77 | this->m_plot->yAxis->setLabel(label); | |
|
78 | this->repaint(); | |
|
78 | 79 | } |
|
79 | 80 | |
|
80 | 81 | void SocExplorerPlot::setXaxisRange(double lower, double upper) |
|
81 | 82 | { |
|
82 |
|
|
|
83 | this->m_plot->xAxis->setRange(lower,upper); | |
|
83 | 84 | } |
|
84 | 85 | |
|
85 | 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 | 92 | void SocExplorerPlot::rescaleAxis() |
|
92 | 93 | { |
|
93 |
|
|
|
94 |
|
|
|
94 | this->m_plot->rescaleAxes(); | |
|
95 | this->m_plot->replot(); | |
|
95 | 96 | } |
|
96 | 97 | |
|
97 | 98 | void SocExplorerPlot::setLegendFont(QFont font) |
|
98 | 99 | { |
|
99 |
|
|
|
100 |
|
|
|
100 | this->m_plot->legend->setFont(font); | |
|
101 | this->repaint(); | |
|
101 | 102 | } |
|
102 | 103 | |
|
103 | 104 | void SocExplorerPlot::setLegendSelectedFont(QFont font) |
|
104 | 105 | { |
|
105 |
|
|
|
106 |
|
|
|
106 | this->m_plot->legend->setSelectedFont(font); | |
|
107 | this->repaint(); | |
|
107 | 108 | } |
|
108 | 109 | |
|
109 | 110 | void SocExplorerPlot::setAdaptativeSampling(int graphIndex, bool enable) |
|
110 | 111 | { |
|
111 |
|
|
|
112 | this->m_plot->graph(graphIndex)->setAdaptiveSampling(enable); | |
|
112 | 113 | } |
|
113 | 114 | |
|
114 | 115 | int SocExplorerPlot::addGraph() |
|
115 | 116 | { |
|
116 |
|
|
|
117 | this->m_plot->addGraph(); | |
|
117 | 118 | return this->m_plot->graphCount() -1; |
|
118 | 119 | } |
|
119 | 120 | |
@@ -134,136 +135,136 void SocExplorerPlot::removeAllGraphs() | |||
|
134 | 135 | |
|
135 | 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 | 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 |
|
|
|
149 | QVector<double> _x(x.count()), _y(y.count()); | |
|
150 | for(int i=0;i<x.count();i++) | |
|
150 | 151 | { |
|
151 |
|
|
|
152 | /*_x[i] = x.at(i).value<double>(); | |
|
152 | 153 | _y[i] = y.at(i).value<double>();*/ |
|
153 |
|
|
|
154 |
|
|
|
154 | _x[i] = x.at(i).toDouble(); | |
|
155 | _y[i] = y.at(i).toDouble(); | |
|
155 | 156 | } |
|
156 |
|
|
|
157 | this->m_plot->graph(graphIndex)->setData(_x,_y); | |
|
157 | 158 | } |
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
159 | else | |
|
160 | { | |
|
161 | if((graphIndex<this->m_plot->graphCount()) && (x.count()==y.count()) && (x.at(0).type()==QVariant::DateTime)) | |
|
161 | 162 | { |
|
162 |
|
|
|
163 |
|
|
|
163 | QVector<double> _x(x.count()), _y(y.count()); | |
|
164 | for(int i=0;i<x.count();i++) | |
|
164 | 165 | { |
|
165 |
|
|
|
166 | /*_x[i] = x.at(i).value<double>(); | |
|
166 | 167 | _y[i] = y.at(i).value<double>();*/ |
|
167 |
|
|
|
168 |
|
|
|
168 | _x[i] = x.at(i).toDateTime().toMSecsSinceEpoch(); | |
|
169 | _y[i] = y.at(i).toDouble(); | |
|
169 | 170 | } |
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
|
171 | this->m_plot->graph(graphIndex)->setData(_x,_y); | |
|
172 | this->m_plot->xAxis->setTickLabelType(QCPAxis::ltDateTime); | |
|
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 | 180 | void SocExplorerPlot::setGraphData(int graphIndex, QCPDataMap *data, bool copy, bool replot) |
|
180 | 181 | { |
|
181 | 182 | if((graphIndex<this->m_plot->graphCount()))// && (x.at(0).type()==QVariant::Double)) |
|
182 | { | |
|
183 | { | |
|
183 | 184 | this->m_plot->graph(graphIndex)->setData(data,copy); |
|
184 | } | |
|
185 | } | |
|
185 | 186 | if(replot) |
|
186 | 187 | this->m_plot->replot(); |
|
187 | 188 | } |
|
188 | 189 | |
|
189 | 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 |
|
|
|
194 | QVector<double> _x(x.count()), _y(y.count()); | |
|
195 | for(int i=0;i<x.count();i++) | |
|
195 | 196 | { |
|
196 |
|
|
|
197 | /*_x[i] = x.at(i).value<double>(); | |
|
197 | 198 | _y[i] = y.at(i).value<double>();*/ |
|
198 |
|
|
|
199 |
|
|
|
199 | _x[i] = x.at(i).toDouble(); | |
|
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 | 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 | 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 | 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 | 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 |
|
|
|
241 | this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsNone); | |
|
242 | return; | |
|
242 | 243 | } |
|
243 |
|
|
|
244 | if(!lineStyle.compare("line")) | |
|
244 | 245 | { |
|
245 |
|
|
|
246 |
|
|
|
246 | this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsLine); | |
|
247 | return; | |
|
247 | 248 | } |
|
248 |
|
|
|
249 | if(!lineStyle.compare("stepleft")) | |
|
249 | 250 | { |
|
250 |
|
|
|
251 |
|
|
|
251 | this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsStepLeft); | |
|
252 | return; | |
|
252 | 253 | } |
|
253 |
|
|
|
254 | if(!lineStyle.compare("stepright")) | |
|
254 | 255 | { |
|
255 |
|
|
|
256 |
|
|
|
256 | this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsStepRight); | |
|
257 | return; | |
|
257 | 258 | } |
|
258 |
|
|
|
259 | if(!lineStyle.compare("stepcenter")) | |
|
259 | 260 | { |
|
260 |
|
|
|
261 |
|
|
|
261 | this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsStepCenter); | |
|
262 | return; | |
|
262 | 263 | } |
|
263 |
|
|
|
264 | if(!lineStyle.compare("impulse")) | |
|
264 | 265 | { |
|
265 |
|
|
|
266 |
|
|
|
266 | this->m_plot->graph(graphIndex)->setLineStyle(QCPGraph::lsImpulse); | |
|
267 | return; | |
|
267 | 268 | } |
|
268 | 269 | |
|
269 | 270 | |
@@ -272,90 +273,90 void SocExplorerPlot::setGraphLineStyle( | |||
|
272 | 273 | |
|
273 | 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 |
|
|
|
280 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssNone); | |
|
281 | return; | |
|
281 | 282 | } |
|
282 |
|
|
|
283 | if(!scatterStyle.compare("dot")) | |
|
283 | 284 | { |
|
284 |
|
|
|
285 |
|
|
|
285 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssDot); | |
|
286 | return; | |
|
286 | 287 | } |
|
287 |
|
|
|
288 | if(!scatterStyle.compare("cross")) | |
|
288 | 289 | { |
|
289 |
|
|
|
290 |
|
|
|
290 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCross); | |
|
291 | return; | |
|
291 | 292 | } |
|
292 |
|
|
|
293 | if(!scatterStyle.compare("plus")) | |
|
293 | 294 | { |
|
294 |
|
|
|
295 |
|
|
|
295 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPlus); | |
|
296 | return; | |
|
296 | 297 | } |
|
297 |
|
|
|
298 | if(!scatterStyle.compare("circle")) | |
|
298 | 299 | { |
|
299 |
|
|
|
300 |
|
|
|
300 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCircle); | |
|
301 | return; | |
|
301 | 302 | } |
|
302 |
|
|
|
303 | if(!scatterStyle.compare("disc")) | |
|
303 | 304 | { |
|
304 |
|
|
|
305 |
|
|
|
305 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssDisc); | |
|
306 | return; | |
|
306 | 307 | } |
|
307 |
|
|
|
308 | if(!scatterStyle.compare("square")) | |
|
308 | 309 | { |
|
309 |
|
|
|
310 |
|
|
|
310 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssSquare); | |
|
311 | return; | |
|
311 | 312 | } |
|
312 |
|
|
|
313 | if(!scatterStyle.compare("diamond")) | |
|
313 | 314 | { |
|
314 |
|
|
|
315 |
|
|
|
315 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssDiamond); | |
|
316 | return; | |
|
316 | 317 | } |
|
317 |
|
|
|
318 | if(!scatterStyle.compare("star")) | |
|
318 | 319 | { |
|
319 |
|
|
|
320 |
|
|
|
320 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssStar); | |
|
321 | return; | |
|
321 | 322 | } |
|
322 |
|
|
|
323 | if(!scatterStyle.compare("triangle")) | |
|
323 | 324 | { |
|
324 |
|
|
|
325 |
|
|
|
325 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssTriangle); | |
|
326 | return; | |
|
326 | 327 | } |
|
327 |
|
|
|
328 | if(!scatterStyle.compare("invertedtriangle")) | |
|
328 | 329 | { |
|
329 |
|
|
|
330 |
|
|
|
330 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssTriangleInverted); | |
|
331 | return; | |
|
331 | 332 | } |
|
332 |
|
|
|
333 | if(!scatterStyle.compare("crosssquare")) | |
|
333 | 334 | { |
|
334 |
|
|
|
335 |
|
|
|
335 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCrossSquare); | |
|
336 | return; | |
|
336 | 337 | } |
|
337 |
|
|
|
338 | if(!scatterStyle.compare("plussquare")) | |
|
338 | 339 | { |
|
339 |
|
|
|
340 |
|
|
|
340 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPlusSquare); | |
|
341 | return; | |
|
341 | 342 | } |
|
342 |
|
|
|
343 | if(!scatterStyle.compare("crosscircle")) | |
|
343 | 344 | { |
|
344 |
|
|
|
345 |
|
|
|
345 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssCrossCircle); | |
|
346 | return; | |
|
346 | 347 | } |
|
347 |
|
|
|
348 | if(!scatterStyle.compare("pluscircle")) | |
|
348 | 349 | { |
|
349 |
|
|
|
350 |
|
|
|
350 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPlusCircle); | |
|
351 | return; | |
|
351 | 352 | } |
|
352 |
|
|
|
353 | if(!scatterStyle.compare("peace")) | |
|
353 | 354 | { |
|
354 |
|
|
|
355 |
|
|
|
355 | this->m_plot->graph(graphIndex)->setScatterStyle(QCPScatterStyle::ssPeace); | |
|
356 | return; | |
|
356 | 357 | } |
|
357 | 358 | |
|
358 |
|
|
|
359 | } | |
|
359 | 360 | } |
|
360 | 361 | |
|
361 | 362 | void SocExplorerPlot::setXaxisTickLabelType(QCPAxis::LabelType type) |
@@ -374,74 +375,107 void SocExplorerPlot::setXaxisDateTimeFo | |||
|
374 | 375 | |
|
375 | 376 | void SocExplorerPlot::keyPressEvent(QKeyEvent * event) |
|
376 | 377 | { |
|
377 |
|
|
|
378 | switch(event->key()) | |
|
378 | 379 | { |
|
379 | 380 | case Qt::Key_Control: |
|
380 |
|
|
|
381 |
|
|
|
381 | this->ctrl_hold = true; | |
|
382 | break; | |
|
382 | 383 | case Qt::Key_Shift: |
|
383 |
|
|
|
384 |
|
|
|
384 | this->shift_hold = true; | |
|
385 | break; | |
|
385 | 386 | case Qt::Key_M: |
|
386 |
|
|
|
387 |
|
|
|
387 | this->rescaleAxis(); | |
|
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 | 429 | default: |
|
389 |
|
|
|
390 |
|
|
|
430 | QWidget::keyPressEvent(event); | |
|
431 | break; | |
|
391 | 432 | } |
|
392 | 433 | } |
|
393 | 434 | |
|
394 | 435 | void SocExplorerPlot::keyReleaseEvent(QKeyEvent * event) |
|
395 | 436 | { |
|
396 |
|
|
|
437 | switch(event->key()) | |
|
397 | 438 | { |
|
398 | 439 | case Qt::Key_Control: |
|
399 |
|
|
|
400 |
|
|
|
401 |
|
|
|
440 | event->accept(); | |
|
441 | this->ctrl_hold = false; | |
|
442 | break; | |
|
402 | 443 | case Qt::Key_Shift: |
|
403 |
|
|
|
404 |
|
|
|
405 |
|
|
|
444 | event->accept(); | |
|
445 | this->shift_hold = false; | |
|
446 | break; | |
|
406 | 447 | default: |
|
407 |
|
|
|
408 |
|
|
|
448 | QWidget::keyReleaseEvent(event); | |
|
449 | break; | |
|
409 | 450 | } |
|
410 | 451 | } |
|
411 | 452 | |
|
412 | 453 | void SocExplorerPlot::wheelEvent(QWheelEvent * event) |
|
413 | 454 | { |
|
414 |
|
|
|
415 |
|
|
|
416 |
|
|
|
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) | |
|
455 | double factor; | |
|
456 | double wheelSteps = event->delta()/120.0; // a single step delta is +/-120 usually | |
|
457 | if(ctrl_hold) | |
|
429 | 458 | { |
|
430 |
|
|
|
459 | if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical)) | |
|
431 | 460 | { |
|
432 |
|
|
|
433 | QCPAxis* axis = this->m_plot->axisRect()->rangeZoomAxis(Qt::Horizontal); | |
|
434 | axis->scaleRange(factor, axis->pixelToCoord(event->pos().x())); | |
|
461 | factor = pow(this->m_plot->axisRect()->rangeZoomFactor(Qt::Vertical), wheelSteps); | |
|
462 | zoom(factor,event->pos().y(),Qt::Vertical); | |
|
435 | 463 | } |
|
436 | this->m_plot->replot(); | |
|
437 | QWidget::wheelEvent(event); | |
|
438 | return; | |
|
464 | QWidget::wheelEvent(event); | |
|
465 | return; | |
|
439 | 466 | } |
|
440 | QCPAxis* Haxis = this->m_plot->axisRect()->rangeDragAxis(Qt::Horizontal); | |
|
441 | double rg = (Haxis->range().upper - Haxis->range().lower)*(wheelSteps/10); | |
|
442 | Haxis->setRange(Haxis->range().lower+(rg), Haxis->range().upper+(rg)); | |
|
443 | this->m_plot->replot(); | |
|
444 | QWidget::wheelEvent(event); | |
|
467 | if(shift_hold) | |
|
468 | { | |
|
469 | if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical)) | |
|
470 | { | |
|
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 | 484 | void SocExplorerPlot::mousePressEvent(QMouseEvent *event) |
|
451 | 485 | { |
|
452 |
|
|
|
486 | if(event->button()==Qt::LeftButton) | |
|
453 | 487 | { |
|
454 |
|
|
|
455 |
|
|
|
456 |
|
|
|
457 |
|
|
|
488 | mDragStart = event->pos(); | |
|
489 | this->mouse_hold = true; | |
|
490 | DragStartHorzRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Horizontal)->range(); | |
|
491 | DragStartVertRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Vertical)->range(); | |
|
458 | 492 | } |
|
459 |
|
|
|
493 | QWidget::mousePressEvent(event); | |
|
460 | 494 | } |
|
461 | 495 | |
|
462 | 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 | 521 | void SocExplorerPlot::mouseMoveEvent(QMouseEvent *event) |
|
472 | 522 | { |
|
473 |
|
|
|
523 | if(mouse_hold) | |
|
474 | 524 | { |
|
475 |
|
|
|
476 |
|
|
|
477 |
|
|
|
478 |
|
|
|
479 |
|
|
|
480 |
|
|
|
481 |
|
|
|
525 | QCPAxis* Haxis = this->m_plot->axisRect()->rangeDragAxis(Qt::Horizontal); | |
|
526 | QCPAxis* Vaxis = this->m_plot->axisRect()->rangeDragAxis(Qt::Vertical); | |
|
527 | double diff = Haxis->pixelToCoord(mDragStart.x()) - Haxis->pixelToCoord(event->pos().x()); | |
|
528 | Haxis->setRange(DragStartHorzRange.lower+diff, DragStartHorzRange.upper+diff); | |
|
529 | diff = Vaxis->pixelToCoord(mDragStart.y()) - Vaxis->pixelToCoord(event->pos().y()); | |
|
530 | Vaxis->setRange(DragStartVertRange.lower+diff, DragStartVertRange.upper+diff); | |
|
531 | this->m_plot->replot(); | |
|
482 | 532 | } |
|
483 |
|
|
|
533 | QWidget::mouseMoveEvent(event); | |
|
484 | 534 | } |
|
485 | 535 | |
|
486 | 536 |
@@ -70,6 +70,8 protected: | |||
|
70 | 70 | void mouseReleaseEvent(QMouseEvent *); |
|
71 | 71 | |
|
72 | 72 | private: |
|
73 | void zoom(double factor, int center, Qt::Orientation orientation); | |
|
74 | void move(double factor, Qt::Orientation orientation); | |
|
73 | 75 | QCustomPlot* m_plot; |
|
74 | 76 | QGridLayout* m_mainlayout; |
|
75 | 77 | bool ctrl_hold; |
@@ -23,26 +23,26 | |||
|
23 | 23 | #include "ui_folderview.h" |
|
24 | 24 | #include <QFileDialog> |
|
25 | 25 | #include <QLabel> |
|
26 | #include <QDebug> | |
|
26 | 27 | |
|
27 | FolderView::FolderView(QWidget *parent) : | |
|
28 |
Q |
|
|
29 | ui(new Ui::FolderView) | |
|
28 | p_FolderView::p_FolderView(QWidget *parent) : | |
|
29 | QWidget(parent), | |
|
30 | ui(new Ui::p_FolderView) | |
|
30 | 31 | { |
|
31 | 32 | ui->setupUi(this); |
|
32 | this->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); | |
|
33 | this->setAllowedAreas(Qt::AllDockWidgetAreas); | |
|
34 | this->setWidget(this->ui->groupBox); | |
|
35 | 33 | connect(this->ui->setFolderQpb,SIGNAL(clicked()),this,SLOT(openFolder())); |
|
36 | 34 | connect(this->ui->refreshQpb,SIGNAL(clicked()),this,SLOT(refreshFolder())); |
|
37 | 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 | 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 | 47 | for(int i=0;i<this->ui->listWidget->count();i++) |
|
48 | 48 | { |
@@ -54,16 +54,31 bool FolderView::contains(const QString | |||
|
54 | 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 | 75 | refreshFolder(); |
|
61 | 76 | } |
|
62 | 77 | |
|
63 | void FolderView::refreshFolder() | |
|
78 | void p_FolderView::refreshFolder() | |
|
64 | 79 | { |
|
65 | 80 | QDir dir; |
|
66 | dir.setPath(currentFolder); | |
|
81 | dir.setPath(p_currentFolder); | |
|
67 | 82 | this->ui->listWidget->clear(); |
|
68 | 83 | dir.setFilter(QDir::Files | QDir::NoSymLinks); |
|
69 | 84 | dir.setSorting(QDir::Name); |
@@ -75,15 +90,16 void FolderView::refreshFolder() | |||
|
75 | 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 | 104 | QWidget::changeEvent(e); |
|
89 | 105 | switch (e->type()) { |
@@ -94,3 +110,56 void FolderView::changeEvent(QEvent *e) | |||
|
94 | 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 | 25 | #include <QWidget> |
|
26 | 26 | #include <QDockWidget> |
|
27 | 27 | #include <QListWidget> |
|
28 | ||
|
28 | #include <QEvent> | |
|
29 | #include <QDropEvent> | |
|
30 | class MainWindow; | |
|
29 | 31 | namespace Ui { |
|
30 | class FolderView; | |
|
32 | class p_FolderView; | |
|
31 | 33 | } |
|
32 | 34 | |
|
35 | class p_FolderView; | |
|
36 | ||
|
33 | 37 | class FolderView : public QDockWidget |
|
34 | 38 | { |
|
35 | 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 | 61 | public: |
|
38 | explicit FolderView(QWidget *parent = 0); | |
|
39 | ~FolderView(); | |
|
62 | explicit p_FolderView(QWidget *parent = 0); | |
|
63 | ~p_FolderView(); | |
|
40 | 64 | bool contains(const QString& fileName); |
|
65 | bool isDraging(const QString& name); | |
|
66 | void setMainWindow(MainWindow* mw); | |
|
67 | QString currentFolder(); | |
|
41 | 68 | public slots: |
|
42 | 69 | void openFolder(); |
|
43 | 70 | void refreshFolder(); |
|
44 | 71 | void itemActivated(QListWidgetItem * item); |
|
45 | 72 | signals: |
|
73 | void askGlobalRescan(); | |
|
46 | 74 | void itemActivated(const QString& item); |
|
47 | 75 | protected: |
|
48 | 76 | void changeEvent(QEvent *e); |
|
77 | bool eventFilter(QObject *object, QEvent *event); | |
|
49 | 78 | |
|
50 | 79 | private: |
|
51 | Ui::FolderView *ui; | |
|
80 | Ui::p_FolderView *ui; | |
|
52 | 81 | QWidget* _Widget; |
|
53 | QString currentFolder; | |
|
82 | QString p_currentFolder; | |
|
54 | 83 | }; |
|
55 | 84 | |
|
56 | 85 | #endif // FOLDERVIEW_H |
@@ -1,7 +1,7 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <ui version="4.0"> |
|
3 | <class>FolderView</class> | |
|
4 | <widget class="QWidget" name="FolderView"> | |
|
3 | <class>p_FolderView</class> | |
|
4 | <widget class="QWidget" name="p_FolderView"> | |
|
5 | 5 | <property name="geometry"> |
|
6 | 6 | <rect> |
|
7 | 7 | <x>0</x> |
@@ -13,78 +13,87 | |||
|
13 | 13 | <property name="windowTitle"> |
|
14 | 14 | <string>Test</string> |
|
15 | 15 | </property> |
|
16 |
< |
|
|
17 | <property name="geometry"> | |
|
18 | <rect> | |
|
19 | <x>9</x> | |
|
20 | <y>9</y> | |
|
21 | <width>282</width> | |
|
22 | <height>268</height> | |
|
23 | </rect> | |
|
24 | </property> | |
|
25 |
<property name=" |
|
|
26 | <string>No Folder</string> | |
|
27 | </property> | |
|
28 | <layout class="QGridLayout" name="gridLayout_2"> | |
|
29 | <item row="0" column="0" colspan="3"> | |
|
30 | <widget class="QListWidget" name="listWidget"> | |
|
31 |
<property name=" |
|
|
32 | <set>QAbstractItemView::NoEditTriggers</set> | |
|
33 | </property> | |
|
34 |
<property name="drag |
|
|
35 |
<bool> |
|
|
36 | </property> | |
|
37 | <property name="dragDropMode"> | |
|
38 | <enum>QAbstractItemView::DragDrop</enum> | |
|
39 | </property> | |
|
40 | <property name="defaultDropAction"> | |
|
41 | <enum>Qt::MoveAction</enum> | |
|
42 | </property> | |
|
43 | </widget> | |
|
44 | </item> | |
|
45 | <item row="1" column="1"> | |
|
46 | <widget class="QPushButton" name="setFolderQpb"> | |
|
47 | <property name="text"> | |
|
48 | <string>Set Folder</string> | |
|
49 | </property> | |
|
50 | </widget> | |
|
51 | </item> | |
|
52 | <item row="1" column="2"> | |
|
53 | <widget class="QPushButton" name="refreshQpb"> | |
|
54 | <property name="styleSheet"> | |
|
55 | <string notr="true"/> | |
|
56 | </property> | |
|
57 | <property name="text"> | |
|
58 | <string/> | |
|
59 | </property> | |
|
60 | <property name="icon"> | |
|
61 | <iconset resource="../resources/qlop.qrc"> | |
|
62 | <normaloff>:/img/Gnome-view-refresh.svg</normaloff>:/img/Gnome-view-refresh.svg</iconset> | |
|
63 | </property> | |
|
64 | <property name="iconSize"> | |
|
65 | <size> | |
|
66 | <width>24</width> | |
|
67 | <height>24</height> | |
|
68 | </size> | |
|
69 | </property> | |
|
70 | </widget> | |
|
71 | </item> | |
|
72 | <item row="1" column="0"> | |
|
73 | <spacer name="horizontalSpacer"> | |
|
74 | <property name="orientation"> | |
|
75 | <enum>Qt::Horizontal</enum> | |
|
76 | </property> | |
|
77 | <property name="sizeHint" stdset="0"> | |
|
78 | <size> | |
|
79 | <width>40</width> | |
|
80 | <height>20</height> | |
|
81 | </size> | |
|
82 | </property> | |
|
83 | </spacer> | |
|
84 | </item> | |
|
85 | </layout> | |
|
86 | </widget> | |
|
16 | <layout class="QGridLayout" name="gridLayout"> | |
|
17 | <item row="0" column="0"> | |
|
18 | <widget class="QGroupBox" name="groupBox"> | |
|
19 | <property name="title"> | |
|
20 | <string>No Folder</string> | |
|
21 | </property> | |
|
22 | <layout class="QGridLayout" name="gridLayout_2"> | |
|
23 | <item row="0" column="0" colspan="3"> | |
|
24 | <widget class="FolderListWidget" name="listWidget"> | |
|
25 | <property name="acceptDrops"> | |
|
26 | <bool>true</bool> | |
|
27 | </property> | |
|
28 | <property name="editTriggers"> | |
|
29 | <set>QAbstractItemView::NoEditTriggers</set> | |
|
30 | </property> | |
|
31 | <property name="dragEnabled"> | |
|
32 | <bool>true</bool> | |
|
33 | </property> | |
|
34 | <property name="dragDropOverwriteMode"> | |
|
35 | <bool>false</bool> | |
|
36 | </property> | |
|
37 | <property name="dragDropMode"> | |
|
38 | <enum>QAbstractItemView::DragDrop</enum> | |
|
39 | </property> | |
|
40 | <property name="defaultDropAction"> | |
|
41 | <enum>Qt::MoveAction</enum> | |
|
42 | </property> | |
|
43 | </widget> | |
|
44 | </item> | |
|
45 | <item row="1" column="1"> | |
|
46 | <widget class="QPushButton" name="setFolderQpb"> | |
|
47 | <property name="text"> | |
|
48 | <string>Set Folder</string> | |
|
49 | </property> | |
|
50 | </widget> | |
|
51 | </item> | |
|
52 | <item row="1" column="2"> | |
|
53 | <widget class="QPushButton" name="refreshQpb"> | |
|
54 | <property name="styleSheet"> | |
|
55 | <string notr="true"/> | |
|
56 | </property> | |
|
57 | <property name="text"> | |
|
58 | <string/> | |
|
59 | </property> | |
|
60 | <property name="icon"> | |
|
61 | <iconset resource="../resources/qlop.qrc"> | |
|
62 | <normaloff>:/img/Gnome-view-refresh.svg</normaloff>:/img/Gnome-view-refresh.svg</iconset> | |
|
63 | </property> | |
|
64 | <property name="iconSize"> | |
|
65 | <size> | |
|
66 | <width>24</width> | |
|
67 | <height>24</height> | |
|
68 | </size> | |
|
69 | </property> | |
|
70 | </widget> | |
|
71 | </item> | |
|
72 | <item row="1" column="0"> | |
|
73 | <spacer name="horizontalSpacer"> | |
|
74 | <property name="orientation"> | |
|
75 | <enum>Qt::Horizontal</enum> | |
|
76 | </property> | |
|
77 | <property name="sizeHint" stdset="0"> | |
|
78 | <size> | |
|
79 | <width>40</width> | |
|
80 | <height>20</height> | |
|
81 | </size> | |
|
82 | </property> | |
|
83 | </spacer> | |
|
84 | </item> | |
|
85 | </layout> | |
|
86 | </widget> | |
|
87 | </item> | |
|
88 | </layout> | |
|
87 | 89 | </widget> |
|
90 | <customwidgets> | |
|
91 | <customwidget> | |
|
92 | <class>FolderListWidget</class> | |
|
93 | <extends>QListWidget</extends> | |
|
94 | <header>folderlistwidget.h</header> | |
|
95 | </customwidget> | |
|
96 | </customwidgets> | |
|
88 | 97 | <resources> |
|
89 | 98 | <include location="../resources/qlop.qrc"/> |
|
90 | 99 | </resources> |
@@ -55,6 +55,7 MainWindow::MainWindow(int OMP_THREADS, | |||
|
55 | 55 | this->progressLayout = new QVBoxLayout(this->progressWidget); |
|
56 | 56 | this->progressWidget->setLayout(this->progressLayout); |
|
57 | 57 | this->progressWidget->setWindowModality(Qt::WindowModal); |
|
58 | progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); | |
|
58 | 59 | for(int i=0;i<OMP_THREADS;i++) |
|
59 | 60 | { |
|
60 | 61 | this->progress.append(new QProgressBar(this->progressWidget)); |
@@ -63,6 +64,7 MainWindow::MainWindow(int OMP_THREADS, | |||
|
63 | 64 | connect(&this->fileReader,SIGNAL(updateProgress(int,int)),this,SLOT(updateProgress(int,int))); |
|
64 | 65 | this->progressLayout->addWidget(this->progress.last()); |
|
65 | 66 | this->progressWidget->hide(); |
|
67 | this->progressThreadIds[i] = -1; | |
|
66 | 68 | } |
|
67 | 69 | this->progressWidget->setWindowTitle("Loading File"); |
|
68 | 70 | } |
@@ -72,6 +74,16 MainWindow::~MainWindow() | |||
|
72 | 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 | 88 | void MainWindow::itemDoubleClicked(QListWidgetItem* item) |
|
77 | 89 | { |
@@ -96,7 +108,14 void MainWindow::plotFile(const QString | |||
|
96 | 108 | |
|
97 | 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 | 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 | 119 | this->ui->Plot->setGraphData(0,ch1,false,false); |
|
101 | 120 | this->ui->Plot->setGraphData(1,ch2,false,false); |
|
102 | 121 | this->ui->Plot->setGraphData(2,ch3,false,false); |
@@ -131,17 +150,36 void MainWindow::downloadData(const QDat | |||
|
131 | 150 | |
|
132 | 151 | void MainWindow::updateProgress(int threadId, int percentProgress) |
|
133 | 152 | { |
|
134 | if(threadId<progress.count()) | |
|
135 | this->progress.at(threadId)->setValue(percentProgress); | |
|
153 | bool updated=false; | |
|
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 | 175 | void MainWindow::addFolderView() |
|
139 | 176 | { |
|
140 | this->folderViews.append(new FolderView()); | |
|
177 | this->folderViews.append(new FolderView(this)); | |
|
141 | 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 | 180 | this->folderViews.last()->setAllowedAreas(Qt::AllDockWidgetAreas); |
|
144 | 181 | connect(this->folderViews.last(),SIGNAL(itemActivated(QString)),this,SLOT(plotFile(QString))); |
|
182 | ||
|
145 | 183 | } |
|
146 | 184 | |
|
147 | 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 | 218 | void MainWindow::changeEvent(QEvent *e) |
|
173 | 219 | { |
|
174 | 220 | QMainWindow::changeEvent(e); |
@@ -44,7 +44,7 class MainWindow : public QMainWindow | |||
|
44 | 44 | public: |
|
45 | 45 | explicit MainWindow(int OMP_THREADS,QWidget *parent = 0); |
|
46 | 46 | ~MainWindow(); |
|
47 | ||
|
47 | QString getFilePath(const QString& name); | |
|
48 | 48 | public slots: |
|
49 | 49 | void itemDoubleClicked(QListWidgetItem *item); |
|
50 | 50 | void plotFile(const QString& File); |
@@ -53,6 +53,7 public slots: | |||
|
53 | 53 | void updateProgress(int threadId,int percentProgress); |
|
54 | 54 | void addFolderView(); |
|
55 | 55 | void fileDownloadComplete(); |
|
56 | void askGlobalRescan(); | |
|
56 | 57 | protected: |
|
57 | 58 | void changeEvent(QEvent *e); |
|
58 | 59 | |
@@ -62,6 +63,7 private: | |||
|
62 | 63 | QList<FileDownloader*> pendingDownloads; |
|
63 | 64 | ThemisDataFile fileReader; |
|
64 | 65 | QList<QProgressBar*> progress; |
|
66 | int* progressThreadIds; | |
|
65 | 67 | QWidget* progressWidget; |
|
66 | 68 | QVBoxLayout*progressLayout; |
|
67 | 69 | int OMP_THREADS; |
@@ -28,10 +28,10 | |||
|
28 | 28 | #include <omp.h> |
|
29 | 29 | #include <QTimer> |
|
30 | 30 | #include <QElapsedTimer> |
|
31 | #include <time.h> | |
|
31 | 32 | |
|
32 | 33 | ThemisDataFile::ThemisDataFile(QObject *parent) : QThread(parent) |
|
33 | 34 | { |
|
34 | // this->moveToThread(this); | |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | 37 | ThemisDataFile::~ThemisDataFile() |
@@ -48,29 +48,32 void ThemisDataFile::parseFile(const QSt | |||
|
48 | 48 | inline double __decodeVal(int ofset,unsigned char* data) |
|
49 | 49 | { |
|
50 | 50 | if(data[ofset]=='-') |
|
51 | return -1.0 * ((10.0 * (data[ofset+1] & 0x0F)) | |
|
52 |
|
|
|
53 |
+ (0 |
|
|
54 |
+ (0 |
|
|
55 |
+ ( |
|
|
51 | return -0.001 * (double)( | |
|
52 | (10000 * (int)(data[ofset+1] & 0x0F)) | |
|
53 | + (1000 * (int)(data[ofset+2] & 0x0F)) | |
|
54 | + (100 * (int)(data[ofset+4] & 0x0F)) | |
|
55 | + (10 * (int)(data[ofset+5] & 0x0F)) | |
|
56 | + ( (int)(data[ofset+6] & 0x0F)) | |
|
56 | 57 | ); |
|
57 | 58 | else |
|
58 | 59 | { |
|
59 | 60 | if(data[ofset+1]=='-') |
|
60 | 61 | { |
|
61 |
return - |
|
|
62 |
|
|
|
63 |
+ (0 |
|
|
64 |
+ ( |
|
|
62 | return -0.001 * (double)( | |
|
63 | (1000 * (int)(data[ofset+2] & 0x0F)) | |
|
64 | + (100 * (int)(data[ofset+4] & 0x0F)) | |
|
65 | + (10 * (int)(data[ofset+5] & 0x0F)) | |
|
66 | + ( (int)(data[ofset+6] & 0x0F)) | |
|
65 | 67 | ); |
|
66 | 68 | } |
|
67 | 69 | else |
|
68 | 70 | { |
|
69 |
return |
|
|
70 |
|
|
|
71 |
+ (0 |
|
|
72 |
+ (0 |
|
|
73 |
+ ( |
|
|
71 | return 0.001 * (double)( | |
|
72 | (10000 * (int)(data[ofset+1] & 0x0F)) | |
|
73 | + (1000 * (int)(data[ofset+2] & 0x0F)) | |
|
74 | + (100 * (int)(data[ofset+4] & 0x0F)) | |
|
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 | 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 | 128 | void ThemisDataFile::run() |
|
98 | 129 | { |
|
99 | 130 | FILE* dataFile; |
@@ -106,9 +137,6 void ThemisDataFile::run() | |||
|
106 | 137 | double _x=0.0; |
|
107 | 138 | char* line; |
|
108 | 139 | QCPData data1,data2,data3; |
|
109 | // QCPData data12,data22,data32; | |
|
110 | // QCPData data13,data23,data33; | |
|
111 | // QCPData data14,data24,data34; | |
|
112 | 140 | if(dataFile != NULL) |
|
113 | 141 | { |
|
114 | 142 | fseek(dataFile, 0L, SEEK_END); |
@@ -138,13 +166,7 void ThemisDataFile::run() | |||
|
138 | 166 | #pragma omp for |
|
139 | 167 | for(int i=0;i<(FileSize/(58));i++) |
|
140 | 168 | { |
|
141 | line[(i*58)+23]='\0'; | |
|
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(); | |
|
169 | _x=__decodeTimeFromEpoch((i*58),(unsigned char*)line); | |
|
148 | 170 | data1.key=_x; |
|
149 | 171 | data2.key=_x; |
|
150 | 172 | data3.key=_x; |
General Comments 0
You need to be logged in to leave comments.
Login now