예제 #1
0
void
MetaQueryWidget::makeGenericComboSelection( bool editable, Collections::QueryMaker* populateQuery )
{
    KComboBox* combo = new KComboBox( this );
    combo->setEditable( editable );

    if( populateQuery != 0 )
    {
        m_runningQueries.insert(populateQuery, QWeakPointer<KComboBox>(combo));
        connect( populateQuery, SIGNAL(newResultReady(QStringList)),
                SLOT(populateComboBox(QStringList)) );
        connect( populateQuery, SIGNAL(queryDone()),
                SLOT(comboBoxPopulated()) );

        populateQuery->run();
    }
    combo->setEditText( m_filter.value );

    connect( combo, SIGNAL(editTextChanged( const QString& ) ),
            SLOT(valueChanged(const QString&)) );

    combo->completionObject()->setIgnoreCase( true );
    combo->setCompletionMode( KGlobalSettings::CompletionPopup );
    combo->setInsertPolicy( QComboBox::InsertAtTop );
    m_valueSelection1 = combo;
}
 EnvironmentSelectionWidgetPrivate( EnvironmentSelectionWidget* _owner )
     : comboBox( new KComboBox( _owner ) )
     , model( new EnvironmentSelectionModel( _owner ) )
     , owner( _owner )
 {
     comboBox->setModel( model );
     comboBox->setEditable( false );
 }
