コード例 #1
0
// going up in the history, rotating when reaching QListBox::count()
//
// Note: this differs from QComboBox because "up" means ++index here,
// to simulate the way shell history works (up goes to the most
// recent item). In QComboBox "down" means ++index, to match the popup...
//
void KHistoryComboBox::rotateUp()
{
    // save the current text in the lineedit
    // (This is also where this differs from standard up/down in QComboBox,
    // where a single keypress can make you lose your typed text)
    if ( d->myIterateIndex == -1 )
        d->myText = currentText();

    ++d->myIterateIndex;

    // skip duplicates/empty items
    const int last = count() - 1; // last valid index
    const QString currText = currentText();

    while ( d->myIterateIndex < last &&
            (currText == itemText( d->myIterateIndex ) ||
             itemText( d->myIterateIndex ).isEmpty()) )
        ++d->myIterateIndex;

    if ( d->myIterateIndex >= count() ) {
        d->myRotated = true;
        d->myIterateIndex = -1;

        // if the typed text is the same as the first item, skip the first
        if ( count() > 0 && d->myText == itemText(0) )
            d->myIterateIndex = 0;

        setEditText( d->myText );
    } else {
        setCurrentIndex(d->myIterateIndex);
    }
}
コード例 #2
0
void QtFallbackWebPopup::populate()
{
    m_combo->clear();

    QStandardItemModel* model = qobject_cast<QStandardItemModel*>(m_combo->model());
    Q_ASSERT(model);

#if !defined(Q_WS_S60)
    m_combo->setFont(font());
#endif
    for (int i = 0; i < itemCount(); ++i) {
        switch (itemType(i)) {
        case Separator:
            m_combo->insertSeparator(i);
            break;
        case Group:
            m_combo->insertItem(i, itemText(i));
            model->item(i)->setEnabled(false);
            break;
        case Option:
            m_combo->insertItem(i, itemText(i));
            model->item(i)->setEnabled(itemIsEnabled(i));
            break;
        }
    }
}
コード例 #3
0
ファイル: qserialselector.cpp プロジェクト: aporto/mariamole
bool QSerialSelector::eventFilter (QObject *object, QEvent *event)
{
    if (event->type() != QEvent::Show) {
        //QComboBox::eventFilter(object, event);
        return QObject::event(event);
    }

    QString curr = "N/A";
    if (currentIndex() >= 0) {
        curr = itemText(currentIndex());
    }

    //cout << "Vamos pra Lapa" << endl;

    QSerialPortInfo serial;
    QStringList info;

    foreach (const QSerialPortInfo &list, QSerialPortInfo::availablePorts()) {
        info << list.portName();
        //cout << list.portName().toStdString() << endl;
    }


    // add all new serial ports
    for (int i=0; i < info.count();i++) {
        bool exists = false;
        for (int j=0; j < count(); j++) {
            if (itemText(j) == info.at(i)) {
                exists = true;
                break;
            }
        }
        if (exists == false) {
            addItem(info.at(i));
        }
    }

    // remove all serial ports that no longer exist
    int j = 0;
    while (j < count()) {
        bool exists = false;
        for (int i=0; i < info.count();i++) {
            QString pName = info.at(i);
            QString cName = itemText(j);
            if ( (cName == pName) || (cName == "N/A") ){
                exists = true;
                break;
            }
        }
        if (exists == false) {
            removeItem(j);
        } else {
            j++;
        }
    }


    QComboBox::eventFilter(object, event);
    return QObject::event( event);
}
コード例 #4
0
ファイル: rsscombobox.cpp プロジェクト: descent/qtermwidget
void RssComboBox::updateDescription(int index)
{
    RssItem item = itemData(index).value<RssItem>();
    if (item.url.isEmpty() && item.description.isEmpty())
        emit updatedDescription(itemText(index));
    else
        emit updatedDescription(tr("<b>%1</b><br>%2")
                .arg(itemText(index)).arg(item.description));
}
コード例 #5
0
void KHistoryComboBox::addToHistory( const QString& item )
{
    if ( item.isEmpty() || (count() > 0 && item == itemText(0) )) {
        return;
    }

    bool wasCurrent = false;
    // remove all existing items before adding
    if ( !duplicatesEnabled() ) {
        int i = 0;
        int itemCount = count();
        while ( i < itemCount ) {
            if ( itemText( i ) == item ) {
                if ( !wasCurrent )
                  wasCurrent = ( i == currentIndex() );
                removeItem( i );
                --itemCount;
            } else {
                ++i;
            }
        }
    }

    // now add the item
    if ( d->myPixProvider )
        insertItem( 0, d->myPixProvider->pixmapFor(item, iconSize().height()), item);
    else
        insertItem( 0, item );

    if ( wasCurrent )
        setCurrentIndex( 0 );

    const bool useComp = useCompletion();

    const int last = count() - 1; // last valid index
    const int mc = maxCount();
    const int stopAt = qMax(mc, 0);

    for (int rmIndex = last; rmIndex >= stopAt; --rmIndex) {
        // remove the last item, as long as we are longer than maxCount()
        // remove the removed item from the completionObject if it isn't
        // anymore available at all in the combobox.
        const QString rmItem = itemText( rmIndex );
        removeItem( rmIndex );
        if ( useComp && !contains( rmItem ) )
            completionObject()->removeItem( rmItem );
    }

    if ( useComp )
        completionObject()->addItem( item );
}
コード例 #6
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);
            }
        }
    }
}
コード例 #7
0
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);
}
コード例 #8
0
ファイル: ingredientcombobox.cpp プロジェクト: KDE/krecipes
void IngredientComboBox::removeIngredient( int id )
{
	int row = -1;
	for ( QMap<int, int>::iterator it = ingredientComboRows.begin(); it != ingredientComboRows.end(); ++it ) {
		if ( it.value() == id ) {
			row = it.key();
			completionObject()->removeItem( itemText(row) );
			removeItem( row );
			ingredientComboRows.erase( it );
			break;
		}
	}

	if ( row == -1 )
		return ;

	//now update the map by pushing everything after this item up
	QMap<int, int> new_map;
	for ( QMap<int, int>::iterator it = ingredientComboRows.begin(); it != ingredientComboRows.end(); ++it ) {
		if ( it.key() > row ) {
			new_map.insert( it.key() - 1, it.value() );
		}
		else
			new_map.insert( it.key(), it.value() );
	}
	ingredientComboRows = new_map;
}
コード例 #9
0
ファイル: mainwindow.cpp プロジェクト: wgq168668/misc
void MainWindow::saveOpenedFileList()
{
	// 填入comboBox;
	auto comboBox_exportPaths = this->findChild<QComboBox *>(tr("comboBox_exportPaths"));
	if (!comboBox_exportPaths)
	{
		Q_ASSERT(false);
		return;
	}

	QVariantList vallist;
	int count = comboBox_exportPaths->maxVisibleItems();
	for (int i=0; i<count; ++i)
	{
		const auto &s = comboBox_exportPaths->itemText(i);
		const auto &val = QVariant(s);
		vallist.push_back(val);
	}

	QString latest_file = comboBox_exportPaths->currentText();

	// 写配置文件;
	QString settingsFileName = QDir::currentPath() + tr("/settings.ini");
	auto &settings = QSettings(settingsFileName, QSettings::IniFormat);

	settings.beginGroup("config");
	settings.setValue(tr("opened_file_list"), vallist);
	settings.setValue(tr("latest_file"), latest_file);
	settings.endGroup();
}
コード例 #10
0
bool KHistoryComboBox::removeFromHistory( const QString& item )
{
    if ( item.isEmpty() )
        return false;

    bool removed = false;
    const QString temp = currentText();
    int i = 0;
    int itemCount = count();
    while ( i < itemCount ) {
        if ( item == itemText( i ) ) {
            removed = true;
            removeItem( i );
            --itemCount;
        } else {
            ++i;
        }
    }

    if ( removed && useCompletion() )
        completionObject()->removeItem( item );

    setEditText( temp );
    return removed;
}
コード例 #11
0
  /**
  * Filter the list to only show those supporting the given technique
  * @param techniques :: A string list containing the names of a techniques to filter the instrument list by
  * @param facility :: A FacilityInfo object
  */
  void InstrumentSelector::filterByTechniquesAtFacility(const QStringList & techniques, const Mantid::Kernel::FacilityInfo & facility)
  {
    if( techniques.isEmpty() ) return;

    this->blockSignals(true);

    QStringList supportedInstruments;
    QStringListIterator techItr(techniques);
    while( techItr.hasNext() )
    {
      const std::vector<InstrumentInfo> instruments = facility.instruments(techItr.next().toStdString());
      const size_t nInstrs = instruments.size();
      for( size_t i = 0; i < nInstrs; ++i )
      {
        supportedInstruments.append(QString::fromStdString(instruments[i].name()));
      }
    }

    // Remove those not supported
    for( int i = 0 ; i < this->count(); )
    {
      if( !supportedInstruments.contains(itemText(i)) )
      {
        removeItem(i);
      }
      else
      {
        ++i;
      }
    }

    this->blockSignals(false);

    emit instrumentListUpdated();
  }
