Example #1
0
KFileFilterCombo::KFileFilterCombo(QWidget *parent, const char *name) : KComboBox(true, parent, name), d(new KFileFilterComboPrivate)
{
    setTrapReturnKey(true);
    setInsertionPolicy(NoInsertion);
    connect(this, SIGNAL(activated(int)), this, SIGNAL(filterChanged()));
    connect(this, SIGNAL(returnPressed()), this, SIGNAL(filterChanged()));
    connect(this, SIGNAL(filterChanged()), SLOT(slotFilterChanged()));
    m_allTypes = false;
}
KonqCombo::KonqCombo( QWidget *parent )
          : KHistoryComboBox( parent ),
            m_returnPressed( false ),
            m_permanent( false ),
	    m_pageSecurity( KonqMainWindow::NotCrypted )
{
    setLayoutDirection(Qt::LeftToRight);
    setInsertPolicy( NoInsert );
    setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ));
    setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLength );

    Q_ASSERT( s_config );

    KConfigGroup locationBarGroup( s_config, "Location Bar" );
    setMaxCount( locationBarGroup.readEntry("Maximum of URLs in combo", 20 ));

    // We should also connect the completionBox' highlighted signal to
    // our setEditText() slot, because we're handling the signals ourselves.
    // But we're lazy and let KCompletionBox do this and simply switch off
    // handling of signals later.
    setHandleSignals( true );

    KonqComboLineEdit *edit = new KonqComboLineEdit( this );
    edit->setHandleSignals( true );
    edit->setCompletionBox( new KonqComboCompletionBox( edit ) );
    setLineEdit( edit );
    setItemDelegate( new KonqComboItemDelegate( this ) );

    connect( edit, SIGNAL(textEdited(QString)),
             this, SLOT(slotTextEdited(QString)) );

    completionBox()->setTabHandling(true); // #167135
    completionBox()->setItemDelegate( new KonqComboItemDelegate( this ) );

    // Make the lineedit consume the Qt::Key_Enter event...
    setTrapReturnKey( true );

    connect( KonqHistoryManager::kself(), SIGNAL(cleared()), SLOT(slotCleared()) );
    connect( this, SIGNAL(cleared()), SLOT(slotCleared()) );
    connect( this, SIGNAL(highlighted(int)), SLOT(slotSetIcon(int)) );
    connect( this, SIGNAL(activated(QString)),
             SLOT(slotActivated(QString)) );
}