예제 #3
0
QWidget* CharactersViewDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    switch (index.column())
    {
    case 0:
    {
        KLineEdit* lineEdit = new KLineEdit(parent);

        lineEdit->setFrame(false);
        lineEdit->setMaxLength(1);
        return lineEdit;
    }
    case 1:
    {
        KLineEdit* lineEdit = new KLineEdit(parent);

        lineEdit->setFrame(false);

        QStringList wordList;

        for (int i = 0; i < m_keyboardLayout->keyCount(); i++)
        {
            if (SpecialKey* key = qobject_cast<SpecialKey*>(m_keyboardLayout->key(i)))
            {
                wordList << key->modifierId();
            }
        }

        QCompleter* completer = new QCompleter(wordList, lineEdit);
        lineEdit->setCompleter(completer);

        return lineEdit;
    }
    case 2:
    {
        KComboBox* comboBox = new KComboBox(parent);

        comboBox->setEditable(false);
        comboBox->addItem(i18n("Hidden"), KeyChar::Hidden);
        comboBox->addItem(i18n("Top left"), KeyChar::TopLeft);
        comboBox->addItem(i18n("Top right"), KeyChar::TopRight);
        comboBox->addItem(i18n("Bottom left"), KeyChar::BottomLeft);
        comboBox->addItem(i18n("Bottom right"), KeyChar::BottomRight);

        return comboBox;
    }
    default:
        return QStyledItemDelegate::createEditor(parent, option, index);
    }
}
예제 #4
0
QWidget * IngredientNameDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */,
	const QModelIndex & index ) const
{
	//Set up the combo box
	KComboBox * editor = new KComboBox( parent );
	editor->setAutoFillBackground( true );
	editor->setEditable( true );
	editor->setCompletionMode( KGlobalSettings::CompletionPopup );

	//Set the models and the completion objects
	if ( !index.data(IngredientsEditor::IsHeaderRole).toBool() ) {
		editor->setModel( m_database->allIngredientsModels()->ingredientNameModel() );
		editor->setCompletionObject(
			m_database->allIngredientsModels()->ingredientNameCompletion() );
	} else {
		editor->setModel( m_database->allIngHeadersModels()->ingHeaderNameModel() );
		editor->setCompletionObject(
			m_database->allIngHeadersModels()->ingHeaderNameCompletion() );
	}

	return editor;
}
예제 #5
0
KComboBoxTest::KComboBoxTest(TQWidget* widget, const char* name )
              :TQWidget(widget, name)
{
  TQVBoxLayout *vbox = new TQVBoxLayout (this, KDialog::marginHint(), KDialog::spacingHint());
  
  // Test for KCombo's KLineEdit destruction
  KComboBox *testCombo = new KComboBox( true, this ); // rw, with KLineEdit
  testCombo->setEditable( false ); // destroys our KLineEdit
  assert( testCombo->delegate() == 0L );
  delete testCombo; // not needed anymore  
  
  // Qt combobox
  TQHBox* hbox = new TQHBox(this);
  hbox->setSpacing (KDialog::spacingHint());
  TQLabel* lbl = new TQLabel("&QCombobox:", hbox);
  lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);
  
  m_qc = new TQComboBox(hbox, "QtReadOnlyCombo" );
  lbl->setBuddy (m_qc);  
  TQObject::connect (m_qc, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
  TQObject::connect (m_qc, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT (slotActivated(const TQString&)));
  vbox->addWidget (hbox);
  
  // Read-only combobox
  hbox = new TQHBox(this);
  hbox->setSpacing (KDialog::spacingHint());
  lbl = new TQLabel("&Read-Only Combo:", hbox);
  lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);

  m_ro = new KComboBox(hbox, "ReadOnlyCombo" );
  lbl->setBuddy (m_ro);
  m_ro->setCompletionMode( TDEGlobalSettings::CompletionAuto );
  TQObject::connect (m_ro, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
  TQObject::connect (m_ro, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT (slotActivated(const TQString&)));
  vbox->addWidget (hbox);

  // Read-write combobox
  hbox = new TQHBox(this);
  hbox->setSpacing (KDialog::spacingHint());
  lbl = new TQLabel("&Editable Combo:", hbox);
  lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);

  m_rw = new KComboBox( true, hbox, "ReadWriteCombo" );
  lbl->setBuddy (m_rw);
  m_rw->setDuplicatesEnabled( true );
  m_rw->setInsertionPolicy( TQComboBox::NoInsertion );
  m_rw->setTrapReturnKey( true );
  TQObject::connect (m_rw, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
  TQObject::connect (m_rw, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT(slotActivated(const TQString&)));
  TQObject::connect (m_rw, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed()));
  TQObject::connect (m_rw, TQT_SIGNAL(returnPressed(const TQString&)), TQT_SLOT(slotReturnPressed(const TQString&)));
  vbox->addWidget (hbox);

  // History combobox...
  hbox = new TQHBox(this);
  hbox->setSpacing (KDialog::spacingHint());
  lbl = new TQLabel("&History Combo:", hbox);
  lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);

  m_hc = new KHistoryCombo( true, hbox, "HistoryCombo" );
  lbl->setBuddy (m_hc);
  m_hc->setDuplicatesEnabled( true );
  m_hc->setInsertionPolicy( TQComboBox::NoInsertion );
  TQObject::connect (m_hc, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
  TQObject::connect (m_hc, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT(slotActivated(const TQString&)));
  TQObject::connect (m_hc, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed()));  
  vbox->addWidget (hbox);
  m_hc->setTrapReturnKey(true);

  // Read-write combobox that is a replica of code in konqueror...
  hbox = new TQHBox(this);
  hbox->setSpacing (KDialog::spacingHint());
  lbl = new TQLabel( "&Konq's Combo:", hbox);
  lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);

  m_konqc = new KComboBox( true, hbox, "KonqyCombo" );
  lbl->setBuddy (m_konqc);
  m_konqc->setMaxCount( 10 );
  TQObject::connect (m_konqc, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
  TQObject::connect (m_konqc, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT (slotActivated(const TQString&)));
  TQObject::connect (m_konqc, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed()));
  vbox->addWidget (hbox);

  // Create an exit button
  hbox = new TQHBox (this);
  m_btnExit = new TQPushButton( "E&xit", hbox );
  TQObject::connect( m_btnExit, TQT_SIGNAL(clicked()), TQT_SLOT(quitApp()) );

  // Create a disable button...
  m_btnEnable = new TQPushButton( "Disa&ble", hbox );
  TQObject::connect (m_btnEnable, TQT_SIGNAL(clicked()), TQT_SLOT(slotDisable()));

  vbox->addWidget (hbox);

  // Popuplate the select-only list box
  TQStringList list;
  list << "Stone" << "Tree" << "Peables" << "Ocean" << "Sand" << "Chips"
       << "Computer" << "Mankind";
  list.sort();
  
  // Setup the qcombobox
  m_qc->insertStringList (list);
  
  // Setup read-only combo
  m_ro->insertStringList( list );
  m_ro->completionObject()->setItems( list );

  // Setup read-write combo
  m_rw->insertStringList( list );
  m_rw->completionObject()->setItems( list );

  // Setup read-write combo
  m_hc->insertStringList( list );
  m_hc->completionObject()->setItems( list );

  // Setup konq's combobox
  KSimpleConfig historyConfig( "konq_history" );
  historyConfig.setGroup( "Location Bar" );
  TDECompletion * s_pCompletion = new TDECompletion;
  s_pCompletion->setOrder( TDECompletion::Weighted );
  s_pCompletion->setItems( historyConfig.readListEntry( "ComboContents" ) );
  s_pCompletion->setCompletionMode( TDEGlobalSettings::completionMode() );
  m_konqc->setCompletionObject( s_pCompletion );

  TQPixmap pix = SmallIcon("www");
  m_konqc->insertItem( pix, "http://www.kde.org" );
  m_konqc->setCurrentItem( m_konqc->count()-1 );

  m_timer = new TQTimer (this);
  connect (m_timer, TQT_SIGNAL (timeout()), TQT_SLOT (slotTimeout()));
}