diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 98cb9b73b..339e064ca 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -12,6 +12,8 @@ #include "simulatorinterface.h" #include "firmwareinterface.h" +Stopwatch gStopwatch("global"); + const QColor colors[C9X_MAX_CURVES] = { QColor(0,0,127), QColor(0,127,0), @@ -1015,7 +1017,6 @@ TableLayout::TableLayout(QWidget * parent, int rowCount, const QStringList & hea tableWidget->setColumnCount(headerLabels.size()); tableWidget->setShowGrid(false); tableWidget->verticalHeader()->setVisible(false); - tableWidget->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); tableWidget->setSelectionMode(QAbstractItemView::NoSelection); tableWidget->setFrameStyle(QFrame::NoFrame | QFrame::Plain); diff --git a/companion/src/helpers.h b/companion/src/helpers.h index 04a204aa7..682b49369 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "eeprominterface.h" extern const QColor colors[C9X_MAX_CURVES]; @@ -224,4 +225,39 @@ private: #endif }; + +class Stopwatch +{ +public: + Stopwatch(const QString & name) : + name(name), total(0) { + timer.start(); + }; + ~Stopwatch() {}; + + void restart() { + total = 0; + timer.restart(); + }; + + void report() { + qint64 elapsed = timer.restart(); + total += elapsed; + qDebug() << name << QString("%1 ms [%2 ms]").arg(elapsed).arg(total); + }; + + void report(const QString & text) { + qint64 elapsed = timer.restart(); + total += elapsed; + qDebug() << name << text << QString("%1 ms [%2 ms]").arg(elapsed).arg(total); + }; + +private: + QString name; + QElapsedTimer timer; + qint64 total; +}; + +extern Stopwatch gStopwatch; + #endif // HELPERS_H diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index 0eac6e804..db5c39722 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -179,11 +179,16 @@ void MdiChild::modelEdit() QApplication::setOverrideCursor(Qt::WaitCursor); checkAndInitModel( row ); ModelData &model = radioData.models[row - 1]; + gStopwatch.restart(); + gStopwatch.report("ModelEdit creation"); ModelEdit *t = new ModelEdit(this, radioData, (row - 1), GetCurrentFirmware()/*firmware*/); + gStopwatch.report("ModelEdit created"); t->setWindowTitle(tr("Editing model %1: ").arg(row) + model.name); connect(t, SIGNAL(modified()), this, SLOT(setModified())); + gStopwatch.report("STARTING MODEL EDIT"); t->show(); QApplication::restoreOverrideCursor(); + gStopwatch.report("ModelEdit shown"); } } diff --git a/companion/src/modeledit/channels.cpp b/companion/src/modeledit/channels.cpp index 3c4a5d899..7e51c6cef 100644 --- a/companion/src/modeledit/channels.cpp +++ b/companion/src/modeledit/channels.cpp @@ -76,6 +76,8 @@ void LimitsGroup::updateMinMax(int max) Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): ModelPanel(parent, model, generalSettings, firmware) { + Stopwatch s1("Channels"); + int channelNameMaxLen = firmware->getCapability(ChannelsName); QStringList headerLabels; @@ -92,6 +94,8 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera headerLabels << tr("Linear Subtrim"); TableLayout * tableLayout = new TableLayout(this, firmware->getCapability(LogicalSwitches), headerLabels); + s1.report("header"); + for (int i=0; igetCapability(Outputs); i++) { int col = 0; @@ -167,10 +171,12 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera tableLayout->addWidget(i, col++, symlimits); } } + s1.report("add elements"); disableMouseScrolling(); tableLayout->resizeColumnsToContents(); tableLayout->pushRowsUp(firmware->getCapability(Outputs)+1); + s1.report("end"); } Channels::~Channels() diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 9b9997da3..3800457d0 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -43,8 +43,7 @@ void RepeatComboBox::update() CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware): GenericPanel(parent, model, generalSettings, firmware), - functions(model ? model->customFn : generalSettings.customFn), - initialized(false) + functions(model ? model->customFn : generalSettings.customFn) #if defined(PHONON) , phononCurrent(-1), @@ -52,6 +51,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, clickOutput(NULL) #endif { + Stopwatch s1("CustomFunctionsPanel - populate"); lock = true; int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions); @@ -67,6 +67,8 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, } } + s1.report("get tracks"); + if (IS_TARANIS(firmware->getBoard())) { scriptsSet = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS", QStringList() << "*.lua", firmware->getCapability(VoicesMaxLength)); for (int i=0; isetSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint))); tableLayout->addWidget(i, 0, label); + // s1.report("label"); // The switch fswtchSwtch[i] = new QComboBox(this); fswtchSwtch[i]->setProperty("index", i); + populateSwitchCB(fswtchSwtch[i], functions[i].swtch, generalSettings, model ? SpecialFunctionsContext : GlobalFunctionsContext); fswtchSwtch[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); fswtchSwtch[i]->setMaxVisibleItems(10); connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); tableLayout->addWidget(i, 1, fswtchSwtch[i]); + // s1.report("switch"); // The function fswtchFunc[i] = new QComboBox(this); fswtchFunc[i]->setProperty("index", i); + populateFuncCB(fswtchFunc[i], functions[i].func); fswtchFunc[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); connect(fswtchFunc[i], SIGNAL(currentIndexChanged(int)), this, SLOT(functionEdited())); tableLayout->addWidget(i, 2, fswtchFunc[i]); + // s1.report("func"); // The parameters QHBoxLayout * paramLayout = new QHBoxLayout(); @@ -120,6 +128,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, fswtchGVmode[i] = new QComboBox(this); fswtchGVmode[i]->setProperty("index", i); + populateGVmodeCB(fswtchGVmode[i], functions[i].adjustMode); fswtchGVmode[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); connect(fswtchGVmode[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); paramLayout->addWidget(fswtchGVmode[i]); @@ -146,6 +155,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, fswtchParamT[i] = new QComboBox(this); fswtchParamT[i]->setProperty("index", i); + populateFuncParamCB(fswtchParamT[i], functions[i].func, functions[i].param, functions[i].adjustMode); paramLayout->addWidget(fswtchParamT[i]); fswtchParamT[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); connect(fswtchParamT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); @@ -190,18 +200,22 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, repeatLayout->addWidget(fswtchEnable[i], i+1); connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited())); } + s1.report("add items"); disableMouseScrolling(); + s1.report("disableMouseScrolling"); lock = false; update(); + s1.report("update"); tableLayout->resizeColumnsToContents(); + s1.report("resizeColumnsToContents"); tableLayout->setColumnWidth(3, 300); tableLayout->pushRowsUp(num_fsw+1); + s1.report("end"); } - CustomFunctionsPanel::~CustomFunctionsPanel() { } @@ -522,15 +536,8 @@ void CustomFunctionsPanel::update() lock = true; int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions); for (int i=0; i tracksSet; QSet scriptsSet; int phononCurrent; diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index f9214739c..bff85bdd4 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -11,6 +11,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, ModelPanel(parent, model, generalSettings, firmware), selectedSwitch(0) { + Stopwatch s1("LogicalSwitchesPanel"); + int channelsMax = model.getChannelsMax(true); QStringList headerLabels; @@ -20,6 +22,7 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, } TableLayout * tableLayout = new TableLayout(this, firmware->getCapability(LogicalSwitches), headerLabels); + s1.report("header"); lock = true; for (int i=0; igetCapability(LogicalSwitches); i++) { @@ -123,11 +126,14 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, } } + s1.report("added elements"); + disableMouseScrolling(); lock = false; update(); tableLayout->resizeColumnsToContents(); tableLayout->pushRowsUp(firmware->getCapability(LogicalSwitches)+1); + s1.report("end"); } LogicalSwitchesPanel::~LogicalSwitchesPanel() diff --git a/companion/src/modeledit/modeledit.cpp b/companion/src/modeledit/modeledit.cpp index feed4c3ba..be5226042 100644 --- a/companion/src/modeledit/modeledit.cpp +++ b/companion/src/modeledit/modeledit.cpp @@ -23,6 +23,9 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw generalSettings(radioData.generalSettings), firmware(firmware) { + Stopwatch s1("ModelEdit"); + gStopwatch.report("ModelEdit start constructor"); + ui->setupUi(this); setWindowIcon(CompanionIcon("edit.png")); restoreGeometry(g.modelEditGeo()); @@ -33,16 +36,23 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw addTab(new HeliPanel(this, model, generalSettings, firmware), tr("Heli")); addTab(new FlightModesPanel(this, model, generalSettings, firmware), tr("Flight Modes")); addTab(new InputsPanel(this, model, generalSettings, firmware), tr("Inputs")); + s1.report("inputs"); addTab(new MixesPanel(this, model, generalSettings, firmware), tr("Mixes")); + s1.report("Mixes"); Channels * chnPanel = new Channels(this, model, generalSettings, firmware); addTab(chnPanel, tr("Outputs")); + s1.report("Outputs"); addTab(new Curves(this, model, generalSettings, firmware), tr("Curves")); addTab(new LogicalSwitchesPanel(this, model, generalSettings, firmware), tr("Logical Switches")); + s1.report("LS"); addTab(new CustomFunctionsPanel(this, &model, generalSettings, firmware), tr("Special Functions")); + s1.report("CF"); if (firmware->getCapability(Telemetry) & TM_HASTELEMETRY) addTab(new TelemetryPanel(this, model, generalSettings, firmware), tr("Telemetry")); connect(setupPanel, SIGNAL(extendedLimitsToggled()), chnPanel, SLOT(refreshExtendedLimits())); + s1.report("end"); + gStopwatch.report("ModelEdit end constructor"); } ModelEdit::~ModelEdit()