Skip to content

Commit

Permalink
Added plugincompat field to gauge QML files, to only load QML dashboa…
Browse files Browse the repository at this point in the history
…rd files that pertain to a particular plugin (And it's specific datalog variable names)
  • Loading branch information
malcom2073 committed Feb 7, 2014
1 parent 7850db6 commit 3fb7c24
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 95 deletions.
3 changes: 2 additions & 1 deletion core/src/gauges.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Rectangle {
width: 1280
height: 900
color: "black"
property string plugincompat: "FREEEMS"

GaugeImage {
x:0
Expand Down Expand Up @@ -177,4 +178,4 @@ Rectangle {
}
}
}
}
}
5 changes: 3 additions & 2 deletions core/src/gaugeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ void GaugeView::passData(QVariantMap data)
{
m_valueMap = data;
}
void GaugeView::setFile(QString file)
QString GaugeView::setFile(QString file)
{
widget->setFile(file);
QString result = widget->setFile(file);
propertiesInUse = widget->getPropertiesInUse();
return result;
}

void GaugeView::passDecoder(DataPacketDecoder *decoder)
Expand Down
2 changes: 1 addition & 1 deletion core/src/gaugeview.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class GaugeView : public QWidget
~GaugeView();
void passData(QVariantMap data);
void passDecoder(DataPacketDecoder *decoder);
void setFile(QString file);
QString setFile(QString file);
private:
QList<QString> propertiesInUse;
QString file;
Expand Down
11 changes: 9 additions & 2 deletions core/src/gaugewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "gaugewidget.h"
#include "roundgaugeitem.h"
#include "bargaugeitem.h"

#include "QsLog.h"
#include <QMetaType>
#include <QDeclarativeContext>
#include <QFile>
Expand Down Expand Up @@ -50,7 +50,7 @@ GaugeWidget::GaugeWidget(QWidget *parent) : QDeclarativeView(parent)
}*/
}