コード例 #12
0
ファイル: admindlg.cpp プロジェクト: Undrizzle/yolanda
bool ecAdminDialog::RemovePackageVersion (wxTreeItemId hTreeItem)
{
    wxTreeCtrl* treeCtrl = (wxTreeCtrl*) FindWindow( ecID_ADMIN_DIALOG_TREE) ;

    const wxTreeItemId hParentItem = treeCtrl->GetParent (hTreeItem);
    wxASSERT (hParentItem);

    ecAdminItemData* data = (ecAdminItemData*) treeCtrl->GetItemData (hParentItem);

    wxASSERT( data );

    if (!data)
        return FALSE;

    wxString pstrPackage = data->m_string ;

    wxString strCommand;
    wxString itemText(treeCtrl->GetItemText (hTreeItem));
    strCommand.Printf (wxT("remove %s --version %s"), (const wxChar*) pstrPackage, (const wxChar*) itemText);
    if (! EvalTclFile (3, strCommand, wxT("Removing package"))) // if not successful
        return false;
    
    treeCtrl->Delete (hTreeItem); // remove the selected item from the tree

    return TRUE;
}
コード例 #13
0
 ProtocolCheckListItem( BackendListViewItem* blvi,
                        Q3ListViewItem* prev, const char * protocolName,
                        const CryptoBackend::Protocol* protocol ) // can be 0
   : Q3CheckListItem( blvi, prev, itemText( protocolName, protocol ),
                     Q3CheckListItem::CheckBox ),
     mProtocol( protocol ), mProtocolName( protocolName )
   {}
コード例 #14
0
void TotalMultipleScoresList::addLineItem(const ItemArray &si,
                                          uint index, QTreeWidgetItem *line)
{
//   kDebug(11001) ;
    const PlayerInfos &pi = internal->playerInfos();
    uint k = 1; // skip "id"
    for (uint i=0; i<4; i++) { // skip additional fields
        const ItemContainer *container;
        if ( i==2 ) container = pi.item(QLatin1String( "nb games" ));
        else if ( i==3 ) container = pi.item(QLatin1String( "mean score" ));
        else {
            container = si[k];
            k++;
        }

        if (line) {
	  line->setText(i, itemText(*container, index));
	  line->setTextAlignment(i, container->item()->alignment());
	}
        else {
            QString label =
                (i==2 ? i18n("Won Games") : container->item()->label());
	    headerItem()->setText(i, label );
            headerItem()->setTextAlignment(i, container->item()->alignment());
        }
    }
}
コード例 #15
0
ファイル: klistwidget.cpp プロジェクト: kxtry/kxfw
void KListItem::itemReset( )
{
	if(layoutType() == KWidget::None)
	{
		setLayoutType(KWidget::HBox);
		setSpacing(3);
	}

	QString ico = itemIcon();
	QString txt = itemText();

	if(m_label == NULL)
	{
		m_label = new KLabel(this);
		addItem(m_label);
	}

	if(!ico.isEmpty() && m_icon == NULL)
	{
		m_icon = new KImageItem(this);
		insertItem(m_icon, 0);
	}

	if(m_icon)
	{
		m_icon->setImagePath(ico);
		QSize s = m_icon->pixmapSize();
		m_icon->setFixWidth(s.width());
	}

	if(m_label)
	{
		m_label->setText(txt);
	}
}
コード例 #16
0
ファイル: searchbar.cpp プロジェクト: wzedmund/filemanager
void SearchBar::setCurrentIndex(int index)
{
    m_lineEdit->setText(itemText(index));
    emit currentTextChanged(m_lineEdit->text());
    m_popupList->clearSelection();
    m_menu->hide();
}
コード例 #17
0
void QgsScaleComboBox::showPopup()
{
  QComboBox::showPopup();

  if ( !currentText().contains( ':' ) )
  {
    return;
  }
  QStringList parts = currentText().split( ':' );
  bool ok;
  int idx = 0;
  int min = 999999;
  long currScale = parts.at( 1 ).toLong( &ok );
  long nextScale, delta;
  for ( int i = 0; i < count(); i++ )
  {
    parts = itemText( i ).split( ':' );
    nextScale = parts.at( 1 ).toLong( &ok );
    delta = qAbs( currScale - nextScale );
    if ( delta < min )
    {
      min = delta;
      idx = i;
    }
  }

  blockSignals( true );
  view()->setCurrentIndex( model()->index( idx, 0 ) );
  blockSignals( false );
}
コード例 #18
0
ファイル: controls.cpp プロジェクト: Zefling/flacon
QStringList HistoryComboBox::history() const
{
    QStringList res;
    for (int i=0; i<count(); ++i)
        res << itemText(i);

    return res;
}
コード例 #19
0
void KonqCombo::slotSetIcon( int index )
{
    if( itemIcon( index ).isNull())
        // on-demand icon loading
        setItemIcon( index, KonqPixmapProvider::self()->pixmapFor( itemText( index ),
                     KIconLoader::SizeSmall ) );
    update();
}
コード例 #20
0
ファイル: ingredientcombobox.cpp プロジェクト: KDE/krecipes
int IngredientComboBox::findInsertionPoint( const QString &name )
{
	for ( int i = 0; i < count(); i++ ) {
		if ( QString::localeAwareCompare( name, itemText( i ) ) < 0 )
			return i;
	}

	return count();
}
コード例 #21
0
QStringList CHistoryComboBox::historyItems() const {
    QStringList items;
    for (int i = 0; i < count(); i++) {
        QString text = itemText(i);
        if (text.size() > 0)
            items << text;
    }
    return items;
}
コード例 #22
0
QStringList KHistoryComboBox::historyItems() const
{
    QStringList list;
    const int itemCount = count();
    for ( int i = 0; i < itemCount; ++i )
        list.append( itemText( i ) );

    return list;
}
コード例 #23
0
void CheckBoxList::updateSelected(const int ind)
{
	bool checked = itemData(ind,Qt::CheckStateRole).toBool();
	QString text = itemText(highli);
	if (checked)
		sel.removeAll(text);
	else
		sel.push_back(text);
}
コード例 #24
0
ファイル: ingredientcombobox.cpp プロジェクト: KDE/krecipes
int IngredientComboBox::id( const QString &ing )
{
	for ( int i = 0; i < count(); i++ ) {
		if ( ing == itemText( i ) )
			return id(i);
	}
	kDebug()<<"Warning: couldn't find the ID for "<<ing;
	return -1;
}
コード例 #25
0
QSize KCompletionDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    Q_UNUSED( option );

    KCompletionItem item = index.data( KCompletionModel::CompletionItemRole ).value<KCompletionItem>();

    QTextDocument doc;
    doc.setHtml( itemText( item ) );
    return doc.size().toSize();
}
コード例 #26
0
void QtFallbackWebPopup::showS60BrowserDialog()
{
    static MBrCtlDialogsProvider* dialogs = CBrowserDialogsProvider::NewL(0);
    if (!dialogs)
        return;

    int size = itemCount();
    CArrayFix<TBrCtlSelectOptionData>* options = new CArrayFixFlat<TBrCtlSelectOptionData>(qMax(1, size));
    RPointerArray<HBufC> items(qMax(1, size));
    CleanupStack::PushL(TCleanupItem(&ResetAndDestroy, &items));

    for (int i = 0; i < size; i++) {
        if (itemType(i) == Separator) {
            TBrCtlSelectOptionData data(_L("----------"), false, false, false);
            options->AppendL(data);
        } else {
            HBufC16* itemStr = HBufC16::NewL(itemText(i).length());
            itemStr->Des().Copy((const TUint16*)itemText(i).utf16(), itemText(i).length());
            CleanupStack::PushL(itemStr);
            TBrCtlSelectOptionData data(*itemStr, i == currentIndex(), false, itemIsEnabled(i));
            options->AppendL(data);
            items.AppendL(itemStr);
            CleanupStack::Pop();
        }
    }

    dialogs->DialogSelectOptionL(KNullDesC(), (TBrCtlSelectOptionType)(ESelectTypeSingle | ESelectTypeWithFindPane), *options);

    CleanupStack::PopAndDestroy(&items);

    int newIndex;
    for (newIndex = 0; newIndex < options->Count() && !options->At(newIndex).IsSelected(); newIndex++) {}
    if (newIndex == options->Count())
        newIndex = currentIndex();
    
    m_popupVisible = false;
    popupDidHide();

    if (currentIndex() != newIndex && newIndex >= 0)
        valueChanged(newIndex);

    delete options;
}
コード例 #27
0
void DisplayFilterCombo::writeRecent(FILE *rf) {
    int i;

    for (i = 0; i < count(); i++) {
        const QByteArray& filter = itemText(i).toUtf8();
        if (!filter.isEmpty()) {
            fprintf(rf, RECENT_KEY_DISPLAY_FILTER ": %s\n", filter.constData());
        }
    }
}
コード例 #28
0
void QgsColorRampComboBox::setSourceColorRamp( QgsVectorColorRampV2* sourceRamp )
{
  mSourceColorRamp = sourceRamp->clone();

  QIcon icon = QgsSymbolLayerV2Utils::colorRampPreviewIcon( mSourceColorRamp, rampIconSize );
  if ( itemText( 0 ) == "[source]" )
    setItemIcon( 0, icon );
  else
    insertItem( 0, icon, "[source]" );
  setCurrentIndex( 0 );
}
コード例 #29
0
void DisplayFilterCombo::writeRecent(FILE *rf) {
    int i;
    const char *filter_str;

    for (i = 0; i < count(); i++) {
        filter_str = itemText(i).toUtf8().constData();
        if(filter_str && strlen(filter_str) > 0) {
            fprintf(rf, RECENT_KEY_DISPLAY_FILTER ": %s\n", filter_str);
        }
    }
}
コード例 #30
0
/*!
    @beta

    \property HbComboBox::currentText

    In case of non-editable combobox it returns the text at current index.
    In case of editable combobox it returns the text in line edit.
*/
QString HbComboBox::currentText( ) const
{
    Q_D( const HbComboBox );
    if( d->mEditable ) {
        return d->mLineEdit->text( );
    }else if( d->mCurrentIndex.isValid( ) ) {
        return itemText ( d->mCurrentIndex.row( ) );
    } else {
        return QString( );
    }
}