@@ -0,0 +1,83 | |||
|
1 | #include "qlopdatabase.h" | |
|
2 | ||
|
3 | QList<QLopData*>* QLopDataBase::m_dataBase=NULL; | |
|
4 | QLopDataBase* QLopDataBase::_self=NULL; | |
|
5 | ||
|
6 | #define INIT() \ | |
|
7 | if(Q_UNLIKELY(_self==NULL))\ | |
|
8 | {\ | |
|
9 | init();\ | |
|
10 | } | |
|
11 | ||
|
12 | QLopDataBase::QLopDataBase(QObject *parent) : QObject(parent) | |
|
13 | { | |
|
14 | this->m_dataBase = new QList<QLopData*>(); | |
|
15 | } | |
|
16 | ||
|
17 | QLopDataBase::~QLopDataBase() | |
|
18 | { | |
|
19 | ||
|
20 | } | |
|
21 | ||
|
22 | void QLopDataBase::init() | |
|
23 | { | |
|
24 | _self=new QLopDataBase(); | |
|
25 | } | |
|
26 | ||
|
27 | int QLopDataBase::addData(QLopData *data) | |
|
28 | { | |
|
29 | INIT(); | |
|
30 | if(!m_dataBase->contains(data)) | |
|
31 | { | |
|
32 | m_dataBase->append(data); | |
|
33 | return 1; | |
|
34 | } | |
|
35 | return 0; | |
|
36 | } | |
|
37 | ||
|
38 | int QLopDataBase::addData(const QLopDataList& data) | |
|
39 | { | |
|
40 | INIT(); | |
|
41 | int addedData=0; | |
|
42 | for (int i = 0; i < data.count(); i++) | |
|
43 | { | |
|
44 | addedData += addData(data.at(i)); | |
|
45 | } | |
|
46 | return addedData; | |
|
47 | } | |
|
48 | ||
|
49 | QLopDataBase *QLopDataBase::self() | |
|
50 | { | |
|
51 | INIT(); | |
|
52 | return _self; | |
|
53 | } | |
|
54 | ||
|
55 | int QLopDataBase::count() | |
|
56 | { | |
|
57 | return m_dataBase->count(); | |
|
58 | } | |
|
59 | ||
|
60 | QLopData *QLopDataBase::getData(const QString &name) | |
|
61 | { | |
|
62 | for (int i = 0; i < m_dataBase->count(); i++) | |
|
63 | { | |
|
64 | if(Q_UNLIKELY(m_dataBase->at(i)->name==name)) | |
|
65 | { | |
|
66 | return m_dataBase->at(i); | |
|
67 | } | |
|
68 | } | |
|
69 | return NULL; | |
|
70 | } | |
|
71 | ||
|
72 | QLopData *QLopDataBase::getData(int ID) | |
|
73 | { | |
|
74 | for (int i = 0; i < m_dataBase->count(); i++) | |
|
75 | { | |
|
76 | if(Q_UNLIKELY(m_dataBase->at(i)->ID==ID)) | |
|
77 | { | |
|
78 | return m_dataBase->at(i); | |
|
79 | } | |
|
80 | } | |
|
81 | return NULL; | |
|
82 | } | |
|
83 |
@@ -0,0 +1,29 | |||
|
1 | #ifndef QLOPDATABASE_H | |
|
2 | #define QLOPDATABASE_H | |
|
3 | ||
|
4 | #include <QObject> | |
|
5 | #include <qlopdata.h> | |
|
6 | #include <QList> | |
|
7 | ||
|
8 | class QLopDataBase : public QObject | |
|
9 | { | |
|
10 | Q_OBJECT | |
|
11 | explicit QLopDataBase(QObject *parent = 0); | |
|
12 | ~QLopDataBase(); | |
|
13 | static QLopDataBase* _self; | |
|
14 | public: | |
|
15 | static void init(); | |
|
16 | static int addData(QLopData* data); | |
|
17 | static int addData(const QLopDataList &data); | |
|
18 | static QLopDataBase* self(); | |
|
19 | static int count(); | |
|
20 | static QLopData* getData(const QString& name); | |
|
21 | static QLopData* getData(int ID); | |
|
22 | signals: | |
|
23 | ||
|
24 | public slots: | |
|
25 | private: | |
|
26 | static QList<QLopData*>* m_dataBase; | |
|
27 | }; | |
|
28 | ||
|
29 | #endif // QLOPDATABASE_H |
@@ -53,7 +53,8 SOURCES += src/main.cpp\ | |||
|
53 | 53 | src/QCustomPlot/qcpdocumentobject.cpp \ |
|
54 | 54 | src/Core/Widgets/filebrowser.cpp \ |
|
55 | 55 | src/Core/Widgets/filesystemmodel.cpp \ |
|
56 | src/Core/Widgets/qcustomplotvect.cpp | |
|
56 | src/Core/Widgets/qcustomplotvect.cpp \ | |
|
57 | src/Core/qlopdatabase.cpp | |
|
57 | 58 | |
|
58 | 59 | HEADERS += src/mainwindow.h \ |
|
59 | 60 | src/SocExplorerPlot.h \ |
@@ -81,7 +82,8 HEADERS += src/mainwindow.h \ | |||
|
81 | 82 | src/QCustomPlot/qcpdocumentobject.h \ |
|
82 | 83 | src/Core/Widgets/filebrowser.h \ |
|
83 | 84 | src/Core/Widgets/filesystemmodel.h \ |
|
84 | src/Core/Widgets/qcustomplotvect.h | |
|
85 | src/Core/Widgets/qcustomplotvect.h \ | |
|
86 | src/Core/qlopdatabase.h | |
|
85 | 87 | |
|
86 | 88 | FORMS += src/mainwindow.ui \ |
|
87 | 89 | src/Core/Widgets/downloadhistory.ui \ |
@@ -203,9 +203,9 void CassiniDataFile::readFile() | |||
|
203 | 203 | QVector<QCPData> *ch2=new QVector<QCPData>(lineCnt); |
|
204 | 204 | QVector<QCPData> *ch3=new QVector<QCPData>(lineCnt); |
|
205 | 205 | QLopDataList data; |
|
206 | QLopData* ch1V=new QLopData(); | |
|
207 | QLopData* ch2V=new QLopData(); | |
|
208 | QLopData* ch3V=new QLopData(); | |
|
206 | QLopDataVector* ch1V=new QLopDataVector(); | |
|
207 | QLopDataVector* ch2V=new QLopDataVector(); | |
|
208 | QLopDataVector* ch3V=new QLopDataVector(); | |
|
209 | 209 | ch1V->data=ch1; |
|
210 | 210 | ch2V->data=ch2; |
|
211 | 211 | ch3V->data=ch3; |
@@ -281,9 +281,9 void CassiniDataFile::writeFile() | |||
|
281 | 281 | { |
|
282 | 282 | if(m_data.count()==3) |
|
283 | 283 | { |
|
284 | QLopData* ch1V=m_data.at(0); | |
|
285 | QLopData* ch2V=m_data.at(1); | |
|
286 | QLopData* ch3V=m_data.at(2); | |
|
284 | QLopDataVector* ch1V=(QLopDataVector*)m_data.at(0); | |
|
285 | QLopDataVector* ch2V=(QLopDataVector*)m_data.at(1); | |
|
286 | QLopDataVector* ch3V=(QLopDataVector*)m_data.at(2); | |
|
287 | 287 | if(ch1V->data->count()==ch2V->data->count() && ch1V->data->count()==ch3V->data->count()) |
|
288 | 288 | { |
|
289 | 289 | for(int i=0;i<ch1V->data->count();i++) |
@@ -154,7 +154,7 void CassiniTools::export_view(int PID) | |||
|
154 | 154 | QLopDataList vectors; |
|
155 | 155 | for(int i=0;i<plot->graphCount();i++) |
|
156 | 156 | { |
|
157 | QLopData* vect = new QLopData(); | |
|
157 | QLopDataVector* vect = new QLopDataVector(); | |
|
158 | 158 | vect->data = plot->getVisibleData(i); |
|
159 | 159 | vectors.append(vect); |
|
160 | 160 | } |
@@ -175,7 +175,7 void CassiniTools::export_view_Predefine | |||
|
175 | 175 | QLopDataList vectors; |
|
176 | 176 | for(int i=0;i<plot->graphCount();i++) |
|
177 | 177 | { |
|
178 | QLopData* vect = new QLopData(); | |
|
178 | QLopDataVector* vect = new QLopDataVector(); | |
|
179 | 179 | vect->data = plot->getVisibleData(i); |
|
180 | 180 | vectors.append(vect); |
|
181 | 181 | } |
@@ -196,16 +196,16 void CassiniTools::compute_fft_on_view(i | |||
|
196 | 196 | QLopDataList vectors; |
|
197 | 197 | for(int i=0;i<plot->graphCount();i++) |
|
198 | 198 | { |
|
199 | QLopData* vect = new QLopData(); | |
|
199 | QLopDataVector* vect = new QLopDataVector(); | |
|
200 | 200 | vect->data = plot->getVisibleData(i); |
|
201 | 201 | vectors.append(vect); |
|
202 | 202 | } |
|
203 | 203 | if(vectors.count()==3) |
|
204 | 204 | { |
|
205 | QLopData* ch1V=vectors.at(0); | |
|
206 | QLopData* ch2V=vectors.at(1); | |
|
207 | QLopData* ch3V=vectors.at(2); | |
|
208 | QLopData* FFTout=new QLopData(); | |
|
205 | QLopDataVector* ch1V=(QLopDataVector*)vectors.at(0); | |
|
206 | QLopDataVector* ch2V=(QLopDataVector*)vectors.at(1); | |
|
207 | QLopDataVector* ch3V=(QLopDataVector*)vectors.at(2); | |
|
208 | QLopDataVector* FFTout=new QLopDataVector(); | |
|
209 | 209 | if(ch1V->data->count()==ch2V->data->count() && ch1V->data->count()==ch3V->data->count()) |
|
210 | 210 | { |
|
211 | 211 | |
@@ -297,7 +297,7 void CassiniTools::dataReady(QLopDataLis | |||
|
297 | 297 | pen.setColor(QLopColours[i%QLopColoursCount]); |
|
298 | 298 | plot->setGraphPen(i,pen); |
|
299 | 299 | plot->setGraphName(i,data.at(i)->name+"("+data.at(i)->unit+")"); |
|
300 | plot->setGraphData(i,data.at(i)->data,false); | |
|
300 | plot->setGraphData(i,((QLopDataVector*)data.at(i))->data,false); | |
|
301 | 301 | } |
|
302 | 302 | plot->rescaleAxis(); |
|
303 | 303 | plot->replot(); |
@@ -46,6 +46,11 | |||
|
46 | 46 | <layout class="QGridLayout" name="gridLayout_4"> |
|
47 | 47 | <item row="0" column="1"> |
|
48 | 48 | <widget class="QPushButton" name="addFolderViewQpb"> |
|
49 | <property name="font"> | |
|
50 | <font> | |
|
51 | <pointsize>7</pointsize> | |
|
52 | </font> | |
|
53 | </property> | |
|
49 | 54 | <property name="text"> |
|
50 | 55 | <string/> |
|
51 | 56 | </property> |
@@ -53,6 +58,12 | |||
|
53 | 58 | <iconset resource="../../resources/qlop.qrc"> |
|
54 | 59 | <normaloff>:/img/Gnome-list-add.svg</normaloff>:/img/Gnome-list-add.svg</iconset> |
|
55 | 60 | </property> |
|
61 | <property name="iconSize"> | |
|
62 | <size> | |
|
63 | <width>16</width> | |
|
64 | <height>16</height> | |
|
65 | </size> | |
|
66 | </property> | |
|
56 | 67 | <property name="flat"> |
|
57 | 68 | <bool>false</bool> |
|
58 | 69 | </property> |
@@ -66,7 +77,7 | |||
|
66 | 77 | <property name="sizeHint" stdset="0"> |
|
67 | 78 | <size> |
|
68 | 79 | <width>40</width> |
|
69 |
<height> |
|
|
80 | <height>8</height> | |
|
70 | 81 | </size> |
|
71 | 82 | </property> |
|
72 | 83 | </spacer> |
@@ -29,6 +29,7 FileBrowser::FileBrowser(QWidget *parent | |||
|
29 | 29 | QDockWidget(parent), |
|
30 | 30 | ui(new Ui::FileBrowser) |
|
31 | 31 | { |
|
32 | this->doubleClickEater = new DoubleClickEater(); | |
|
32 | 33 | ui->setupUi(this); |
|
33 | 34 | this->model = new FileSystemModel(this); |
|
34 | 35 | this->model->setRootPath(QDir::currentPath()); |
@@ -38,6 +39,7 FileBrowser::FileBrowser(QWidget *parent | |||
|
38 | 39 | this->cd(model->rootPath()); |
|
39 | 40 | connect(this->view,SIGNAL(clicked(QModelIndex)),this,SLOT(clicked(QModelIndex))); |
|
40 | 41 | connect(this->view,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(doubleClicked(QModelIndex))); |
|
42 | connect(this->view,SIGNAL(activated(QModelIndex)),this,SLOT(activated(QModelIndex))); | |
|
41 | 43 | connect(this->ui->ListViewQpb,SIGNAL(clicked()),this,SLOT(changeToListView())); |
|
42 | 44 | connect(this->ui->TreeViewQpb,SIGNAL(clicked()),this,SLOT(changeToTreeView())); |
|
43 | 45 | connect(this->ui->parentDirQpb,SIGNAL(clicked()),this,SLOT(parentDir())); |
@@ -49,6 +51,9 FileBrowser::FileBrowser(QWidget *parent | |||
|
49 | 51 | this->pathCompleter = new QCompleter(this->model,this); |
|
50 | 52 | this->ui->pathLineEdit->setCompleter(pathCompleter); |
|
51 | 53 | this->pathLineEditEnterEditMode(false); |
|
54 | this->setFocusPolicy(Qt::StrongFocus); | |
|
55 | this->ui->pathLineEdit->installEventFilter(this->doubleClickEater); | |
|
56 | connect(this->doubleClickEater,SIGNAL(doubleClicked()),this,SLOT(pathLineEditDblClicked())); | |
|
52 | 57 | } |
|
53 | 58 | |
|
54 | 59 | FileBrowser::~FileBrowser() |
@@ -115,6 +120,11 void FileBrowser::doubleClicked(QModelIn | |||
|
115 | 120 | } |
|
116 | 121 | } |
|
117 | 122 | |
|
123 | void FileBrowser::activated(const QModelIndex &index) | |
|
124 | { | |
|
125 | doubleClicked(index); | |
|
126 | } | |
|
127 | ||
|
118 | 128 | void FileBrowser::parentDir() |
|
119 | 129 | { |
|
120 | 130 | this->cd(model->rootPath()+"/.."); |
@@ -127,6 +137,12 void FileBrowser::cd(const QString &newP | |||
|
127 | 137 | this->ui->pathLineEdit->setText(model->rootPath()); |
|
128 | 138 | } |
|
129 | 139 | |
|
140 | void FileBrowser::pathLineEditDblClicked() | |
|
141 | { | |
|
142 | if(this->ui->pathLineEdit->isReadOnly()) | |
|
143 | pathLineEditEnterEditMode(true); | |
|
144 | } | |
|
145 | ||
|
130 | 146 | |
|
131 | 147 | void FileBrowser::changeEvent(QEvent *e) |
|
132 | 148 | { |
@@ -152,11 +168,20 void FileBrowser::keyPressEvent(QKeyEven | |||
|
152 | 168 | } |
|
153 | 169 | break; |
|
154 | 170 | case Qt::Key_Return: |
|
155 | pathLineEditEnterEditMode(false); | |
|
156 | if(QFile::exists(this->ui->pathLineEdit->text())) | |
|
171 | if(!this->view->hasFocus()) | |
|
157 | 172 | { |
|
158 |
|
|
|
159 |
|
|
|
173 | if(QFile::exists(this->ui->pathLineEdit->text())) | |
|
174 | { | |
|
175 | this->cd(this->ui->pathLineEdit->text()); | |
|
176 | e->accept(); | |
|
177 | } | |
|
178 | pathLineEditEnterEditMode(false); | |
|
179 | } | |
|
180 | break; | |
|
181 | case Qt::Key_Backspace: | |
|
182 | if(this->view->hasFocus()) | |
|
183 | { | |
|
184 | parentDir(); | |
|
160 | 185 | } |
|
161 | 186 | break; |
|
162 | 187 | default: |
@@ -173,3 +198,17 void FileBrowser::pathLineEditEnterEditM | |||
|
173 | 198 | if(enter) |
|
174 | 199 | this->ui->pathLineEdit->setFocus(); |
|
175 | 200 | } |
|
201 | ||
|
202 | ||
|
203 | bool DoubleClickEater::eventFilter(QObject *obj, QEvent *event) | |
|
204 | { | |
|
205 | if (event->type() == QEvent::MouseButtonDblClick) | |
|
206 | { | |
|
207 | emit doubleClicked(); | |
|
208 | return true; | |
|
209 | } else | |
|
210 | { | |
|
211 | // standard event processing | |
|
212 | return QObject::eventFilter(obj, event); | |
|
213 | } | |
|
214 | } |
@@ -34,6 +34,21 namespace Ui { | |||
|
34 | 34 | class FileBrowser; |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | class DoubleClickEater : public QObject | |
|
38 | { | |
|
39 | Q_OBJECT | |
|
40 | public: | |
|
41 | DoubleClickEater(){} | |
|
42 | ~DoubleClickEater(){} | |
|
43 | signals: | |
|
44 | void doubleClicked(); | |
|
45 | protected: | |
|
46 | bool eventFilter(QObject *obj, QEvent *event); | |
|
47 | }; | |
|
48 | ||
|
49 | ||
|
50 | ||
|
51 | ||
|
37 | 52 | class FileBrowser : public QDockWidget |
|
38 | 53 | { |
|
39 | 54 | Q_OBJECT |
@@ -50,8 +65,10 private slots: | |||
|
50 | 65 | void changeToListView(); |
|
51 | 66 | void clicked(QModelIndex index); |
|
52 | 67 | void doubleClicked(QModelIndex index); |
|
68 | void activated(const QModelIndex & index); | |
|
53 | 69 | void parentDir(); |
|
54 | 70 | void cd(const QString& newPath); |
|
71 | void pathLineEditDblClicked(); | |
|
55 | 72 | protected: |
|
56 | 73 | void changeEvent(QEvent *e); |
|
57 | 74 | void keyPressEvent(QKeyEvent *e); |
@@ -61,6 +78,7 private: | |||
|
61 | 78 | FileSystemModel* model; |
|
62 | 79 | QAbstractItemView* view; |
|
63 | 80 | QCompleter* pathCompleter; |
|
81 | DoubleClickEater* doubleClickEater; | |
|
64 | 82 | }; |
|
65 | 83 | |
|
66 | 84 | #endif // FILEBROWSER_H |
@@ -24,11 +24,24 | |||
|
24 | 24 | |
|
25 | 25 | QLopData::QLopData(QObject *parent) : QObject(parent) |
|
26 | 26 | { |
|
27 | ||
|
27 | this->unit = ""; | |
|
28 | this->source = "Not set"; | |
|
29 | this->type = QLopData::None; | |
|
28 | 30 | } |
|
29 | 31 | |
|
30 | 32 | QLopData::~QLopData() |
|
31 | 33 | { |
|
34 | // delete data; | |
|
35 | } | |
|
36 | ||
|
37 | ||
|
38 | ||
|
39 | QLopDataVector::QLopDataVector(QObject *parent) | |
|
40 | { | |
|
41 | this->type = QLopData::Vector; | |
|
42 | } | |
|
43 | ||
|
44 | QLopDataVector::~QLopDataVector() | |
|
45 | { | |
|
32 | 46 | delete data; |
|
33 | 47 | } |
|
34 |
@@ -41,13 +41,35 class QLopData : public QObject | |||
|
41 | 41 | { |
|
42 | 42 | Q_OBJECT |
|
43 | 43 | public: |
|
44 | typedef enum QLopDataType | |
|
45 | { | |
|
46 | Scalar=0, | |
|
47 | Vector=1, | |
|
48 | Matrix=2, | |
|
49 | None=-1, | |
|
50 | } | |
|
51 | QLopDataType; | |
|
44 | 52 | explicit QLopData(QObject *parent = 0); |
|
45 | 53 | ~QLopData(); |
|
46 | 54 | QString name; |
|
55 | QString source; | |
|
47 | 56 | QString unit; |
|
57 | QLopDataType type; | |
|
58 | int ID; | |
|
59 | signals: | |
|
60 | void dataChanged(); | |
|
61 | public slots: | |
|
62 | private: | |
|
63 | }; | |
|
64 | ||
|
65 | class QLopDataVector : public QLopData | |
|
66 | { | |
|
67 | Q_OBJECT | |
|
68 | public: | |
|
69 | explicit QLopDataVector(QObject *parent = 0); | |
|
70 | ~QLopDataVector(); | |
|
48 | 71 | QVector<QCPData>* data; |
|
49 | 72 | signals: |
|
50 | void dataChanged(); | |
|
51 | 73 | public slots: |
|
52 | 74 | private: |
|
53 | 75 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now