コード例 #1
0
ファイル: bgdialog.cpp プロジェクト: aarontc/kde-workspace
void BGDialog::setWallpaper(const QString &s)
{
    KComboBox *comboWallpaper = m_urlWallpaperBox;
    int i = comboWallpaper->count();
    if (i == 0)
        return;
    comboWallpaper->blockSignals(true);

    if (m_wallpaper.find(s) == m_wallpaper.end()) {
        QString imageCaption;
        int slash = s.lastIndexOf('/') + 1;
        int endDot = s.lastIndexOf('.');

        // strip the extension if it exists
        if (endDot != -1 && endDot > slash)
            imageCaption = s.mid(slash, endDot - slash);
        else
            imageCaption = s.mid(slash);
        if (comboWallpaper->itemText(i - 1) == imageCaption) {
            i--;
            comboWallpaper->removeItem(i);
        }
        comboWallpaper->addItem(imageCaption);
        m_wallpaper[s] = i;
        comboWallpaper->setCurrentIndex(i);
    } else {
        comboWallpaper->setCurrentIndex(m_wallpaper[s]);
    }
    comboWallpaper->blockSignals(false);
}
コード例 #2
0
void KOTodoPriorityDelegate::setEditorData( QWidget *editor,
                                            const QModelIndex &index ) const
{
  KComboBox *combo = static_cast<KComboBox *>( editor );

  combo->setCurrentIndex( index.data( Qt::EditRole ).toInt() );
}
コード例 #3
0
ファイル: widgets.cpp プロジェクト: vishesh/kde-baseapps
bool Widgets::comboBox(QWidget *parent, const QString& title, const QString& text, const QStringList& args,
		       const QString& defaultEntry, QString &result)
{
  KDialog dlg( parent );
  kapp->setTopWidget( &dlg );
  dlg.setCaption( title );
  dlg.setButtons( KDialog::Ok|KDialog::Cancel );
  dlg.setModal( true );
  dlg.setDefaultButton( KDialog::Ok );

  KVBox* vbox = new KVBox( &dlg );
  dlg.setMainWidget( vbox );

  QLabel label (vbox);
  label.setText (text);
  KComboBox combo (vbox);
  combo.insertItems (0, args);
  combo.setCurrentIndex( combo.findText( defaultEntry ) );

  handleXGeometry(&dlg);

  bool retcode = (dlg.exec() == QDialog::Accepted);

  if (retcode)
    result = combo.currentText();

  return retcode;
}
コード例 #4
0
void KisInputModeDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    KComboBox *combo = qobject_cast<KComboBox *>(editor);
    Q_ASSERT(combo);

    int i = combo->findText(d->action->shortcutIndexes().key(index.data(Qt::EditRole).toUInt()));
    combo->setCurrentIndex(i);
}
コード例 #5
0
void TracksDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    KComboBox *comboBox = qobject_cast<KComboBox *>(editor);
    if (!comboBox)
        return;
    const int pos = comboBox->findText(index.model()->data(index).toString(), Qt::MatchExactly);
    comboBox->setCurrentIndex(pos);
}
コード例 #6
0
void HolidayRegionSelector::Private::initItem( QTreeWidgetItem *listItem, HolidayRegion *region )
{
  m_ui.regionTreeWidget->blockSignals( true );
  QString languageName = KGlobal::locale()->languageCodeToName( region->languageCode() );
  listItem->setCheckState( Private::SelectColumn, Qt::Unchecked );
  QString text = i18n( "<p>Select to use Holiday Region</p>" );
  listItem->setToolTip( Private::SelectColumn, text );
  listItem->setToolTip( Private::ComboColumn, text );
  text = i18n( "<p>Select to use Holiday Region</p>" );
  listItem->setToolTip( Private::SelectColumn, text );
  listItem->setToolTip( Private::ComboColumn, text );
  listItem->setText( Private::RegionColumn, region->name() );
  QString toolTip = i18n( "<p><b>Region:</b> %1<br/>"
                          "<b>Language:</b> %2<br/>"
                          "<b>Description:</b> %3</p>",
                          region->name(), languageName, region->description() );
  listItem->setToolTip( Private::RegionColumn, toolTip );
  listItem->setData( Private::RegionColumn, Qt::UserRole, region->regionCode() );
  listItem->setText( Private::LanguageColumn, languageName );
  listItem->setData( Private::LanguageColumn, Qt::UserRole, region->languageCode() );
  listItem->setText( Private::DescriptionColumn, region->description() );
  listItem->setToolTip( Private::DescriptionColumn, region->description() );
  KComboBox *combo = new KComboBox();
  combo->setAutoFillBackground( true );
  QString comboText = i18n( "<p>You can choose to display the Holiday Region for information only, "
                            "or to use the Holiday Region when displaying or calculating days off "
                            "such as Public Holidays.  If you choose to use the Holiday Region for "
                            "Days Off, then only those Holiday Events marked in the Holiday Region "
                            "as Days Off will be used for non-work days, Holiday Events that are "
                            "not marked in the Holiday Region as Days Off will continue to be "
                            "work days.</p>" );
  combo->setToolTip( comboText );
  comboText = i18nc( "Combobox label, Holiday Region not used", "Not Used" );
  combo->addItem( comboText, QVariant( NotUsed ) );
  comboText = i18nc( "Combobox label, use Holiday Region for information only", "Information" );
  combo->addItem( comboText, QVariant( UseInformationOnly ) );
  comboText = i18nc( "Combobox label, use Holiday Region for days off", "Days Off" );
  combo->addItem( comboText, QVariant( UseDaysOff ) );
  combo->setCurrentIndex( 0 );
  listItem->setData( Private::ComboColumn, Qt::UserRole, NotUsed );
  m_ui.regionTreeWidget->setItemWidget( listItem, ComboColumn, combo );
  connect( combo, SIGNAL(currentIndexChanged(int)),
           q, SLOT(itemChanged(int)) );
  m_ui.regionTreeWidget->blockSignals( false );
}
コード例 #7
0
void RuleDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    const QString rule = index.data(Qt::EditRole).toString();

    if (rule.isEmpty())
    {
        return;
    }

    KLineEdit *ruleLineEdit = static_cast<KLineEdit*>(editor->layout()->itemAt(0)->widget());
    ruleLineEdit->setText(rule.mid(rule.indexOf('+', 3) + 1));

    KComboBox *matchComboBox = static_cast<KComboBox*>(editor->layout()->itemAt(1)->widget());
    matchComboBox->setCurrentIndex(rule.mid(2, (rule.indexOf('+', 3) - 2)).toInt());

    QCheckBox *requiredCheckBox = static_cast<QCheckBox*>(editor->layout()->itemAt(2)->widget());
    requiredCheckBox->setChecked(rule.at(0) == '1');
}
コード例 #8
0
void
MetaQueryWidget::makeFormatComboSelection()
{
    KComboBox* combo = new KComboBox( this );
    combo->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );
    QStringList filetypes = Amarok::FileTypeSupport::possibleFileTypes();
    for (int listpos=0;listpos<filetypes.size();listpos++)
    {
        combo->addItem(filetypes.at(listpos),listpos);
    }

    int index = m_fieldSelection->findData( (int)m_filter.numValue );
    combo->setCurrentIndex( index == -1 ? 0 : index );

    connect( combo,
             SIGNAL( currentIndexChanged(int) ),
             SLOT( numValueFormatChanged(int) ) );

    m_valueSelection1 = combo;
}
コード例 #9
0
void CharactersViewDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
{
    switch (index.column())
    {
    case 0:
    case 1:
    {
        KLineEdit* lineEdit = static_cast<KLineEdit*>(editor);
        lineEdit->setText(index.data(Qt::EditRole).toString());
        break;
    }
    case 2:
    {
        KComboBox* comboBox = static_cast<KComboBox*>(editor);
        comboBox->setCurrentIndex(index.data(Qt::EditRole).toInt());
        break;
    }
    default:
        QStyledItemDelegate::setEditorData(editor, index);
    }
}
コード例 #10
0
ファイル: ConditionalDialog.cpp プロジェクト: KDE/koffice
void ConditionalDialog::init(KCConditional const & tmp, int numCondition)
{
    kDebug() << "Adding" << numCondition;
    KComboBox * cb  = 0;
    KComboBox * sb  = 0;
    KLineEdit * kl1 = 0;
    KLineEdit * kl2 = 0;
    QString value;
    KCMap *const map = m_selection->activeSheet()->map();
    KCValueConverter *const converter = map->converter();

    switch (numCondition) {
    case 0:
        cb  = m_dlg->m_condition_1;
        sb  = m_dlg->m_style_1;
        kl1 = m_dlg->m_firstValue_1;
        kl2 = m_dlg->m_secondValue_1;
        break;
    case 1:
        cb  = m_dlg->m_condition_2;
        sb  = m_dlg->m_style_2;
        kl1 = m_dlg->m_firstValue_2;
        kl2 = m_dlg->m_secondValue_2;
        break;
    case 2:
        cb  = m_dlg->m_condition_3;
        sb  = m_dlg->m_style_3;
        kl1 = m_dlg->m_firstValue_3;
        kl2 = m_dlg->m_secondValue_3;
        break;
    default:
        return;
    }

    if (!tmp.styleName.isEmpty()) {
        sb->setCurrentIndex(sb->findText(tmp.styleName));
        sb->setEnabled(true);
    }

    switch (tmp.cond) {
    case KCConditional::None :
    case KCConditional::IsTrueFormula: // was unhandled
        break;

    case KCConditional::Equal :
        cb->setCurrentIndex(1);
        break;

    case KCConditional::Superior :
        cb->setCurrentIndex(2);
        break;

    case KCConditional::Inferior :
        cb->setCurrentIndex(3);
        break;

    case KCConditional::SuperiorEqual :
        cb->setCurrentIndex(4);
        break;

    case KCConditional::InferiorEqual :
        cb->setCurrentIndex(5);
        break;

    case KCConditional::Between :
        cb->setCurrentIndex(6);
        kl2->setText(converter->asString(tmp.value2).asString());
        break;

    case KCConditional::Different :
        cb->setCurrentIndex(7);
        kl2->setText(converter->asString(tmp.value2).asString());
        break;
    case KCConditional::DifferentTo :
        cb->setCurrentIndex(8);
        break;
    }

    if (tmp.cond != KCConditional::None) {
        kl1->setEnabled(true);
        kl1->setText(converter->asString(tmp.value1).asString());
    }
}
コード例 #11
0
ファイル: assoctab.cpp プロジェクト: Elv13/Umbrello-ng
/**
 *  Fills the list box with the objects associations.
 */
