mirror of
https://github.com/opentx/opentx.git
synced 2025-07-17 13:25:20 +03:00
timing code (796 ms with grid layout, 1394 ms with table layout)
This commit is contained in:
parent
191e37f29c
commit
e37dcabd95
8 changed files with 82 additions and 12 deletions
|
@ -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);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QtGui>
|
||||
#include <QTableWidget>
|
||||
#include <QGridLayout>
|
||||
#include <QDebug>
|
||||
#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
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue