summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/qt3/opieui/ocombobox.cpp5
-rw-r--r--libopie2/qt3/opieui/oeditlistbox.cpp5
2 files changed, 7 insertions, 3 deletions
diff --git a/libopie2/qt3/opieui/ocombobox.cpp b/libopie2/qt3/opieui/ocombobox.cpp
index a1dd5f5..8dbda8f 100644
--- a/libopie2/qt3/opieui/ocombobox.cpp
+++ b/libopie2/qt3/opieui/ocombobox.cpp
@@ -227,193 +227,196 @@ bool OComboBox::eventFilter( QObject* o, QEvent* ev )
}
}
}
// wheel-scrolling changes the current item
if ( type == QEvent::Wheel ) {
if ( !listBox() || listBox()->isHidden() ) {
QWheelEvent *e = static_cast<QWheelEvent*>( ev );
static const int WHEEL_DELTA = 120;
int skipItems = e->delta() / WHEEL_DELTA;
if ( e->state() & ControlButton ) // fast skipping
skipItems *= 10;
int newItem = currentItem() - skipItems;
if ( newItem < 0 )
newItem = 0;
else if ( newItem >= count() )
newItem = count() -1;
setCurrentItem( newItem );
if ( !text( newItem ).isNull() )
emit activated( text( newItem ) );
emit activated( newItem );
e->accept();
return true;
}
}
return QComboBox::eventFilter( o, ev );
}
void OComboBox::setTrapReturnKey( bool grab )
{
m_trapReturnKey = grab;
}
bool OComboBox::trapReturnKey() const
{
return m_trapReturnKey;
}
/*
void OComboBox::setEditURL( const OURL& url )
{
QComboBox::setEditText( url.prettyURL() );
}
void OComboBox::insertURL( const OURL& url, int index )
{
QComboBox::insertItem( url.prettyURL(), index );
}
void OComboBox::insertURL( const QPixmap& pixmap, const OURL& url, int index )
{
QComboBox::insertItem( pixmap, url.prettyURL(), index );
}
void OComboBox::changeURL( const OURL& url, int index )
{
QComboBox::changeItem( url.prettyURL(), index );
}
void OComboBox::changeURL( const QPixmap& pixmap, const OURL& url, int index )
{
QComboBox::changeItem( pixmap, url.prettyURL(), index );
}
*/
void OComboBox::setCompletedItems( const QStringList& items )
{
if ( d->olineEdit )
d->olineEdit->setCompletedItems( items );
}
OCompletionBox * OComboBox::completionBox( bool create )
{
if ( d->olineEdit )
return d->olineEdit->completionBox( create );
return 0;
}
// QWidget::create() turns off mouse-Tracking which would break auto-hiding
void OComboBox::create( WId id, bool initializeWindow, bool destroyOldWindow )
{
QComboBox::create( id, initializeWindow, destroyOldWindow );
//OCursor::setAutoHideCursor( lineEdit(), true, true );
}
void OComboBox::setLineEdit( OLineEdit *edit )
{
#if QT_VERSION > 290
QComboBox::setLineEdit( edit );
- d->olineEdit = dynamic_cast<OLineEdit*>( edit );
+ if ( !edit->inherits( "OLineEdit" ) )
+ d->olineEdit = 0;
+ else
+ d->olineEdit = static_cast<OLineEdit*>( edit );
setDelegate( d->olineEdit );
// forward some signals. We only emit returnPressed() ourselves.
if ( d->olineEdit ) {
connect( d->olineEdit, SIGNAL( completion( const QString& )),
SIGNAL( completion( const QString& )) );
connect( d->olineEdit, SIGNAL( substringCompletion( const QString& )),
SIGNAL( substringCompletion( const QString& )) );
connect( d->olineEdit,
SIGNAL( textRotation( OCompletionBase::KeyBindingType )),
SIGNAL( textRotation( OCompletionBase::KeyBindingType )) );
connect( d->olineEdit,
SIGNAL( completionModeChanged( OGlobalSettings::Completion )),
SIGNAL( completionModeChanged( OGlobalSettings::Completion)));
connect( d->olineEdit,
SIGNAL( aboutToShowContextMenu( QPopupMenu * )),
SIGNAL( aboutToShowContextMenu( QPopupMenu * )) );
}
#else
#warning OComboBox is not fully functional with Qt2
#endif
}
// Temporary functions until QT3 appears. - Seth Chaiklin 20 may 2001
void OComboBox::deleteWordForward()
{
lineEdit()->cursorWordForward(TRUE);
#if QT_VERSION > 290
if ( lineEdit()->hasSelectedText() )
#else
if ( lineEdit()->hasMarkedText() )
#endif
{
lineEdit()->del();
}
}
void OComboBox::deleteWordBack()
{
lineEdit()->cursorWordBackward(TRUE);
#if QT_VERSION > 290
if ( lineEdit()->hasSelectedText() )
#else
if ( lineEdit()->hasMarkedText() )
#endif
{
lineEdit()->del();
}
}
void OComboBox::setCurrentItem( const QString& item, bool insert, int index )
{
int sel = -1;
for (int i = 0; i < count(); ++i)
if (text(i) == item)
{
sel = i;
break;
}
if (sel == -1 && insert)
{
insertItem(item, index);
if (index >= 0)
sel = index;
else
sel = count() - 1;
}
setCurrentItem(sel);
}
void OComboBox::setCurrentItem(int index)
{
QComboBox::setCurrentItem(index);
}
/*======================================================================================
* OHistoryCombo
*======================================================================================*/
// we are always read-write
OHistoryCombo::OHistoryCombo( QWidget *parent, const char *name )
: OComboBox( true, parent, name )
{
init( true ); // using completion
}
// we are always read-write
OHistoryCombo::OHistoryCombo( bool useCompletion,
QWidget *parent, const char *name )
: OComboBox( true, parent, name )
{
init( useCompletion );
}
diff --git a/libopie2/qt3/opieui/oeditlistbox.cpp b/libopie2/qt3/opieui/oeditlistbox.cpp
index 3c53552..0e95274 100644
--- a/libopie2/qt3/opieui/oeditlistbox.cpp
+++ b/libopie2/qt3/opieui/oeditlistbox.cpp
@@ -318,99 +318,100 @@ void OEditListBox::removeItem()
m_listBox->removeItem( selected );
if ( count() > 0 )
m_listBox->setSelected( QMIN( selected, count() - 1 ), true );
emit changed();
emit removed( removedText );
}
if ( servRemoveButton && m_listBox->currentItem() == -1 )
servRemoveButton->setEnabled(false);
}
void OEditListBox::enableMoveButtons(int index)
{
// Update the lineEdit when we select a different line.
if(currentText() != m_lineEdit->text())
m_lineEdit->setText(currentText());
bool moveEnabled = servUpButton && servDownButton;
if (moveEnabled )
{
if (m_listBox->count() <= 1)
{
servUpButton->setEnabled(false);
servDownButton->setEnabled(false);
}
else if ((uint) index == (m_listBox->count() - 1))
{
servUpButton->setEnabled(true);
servDownButton->setEnabled(false);
}
else if (index == 0)
{
servUpButton->setEnabled(false);
servDownButton->setEnabled(true);
}
else
{
servUpButton->setEnabled(true);
servDownButton->setEnabled(true);
}
}
if ( servRemoveButton )
servRemoveButton->setEnabled(true);
}
void OEditListBox::clear()
{
m_lineEdit->clear();
m_listBox->clear();
emit changed();
}
void OEditListBox::insertStringList(const QStringList& list, int index)
{
m_listBox->insertStringList(list,index);
}
void OEditListBox::insertStrList(const QStrList* list, int index)
{
m_listBox->insertStrList(list,index);
}
void OEditListBox::insertStrList(const QStrList& list, int index)
{
m_listBox->insertStrList(list,index);
}
void OEditListBox::insertStrList(const char ** list, int numStrings, int index)
{
m_listBox->insertStrList(list,numStrings,index);
}
QStringList OEditListBox::items() const
{
QStringList list;
for ( uint i = 0; i < m_listBox->count(); i++ )
list.append( m_listBox->text( i ));
return list;
}
void OEditListBox::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }
/*======================================================================================
* CustomEditor
*======================================================================================*/
OEditListBox::CustomEditor::CustomEditor( OComboBox *combo )
{
m_representationWidget = combo;
- m_lineEdit = dynamic_cast<OLineEdit*>( combo->lineEdit() );
- assert( m_lineEdit );
+ assert( combo->lineEdit()->inherits( "OLineEdit" ) );
+ m_lineEdit = static_cast<OLineEdit*>( combo->lineEdit() );
+
}