void AssocTab::fillListBox()
{
    m_List.clear();
    m_pAssocTW->clear();
    setupCols();
    m_pAssocTW->setRowCount(0);
    m_pView->getWidgetAssocs(m_pObject, m_List);
    int i = 0;
    foreach( AssociationWidget* assocwidget, m_List ) {
        if( assocwidget->associationType() != Uml::at_Anchor) {
            m_pAssocTW->setRowCount(m_pAssocTW->rowCount()+1);
            
            QTableWidgetItem* nameWidget = new QTableWidgetItem("");
            nameWidget->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
            nameWidget->setText(assocwidget->getName());
            m_pAssocTW->setItem(m_pAssocTW->rowCount()-1,0,nameWidget);
          
            /*QTableWidgetItem* newItem = new QTableWidgetItem(assocwidget->toString());
            m_pAssocTW->setItem(m_pAssocTW->rowCount()-1,1,newItem);*/
            KComboBox *typeCB = new KComboBox(this);
            m_pAssocTW->setCellWidget(m_pAssocTW->rowCount()-1,3,typeCB);
            
            Uml::Association_Type currentType =  assocwidget->associationType();
            
            int found=-1;
            QStringList assocTypeStrings;
            QList<Uml::Association_Type> assocType;
            // dynamically load all allowed associations
            for ( int i = Uml::at_Generalization; i<= Uml::at_Relationship ;  ++i ) {
                // we don't need to check for current type
                if (  ( Uml::Association_Type )i == currentType )
                    continue;

                if ( AssocRules::allowAssociation( ( Uml::Association_Type )i, assocwidget->getWidget( Uml::A ),
                                                  assocwidget->getWidget( Uml::B ))
                    ) {
                    assocType << (Uml::Association_Type)i;
                    assocTypeStrings << UMLAssociation::toString((Uml::Association_Type)i);
                    if ((Uml::Association_Type)i == currentType) 
                      found=true;
                }
            }

  
            if (found == -1) {
                assocType.insert(0, currentType);
                assocTypeStrings.insert(0,UMLAssociation::toString(currentType));
            }
            else {
              typeCB->setCurrentIndex(found);
            }
            typeCB->addItems(assocTypeStrings);
            
            QTableWidgetItem* newItem2 = new QTableWidgetItem(assocwidget->getWidget(Uml::A)->name());
            m_pAssocTW->setItem(m_pAssocTW->rowCount()-1,1,newItem2);
            
            QTableWidgetItem* newItem3 = new QTableWidgetItem(assocwidget->getWidget(Uml::B)->name());
            m_pAssocTW->setItem(m_pAssocTW->rowCount()-1,2,newItem3);
            
            QPushButton* morePb = new QPushButton(this);
            morePb->setText("Doc");
            m_pAssocTW->setCellWidget(m_pAssocTW->rowCount()-1,4,morePb);
            
            QPushButton* docPb = new QPushButton(this);
            docPb->setText("Doc");
            m_pAssocTW->setCellWidget(m_pAssocTW->rowCount()-1,5,docPb);
            
            i++;
        }
    }
}