timing code (796 ms with grid layout, 1394 ms with table layout)

This commit is contained in:
Damjan Adamic
2015-12-07 18:03:36 +01:00
parent 191e37f29c
commit e37dcabd95
8 changed files with 82 additions and 12 deletions
+6
View File
@@ -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; i<firmware->getCapability(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()
+17 -10
View File
@@ -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; i<num_fsw; i++) {
@@ -78,6 +80,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
}
}
}
s1.report("get scripts");
CompanionIcon playIcon("play.png");
@@ -98,21 +101,26 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
label->setSizePolicy(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<num_fsw; i++) {
if (!initialized) {
populateSwitchCB(fswtchSwtch[i], functions[i].swtch, generalSettings, model ? SpecialFunctionsContext : GlobalFunctionsContext);
populateFuncCB(fswtchFunc[i], functions[i].func);
populateGVmodeCB(fswtchGVmode[i], functions[i].adjustMode);
populateFuncParamCB(fswtchParamT[i], functions[i].func, functions[i].param, functions[i].adjustMode);
}
refreshCustomFunction(i);
}
initialized = true;
lock = false;
}
@@ -66,7 +66,6 @@ class CustomFunctionsPanel : public GenericPanel
void populateGVmodeCB(QComboBox *b, unsigned int value);
void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode=0);
bool initialized;
QSet<QString> tracksSet;
QSet<QString> scriptsSet;
int phononCurrent;
@@ -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; i<firmware->getCapability(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()
+10
View File
@@ -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()