Ejemplo n.º 1
0
void XComboBox::setCode(QString pString)
{
  if (DEBUG)
    qDebug("%s::setCode(%d %d %s) with _codes.count %d and _ids.count %d",
           objectName().toAscii().data(), pString.isNull(), pString.isEmpty(),
           pString.toAscii().data(), _codes.count(), _ids.count());

  if (pString.isEmpty())
  {
    setId(-1);
    setCurrentText(pString);
  }
  else if (count() == _codes.count())
  {
    for (int counter = ((allowNull()) ? 1 : 0); counter < count(); counter++)
    {
      if (_codes.at(counter) == pString)
      {
        if (DEBUG)
          qDebug("%s::setCode(%s) found at %d with _ids.count %d & _lastId %d",
                 objectName().toAscii().data(), pString.toAscii().data(),
                 counter, _ids.count(), _lastId);
        setCurrentIndex(counter);

        if (_ids.count() && _lastId!=_ids.at(counter))
          setId(_ids.at(counter));

        return;
      }
      else if (DEBUG)
        qDebug("%s::setCode(%s) not found (%s)",
               qPrintable(objectName()), qPrintable(pString),
               qPrintable(_codes.at(counter)));
    }
  }
  else  // this is an ad-hoc combobox without a query behind it?
  {
    setCurrentItem(findText(pString));
    if (DEBUG)
      qDebug("%s::setCode(%s) set current item to %d using findData()",
             objectName().toAscii().data(), pString.toAscii().data(),
             currentItem());
    if (_ids.count() > currentItem())
      setId(_ids.at(currentItem()));
    if (DEBUG)
      qDebug("%s::setCode(%s) current item is %d after setId",
             objectName().toAscii().data(), pString.toAscii().data(),
             currentItem());
  }

  if (editable())
  {
    setId(-1);
    setCurrentText(pString);
  }
}
/******************************************************************************
* This is called whenever the node selection has changed.
******************************************************************************/
void SceneNodeSelectionBox::onSceneSelectionChanged()
{
	SelectionSet* selection = _datasetContainer.currentSet() ? _datasetContainer.currentSet()->selection() : nullptr;
	if(!selection || selection->empty()) {
		setCurrentText(tr("No selection"));
	}
	else if(selection->size() > 1) {
		setCurrentText(tr("%i selected objects").arg(selection->size()));
	}
	else {
		int index = findData(QVariant::fromValue(selection->node(0)));
		setCurrentIndex(index);
	}
}
Ejemplo n.º 3
0
void MainWindow::loadOpenedFileList()
{
	// 读配置文件;
	QString settingsFileName = QDir::currentPath() + tr("/settings.ini");
	auto &settings = QSettings(settingsFileName, QSettings::IniFormat);

	settings.beginGroup("config");
	const auto &vallist = settings.value(tr("opened_file_list"), QVariantList()).toList();
	const auto &latest_file = settings.value(tr("latest_file"), QString()).toString();
	settings.endGroup();

	// 解析到字符串列表中;
	QStringList filelist;
	for (auto it=vallist.begin(); it!=vallist.end(); ++it)
	{
		const auto &val = *it;
		filelist.push_back(val.toString());
	}

	// 填入comboBox;
	auto comboBox_exportPaths = this->findChild<QComboBox *>(tr("comboBox_exportPaths"));
	if (comboBox_exportPaths)
	{
		comboBox_exportPaths->addItems(filelist);
		comboBox_exportPaths->setCurrentText(latest_file);
	}
}
Ejemplo n.º 4
0
void toRefreshCombo::setRefreshInterval(QString const& interval)
{
#if QT_VERSION < 0x050000
	int index = findText(interval);
	setCurrentIndex(index);
#else
	setCurrentText(interval);
#endif	
}
void KTimezoneCombo::setTimezone(const QString& tz) {
  int idx = d->_names.findIndex(tz);

  if (idx != -1) {
    setCurrentItem(idx);
  } else {
    setCurrentItem(0);
    setCurrentText(tz);
  }
}
Ejemplo n.º 6
0
void KFileFilterCombo::setCurrentFilter( const QString& filter )
{
    int pos = 0;
    for( QStringList::ConstIterator it = filters.begin();
         it != filters.end();
         ++it, ++pos ) {
        if( *it == filter ) {
            setCurrentItem( pos );
            filterChanged();
            return;
        }
    }
    setCurrentText( filter );
    filterChanged();
}
Ejemplo n.º 7
0
void XComboBox::setText(const QString &pString)
{
  if (count())
  {
    for (int counter = ((allowNull()) ? 1 : 0); counter < count(); counter++)
  {
      if (text(counter) == pString)
      {
        setCurrentItem(counter);
        return;
      }
    }
  }

  if (editable())
  {
    setId(-1);
    setCurrentText(pString);
  }
}
Ejemplo n.º 8
0
void ColorSelect::setColor(lc::Color color) {
    QColor qColor(color.redI(), color.greenI(), color.blueI(), color.alphaI());
    setCurrentText(CUSTOM);

    on_customColorChanged(qColor);
}
Ejemplo n.º 9
0
void SetComboText(QTableWidget& Widget, QString Text, int Row, int Col)
{
    auto Combo((QComboBox*) Widget.cellWidget(Row, Col));
    Combo->setCurrentText(Text);
}