Beispiel #1
0
QTime KTimeEdit::getTime() const
{
    //kdDebug(5300) << "KTimeEdit::getTime(), currentText() = " << currentText() << endl;
    // TODO use KLocale::WithoutSeconds in HEAD
    bool ok = false;
    QTime time = KGlobal::locale()->readTime(currentText(), KLocale::WithoutSeconds, &ok);
    if(!ok)
    {
        // Also try to accept times in "military format", i.e. no delimiter, like 1200
        int tm = currentText().toInt(&ok);
        if((0 <= tm) && (tm < 2400) && (tm % 100 < 60) && ok)
        {
            time.setHMS(tm / 100, tm % 100, 0);
        }
        else
        {
            ok = false;
        }
    }
    kdDebug(5300) << "KTimeEdit::getTime(): " << time.toString() << endl;
    return time;
}
Beispiel #2
0
/**
 * Called when the pattern has changed. This method 
 * sets the current pattern to the value chosen.
 */
void QG_PatternBox::slotPatternChanged(int index) {

    RS_DEBUG->print("QG_PatternBox::slotPatternChanged %d\n", index);

    currentPattern = RS_PATTERNLIST->requestPattern(currentText());

    if (currentPattern!=NULL) {
        RS_DEBUG->print("Current pattern is (%d): %s\n",
                        index, currentPattern->getFileName().toLatin1().data());
    }

    emit patternChanged(currentPattern);
}
QString QgsFieldExpressionWidget::currentField( bool *isExpression, bool *isValid ) const
{
  QString text = currentText();
  if ( isValid )
  {
    *isValid = isValidExpression();
  }
  if ( isExpression )
  {
    *isExpression = this->isExpression();
  }
  return text;
}
GeocoordType GeocoordTypeComboBox::getGeocoordType() const
{
   if (currentIndex() != -1)
   {
      std::string typeText = currentText().toStdString();
      if (typeText.empty() == false)
      {
         return StringUtilities::fromDisplayString<GeocoordType>(typeText);
      }
   }

   return GeocoordType();
}
bool CommandComboBox::event(QEvent *e)
{
    if (e->type() == QEvent::ToolTip) {
        const QString text = currentText();
        if (const Core::Command *cmd = command(text)) {
            const QString tooltip = tr("Activate %1 Pane").arg(text);
            setToolTip(cmd->stringWithAppendedShortcut(tooltip));
        } else {
            setToolTip(text);
        }
    }
    return QComboBox::event(e);
}
void KonqCombo::removeURL( const QString& url )
{
    setUpdatesEnabled( false );
    lineEdit()->setUpdatesEnabled( false );

    removeFromHistory( url );
    applyPermanent();
    setTemporary( currentText() );

    setUpdatesEnabled( true );
    lineEdit()->setUpdatesEnabled( true );
    update();
}
QgsVectorColorRampV2* QgsColorRampComboBox::currentColorRamp()
{
  QString rampName = currentText();

  if ( rampName == tr( "Random colors" ) )
  {
    return new QgsRandomColorsV2();
  }
  else if ( rampName == "[source]" && mSourceColorRamp )
    return mSourceColorRamp->clone();
  else
    return mStyle->colorRamp( rampName );
}
ModisUtilities::RasterConversionType RasterConversionTypeComboBox::getRasterConversion() const
{
   if (currentIndex() != -1)
   {
      std::string typeText = currentText().toStdString();
      if (typeText.empty() == false)
      {
         return StringUtilities::fromDisplayString<ModisUtilities::RasterConversionType>(typeText);
      }
   }

   return ModisUtilities::RasterConversionType();
}
bool ClassNameValidatingComboBox::isValid() const
{
    const QString baseClass = currentText().trimmed();
    if (!baseClass.isEmpty())
    {
        if (!d->m_validator.validate(baseClass)) {
            d->m_errorMessage = tr("Invalid base class name");
            return false;
        }
    }
    d->m_errorMessage.clear();
    return true;
}
void
VBoxDbgConsoleInput::returnPressed()
{
    Assert(m_hGUIThread == RTThreadNativeSelf());

    QString strCommand = currentText();
    /** @todo trim whitespace? */
    if (strCommand.isEmpty())
        return;

    /* deal with the current command. */
    emit commandSubmitted(strCommand);


    /*
     * Add current command to history.
     */
    bool fNeedsAppending = true;

    /* invariant: empty line at the end */
    int iLastItem = count() - 1;
    Assert(itemText(iLastItem).isEmpty());

    /* have previous command? check duplicate. */
    if (iLastItem > 0)
    {
        const QString strPrevCommand(itemText(iLastItem - 1));
        if (strCommand == strPrevCommand)
            fNeedsAppending = false;
    }

    if (fNeedsAppending)
    {
        /* history full? drop the oldest command. */
        if (count() == maxCount())
        {
            removeItem(0);
            --iLastItem;
        }

        /* insert before the empty line. */
        insertItem(iLastItem, strCommand);
    }

    /* invariant: empty line at the end */
    int iNewLastItem = count() - 1;
    Assert(itemText(iNewLastItem).isEmpty());

    /* select empty line to present "new" command line to the user */
    setCurrentIndex(iNewLastItem);
}
Beispiel #11
0
void GenreCombo::update(const QSet<QString> &g)
{
    if (count() && g==genres) {
        return;
    }

    QSet<QString> mg=g;
    mg.remove(QString());
    if (mg.count()!=g.count() && count() && mg==genres) {
        return;
    }

    genres=mg;
    QStringList entries=g.toList();
    qSort(entries);
    entries.prepend(i18n("All Genres"));

    if (count()==entries.count()) {
        bool noChange=true;
        for (int i=0; i<count(); ++i) {
            if (itemText(i)!=entries.at(i)) {
                noChange=false;
                break;
            }
        }
        if (noChange) {
            return;
        }
    }

    QString currentFilter = currentIndex() ? currentText() : QString();

    clear();
    addItems(entries);
    if (0==genres.count()) {
        setCurrentIndex(0);
    } else {
        if (!currentFilter.isEmpty()) {
            bool found=false;
            for (int i=1; i<count() && !found; ++i) {
                if (itemText(i) == currentFilter) {
                    setCurrentIndex(i);
                    found=true;
                }
            }
            if (!found) {
                setCurrentIndex(0);
            }
        }
    }
}
Beispiel #12
0
void RComboBox::keyPressEvent(QKeyEvent *e)
{
    timer->stop();
    if (completer && completer->popup()->isVisible())
    {
        // The following keys are forwarded by the completer to the widget
        switch (e->key())
        {
        case Qt::Key_Enter:
        case Qt::Key_Return:
        case Qt::Key_Escape:
        case Qt::Key_Tab:
        case Qt::Key_Backtab:
            e->ignore();
            return; // Let the completer do default behavior
        }
    }

    if (e->text().length() > 0 && e->text().at(0).isPrint()){
        if(this->lineEdit()->selectedText().size() > 0)
            this->lineEdit()->del();
        QString cur = currentText();
        int pos = this->lineEdit()->cursorPosition();
        cur = cur.left(pos)
                .append(e->text())
                .append(cur.right(cur.length()-pos));
        setEditText(cur);
        this->lineEdit()->setCursorPosition(pos+1);
        //CustomComboBox::keyPressEvent(e);
    }
    else CustomComboBox::keyPressEvent(e);

    if(currentText().length() < min_chars && completer->popup()->isVisible())
        completer->popup()->close();
    this->lineEdit()->deselect();

    timer->start(timeout);
}
Beispiel #13
0
void hashBox::setupHashes(QList<int> nids)
{
	QString md = currentText();
	if (!wanted_md.isEmpty())
		md = wanted_md;
	clear();
	for (unsigned i=0; i<ARRAY_SIZE(hashalgos); i++) {
		if (nids.contains(hashalgos[i].md->type)) {
			addItem(QString(hashalgos[i].name));
		}
	}
	setDefaultHash();
	setCurrentString(md);
}
Beispiel #14
0
//! Slot called when QComboBox has changed
void QgsScaleComboBox::fixupScale()
{
  QStringList txtList = currentText().split( ':' );
  bool userSetScale = txtList.size() != 2;

  bool ok;
  double newScale = toDouble( currentText(), &ok );

  // Valid string representation
  if ( ok )
  {
    // if a user types scale = 2345, we transform to 1:2345
    if ( userSetScale && newScale >= 1.0 )
    {
      newScale = 1 / newScale;
    }
    setScale( newScale );
  }
  else
  {
    setScale( mScale );
  }
}
Beispiel #15
0
void DictionaryComboBox::setCurrentByDictionaryName( const QString & name )
{
    if ( name.isEmpty() || name == currentText() )
        return;

    int idx = findText( name );
    if ( idx == -1 ) {
        kDebug() << "name not found" << name;
        return;
    }

    setCurrentIndex( idx );
    d->slotDictionaryChanged( idx );
}
Beispiel #16
0
void OCompletionBox::down()
{
    int i = currentItem();

    if ( i == 0 && d->down_workaround ) {
        d->down_workaround = false;
        setCurrentItem( 0 );
        setSelected( 0, true );
        emit highlighted( currentText() );
    }

    else if ( i < (int) count() - 1 )
        setCurrentItem( i + 1 );
}
Beispiel #17
0
// going down in the history, no rotation possible. Last item will be
// the text that was in the lineedit before Up was called.
void KHistoryComboBox::rotateDown()
{
    // save the current text in the lineedit
    if ( d->myIterateIndex == -1 )
        d->myText = currentText();

    --d->myIterateIndex;

    const QString currText = currentText();
    // skip duplicates/empty items
    while ( d->myIterateIndex >= 0 &&
            (currText == itemText( d->myIterateIndex ) ||
             itemText( d->myIterateIndex ).isEmpty()) )
        --d->myIterateIndex;


    if ( d->myIterateIndex < 0 ) {
        if ( d->myRotated && d->myIterateIndex == -2 ) {
            d->myRotated = false;
            d->myIterateIndex = count() - 1;
            setEditText( itemText(d->myIterateIndex) );
        }
        else { // bottom of history
            if ( d->myIterateIndex == -2 ) {
                KNotification::event( "Textcompletion: No Match" ,
                                      i18n("No further items in the history."),
                                       QPixmap() , this, KNotification::DefaultEvent);
            }

            d->myIterateIndex = -1;
            if ( currentText() != d->myText )
                setEditText( d->myText );
        }
    } else {
        setCurrentIndex(d->myIterateIndex);
    }
}
QString QgsFieldExpressionWidget::currentField( bool *isExpression, bool *isValid ) const
{
  QString text = currentText();
  bool valueIsExpression = this->isExpression();
  if ( isValid )
  {
    // valid if not an expression (ie, set to a field), or set to an expression and expression is valid
    *isValid = !valueIsExpression || isValidExpression();
  }
  if ( isExpression )
  {
    *isExpression = valueIsExpression;
  }
  return text;
}
Beispiel #19
0
QString MyComboBox::getComboText() const
{
    QString text = currentText();
    if (!text.isEmpty())
    {
        int index = currentIndex();
        if ((index == -1) || (itemText(index) != text))
        {
            MyStringListModel* m = qobject_cast<MyStringListModel*>(model());
            if (m)
                m->checkString(text);
        }
    }
    return text;
}
Beispiel #20
0
void ValueSlider::
        editingFinished()
{
    QString text = currentText();
    if (text == valueAsString(true))
        return;

    bool ok = false;
    qreal v = text.toDouble(&ok);

    if (!ok)
        v = value();

    setValue( v );
}
Beispiel #21
0
void KFileFilterCombo::setMimeFilter(const QStringList &types, const QString &defaultType)
{
    clear();
    filters.clear();
    QString delim = QString::fromLatin1(", ");
    d->hasAllSupportedFiles = false;

    m_allTypes = defaultType.isEmpty() && (types.count() > 1);

    QString allComments, allTypes;
    int i = 0;
    for(QStringList::ConstIterator it = types.begin(); it != types.end(); ++it, ++i)
    {
        if(m_allTypes && it != types.begin())
        {
            allComments += delim;
            allTypes += ' ';
        }

        kdDebug(kfile_area) << *it << endl;
        KMimeType::Ptr type = KMimeType::mimeType(*it);
        filters.append(type->name());
        if(m_allTypes)
        {
            allTypes += type->name();
            allComments += type->comment();
        }
        insertItem(type->comment());
        if(type->name() == defaultType)
            setCurrentItem(i);
    }

    if(m_allTypes)
    {
        if(i < 3) // show the mime-comments of at max 3 types
            insertItem(allComments, 0);
        else
        {
            insertItem(i18n("All Supported Files"), 0);
            d->hasAllSupportedFiles = true;
        }

        filters.prepend(allTypes);
    }

    d->lastFilter = currentText();
    d->isMimeFilter = true;
}
Beispiel #22
0
void MainWindow::onExportData()
{
	// 判断有无导出路径;
	auto comboBox_exportPaths = this->findChild<QComboBox *>(tr("comboBox_exportPaths"));
	const auto &exportPath = comboBox_exportPaths->currentText();
	if (exportPath.isEmpty())
	{
		QMessageBox::information(NULL, "information", "Please set export path first!", QMessageBox::Yes, QMessageBox::Yes);
		return;
	}

	DataTree *tree = this->findChild<DataTree *>(tr("treeWidget"));
	tree->exportData(exportPath);

	QMessageBox::information(NULL, "information", "export done", QMessageBox::Yes, QMessageBox::Yes);
}
Beispiel #23
0
QString KFileFilterCombo::currentFilter() const
{
    QString f = currentText();
    if (f == text(currentItem())) { // user didn't edit the text
	f = *filters.at(currentItem());
        if ( d->isMimeFilter || (currentItem() == 0 && d->hasAllSupportedFiles) ) {
            return f; // we have a mimetype as filter
        }
    }

    int tab = f.find('|');
    if (tab < 0)
	return f;
    else
	return f.left(tab);
}
Beispiel #24
0
const EVP_MD *hashBox::currentHash()
{
	switch(key_type) {
	case EVP_PKEY_DSA:
		return EVP_dss1();
	case EVP_PKEY_EC:
		return EVP_ecdsa();
	default:
		QString hash = currentText();
		for (unsigned i=0; i<ARRAY_SIZE(hashalgos); i++) {
			if (hash == hashalgos[i].name)
				return hashalgos[i].md;
		}
	}
	return hashalgos[1].md; /* SHA1 as fallback */
}
void QgsFieldExpressionWidget::editExpression()
{
  QString currentExpression = currentText();
  QgsVectorLayer* vl = layer();

  QgsExpressionBuilderDialog dlg( vl, currentExpression );
  if ( !mDa.isNull() )
  {
    dlg.setGeomCalculator( *mDa );
  }
  dlg.setWindowTitle( mExpressionDialogTitle );

  if ( dlg.exec() )
  {
    QString newExpression = dlg.expressionText();
    setField( newExpression );
  }
}
Beispiel #26
0
void CurveCmb::slotComboCurve(bool toggle)
{
  if (toggle)
  {
    setEnabled(true);

    if (currentText().isEmpty())
    {
      for (int index = 0; index < count(); index++)
      {
        if (text(index) == DefaultCurveName)
        {
          setCurrentItem(index);
          break;
        }
      }
    }
  }
}
Beispiel #27
0
void QSolventBox::solventIndexChanged(int arg)
{
    if (currentText()=="Custom")
    {
        qDebug() << "Changed to custom.";
        QString fileName = QFileDialog::getOpenFileName(this,tr("Open Solvent Reference"),
                                                             (ActiveDir==NULL ? "C:/" : ActiveDir->value("CURRENT_RAMAN_DIR").toString()));
        if(!fileName.isEmpty())
        {
            if (ActiveDir!=NULL) ActiveDir->setValue("CURRENT_RAMAN_DIR",GetCurrentDir(fileName));
            Map["Custom"] = fileName;
        }
        else
        {
            disconnect(this,SIGNAL(currentIndexChanged(int)),this,SLOT(solventIndexChanged(int)));
            setCurrentIndex(0);
            connect(this,SIGNAL(currentIndexChanged(int)),this,SLOT(solventIndexChanged(int)));
        }
    }
Beispiel #28
0
std::string SwordFuncs::parseInput(char *input) {
  std::string str = input;
  if (str.compare(0, 2, "??") == 0) {
    std::cout << "perform global search" << std::endl;
  } else if (str.compare(0, 1, "?") == 0) {
    std::cout << "perform search within module" << std::endl;
  } else if (str.compare(0, 1, "!") == 0) {
    std::string mod = str.substr(1);
    trim(mod);
    SetModule(mod);
  } else if (str.empty()) {
    if (vkey.isTraversable()) {
      vkey++;
    }
  } else {
    return lookup(str);
  }
  return currentText();
}
Beispiel #29
0
void QgsScaleComboBox::updateScales( const QStringList &scales )
{
  QStringList myScalesList;
  QString oldScale = currentText();

  if ( scales.isEmpty() )
  {
    QSettings settings;
    QString myScales = settings.value( "Map/scales", PROJECT_SCALES ).toString();
    if ( !myScales.isEmpty() )
    {
      myScalesList = myScales.split( ',' );
    }
  }
  else
  {
    QStringList::const_iterator scaleIt = scales.constBegin();
    for ( ; scaleIt != scales.constEnd(); ++scaleIt )
    {
      myScalesList.append( *scaleIt );
    }
  }

  QStringList parts;
  double denominator;
  bool ok;
  for ( int i = 0; i < myScalesList.size(); ++i )
  {
    parts = myScalesList[ i ] .split( ':' );
    denominator = QLocale::system().toDouble( parts[1], &ok );
    if ( ok )
    {
      myScalesList[ i ] = toString( 1.0 / denominator );
    }
  }

  blockSignals( true );
  clear();
  addItems( myScalesList );
  setScaleString( oldScale );
  blockSignals( false );
}
void QgsLayoutItemLabel::contentChanged()
{
  switch ( mMode )
  {
    case ModeHtml:
    {
      const QString textToDraw = currentText();

      //mHtmlLoaded tracks whether the QWebPage has completed loading
      //its html contents, set it initially to false. The loadingHtmlFinished slot will
      //set this to true after html is loaded.
      mHtmlLoaded = false;

      const QUrl baseUrl = QUrl::fromLocalFile( mLayout->project()->absoluteFilePath() );
      mWebPage->mainFrame()->setHtml( textToDraw, baseUrl );

      //For very basic html labels with no external assets, the html load will already be
      //complete before we even get a chance to start the QEventLoop. Make sure we check
      //this before starting the loop
      if ( !mHtmlLoaded )
      {
        //Setup event loop and timeout for rendering html
        QEventLoop loop;

        //Connect timeout and webpage loadFinished signals to loop
        connect( mWebPage.get(), &QWebPage::loadFinished, &loop, &QEventLoop::quit );

        // Start a 20 second timeout in case html loading will never complete
        QTimer timeoutTimer;
        timeoutTimer.setSingleShot( true );
        connect( &timeoutTimer, &QTimer::timeout, &loop, &QEventLoop::quit );
        timeoutTimer.start( 20000 );

        // Pause until html is loaded
        loop.exec( QEventLoop::ExcludeUserInputEvents );
      }
      break;
    }
    case ModeFont:
      break;
  }
}