void GaugeWidget::setFile(QString file)
QString GaugeWidget::setFile(QString file)
{
setSource(QUrl::fromLocalFile(file));
if (rootObject())
Expand All @@ -63,5 +63,12 @@ void GaugeWidget::setFile(QString file)
propertylist.append(obj->property("propertyMapProperty").toString());
}
}
if (rootObject()->property("plugincompat").isValid())
{
QString plugincompat = rootObject()->property("plugincompat").toString();
QLOG_DEBUG() << "Plugin compatability:" << plugincompat;
return plugincompat;
}
}
return "";
}
2 changes: 1 addition & 1 deletion core/src/gaugewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GaugeWidget : public QDeclarativeView
public:
GaugeWidget(QWidget *parent=0);
QDeclarativePropertyMap propertyMap;
void setFile(QString file);
QString setFile(QString file);
const QList<QString> getPropertiesInUse() { return propertylist; }
private:
QList<QString> propertylist;
Expand Down
214 changes: 126 additions & 88 deletions core/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,13 +1295,19 @@ void MainWindow::loadDashboards(QString dir)
mdiView->setGeometry(view->geometry());
mdiView->hide();
mdiView->setWindowTitle(view->windowTitle());
view->setFile(dashboards.absoluteFilePath(file));
QString plugincompat = view->setFile(dashboards.absoluteFilePath(file));
QAction *action = new QAction(this);
action->setText(file.mid(0,file.lastIndexOf(".")));
action->setCheckable(true);
ui.menuDashboards->addAction(action);
connect(action,SIGNAL(triggered(bool)),mdiView,SLOT(setVisible(bool)));
m_dashboardList.append(view);
if (!m_gaugeActionMap.contains(plugincompat))
{
m_gaugeActionMap[plugincompat] = QList<QAction*>();
}
m_gaugeActionMap[plugincompat].append(action);

}
}
}
Expand Down Expand Up @@ -1362,6 +1368,24 @@ void MainWindow::emsCommsConnected()
m_wizardList[j]->addConfig(emsComms->getConfigList()[i],emsComms->getConfigData(emsComms->getConfigList()[i]));
}*/
}
if (m_gaugeActionMap.contains(emsComms->getPluginCompat()))
{
for (int i=0;i<ui.menuDashboards->actions().size();i++)
{
if (!m_gaugeActionMap[emsComms->getPluginCompat()].contains(ui.menuDashboards->actions()[i]))
{
ui.menuDashboards->actions()[i]->setVisible(false);

}
}
}
else if (emsComms->getPluginCompat() != "")
{
for (int i=0;i<ui.menuDashboards->actions().size();i++)
{
ui.menuDashboards->actions()[i]->setVisible(false);
}
}
//New log and settings file here.
if (m_memoryInfoMap.size() == 0)
{
Expand Down Expand Up @@ -1421,110 +1445,117 @@ void MainWindow::interrogationComplete()
}
bool oneShown = false; //Check to see if at least one window is visisble.
QSettings windowsettings;
int size = windowsettings.beginReadArray("rawwindows");
for (int i=0;i<size;i++)
{
//createView()
windowsettings.setArrayIndex(i);
unsigned short locid = windowsettings.value("window").toInt();
QString type = windowsettings.value("type").toString();
if (type == "TableView2D")
{
createView(locid,DATA_TABLE_2D);
QWidget *parent = (QWidget*)m_rawDataView[locid]->parent();
parent->restoreGeometry(windowsettings.value("location").toByteArray());
}
else if (type == "TableView3D")
{
createView(locid,DATA_TABLE_3D);
QWidget *parent = (QWidget*)m_rawDataView[locid]->parent();
parent->restoreGeometry(windowsettings.value("location").toByteArray());
}
else if (type == "tablesMdiWindow")
QString compat = emsComms->getPluginCompat();
QString savecompat = windowsettings.value("plugincompat","").toString();
if (compat == savecompat)
{
windowsettings.sync();
int size = windowsettings.beginReadArray("rawwindows");
for (int i=0;i<size;i++)
{
tablesMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
//createView()
windowsettings.setArrayIndex(i);
unsigned short locid = windowsettings.value("window").toInt();
QString type = windowsettings.value("type").toString();
if (type == "TableView2D")
{
createView(locid,DATA_TABLE_2D);
QWidget *parent = (QWidget*)m_rawDataView[locid]->parent();
parent->restoreGeometry(windowsettings.value("location").toByteArray());
}
else if (type == "TableView3D")
{
oneShown = true;
createView(locid,DATA_TABLE_3D);
QWidget *parent = (QWidget*)m_rawDataView[locid]->parent();
parent->restoreGeometry(windowsettings.value("location").toByteArray());
}
tablesMdiWindow->setHidden(hidden);
else if (type == "tablesMdiWindow")
{
tablesMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
{
oneShown = true;
}
tablesMdiWindow->setHidden(hidden);

}
else if (type == "firmwareMetaMdiWindow")
{
firmwareMetaMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
}
else if (type == "firmwareMetaMdiWindow")
{
oneShown = true;
firmwareMetaMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
{
oneShown = true;
}
firmwareMetaMdiWindow->setHidden(hidden);
}
firmwareMetaMdiWindow->setHidden(hidden);
}
else if (type == "interrogateProgressMdiWindow")
{
// interrogateProgressMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
// interrogateProgressMdiWindow->setHidden(windowsettings.value("hidden",true).toBool());
}
else if (type == "emsMdiWindow")
{
emsMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
else if (type == "interrogateProgressMdiWindow")
{
oneShown = true;
// interrogateProgressMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
// interrogateProgressMdiWindow->setHidden(windowsettings.value("hidden",true).toBool());
}
emsMdiWindow->setHidden(hidden);
}
else if (type == "flagsMdiWindow")
{
flagsMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
else if (type == "emsMdiWindow")
{
oneShown = true;
emsMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
{
oneShown = true;
}
emsMdiWindow->setHidden(hidden);
}
flagsMdiWindow->setHidden(hidden);
}
else if (type == "gaugesMdiWindow")
{
gaugesMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
else if (type == "flagsMdiWindow")
{
oneShown = true;
flagsMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
{
oneShown = true;
}
flagsMdiWindow->setHidden(hidden);
}
gaugesMdiWindow->setHidden(hidden);
}
else if (type == "packetStatusMdiWindow")
{
packetStatusMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
else if (type == "gaugesMdiWindow")
{
oneShown = true;
gaugesMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
{
oneShown = true;
}
gaugesMdiWindow->setHidden(hidden);
}
packetStatusMdiWindow->setHidden(hidden);
}
else if (type == "aboutMdiWindow")
{
aboutMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
else if (type == "packetStatusMdiWindow")
{
oneShown = true;
packetStatusMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
{
oneShown = true;
}
packetStatusMdiWindow->setHidden(hidden);
}
aboutMdiWindow->setHidden(hidden);
}
else if (type == "emsStatusMdiWindow")
{
else if (type == "aboutMdiWindow")
{
aboutMdiWindow->restoreGeometry(windowsettings.value("location").toByteArray());
bool hidden = windowsettings.value("hidden",true).toBool();
if (!hidden)
{
oneShown = true;
}
aboutMdiWindow->setHidden(hidden);
}
else if (type == "emsStatusMdiWindow")
{

}
else
{
qDebug() << "Unknown type:" << type;
}
}
else
{
qDebug() << "Unknown type:" << type;
}

}
windowsettings.endArray();
}
if (!oneShown)
{
Expand All @@ -1540,7 +1571,7 @@ void MainWindow::interrogationComplete()
QMdiSubWindow *packetStatusMdiWindow;
QMdiSubWindow *aboutMdiWindow;
QMdiSubWindow *emsStatusMdiWindow;*/
windowsettings.endArray();

/*for (QMap<unsigned short,QWidget*>::const_iterator i=m_rawDataView.constBegin();i!=m_rawDataView.constEnd();i++)
{
windowsettings.setArrayIndex(val++);
Expand Down Expand Up @@ -2057,6 +2088,13 @@ MainWindow::~MainWindow()
windowsettings.endGroup();
windowsettings.sync();

if (emsComms)
{
QString compat = emsComms->getPluginCompat();
windowsettings.setValue("plugincompat",compat);
windowsettings.sync();
}

//Remove all WizardView windows
for (int i=0;i<m_wizardList.size();i++)
{
Expand Down
1 change: 1 addition & 0 deletions core/src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class MainWindow : public QMainWindow
int m_currentEcuClock;
QMap<QMdiSubWindow*,QAction*> m_mdiSubWindowToActionMap;
bool m_EcuResetPopup;
QMap<QString,QList<QAction*> > m_gaugeActionMap;
private slots:
void showTable(QString table);
void windowHidden(QMdiSubWindow* window);
Expand Down
1 change: 1 addition & 0 deletions lib/core/emscomms.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class EmsComms : public QThread
Q_OBJECT
public:
EmsComms(QObject *parent) : QThread(parent) {}
virtual QString getPluginCompat()=0;
virtual void passLogger(QsLogging::Logger *log)=0;
virtual void stop()=0;
virtual void setLogsEnabled(bool enabled)=0;
Expand Down
1 change: 1 addition & 0 deletions plugins/freeems/freeemscomms.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class FreeEmsComms : public EmsComms
public:
FreeEmsComms(QObject *parent = 0);
~FreeEmsComms();
QString getPluginCompat() { return QString("FREEEMS"); }
DataPacketDecoder *getDecoder();
MemoryMetaData *getMetaParser();
Table3DData *getNew3DTableData();
Expand Down

0 comments on commit 3fb7c24

Please sign in to comment.