本文整理汇总了C++中QComboBox::setCurrentIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::setCurrentIndex方法的具体用法?C++ QComboBox::setCurrentIndex怎么用?C++ QComboBox::setCurrentIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::setCurrentIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
QgsGeometryCheckerResultTab::QgsGeometryCheckerResultTab( QgisInterface *iface, QgsGeometryChecker *checker, QTabWidget *tabWidget, QWidget *parent )
: QWidget( parent )
, mTabWidget( tabWidget )
, mIface( iface )
, mChecker( checker )
{
ui.setupUi( this );
mErrorCount = 0;
mFixedCount = 0;
mCloseable = true;
for ( const QString &layerId : mChecker->getContext()->featurePools.keys() )
{
QgsVectorLayer *layer = mChecker->getContext()->featurePools[layerId]->layer();
QTreeWidgetItem *item = new QTreeWidgetItem( ui.treeWidgetMergeAttribute, QStringList() << layer->name() << "" );
QComboBox *attribCombo = new QComboBox();
for ( int i = 0, n = layer->fields().count(); i < n; ++i )
{
attribCombo->addItem( layer->fields().at( i ).name() );
}
attribCombo->setCurrentIndex( 0 );
connect( attribCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateMergeAttributeIndices() ) );
ui.treeWidgetMergeAttribute->setItemWidget( item, 1, attribCombo );
}
updateMergeAttributeIndices();
connect( checker, &QgsGeometryChecker::errorAdded, this, &QgsGeometryCheckerResultTab::addError );
connect( checker, &QgsGeometryChecker::errorUpdated, this, &QgsGeometryCheckerResultTab::updateError );
connect( ui.tableWidgetErrors->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsGeometryCheckerResultTab::onSelectionChanged );
connect( ui.buttonGroupSelectAction, static_cast<void ( QButtonGroup::* )( int )>( &QButtonGroup::buttonClicked ), this, [this]( int ) { QgsGeometryCheckerResultTab::highlightErrors(); } );
connect( ui.pushButtonOpenAttributeTable, &QAbstractButton::clicked, this, &QgsGeometryCheckerResultTab::openAttributeTable );
connect( ui.pushButtonFixWithDefault, &QAbstractButton::clicked, this, &QgsGeometryCheckerResultTab::fixErrorsWithDefault );
connect( ui.pushButtonFixWithPrompt, &QAbstractButton::clicked, this, &QgsGeometryCheckerResultTab::fixErrorsWithPrompt );
connect( ui.pushButtonErrorResolutionSettings, &QAbstractButton::clicked, this, &QgsGeometryCheckerResultTab::setDefaultResolutionMethods );
connect( ui.checkBoxHighlight, &QAbstractButton::clicked, this, &QgsGeometryCheckerResultTab::highlightErrors );
connect( QgsProject::instance(), static_cast<void ( QgsProject::* )( const QStringList & )>( &QgsProject::layersWillBeRemoved ), this, &QgsGeometryCheckerResultTab::checkRemovedLayer );
connect( ui.pushButtonExport, &QAbstractButton::clicked, this, &QgsGeometryCheckerResultTab::exportErrors );
bool allLayersEditable = true;
for ( const QgsFeaturePool *featurePool : mChecker->getContext()->featurePools.values() )
{
if ( ( featurePool->layer()->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeGeometries ) == 0 )
{
allLayersEditable = false;
break;
}
}
if ( !allLayersEditable )
{
ui.pushButtonFixWithDefault->setEnabled( false );
ui.pushButtonFixWithPrompt->setEnabled( false );
}
ui.progressBarFixErrors->setVisible( false );
ui.tableWidgetErrors->horizontalHeader()->setSortIndicator( 0, Qt::AscendingOrder );
ui.tableWidgetErrors->resizeColumnToContents( 0 );
ui.tableWidgetErrors->resizeColumnToContents( 1 );
ui.tableWidgetErrors->horizontalHeader()->setResizeMode( 2, QHeaderView::Stretch );
ui.tableWidgetErrors->horizontalHeader()->setResizeMode( 3, QHeaderView::Stretch );
ui.tableWidgetErrors->horizontalHeader()->setResizeMode( 4, QHeaderView::Stretch );
ui.tableWidgetErrors->horizontalHeader()->setResizeMode( 5, QHeaderView::Stretch );
// Not sure why, but this is needed...
ui.tableWidgetErrors->setSortingEnabled( true );
ui.tableWidgetErrors->setSortingEnabled( false );
}
示例2: SynchronizeInterfaceWindow
//.........这里部分代码省略.........
if (type == QString("colorpalette"))
{
if (mode == read)
{
cColorPalette palette = colorPaletteWidget->GetPalette();
par->Set(parameterName, palette);
}
else if (mode == write)
{
cColorPalette palette = par->Get<cColorPalette>(parameterName);
colorPaletteWidget->SetPalette(palette);
}
}
}
}
}
WriteLog("cInterface::SynchronizeInterface: QComboBox", 3);
//combo boxes
{
QList<QComboBox *> widgetListPushButton = window->findChildren<QComboBox*>();
QList<QComboBox *>::iterator it;
for (it = widgetListPushButton.begin(); it != widgetListPushButton.end(); ++it)
{
QString name = (*it)->objectName();
//qDebug() << "QComboBox:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl;
if (name.length() > 1 && (*it)->metaObject()->className() == QString("QComboBox"))
{
QComboBox *comboBox = *it;
QString type, parameterName;
GetNameAndType(name, ¶meterName, &type);
if (type == QString("comboBox"))
{
if (mode == read)
{
int selection = comboBox->currentIndex();
if (parameterName.left(7) == QString("formula"))
{
selection = fractalList[comboBox->itemData(selection).toInt()].internalID;
}
par->Set(parameterName, selection);
}
else if (mode == write)
{
int selection = par->Get<int>(parameterName);
if (parameterName.left(7) == QString("formula"))
{
for (int i = 0; i < fractalList.size(); i++)
{
if (fractalList[i].internalID == selection)
{
selection = comboBox->findData(i);
break;
}
}
}
comboBox->setCurrentIndex(selection);
}
}
}
}
}
WriteLog("cInterface::SynchronizeInterface: cMaterialSelector", 3);
//---------- material selector -----------
{
QList<cMaterialSelector *> widgetListMaterialSelector =
window->findChildren<cMaterialSelector*>();
QList<cMaterialSelector *>::iterator it;
for (it = widgetListMaterialSelector.begin(); it != widgetListMaterialSelector.end(); ++it)
{
QString name = (*it)->objectName();
// QString className = (*it)->metaObject()->className();
if (name.length() > 1 && (*it)->metaObject()->className() == QString("cMaterialSelector"))
{
QString type, parameterName;
GetNameAndType(name, ¶meterName, &type);
cMaterialSelector *materialSelector = *it;
materialSelector->AssignParameterContainer(par);
materialSelector->AssingParameterName(parameterName);
if (type == QString("materialselector"))
{
if (mode == read)
{
par->Set(parameterName, materialSelector->GetMaterialIndex());
}
else if (mode == write)
{
materialSelector->SetMaterialIndex(par->Get<int>(parameterName));
}
}
}
}
}
WriteLog("cInterface::SynchronizeInterface: Done", 3);
}
示例3: buildLayout
//.........这里部分代码省略.........
moveUpButton->setProperty("pass", i);
/* Can't move down if we're already at the bottom. */
if (i < avail_shader->passes - 1)
connect(moveDownButton, SIGNAL(clicked()), this, SLOT(onShaderPassMoveDownClicked()));
else
moveDownButton->setDisabled(true);
/* Can't move up if we're already at the top. */
if (i > 0)
connect(moveUpButton, SIGNAL(clicked()), this, SLOT(onShaderPassMoveUpClicked()));
else
moveUpButton->setDisabled(true);
for (;;)
{
QString filterLabel = getFilterLabel(j);
if (filterLabel.isEmpty())
break;
if (j == 0)
filterLabel = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DONT_CARE);
filterComboBox->addItem(filterLabel, j);
j++;
}
for (j = 0; j < 7; j++)
{
QString label;
if (j == 0)
label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DONT_CARE);
else
label = QString::number(j) + "x";
scaleComboBox->addItem(label, j);
}
filterComboBox->setCurrentIndex(static_cast<int>(avail_shader->pass[i].filter));
scaleComboBox->setCurrentIndex(static_cast<int>(avail_shader->pass[i].fbo.scale_x));
/* connect the signals only after the initial index is set */
connect(filterComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onFilterComboBoxIndexChanged(int)));
connect(scaleComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onScaleComboBoxIndexChanged(int)));
form = new QFormLayout();
groupBox = new QGroupBox(shaderBasename);
groupBox->setLayout(form);
groupBox->setProperty("pass", i);
groupBox->setContextMenuPolicy(Qt::CustomContextMenu);
connect(groupBox, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onGroupBoxContextMenuRequested(const QPoint&)));
m_layout->addWidget(groupBox);
filterScaleHBoxLayout = new QHBoxLayout();
filterScaleHBoxLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred));
filterScaleHBoxLayout->addWidget(new QLabel(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FILTER)) + ":", this));
filterScaleHBoxLayout->addWidget(filterComboBox);
filterScaleHBoxLayout->addWidget(new QLabel(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCALE)) + ":", this));
filterScaleHBoxLayout->addWidget(scaleComboBox);
filterScaleHBoxLayout->addSpacerItem(new QSpacerItem(20, 0, QSizePolicy::Preferred, QSizePolicy::Preferred));
if (moveUpButton)
filterScaleHBoxLayout->addWidget(moveUpButton);
if (moveDownButton)
filterScaleHBoxLayout->addWidget(moveDownButton);
form->addRow("", filterScaleHBoxLayout);
for (j = 0; j < avail_shader->num_parameters; j++)
{
struct video_shader_parameter *param = &avail_shader->parameters[j];
if (param->pass != static_cast<int>(i))
continue;
addShaderParam(param, form);
}
}
if (!hasPasses)
{
QLabel *noParamsLabel = new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SHADER_NO_PASSES), this);
noParamsLabel->setAlignment(Qt::AlignCenter);
m_layout->addWidget(noParamsLabel);
}
m_layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
/* Why is this required?? The layout is corrupt without both resizes. */
resize(width() + 1, height());
show();
resize(width() - 1, height());
}
示例4: autogenerateUi
void EffectWidgetPrivate::autogenerateUi()
{
Q_Q(EffectWidget);
QVBoxLayout *mainLayout = new QVBoxLayout(q);
mainLayout->setMargin(0);
const QList<Phonon::EffectParameter> parameters = effect->parameters();
for (int i = 0; i < parameters.count(); ++i) {
const EffectParameter ¶ = parameters.at(i);
QVariant value = effect->parameterValue(para);
QHBoxLayout *pLayout = new QHBoxLayout;
mainLayout->addLayout(pLayout);
QLabel *label = new QLabel(q);
pLayout->addWidget(label);
label->setText(para.name());
#ifndef QT_NO_TOOLTIP
label->setToolTip(para.description());
#endif
QWidget *control = 0;
switch (int(para.type())) {
case QVariant::String:
{
QComboBox *cb = new QComboBox(q);
control = cb;
if (value.type() == QVariant::Int) {
//value just defines the item index
for (int i = 0; i < para.possibleValues().count(); ++i) {
cb->addItem(para.possibleValues().at(i).toString());
}
cb->setCurrentIndex(value.toInt());
QObject::connect(cb, SIGNAL(currentIndexChanged(int)), q, SLOT(_k_setIntParameter(int)));
} else {
for (int i = 0; i < para.possibleValues().count(); ++i) {
const QVariant &item = para.possibleValues().at(i);
cb->addItem(item.toString());
if (item == value) {
cb->setCurrentIndex(cb->count() - 1);
}
}
QObject::connect(cb, SIGNAL(currentIndexChanged(QString)), q, SLOT(_k_setStringParameter(QString)));
}
}
break;
case QVariant::Bool:
{
QCheckBox *cb = new QCheckBox(q);
control = cb;
cb->setChecked(value.toBool());
QObject::connect(cb, SIGNAL(toggled(bool)), q, SLOT(_k_setToggleParameter(bool)));
}
break;
case QVariant::Int:
{
QSpinBox *sb = new QSpinBox(q);
control = sb;
bool minValueOk = false;
bool maxValueOk = false;
const int minValue = para.minimumValue().toInt(&minValueOk);
const int maxValue = para.maximumValue().toInt(&maxValueOk);
sb->setRange(minValueOk ? minValue : DEFAULT_MIN_INT, maxValueOk ? maxValue : DEFAULT_MAX_INT);
sb->setValue(value.toInt());
QObject::connect(sb, SIGNAL(valueChanged(int)), q, SLOT(_k_setIntParameter(int)));
}
break;
case QMetaType::Float:
case QVariant::Double:
{
const qreal minValue = para.minimumValue().canConvert(QVariant::Double) ?
para.minimumValue().toReal() : DEFAULT_MIN;
const qreal maxValue = para.maximumValue().canConvert(QVariant::Double) ?
para.maximumValue().toReal() : DEFAULT_MAX;
if (minValue == -1. && maxValue == 1.) {
//Special case values between -1 and 1.0 to use a slider for improved usability
QSlider *slider = new QSlider(Qt::Horizontal, q);
control = slider;
slider->setRange(-SLIDER_RANGE, +SLIDER_RANGE);
slider->setValue(int(SLIDER_RANGE * value.toReal()));
slider->setTickPosition(QSlider::TicksBelow);
slider->setTickInterval(TICKINTERVAL);
QObject::connect(slider, SIGNAL(valueChanged(int)), q, SLOT(_k_setSliderParameter(int)));
} else {
double step = 0.1;
if (qAbs(maxValue - minValue) > 50)
step = 1.0;
QDoubleSpinBox *sb = new QDoubleSpinBox(q);
control = sb;
sb->setRange(minValue, maxValue);
sb->setValue(value.toDouble());
sb->setSingleStep(step);
QObject::connect(sb, SIGNAL(valueChanged(double)), q,
SLOT(_k_setDoubleParameter(double)));
}
}
break;
default:
break;
}
//.........这里部分代码省略.........
示例5: QWizard
AutoConfig::AutoConfig(QWidget *parent)
: QWizard(parent)
{
EnableThreadedMessageBoxes(true);
calldata_t cd = {0};
calldata_set_int(&cd, "seconds", 5);
proc_handler_t *ph = obs_get_proc_handler();
proc_handler_call(ph, "twitch_ingests_refresh", &cd);
calldata_free(&cd);
OBSBasic *main = reinterpret_cast<OBSBasic*>(parent);
main->EnableOutputs(false);
installEventFilter(CreateShortcutFilter());
std::string serviceType;
GetServiceInfo(serviceType, serviceName, server, key);
#ifdef _WIN32
setWizardStyle(QWizard::ModernStyle);
#endif
streamPage = new AutoConfigStreamPage();
setPage(StartPage, new AutoConfigStartPage());
setPage(VideoPage, new AutoConfigVideoPage());
setPage(StreamPage, streamPage);
setPage(TestPage, new AutoConfigTestPage());
setWindowTitle(QTStr("Basic.AutoConfig"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
obs_video_info ovi;
obs_get_video_info(&ovi);
baseResolutionCX = ovi.base_width;
baseResolutionCY = ovi.base_height;
/* ----------------------------------------- */
/* check to see if Twitch's "auto" available */
OBSData twitchSettings = obs_data_create();
obs_data_release(twitchSettings);
obs_data_set_string(twitchSettings, "service", "Twitch");
obs_properties_t *props = obs_get_service_properties("rtmp_common");
obs_properties_apply_settings(props, twitchSettings);
obs_property_t *p = obs_properties_get(props, "server");
const char *first = obs_property_list_item_string(p, 0);
twitchAuto = strcmp(first, "auto") == 0;
obs_properties_destroy(props);
/* ----------------------------------------- */
/* load service/servers */
customServer = serviceType == "rtmp_custom";
QComboBox *serviceList = streamPage->ui->service;
if (!serviceName.empty()) {
serviceList->blockSignals(true);
int count = serviceList->count();
bool found = false;
for (int i = 0; i < count; i++) {
QString name = serviceList->itemText(i);
if (name == serviceName.c_str()) {
serviceList->setCurrentIndex(i);
found = true;
break;
}
}
if (!found) {
serviceList->insertItem(0, serviceName.c_str());
serviceList->setCurrentIndex(0);
}
serviceList->blockSignals(false);
}
streamPage->UpdateServerList();
streamPage->UpdateKeyLink();
streamPage->lastService.clear();
if (!customServer) {
QComboBox *serverList = streamPage->ui->server;
int idx = serverList->findData(QString(server.c_str()));
if (idx == -1)
idx = 0;
serverList->setCurrentIndex(idx);
} else {
streamPage->ui->customServer->setText(server.c_str());
int idx = streamPage->ui->service->findData(
QVariant((int)ListOpt::Custom));
//.........这里部分代码省略.........
示例6: setupParameterUI
void ShaderProgram::setupParameterUI(QWidget* parentWidget)
{
QFormLayout* layout = new QFormLayout(parentWidget);
QList<QPair<ShaderParam,QVariant> > paramsOrdered;
for (auto p = m_params.begin(); p != m_params.end(); ++p)
{
paramsOrdered.push_back(qMakePair(p.key(), p.value()));
}
qSort(paramsOrdered.begin(), paramsOrdered.end(), paramOrderingLess);
for (int i = 0; i < paramsOrdered.size(); ++i)
{
QWidget* edit = 0;
const ShaderParam& parDesc = paramsOrdered[i].first;
const QVariant& parValue = paramsOrdered[i].second;
switch (parDesc.type)
{
case ShaderParam::Float:
{
bool expScaling = parDesc.kvPairs.value("scaling", "exponential").
startsWith("exp");
double speed = parDesc.kvPairs.value("speed", "1").toDouble();
if (speed == 0)
speed = 1;
DragSpinBox* spin = new DragSpinBox(expScaling, speed, parentWidget);
double min = parDesc.getDouble("min", 0);
double max = parDesc.getDouble("max", 100);
if (expScaling)
{
// Prevent min or max == 0 for exp scaling which would be invalid
if (max == 0) max = 100;
if (min == 0) min = max > 0 ? 1e-8 : -1e-8;
spin->setDecimals((int)floor(std::max(0.0, -log(min)/log(10.0)) + 0.5) + 2);
}
else
{
double m = std::max(fabs(min), fabs(max));
spin->setDecimals((int)floor(std::max(0.0, -log(m)/log(10.0)) + 0.5) + 2);
}
spin->setMinimum(min);
spin->setMaximum(max);
spin->setValue(parValue.toDouble());
connect(spin, SIGNAL(valueChanged(double)),
this, SLOT(setUniformValue(double)));
edit = spin;
}
break;
case ShaderParam::Int:
if (parDesc.kvPairs.contains("enum"))
{
// Parameter is an enumeration variable
QComboBox* box = new QComboBox(parentWidget);
QStringList names = parDesc.kvPairs.value("enum").split('|');
box->insertItems(0, names);
box->setCurrentIndex(parValue.toInt());
connect(box, SIGNAL(currentIndexChanged(int)),
this, SLOT(setUniformValue(int)));
edit = box;
}
else
{
// Parameter is a freely ranging integer
QSpinBox* spin = new QSpinBox(parentWidget);
spin->setMinimum(parDesc.getInt("min", 0));
spin->setMaximum(parDesc.getInt("max", 100));
spin->setValue(parValue.toInt());
connect(spin, SIGNAL(valueChanged(int)),
this, SLOT(setUniformValue(int)));
edit = spin;
}
break;
default:
// FIXME
continue;
}
示例7: processAuthForm
void OpenconnectAuthWidget::processAuthForm(struct oc_auth_form *form)
{
Q_D(OpenconnectAuthWidget);
deleteAllFromLayout(d->ui.loginBoxLayout);
if (form->banner) {
addFormInfo(QLatin1String("dialog-information"), form->banner);
}
if (form->message) {
addFormInfo(QLatin1String("dialog-information"), form->message);
}
if (form->error) {
addFormInfo(QLatin1String("dialog-error"), form->error);
}
struct oc_form_opt *opt;
QFormLayout *layout = new QFormLayout();
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Fixed);
bool focusSet = false;
for (opt = form->opts; opt; opt = opt->next) {
if (opt->type == OC_FORM_OPT_HIDDEN || IGNORE_OPT(opt)) {
continue;
}
QLabel *text = new QLabel(this);
text->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
text->setText(QString(opt->label));
QWidget *widget = 0;
const QString key = QString("form:%1:%2").arg(QLatin1String(form->auth_id)).arg(QLatin1String(opt->name));
const QString value = d->secrets.value(key);
if (opt->type == OC_FORM_OPT_PASSWORD || opt->type == OC_FORM_OPT_TEXT) {
PasswordField *le = new PasswordField(this);
le->setText(value);
if (opt->type == OC_FORM_OPT_PASSWORD) {
le->setPasswordModeEnabled(true);
}
if (!focusSet && le->text().isEmpty()) {
le->setFocus(Qt::OtherFocusReason);
focusSet = true;
}
widget = qobject_cast<QWidget*>(le);
} else if (opt->type == OC_FORM_OPT_SELECT) {
QComboBox *cmb = new QComboBox(this);
struct oc_form_opt_select *sopt = reinterpret_cast<oc_form_opt_select *>(opt);
for (int i = 0; i < sopt->nr_choices; i++) {
cmb->addItem(QString::fromUtf8(FORMCHOICE(sopt, i)->label), QString::fromUtf8(FORMCHOICE(sopt, i)->name));
if (value == QString::fromUtf8(FORMCHOICE(sopt, i)->name)) {
cmb->setCurrentIndex(i);
if (sopt == AUTHGROUP_OPT(form) && i != AUTHGROUP_SELECTION(form)) {
QTimer::singleShot(0, this, &OpenconnectAuthWidget::formGroupChanged);
}
}
}
if (sopt == AUTHGROUP_OPT(form)) {
connect(cmb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &OpenconnectAuthWidget::formGroupChanged);
}
widget = qobject_cast<QWidget*>(cmb);
}
if (widget) {
widget->setProperty("openconnect_opt", (quintptr)opt);
widget->setSizePolicy(policy);
layout->addRow(text, widget);
}
}
d->ui.loginBoxLayout->addLayout(layout);
d->passwordFormIndex = d->ui.loginBoxLayout->count() - 1;
QDialogButtonBox *box = new QDialogButtonBox(this);
QPushButton *btn = box->addButton(QDialogButtonBox::Ok);
btn->setText(i18n("Login"));
btn->setDefault(true);
d->ui.loginBoxLayout->addWidget(box);
box->setProperty("openconnect_form", (quintptr)form);
connect(box, &QDialogButtonBox::accepted, this, &OpenconnectAuthWidget::formLoginClicked);
}
示例8: ui
CarMainWindow::CarMainWindow()
: base_class()
, ui(new Ui_MainWindow())
, m_server("http://carcomm.cstimming.de/")
// , m_server("http://localhost:3000/")
, m_gpsDevice(NULL)
, m_sliceSender(new SliceSender(m_server, this))
, m_mapViewer(NULL) // must be initialized after setupUi()!
{
ui->setupUi(this);
setGpsReceiverStatus(cs::BAD);
m_mapViewer = new MapViewer(ui->webView, m_server, this);
// Set the date to now
ui->dateTimeEdit->setDateTime(QDateTime::currentDateTime());
// Fill the list of available time intervals
QComboBox* comboBox = ui->comboBoxInterval;
comboBox->addItem("1 Year", QVariant(525600));
comboBox->addItem("6 Weeks", QVariant(60480));
comboBox->addItem("1 Week", QVariant(10080));
comboBox->addItem("1 Day", QVariant(1440));
comboBox->addItem("2 Hours", QVariant(120));
comboBox->addItem("15 Minutes", QVariant(15));
comboBox->addItem("5 Minutes", QVariant(5));
comboBox->setCurrentIndex(comboBox->findText("1 Week"));
// Fill the list of COM ports
comboBox = ui->comboBoxPort;
#ifdef Q_OS_WIN32
for (int i = 1; i <= 8; ++i)
comboBox->addItem("COM" + QString::number(i));
comboBox->setCurrentIndex(comboBox->findText("COM4"));
#else
comboBox->addItem("/dev/ttyACM0");
for (int i = 0; i <= 4; ++i)
comboBox->addItem("/dev/ttyUSB" + QString::number(i));
comboBox->setCurrentIndex(comboBox->findText("/dev/ttyUSB0"));
#endif
// Fill the list of baud rates
comboBox = ui->comboBoxBaudrate;
comboBox->addItem("1200", QVariant(1200));
comboBox->addItem("2400", QVariant(2400));
comboBox->addItem("4800", QVariant(4800));
comboBox->addItem("9600", QVariant(9600));
comboBox->addItem("14400", QVariant(14400));
comboBox->addItem("38400", QVariant(38400));
comboBox->addItem("57600", QVariant(57600));
comboBox->addItem("115200", QVariant(115200));
comboBox->setCurrentIndex(comboBox->findData(QVariant(38400)));
#if 0 // 1 //defined(Q_WS_S60)
ui->groupBoxCurrentPos->setVisible(false);
ui->groupBoxSerial->setVisible(false);
#endif
// Signal/slots of SliceSender
connect(m_sliceSender, SIGNAL(showMessage( const QString &, int)),
statusBar(), SLOT(showMessage( const QString &, int)));
connect(ui->actionTransmitPositionMessages, SIGNAL(triggered(bool)),
m_sliceSender, SLOT(setAutoSendData(bool)));
m_sliceSender->setAutoSendData(ui->actionTransmitPositionMessages->isChecked());
connect(ui->buttonSendData, SIGNAL(clicked()),
m_sliceSender, SLOT(sendDataNow()));
connect(m_sliceSender, SIGNAL(showStatus(cs::Status)),
this, SLOT(setSliceSenderStatus(cs::Status)));
// Signal/slots of MapViewer
connect(ui->actionAutoReloadMap, SIGNAL(triggered(bool)),
m_mapViewer, SLOT(setAutoReloadWays(bool)));
m_mapViewer->setAutoReloadWays(ui->actionAutoReloadMap->isChecked());
connect(ui->buttonReload, SIGNAL(clicked()),
m_mapViewer, SLOT(reloadWays()));
connect(ui->actionResetMap, SIGNAL(triggered()),
m_mapViewer, SLOT(reset()));
on_comboBoxInterval_currentIndexChanged(ui->comboBoxInterval->currentIndex());
connect(m_mapViewer, SIGNAL(showStatus(cs::Status)),
this, SLOT(setMapViewerStatus(cs::Status)));
}
示例9: createWidget
//.........这里部分代码省略.........
// === define update function ===
auto update = [=]() {
posComboBox->blockSignals(true);
posObject->blockSignals(true);
affectXCB->blockSignals(true);
affectYCB->blockSignals(true);
rotComboBox->blockSignals(true);
rotObject->blockSignals(true);
scaleComboBox->blockSignals(true);
scaleObject->blockSignals(true);
bool pModeDifference = false;
bool affectXDifference = false;
bool affectYDifference = false;
bool pIdDifference = false;
bool rModeDifference = false;
bool rIdDifference = false;
bool sModeDifference = false;
bool sIdDifference = false;
Mode pMode = ((ConstraintTag*) tags.first())->_positionMode;
bool affectX = ((ConstraintTag*) tags.first())->_affectX;
bool affectY = ((ConstraintTag*) tags.first())->_affectY;
quint64 pId = ((ConstraintTag*) tags.first())->_posId;
bool hasPId = ((ConstraintTag*) tags.first())->_hasPosId;
Mode rMode = ((ConstraintTag*) tags.first())->_rotationMode;
quint64 rId = ((ConstraintTag*) tags.first())->_rotId;
bool hasRId = ((ConstraintTag*) tags.first())->_hasRotId;
Mode sMode = ((ConstraintTag*) tags.first())->_scalationMode;
quint64 sId = ((ConstraintTag*) tags.first())->_scaleId;
bool hasSId = ((ConstraintTag*) tags.first())->_hasScaleId;
foreach (Tag* t, tags) {
ConstraintTag* ct = (ConstraintTag*) t;
if (ct->_positionMode != pMode) pModeDifference = true;
if (ct->_affectX != affectX) affectXDifference = true;
if (ct->_affectY != affectY) affectYDifference = true;
if ((ct->_hasPosId != hasPId)
|| (ct->_hasPosId && hasPId && ct->_posId != pId)) pIdDifference = true;
if (ct->_rotationMode != rMode) rModeDifference = true;
if ((ct->_hasRotId != hasRId)
|| (ct->_hasRotId && hasRId && ct->_rotId != rId)) rIdDifference = true;
if (ct->_scalationMode != sMode) sModeDifference = true;
if ((ct->_hasScaleId != hasSId)
|| (ct->_hasScaleId && hasSId && ct->_scaleId != sId)) sIdDifference = true;
}
if (pModeDifference) posComboBox->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else posComboBox->setStyleSheet("");
if (affectXDifference) affectXCB->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else affectXCB->setStyleSheet("");
if (affectYDifference) affectYCB->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else affectYCB->setStyleSheet("");
if (pIdDifference) posObject->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else posObject->setStyleSheet("");
posComboBox->setCurrentIndex(modeToIndex(pMode));
affectXCB->setChecked(affectX);
affectXCB->setEnabled(pMode != Mode::ignore);
affectYCB->setChecked(affectY);
affectYCB->setEnabled(pMode != Mode::ignore);
posObject->setEnabled(pMode != Mode::ignore);
if (hasPId)
posObject->setId(pId);
else
posObject->clear();
if (rModeDifference) rotComboBox->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else rotComboBox->setStyleSheet("");
if (rIdDifference) rotObject->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else rotObject->setStyleSheet("");
rotComboBox->setCurrentIndex(modeToIndex(rMode));
rotObject->setEnabled(rMode != Mode::ignore);
if (hasRId)
rotObject->setId(rId);
else
rotObject->clear();
if (sModeDifference) scaleComboBox->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else scaleComboBox->setStyleSheet("");
if (sIdDifference) scaleObject->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else scaleObject->setStyleSheet("");
scaleComboBox->setCurrentIndex(modeToIndex(sMode));
scaleObject->setEnabled(sMode != Mode::ignore);
if (hasSId)
scaleObject->setId(sId);
else
scaleObject->clear();
posComboBox->blockSignals(false);
posObject->blockSignals(false);
affectXCB->blockSignals(false);
affectYCB->blockSignals(false);
rotComboBox->blockSignals(false);
rotObject->blockSignals(false);
scaleComboBox->blockSignals(false);
scaleObject->blockSignals(false);
};
示例10: if
static QList<QWidget*> getFormWidgets(QList<FormField> formFields, const QObject *receiver)
{
QList<QWidget*> formWidgets;
for (int i = 0; i < formFields.size(); ++i)
{
Poppler::FormField *formField = formFields.at(i).field;
if (formField->type() == Poppler::FormField::FormText)
{
Poppler::FormFieldText *formFieldText = static_cast<Poppler::FormFieldText*>(formField);
switch (formFieldText->textType())
{
case Poppler::FormFieldText::FileSelect:
{
// TODO replace this by a file selection widget
QLineEdit *lineEdit = new QLineEdit;
lineEdit->setText(formFieldText->text());
lineEdit->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
QObject::connect(lineEdit, SIGNAL(textEdited(QString)), receiver, SLOT(slotSetFormData(QString)));
formWidgets << lineEdit;
}
break;
case Poppler::FormFieldText::Multiline:
{
QTextEdit *textEdit = new QTextEdit;
textEdit->setText(formFieldText->text());
textEdit->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
QObject::connect(textEdit, SIGNAL(textChanged()), receiver, SLOT(slotSetFormData()));
formWidgets << textEdit;
}
break;
case Poppler::FormFieldText::Normal:
default:
{
QLineEdit *lineEdit = new QLineEdit;
lineEdit->setText(formFieldText->text());
lineEdit->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
QObject::connect(lineEdit, SIGNAL(textEdited(QString)), receiver, SLOT(slotSetFormData(QString)));
formWidgets << lineEdit;
}
break;
}
}
else if (formField->type() == Poppler::FormField::FormButton)
{
Poppler::FormFieldButton *formFieldButton = static_cast<Poppler::FormFieldButton*>(formField);
switch (formFieldButton->buttonType())
{
case Poppler::FormFieldButton::CheckBox:
{
QCheckBox *checkBox = new QCheckBox;
// checkBox->setText(formFieldButton->caption());
checkBox->setChecked(formFieldButton->state());
checkBox->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
QObject::connect(checkBox, SIGNAL(toggled(bool)), receiver, SLOT(slotSetFormData(bool)));
formWidgets << checkBox;
}
break;
case Poppler::FormFieldButton::Radio:
{
QRadioButton *radioButton = new QRadioButton;
radioButton->setText(formFieldButton->caption());
radioButton->setChecked(formFieldButton->state());
radioButton->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
QObject::connect(radioButton, SIGNAL(toggled(bool)), receiver, SLOT(slotSetFormData(bool)));
formWidgets << radioButton;
}
break;
case Poppler::FormFieldButton::Push:
default:
{
QPushButton *pushButton = new QPushButton;
pushButton->setText(formFieldButton->caption());
pushButton->setChecked(formFieldButton->state());
pushButton->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
QObject::connect(pushButton, SIGNAL(toggled(bool)), receiver, SLOT(slotSetFormData(bool)));
formWidgets << pushButton;
}
break;
}
}
else if (formField->type() == Poppler::FormField::FormChoice)
{
Poppler::FormFieldChoice *formFieldChoice = static_cast<Poppler::FormFieldChoice*>(formField);
switch (formFieldChoice->choiceType())
{
case Poppler::FormFieldChoice::ComboBox:
{
QComboBox *comboBox = new QComboBox;
comboBox->addItems(formFieldChoice->choices());
comboBox->setEditable(formFieldChoice->isEditable());
comboBox->setCurrentIndex(formFieldChoice->currentChoices().at(0));
comboBox->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), receiver, SLOT(slotSetFormData(int)));
formWidgets << comboBox;
}
break;
case Poppler::FormFieldChoice::ListBox:
default:
{
//.........这里部分代码省略.........
示例11: setData
void TransactionActionDialog::setData(const QVector<TransactionTable::Data> &data)
{
for(const TransactionTable::Data& item: data)
{
// Add new transaction
int currRow = ui->tableWidget->rowCount();
// Insert row after current row
ui->tableWidget->insertRow(currRow);
// Create new plus minus widget
PlusMinusPushWidget* plusMinusWidget = new PlusMinusPushWidget(
ui->tableWidget);
// Create temporary variable to hold the item amount.
// This is due to the const restrictions, we can not modify the value
// directly
int tempNoStock = item.noSold;
// Check if value is negative
if(tempNoStock < 0)
{
// Click the button so that its set to -
plusMinusWidget->click();
// Make value positive
tempNoStock *= -1;
}
// Set the plus minus widget to the table
ui->tableWidget->setCellWidget(currRow, POS_NEG, plusMinusWidget);
// Create combo box that links to stock table model
// and add to row and column
QComboBox* comboBox = new QComboBox(ui->tableWidget);
comboBox->setModel(m_stockTable);
// show the reference column
comboBox->setModelColumn(StockTable::REF);
// get view index from model
int stock_index = DB::GetViewIndex(item.stock_id,
static_cast<QSqlQueryModel*>(m_stockTable));
// Set index of row to view index we found earlier
comboBox->setCurrentIndex(stock_index);
// Set widget to table
ui->tableWidget->setCellWidget(currRow, STOCK_ITEM, comboBox);
// create new line edit containing amount data
QLineEdit* lineEdit = new QLineEdit(QString::number(item.amount, 'd', 2), ui->tableWidget);
// set numeric values only regex
lineEdit->setValidator(DB::GetNumericValidator(lineEdit));
// set line edit in to amount column
ui->tableWidget->setCellWidget(currRow, AMOUNT,
lineEdit);
// create new line edit containing number of stock data
lineEdit = new QLineEdit(QString::number(tempNoStock), ui->tableWidget);
// set validator as non negative regex
lineEdit->setValidator(DB::GetNonNegativeNumericValidator(lineEdit));
// set the line edit widget in to the no sold column
ui->tableWidget->setCellWidget(currRow, NO_SOLD, lineEdit);
// create line edit, add id number and insert in to id column
ui->tableWidget->setCellWidget(currRow, ID,
new QLineEdit(QString::number(item.id), ui->tableWidget));
// create line edit, add deleted mark and insert in to deleted column
ui->tableWidget->setCellWidget(currRow, DELETED,
new QLineEdit(QString::number(item.deleted, 'd', 2), ui->tableWidget));
}
}
示例12: rx
Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
ModelPanel(parent, model, generalSettings, firmware)
{
QGridLayout * gridLayout = new QGridLayout(this);
bool minimize = false;
int col = 1;
if (firmware->getCapability(ChannelsName))
{
minimize=true;
addLabel(gridLayout, tr("Name"), col++);
}
addLabel(gridLayout, tr("Subtrim"), col++, minimize);
addLabel(gridLayout, tr("Min"), col++, minimize);
addLabel(gridLayout, tr("Max"), col++, minimize);
addLabel(gridLayout, tr("Direction"), col++, minimize);
if (IS_TARANIS(GetEepromInterface()->getBoard()))
addLabel(gridLayout, tr("Curve"), col++, minimize);
if (firmware->getCapability(PPMCenter))
addLabel(gridLayout, tr("PPM Center"), col++, minimize);
if (firmware->getCapability(SYMLimits))
addLabel(gridLayout, tr("Linear Subtrim"), col++, true);
for (int i=0; i<firmware->getCapability(Outputs); i++) {
col = 0;
// Channel label
QLabel *label = new QLabel(this);
label->setText(tr("Channel %1").arg(i+1));
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
gridLayout->addWidget(label, i+1, col++, 1, 1);
// Channel name
int nameLen = firmware->getCapability(ChannelsName);
if (nameLen > 0) {
QLineEdit * name = new QLineEdit(this);
name->setProperty("index", i);
name->setMaxLength(nameLen);
QRegExp rx(CHAR_FOR_NAMES_REGEX);
name->setValidator(new QRegExpValidator(rx, this));
name->setText(model.limitData[i].name);
connect(name, SIGNAL(editingFinished()), this, SLOT(nameEdited()));
gridLayout->addWidget(name, i+1, col++, 1, 1);
}
// Channel offset
QDoubleSpinBox * offset = new QDoubleSpinBox(this);
offset->setProperty("index", i);
offset->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
offset->setAccelerated(true);
offset->setDecimals(1);
offset->setMinimum(-100);
offset->setSingleStep(0.1);
offset->setValue(float(model.limitData[i].offset) / 10);
connect(offset, SIGNAL(editingFinished()), this, SLOT(offsetEdited()));
gridLayout->addWidget(offset, i+1, col++, 1, 1);
// Channel min
QDoubleSpinBox * minSB = new QDoubleSpinBox(this);
minSB->setProperty("index", i);
minSB->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
minSB->setAccelerated(true);
minSB->setDecimals(1);
minSB->setMinimum(-model.getChannelsMax());
minSB->setSingleStep(0.1);
minSB->setMaximum(0);
minSB->setValue(float(model.limitData[i].min) / 10);
connect(minSB, SIGNAL(editingFinished()), this, SLOT(minEdited()));
gridLayout->addWidget(minSB, i+1, col++, 1, 1);
minSpins << minSB;
// Channel max
QDoubleSpinBox * maxSB = new QDoubleSpinBox(this);
maxSB->setProperty("index", i);
maxSB->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
maxSB->setAccelerated(true);
maxSB->setDecimals(1);
maxSB->setMinimum(0);
maxSB->setSingleStep(0.1);
maxSB->setMaximum(model.getChannelsMax());
maxSB->setValue(float(model.limitData[i].max) / 10);
connect(maxSB, SIGNAL(editingFinished()), this, SLOT(maxEdited()));
gridLayout->addWidget(maxSB, i+1, col++, 1, 1);
maxSpins << maxSB;
// Channel inversion
QComboBox * invCB = new QComboBox(this);
invCB->insertItems(0, QStringList() << tr("---") << tr("INV"));
invCB->setProperty("index", i);
invCB->setCurrentIndex((model.limitData[i].revert) ? 1 : 0);
connect(invCB, SIGNAL(currentIndexChanged(int)), this, SLOT(invEdited()));
gridLayout->addWidget(invCB, i+1, col++, 1, 1);
// Curve
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
QComboBox * curveCB = new QComboBox(this);
curveCB->setProperty("index", i);
int numcurves = firmware->getCapability(NumCurves);
for (int j=-numcurves; j<=numcurves; j++) {
curveCB->addItem(CurveReference(CurveReference::CURVE_REF_CUSTOM, j).toString(), j);
//.........这里部分代码省略.........
示例13: propertyUpdated
void protoObject::propertyUpdated(QString propertyName){
QObject *receiver = mapper->mapping(propertyName);
QWidget *widget;
if (receiver) return; //if not binding, just leave
widget = qobject_cast<QLabel*>(receiver);
if (widget) {
QLabel* edit = qobject_cast<QLabel*>(receiver);
QString value = this->property(propertyName.toLatin1()).toString();
edit->blockSignals(true);
edit->setText(edit->text().arg(value));
edit->blockSignals(false);
};
widget = qobject_cast<QLineEdit*>(receiver);
if (widget) {
QLineEdit* edit = qobject_cast<QLineEdit*>(receiver);
QString value = this->property(propertyName.toLatin1()).toString();
edit->blockSignals(true);
edit->setText(value);
edit->blockSignals(false);
};
widget = qobject_cast<QComboBox*>(receiver);
if (widget) {
QComboBox* edit = qobject_cast<QComboBox*>(receiver);
edit->blockSignals(true);
edit->setCurrentIndex(edit->findData(this->property(propertyName.toLatin1()), Qt::UserRole));
edit->blockSignals(false);
};
widget = qobject_cast<QRadioButton*>(receiver);
if (widget) {
QRadioButton* edit = qobject_cast<QRadioButton*>(receiver);
bool value = this->property(propertyName.toLatin1()).toBool();
edit->blockSignals(true);
edit->setChecked(value);
edit->blockSignals(false);
};
widget = qobject_cast<QCheckBox*>(receiver);
if (widget) {
QCheckBox* edit = qobject_cast<QCheckBox*>(receiver);
bool value = this->property(propertyName.toLatin1()).toBool();
edit->blockSignals(true);
edit->setChecked(value);
edit->blockSignals(false);
};
widget = qobject_cast<QPlainTextEdit*>(receiver);
if (widget) {
QPlainTextEdit* edit = qobject_cast<QPlainTextEdit*>(receiver);
QString value = this->property(propertyName.toLatin1()).toString();
edit->blockSignals(true);
edit->setPlainText(value);
edit->blockSignals(false);
};
widget = qobject_cast<QSpinBox*>(receiver);
if (widget) {
QSpinBox* edit = qobject_cast<QSpinBox*>(receiver);
int value = this->property(propertyName.toLatin1()).toInt();
edit->blockSignals(true);
edit->setValue(value);
edit->blockSignals(false);
};
widget = qobject_cast<QDoubleSpinBox*>(receiver);
if (widget) {
QDoubleSpinBox* edit = qobject_cast<QDoubleSpinBox*>(receiver);
double value = this->property(propertyName.toLatin1()).toDouble();
edit->blockSignals(true);
edit->setValue(value);
edit->blockSignals(false);
};
widget = qobject_cast<QDateTimeEdit*>(receiver);
if (widget) {
QDateTimeEdit* edit = qobject_cast<QDateTimeEdit*>(receiver);
QDateTime value = this->property(propertyName.toLatin1()).toDateTime();
edit->blockSignals(true);
edit->setDateTime(value);
edit->blockSignals(false);
};
}
示例14: load
void DesignerFields::load( DesignerFields::Storage *storage )
{
QStringList keys = storage->keys();
// clear all custom page widgets
// we can't do this in the following loop, as it works on the
// custom fields of the vcard, which may not be set.
QMap<QString, QWidget *>::ConstIterator widIt;
for ( widIt = mWidgets.constBegin(); widIt != mWidgets.constEnd(); ++widIt ) {
QString value;
if ( widIt.value()->inherits( "QLineEdit" ) ) {
QLineEdit *wdg = static_cast<QLineEdit*>( widIt.value() );
wdg->setText( QString() );
} else if ( widIt.value()->inherits( "QSpinBox" ) ) {
QSpinBox *wdg = static_cast<QSpinBox*>( widIt.value() );
wdg->setValue( wdg->minimum() );
} else if ( widIt.value()->inherits( "QCheckBox" ) ) {
QCheckBox *wdg = static_cast<QCheckBox*>( widIt.value() );
wdg->setChecked( false );
} else if ( widIt.value()->inherits( "QDateTimeEdit" ) ) {
Q3DateTimeEdit *wdg = static_cast<Q3DateTimeEdit*>( widIt.value() );
wdg->setDateTime( QDateTime::currentDateTime() );
} else if ( widIt.value()->inherits( "KDateTimeWidget" ) ) {
KDateTimeWidget *wdg = static_cast<KDateTimeWidget*>( widIt.value() );
wdg->setDateTime( QDateTime::currentDateTime() );
} else if ( widIt.value()->inherits( "KDatePicker" ) ) {
KDatePicker *wdg = static_cast<KDatePicker*>( widIt.value() );
wdg->setDate( QDate::currentDate() );
} else if ( widIt.value()->inherits( "QComboBox" ) ) {
QComboBox *wdg = static_cast<QComboBox*>( widIt.value() );
wdg->setCurrentIndex( 0 );
} else if ( widIt.value()->inherits( "QTextEdit" ) ) {
QTextEdit *wdg = static_cast<QTextEdit*>( widIt.value() );
wdg->setPlainText( QString() );
}
}
QStringList::ConstIterator it2;
for ( it2 = keys.constBegin(); it2 != keys.constEnd(); ++it2 ) {
QString value = storage->read( *it2 );
QMap<QString, QWidget *>::ConstIterator it = mWidgets.constFind( *it2 );
if ( it != mWidgets.constEnd() ) {
if ( it.value()->inherits( "QLineEdit" ) ) {
QLineEdit *wdg = static_cast<QLineEdit*>( it.value() );
wdg->setText( value );
} else if ( it.value()->inherits( "QSpinBox" ) ) {
QSpinBox *wdg = static_cast<QSpinBox*>( it.value() );
wdg->setValue( value.toInt() );
} else if ( it.value()->inherits( "QCheckBox" ) ) {
QCheckBox *wdg = static_cast<QCheckBox*>( it.value() );
wdg->setChecked( value == "true" || value == "1" );
} else if ( it.value()->inherits( "QDateTimeEdit" ) ) {
Q3DateTimeEdit *wdg = static_cast<Q3DateTimeEdit*>( it.value() );
wdg->setDateTime( QDateTime::fromString( value, Qt::ISODate ) );
} else if ( it.value()->inherits( "KDateTimeWidget" ) ) {
KDateTimeWidget *wdg = static_cast<KDateTimeWidget*>( it.value() );
wdg->setDateTime( QDateTime::fromString( value, Qt::ISODate ) );
} else if ( it.value()->inherits( "KDatePicker" ) ) {
KDatePicker *wdg = static_cast<KDatePicker*>( it.value() );
wdg->setDate( QDate::fromString( value, Qt::ISODate ) );
} else if ( it.value()->inherits( "QComboBox" ) ) {
QComboBox *wdg = static_cast<QComboBox*>( it.value() );
wdg->setItemText( wdg->currentIndex(), value );
} else if ( it.value()->inherits( "QTextEdit" ) ) {
QTextEdit *wdg = static_cast<QTextEdit*>( it.value() );
wdg->setPlainText( value );
}
}
}
}
示例15: show
void AdjustSubnets::show()
{
QDialog::show();
scenarioName->setText(QString( "Scenario Name: ") + extractor->setup->scenarioName->text());
scenarioDirectory->setText(QString("Scenario Directory: ") + extractor->setup->scenarioDirectory->text());
tableWidget->horizontalHeaderItem(0)->setToolTip("This is the name of the radio. It consists of the EXata/QualNet name and the interface id");
tableWidget->horizontalHeaderItem(1)->setToolTip("The radio belongs to this force");
tableWidget->horizontalHeaderItem(2)->setToolTip("Select an IPv4 subnet for the radio to use for communicationsI");
QStringList addrs;
SNT_HLA::NetworkSet& nets = extractor->ns->networksUsed();
SNT_HLA::NetworkSet::iterator netIt = nets.begin();
while( netIt != nets.end() )
{
QString addr((*netIt)->address.c_str());
if( addrs.indexOf(addr) == -1 )
addrs << addr;
netIt++;
}
tableWidget->clearContents();
tableWidget->setRowCount(0);
QAbstractItemModel* model = tableWidget->model();
rowInfo.clear();
SNT_HLA::NodeSet::iterator it = extractor->ns->begin();
while( it != extractor->ns->end() )
{
QApplication::processEvents();
if( extractor == 0 )
break;
if( (*it)->entity )
{
std::set<SNT_HLA::RadioTransmitter*>::iterator rit = (*it)->radios.begin();
while( rit != (*it)->radios.end() )
{
int row = tableWidget->rowCount();
tableWidget->insertRow(row);
subnetRowInfo info;
info.row = row;
info.node = *it;
info.net = extractor->ns->getNetwork(*it, (*rit));
rowInfo.append(info);
QString name = QString((*it)->getNodeName()) + ":" + QString::number((*rit)->RadioIndex);
QString addr(extractor->ns->getNetworkAddress(*it, (*rit)).c_str());
QModelIndex index = model->index(row, 0, QModelIndex());
std::stringstream fs;
fs << (*it)->entity->ForceIdentifier << std::ends;
QString force = fs.str().c_str();
model->setData(index, name);
index = model->index(row, 1, QModelIndex());
model->setData(index, force);
QComboBox* box = new QComboBox;
box->addItems(addrs);
int idx = addrs.indexOf(addr);
if( idx == -1 )
{
idx = box->count();
box->insertItem(idx, addr);
}
box->setCurrentIndex(idx);
box->setToolTip("Select an IPv4 subnet for the radio to use for communications");
tableWidget->setCellWidget(row, 2, box);
tableWidget->item(row, 0)->setFlags(0);
tableWidget->item(row, 1)->setFlags(0);
tableWidget->item(row,0)->setToolTip("This is the name of the radio. It consists of the EXata/QualNet name and the interface id");
tableWidget->item(row,1)->setToolTip("The radio belongs to this force");
tableWidget->resizeColumnToContents(0);
rit++;
}
}
it++;
}
}