QGCPendingParamWidget.cc 2.54 KB
Newer Older
1 2 3 4 5 6 7
#include "QGCPendingParamWidget.h"

#include "UASManager.h"
#include "UASParameterCommsMgr.h"


QGCPendingParamWidget::QGCPendingParamWidget(QObject *parent) :
8
    QGCParamWidget((QWidget*)parent)
9 10 11 12
{
}


13
void QGCPendingParamWidget::connectToParamManager()
14
{
15 16 17 18
    //TODO route via paramManager instead?
    // Listen to updated param signals from the data model
    connect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
            this, SLOT(handlePendingParamUpdate(int , const QString& ,  QVariant, bool )));
19

20 21 22
    // Listen to communications status messages so we can display them
    connect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
            this, SLOT(handleParamStatusMsgUpdate(QString , int )));
23 24
}

25 26

void QGCPendingParamWidget::disconnectFromParamManager()
27
{
28 29 30
    //TODO route via paramManager instead?
    // Listen to updated param signals from the data model
    disconnect(paramMgr->dataModel(), SIGNAL(pendingParamUpdate(int , const QString&, QVariant , bool )),
31 32 33
            this, SLOT(handlePendingParamUpdate(int , const QString& ,  QVariant, bool )));

    // Listen to communications status messages so we can display them
34
    disconnect(paramMgr, SIGNAL(parameterStatusMsgUpdated(QString,int)),
35 36 37
            this, SLOT(handleParamStatusMsgUpdate(QString , int )));
}

38 39 40 41 42 43 44 45 46 47 48 49

void QGCPendingParamWidget::disconnectViewSignalsAndSlots()
{
    //we ignore edits from the tree view
}


void QGCPendingParamWidget::connectViewSignalsAndSlots()
{
    //we ignore edits from the tree view
}

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
void QGCPendingParamWidget::handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending)
{
   // qDebug() << "handlePendingParamUpdate:" << paramName << "with updatingParamNameLock:" << updatingParamNameLock;

    if (updatingParamNameLock == paramName) {
        //qDebug() << "ignoring bounce from " << paramName;
        return;
    }
    else {
        updatingParamNameLock = paramName;
    }

    QTreeWidgetItem* paramItem = updateParameterDisplay(compId,paramName,value);

    if (isPending) {
        QTreeWidgetItem* paramItem = updateParameterDisplay(compId,paramName,value);
        paramItem->setFlags(paramItem->flags() & ~Qt::ItemIsEditable); //disallow editing
        paramItem->setBackground(0, QBrush(QColor(QGC::colorOrange)));
        paramItem->setBackground(1, QBrush(QColor(QGC::colorOrange)));
        tree->expandAll();
    }
    else {
        //we don't display non-pending items
        paramItem->parent()->removeChild(paramItem);
    }

    updatingParamNameLock.clear();

}
79