-rw-r--r-- | libopie2/opieui/olistview.cpp | 8 | ||||
-rw-r--r-- | libopie2/opieui/opopupmenu.cpp | 4 | ||||
-rw-r--r-- | libopie2/opieui/oselector.cpp | 2 | ||||
-rw-r--r-- | libopie2/opieui/oselector.h | 4 | ||||
-rw-r--r-- | libopie2/qt3/opiecore/osortablevaluelist.h | 2 | ||||
-rw-r--r-- | libopie2/qt3/opieui/ocombobox.cpp | 6 | ||||
-rw-r--r-- | libopie2/qt3/opieui/oeditlistbox.cpp | 6 | ||||
-rw-r--r-- | libopie2/qt3/opieui/olineedit.cpp | 6 |
8 files changed, 19 insertions, 19 deletions
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp index 67b4b83..4386e0e 100644 --- a/libopie2/opieui/olistview.cpp +++ b/libopie2/opieui/olistview.cpp @@ -2,166 +2,166 @@ This file is part of the Opie Project =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* QT */ #include <qpixmap.h> /* OPIE */ #include <opie2/odebug.h> #include <opie2/olistview.h> using namespace Opie::Core; namespace Opie { namespace Ui { /*====================================================================================== * OListView *======================================================================================*/ OListView::OListView( QWidget *parent, const char *name, WFlags fl ) :QListView( parent, name, fl ) { //FIXME: get from global settings and calculate ==> see oglobalsettings.* m_alternateBackground = QColor( 238, 246, 255 ); m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); m_fullWidth = true; connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); } OListView::~OListView() { } void OListView::setFullWidth( bool fullWidth ) { m_fullWidth = fullWidth; - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 header()->setStretchEnabled( fullWidth, columns()-1 ); #endif } bool OListView::fullWidth() const { return m_fullWidth; } int OListView::addColumn( const QString& label, int width ) { int result = QListView::addColumn( label, width ); - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 if (m_fullWidth) { header()->setStretchEnabled( false, columns()-2 ); header()->setStretchEnabled( true, columns()-1 ); } #endif return result; } int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) { int result = QListView::addColumn( iconset, label, width ); - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 if (m_fullWidth) { header()->setStretchEnabled( false, columns()-2 ); header()->setStretchEnabled( true, columns()-1 ); } #endif return result; } void OListView::removeColumn( int index ) { QListView::removeColumn(index); - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 if ( m_fullWidth && index == columns() ) { header()->setStretchEnabled( true, columns()-1 ); } #endif } const QColor& OListView::alternateBackground() const { return m_alternateBackground; } void OListView::setAlternateBackground( const QColor &c ) { m_alternateBackground = c; repaint(); } const QPen& OListView::columnSeparator() const { return m_columnSeparator; } void OListView::setColumnSeparator( const QPen& p ) { m_columnSeparator = p; repaint(); } void OListView::expand(QListViewItem *item) { ((OListViewItem*)item)->expand(); } OListViewItem* OListView::childFactory() { return new OListViewItem( this ); } #ifndef QT_NO_DATASTREAM void OListView::serializeTo( QDataStream& s ) const { #warning Caution... the binary format is still under construction... odebug << "storing OListView..." << oendl; // store number of columns and the labels s << columns(); for ( int i = 0; i < columns(); ++i ) s << columnText( i ); // calculate the number of top-level items to serialize int items = 0; QListViewItem* item = firstChild(); while ( item ) { item = item->nextSibling(); items++; } // store number of items and the items itself s << items; item = firstChild(); for ( int i = 0; i < items; ++i ) { diff --git a/libopie2/opieui/opopupmenu.cpp b/libopie2/opieui/opopupmenu.cpp index 50c613f..5ce048e 100644 --- a/libopie2/opieui/opopupmenu.cpp +++ b/libopie2/opieui/opopupmenu.cpp @@ -24,129 +24,129 @@ /* QT */ #include <qdrawutil.h> #include <qtimer.h> using namespace Opie::Core; using namespace Opie::Ui; OPopupTitle::OPopupTitle(QWidget *parent, const char *name) : QWidget(parent, name) { setMinimumSize(16, fontMetrics().height()+8); } OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */, const QColor &/* color */, const QColor &/* textColor */, QWidget *parent, const char *name) : QWidget(parent, name) { setMinimumSize(16, fontMetrics().height()+8); } OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */, const QColor &/* textColor */, QWidget *parent, const char *name) : QWidget(parent, name) { setMinimumSize(16, fontMetrics().height()+8); } void OPopupTitle::setTitle(const QString &text, const QPixmap *icon) { titleStr = text; if (icon) miniicon = *icon; else miniicon.resize(0, 0); int w = miniicon.width()+fontMetrics().width(titleStr); int h = QMAX( fontMetrics().height(), miniicon.height() ); setMinimumSize( w+16, h+8 ); } void OPopupTitle::setText( const QString &text ) { titleStr = text; int w = miniicon.width()+fontMetrics().width(titleStr); int h = QMAX( fontMetrics().height(), miniicon.height() ); setMinimumSize( w+16, h+8 ); } void OPopupTitle::setIcon( const QPixmap &pix ) { miniicon = pix; int w = miniicon.width()+fontMetrics().width(titleStr); int h = QMAX( fontMetrics().height(), miniicon.height() ); setMinimumSize( w+16, h+8 ); } void OPopupTitle::paintEvent(QPaintEvent *) { QRect r(rect()); QPainter p(this); - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 qApp->style().drawPrimitive(QStyle::PE_HeaderSection, &p, r, palette().active()); #else #warning OPopupMenu is not fully functional on Qt2 #endif if (!miniicon.isNull()) p.drawPixmap(4, (r.height()-miniicon.height())/2, miniicon); if (!titleStr.isNull()) { p.setPen(palette().active().text()); QFont f = p.font(); f.setBold(true); p.setFont(f); if(!miniicon.isNull()) { p.drawText(miniicon.width()+8, 0, width()-(miniicon.width()+8), height(), AlignLeft | AlignVCenter | SingleLine, titleStr); } else { p.drawText(0, 0, width(), height(), AlignCenter | SingleLine, titleStr); } } p.setPen(palette().active().highlight()); p.drawLine(0, 0, r.right(), 0); } QSize OPopupTitle::sizeHint() const { return(minimumSize()); } class OPopupMenu::OPopupMenuPrivate { public: OPopupMenuPrivate () : noMatches(false) , shortcuts(false) , autoExec(false) , lastHitIndex(-1) , m_ctxMenu(0) {} ~OPopupMenuPrivate () { delete m_ctxMenu; } QString m_lastTitle; // variables for keyboard navigation QTimer clearTimer; bool noMatches : 1; bool shortcuts : 1; bool autoExec : 1; QString keySeq; QString originalText; @@ -488,113 +488,113 @@ void OPopupMenu::cancelContextMenuShow() OPopupMenuPrivate::s_continueCtxMenuShow = false; } int OPopupMenu::contextMenuFocusItem() { return OPopupMenuPrivate::s_highlightedItem; } OPopupMenu* OPopupMenu::contextMenuFocus() { return OPopupMenuPrivate::s_contextedMenu; } void OPopupMenu::itemHighlighted(int /* whichItem */) { if (!d->m_ctxMenu || !d->m_ctxMenu->isVisible()) { return; } d->m_ctxMenu->hide(); showCtxMenu(mapFromGlobal(QCursor::pos())); } void OPopupMenu::showCtxMenu(QPoint pos) { OPopupMenuPrivate::s_highlightedItem = idAt(pos); if (OPopupMenuPrivate::s_highlightedItem == -1) { OPopupMenuPrivate::s_contextedMenu = 0; return; } emit aboutToShowContextMenu(this, OPopupMenuPrivate::s_highlightedItem, d->m_ctxMenu); if (!OPopupMenuPrivate::s_continueCtxMenuShow) { OPopupMenuPrivate::s_continueCtxMenuShow = true; return; } OPopupMenuPrivate::s_contextedMenu = this; d->m_ctxMenu->popup(this->mapToGlobal(pos)); connect(this, SIGNAL(highlighted(int)), this, SLOT(itemHighlighted(int))); } void OPopupMenu::ctxMenuHiding() { disconnect(this, SIGNAL(highlighted(int)), this, SLOT(itemHighlighted(int))); OPopupMenuPrivate::s_continueCtxMenuShow = true; } bool OPopupMenu::eventFilter(QObject* obj, QEvent* event) { if (d->m_ctxMenu && obj == this) { if (event->type() == QEvent::MouseButtonRelease) { if (d->m_ctxMenu->isVisible()) { return true; } } - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 else if (event->type() == QEvent::ContextMenu) #else else if ( (event->type() == QEvent::MouseButtonPress) && ( (QMouseEvent*) event )->button() == QMouseEvent::RightButton ) #endif { showCtxMenu(mapFromGlobal(QCursor::pos())); return true; } } return QWidget::eventFilter(obj, event); } void OPopupMenu::hideEvent(QHideEvent*) { if (d->m_ctxMenu) { d->m_ctxMenu->hide(); } } /** * end of RMB menus on menus support */ // Obsolete OPopupMenu::OPopupMenu(const QString& title, QWidget *parent, const char *name) : QPopupMenu(parent, name) { d = new OPopupMenuPrivate; setTitle(title); } // Obsolete void OPopupMenu::setTitle(const QString &title) { OPopupTitle *titleItem = new OPopupTitle(); titleItem->setTitle(title); insertItem(titleItem); d->m_lastTitle = title; } void OPopupTitle::virtual_hook( int, void* ) { /*BASE::virtual_hook( id, data );*/ } void OPopupMenu::virtual_hook( int, void* ) { /*BASE::virtual_hook( id, data );*/ } diff --git a/libopie2/opieui/oselector.cpp b/libopie2/opieui/oselector.cpp index 05543c5..936dfe6 100644 --- a/libopie2/opieui/oselector.cpp +++ b/libopie2/opieui/oselector.cpp @@ -78,129 +78,129 @@ void OXYSelector::setValues( int _xPos, int _yPos ) if ( yPos > maxY ) yPos = maxY; else if ( yPos < minY ) yPos = minY; int xp = 2 + (width() - 4) * xPos / (maxX - minX); int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY); setPosition( xp, yp ); } QRect OXYSelector::contentsRect() const { return QRect( 2, 2, width()-4, height()-4 ); } void OXYSelector::paintEvent( QPaintEvent *ev ) { QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2); QRect paintRect = ev->rect(); QPainter painter; painter.begin( this ); QBrush brush; qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(), TRUE, 2, &brush ); drawContents( &painter ); if (paintRect.contains(cursorRect)) { bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W, STORE_W2, STORE_W2, CopyROP ); drawCursor( &painter, px, py ); } else if (paintRect.intersects(cursorRect)) { repaint( cursorRect, false); } painter.end(); } void OXYSelector::mousePressEvent( QMouseEvent *e ) { int xVal, yVal; valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); setValues( xVal, yVal ); emit valueChanged( xPos, yPos ); } void OXYSelector::mouseMoveEvent( QMouseEvent *e ) { int xVal, yVal; valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); setValues( xVal, yVal ); emit valueChanged( xPos, yPos ); } void OXYSelector::wheelEvent( QWheelEvent *e ) { - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 if ( e->orientation() == Qt::Horizontal ) setValues( xValue() + e->delta()/120, yValue() ); else setValues( xValue(), yValue() + e->delta()/120 ); emit valueChanged( xPos, yPos ); #else Q_UNUSED( e ) #endif } void OXYSelector::valuesFromPosition( int x, int y, int &xVal, int &yVal ) const { xVal = ( (maxX-minX) * (x-2) ) / ( width()-4 ); yVal = maxY - ( ( (maxY-minY) * (y-2) ) / ( height()-4 ) ); if ( xVal > maxX ) xVal = maxX; else if ( xVal < minX ) xVal = minX; if ( yVal > maxY ) yVal = maxY; else if ( yVal < minY ) yVal = minY; } void OXYSelector::setPosition( int xp, int yp ) { if ( xp < 2 ) xp = 2; else if ( xp > width() - 2 ) xp = width() - 2; if ( yp < 2 ) yp = 2; else if ( yp > height() - 2 ) yp = height() - 2; QPainter painter; painter.begin( this ); bitBlt( this, px - STORE_W, py - STORE_W, &store, 0, 0, STORE_W2, STORE_W2, CopyROP ); bitBlt( &store, 0, 0, this, xp - STORE_W, yp - STORE_W, STORE_W2, STORE_W2, CopyROP ); drawCursor( &painter, xp, yp ); px = xp; py = yp; painter.end(); } void OXYSelector::drawContents( QPainter * ) {} void OXYSelector::drawCursor( QPainter *p, int xp, int yp ) { p->setPen( QPen( white ) ); p->drawLine( xp - 6, yp - 6, xp - 2, yp - 2 ); p->drawLine( xp - 6, yp + 6, xp - 2, yp + 2 ); p->drawLine( xp + 6, yp - 6, xp + 2, yp - 2 ); diff --git a/libopie2/opieui/oselector.h b/libopie2/opieui/oselector.h index fe75a46..3dbdb38 100644 --- a/libopie2/opieui/oselector.h +++ b/libopie2/opieui/oselector.h @@ -147,144 +147,144 @@ private: * * A custom drawing routine for the widget surface has * to be provided by the subclass. */ class OSelector : public QWidget, public QRangeControl { Q_OBJECT Q_PROPERTY( int value READ value WRITE setValue ) Q_PROPERTY( int minValue READ minValue WRITE setMinValue ) Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue ) public: /** * Constructs a horizontal one-dimensional selection widget. */ OSelector( QWidget *parent=0, const char *name=0 ); /** * Constructs a one-dimensional selection widget with * a given orientation. */ OSelector( Orientation o, QWidget *parent = 0L, const char *name = 0L ); /* * Destructs the widget. */ ~OSelector(); /** * @return the orientation of the widget. */ Orientation orientation() const { return _orientation; } /** * @return the rectangle on which subclasses should draw. */ QRect contentsRect() const; /** * Sets the indent option of the widget to i. * This determines whether a shaded frame is drawn. */ void setIndent( bool i ) { _indent = i; } /** * @return whether the indent option is set. */ bool indent() const { return _indent; } /** * Sets the value. */ void setValue(int value) { QRangeControl::setValue(value); } /** * @returns the value. */ int value() const { return QRangeControl::value(); } /** * Sets the min value. */ - #if ( QT_VERSION > 290 ) + #if ( QT_VERSION >= 0x030000 ) void setMinValue(int value) { QRangeControl::setMinValue(value); } #else void setMinValue(int value) { QRangeControl::setRange(value,QRangeControl::maxValue()); } #endif /** * @return the min value. */ int minValue() const { return QRangeControl::minValue(); } /** * Sets the max value. */ - #if ( QT_VERSION > 290 ) + #if ( QT_VERSION >= 0x030000 ) void setMaxValue(int value) { QRangeControl::setMaxValue(value); } #else void setMaxValue(int value) { QRangeControl::setRange(QRangeControl::minValue(),value); } #endif /** * @return the max value. */ int maxValue() const { return QRangeControl::maxValue(); } signals: /** * This signal is emitted whenever the user chooses a value, * e.g. by clicking with the mouse on the widget. */ void valueChanged( int value ); protected: /** * Override this function to draw the contents of the control. * The default implementation does nothing. * * Draw only within contentsRect(). */ virtual void drawContents( QPainter * ); /** * Override this function to draw the cursor which * indicates the current value. This function is * always called twice, once with argument show=false * to clear the old cursor, once with argument show=true * to draw the new one. */ virtual void drawArrow( QPainter *painter, bool show, const QPoint &pos ); /** * @reimplemented */ virtual void valueChange(); /** * @reimplemented */ virtual void paintEvent( QPaintEvent * ); /** * @reimplemented */ virtual void mousePressEvent( QMouseEvent *e ); /** * @reimplemented */ virtual void mouseMoveEvent( QMouseEvent *e ); /** * @reimplemented */ virtual void wheelEvent( QWheelEvent * ); private: QPoint calcArrowPos( int val ); void moveArrow( const QPoint &pos ); Orientation _orientation; bool _indent; private: diff --git a/libopie2/qt3/opiecore/osortablevaluelist.h b/libopie2/qt3/opiecore/osortablevaluelist.h index f66cf25..a3f75b4 100644 --- a/libopie2/qt3/opiecore/osortablevaluelist.h +++ b/libopie2/qt3/opiecore/osortablevaluelist.h @@ -1,98 +1,98 @@ /* This file is part of the Opie Project Originally a part of the KDE Project (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OSORTABLEVALUELIST_H #define OSORTABLEVALUELIST_H -#if QT_VERSION > 290 +#if QT_VERSION >= 0x030000 #include <qtl.h> #include <qpair.h> #else #include <opie2/otl.h> #include <opie2/opair.h> #endif #include <qvaluelist.h> template<class T, class Key = int> class OSortableItem : public QPair<Key,T> { public: OSortableItem( Key i, const T& t ) : QPair<Key, T>( i, t ) {} OSortableItem( const OSortableItem<T, Key> &rhs ) : QPair<Key,T>( rhs.first, rhs.second ) {} OSortableItem() {} OSortableItem<T, Key> &operator=( const OSortableItem<T, Key>& i ) { first = i.first; second = i.second; return *this; } // operators for sorting bool operator> ( const OSortableItem<T, Key>& i2 ) const { return (i2.first < first); } bool operator< ( const OSortableItem<T, Key>& i2 ) const { return (first < i2.first); } bool operator>= ( const OSortableItem<T, Key>& i2 ) const { return (first >= i2.first); } bool operator<= ( const OSortableItem<T, Key>& i2 ) const { return !(i2.first < first); } bool operator== ( const OSortableItem<T, Key>& i2 ) const { return (first == i2.first); } bool operator!= ( const OSortableItem<T, Key>& i2 ) const { return (first != i2.first); } T& value() { return second; } const T& value() const { return second; } Key index() const { return first; } }; // convenience template <class T, class Key = int> class OSortableValueList : public QValueList<OSortableItem<T, Key> > { public: void insert( Key i, const T& t ) { QValueList<OSortableItem<T, Key> >::append( OSortableItem<T, Key>( i, t ) ); } diff --git a/libopie2/qt3/opieui/ocombobox.cpp b/libopie2/qt3/opieui/ocombobox.cpp index bd330e0..130112c 100644 --- a/libopie2/qt3/opieui/ocombobox.cpp +++ b/libopie2/qt3/opieui/ocombobox.cpp @@ -257,176 +257,176 @@ bool OComboBox::eventFilter( QObject* o, QEvent* ev ) 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 + #if QT_VERSION >= 0x030000 QComboBox::setLineEdit( 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 QT_VERSION >= 0x030000 if ( lineEdit()->hasSelectedText() ) #else if ( lineEdit()->hasMarkedText() ) #endif { lineEdit()->del(); } } void OComboBox::deleteWordBack() { lineEdit()->cursorWordBackward(TRUE); - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 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 ); } void OHistoryCombo::init( bool useCompletion ) { if ( useCompletion ) completionObject()->setOrder( OCompletion::Weighted ); setInsertionPolicy( NoInsertion ); myIterateIndex = -1; myRotated = false; myPixProvider = 0L; diff --git a/libopie2/qt3/opieui/oeditlistbox.cpp b/libopie2/qt3/opieui/oeditlistbox.cpp index 0e95274..dcc697d 100644 --- a/libopie2/qt3/opieui/oeditlistbox.cpp +++ b/libopie2/qt3/opieui/oeditlistbox.cpp @@ -131,237 +131,237 @@ void OEditListBox::init( bool checkAtEntering, int buttons, connect(servNewButton, SIGNAL(clicked()), SLOT(addItem())); grid->addWidget(servNewButton, row++, 1); } if ( buttons & Remove ) { servRemoveButton = new QPushButton(tr("&Remove"), gb); servRemoveButton->setEnabled(false); connect(servRemoveButton, SIGNAL(clicked()), SLOT(removeItem())); grid->addWidget(servRemoveButton, row++, 1); } if ( buttons & UpDown ) { servUpButton = new QPushButton(tr("Move &Up"), gb); servUpButton->setEnabled(false); connect(servUpButton, SIGNAL(clicked()), SLOT(moveItemUp())); servDownButton = new QPushButton(tr("Move &Down"), gb); servDownButton->setEnabled(false); connect(servDownButton, SIGNAL(clicked()), SLOT(moveItemDown())); grid->addWidget(servUpButton, row++, 1); grid->addWidget(servDownButton, row++, 1); } connect(m_lineEdit,SIGNAL(textChanged(const QString&)),this,SLOT(typedSomething(const QString&))); m_lineEdit->setTrapReturnKey(true); connect(m_lineEdit,SIGNAL(returnPressed()),this,SLOT(addItem())); connect(m_listBox, SIGNAL(highlighted(int)), SLOT(enableMoveButtons(int))); // maybe supplied lineedit has some text already typedSomething( m_lineEdit->text() ); } void OEditListBox::typedSomething(const QString& text) { if(currentItem() >= 0) { if(currentText() != m_lineEdit->text()) { // IMHO changeItem() shouldn't do anything with the value // of currentItem() ... like changing it or emitting signals ... // but TT disagree with me on this one (it's been that way since ages ... grrr) bool block = m_listBox->signalsBlocked(); m_listBox->blockSignals( true ); m_listBox->changeItem(text, currentItem()); m_listBox->blockSignals( block ); emit changed(); } } if ( !servNewButton ) return; if (!d->m_checkAtEntering) servNewButton->setEnabled(!text.isEmpty()); else { if (text.isEmpty()) { servNewButton->setEnabled(false); } else { - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 StringComparisonMode mode = (StringComparisonMode) (ExactMatch | CaseSensitive ); bool enable = (m_listBox->findItem( text, mode ) == 0L); #else bool enable = (m_listBox->findItem( text ) == 0L); #endif servNewButton->setEnabled( enable ); } } } void OEditListBox::moveItemUp() { if (!m_listBox->isEnabled()) { //ONotifyClient::beep(); return; } unsigned int selIndex = m_listBox->currentItem(); if (selIndex == 0) { //ONotifyClient::beep(); return; } QListBoxItem *selItem = m_listBox->item(selIndex); m_listBox->takeItem(selItem); m_listBox->insertItem(selItem, selIndex-1); m_listBox->setCurrentItem(selIndex - 1); emit changed(); } void OEditListBox::moveItemDown() { if (!m_listBox->isEnabled()) { //ONotifyClient::beep(); return; } unsigned int selIndex = m_listBox->currentItem(); if (selIndex == m_listBox->count() - 1) { //ONotifyClient::beep(); return; } QListBoxItem *selItem = m_listBox->item(selIndex); m_listBox->takeItem(selItem); m_listBox->insertItem(selItem, selIndex+1); m_listBox->setCurrentItem(selIndex + 1); emit changed(); } void OEditListBox::addItem() { // when m_checkAtEntering is true, the add-button is disabled, but this // slot can still be called through Key_Return/Key_Enter. So we guard // against this. if ( !servNewButton || !servNewButton->isEnabled() ) return; const QString& currentTextLE=m_lineEdit->text(); bool alreadyInList(false); //if we didn't check for dupes at the inserting we have to do it now if (!d->m_checkAtEntering) { // first check current item instead of dumb iterating the entire list if ( m_listBox->currentText() == currentTextLE ) alreadyInList = true; else { - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 StringComparisonMode mode = (StringComparisonMode) (ExactMatch | CaseSensitive ); alreadyInList =(m_listBox->findItem(currentTextLE, mode) != 0); #else alreadyInList =(m_listBox->findItem(currentTextLE) != 0); #endif } } if ( servNewButton ) servNewButton->setEnabled(false); bool block = m_lineEdit->signalsBlocked(); m_lineEdit->blockSignals(true); m_lineEdit->clear(); m_lineEdit->blockSignals(block); m_listBox->setSelected(currentItem(), false); if (!alreadyInList) { block = m_listBox->signalsBlocked(); m_listBox->blockSignals( true ); m_listBox->insertItem(currentTextLE); m_listBox->blockSignals( block ); emit changed(); emit added( currentTextLE ); } } int OEditListBox::currentItem() const { int nr = m_listBox->currentItem(); - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 if(nr >= 0 && !m_listBox->item(nr)->isSelected()) return -1; #else if(nr >= 0 && !m_listBox->isSelected(m_listBox->item(nr))) return -1; #endif return nr; } void OEditListBox::removeItem() { int selected = m_listBox->currentItem(); if ( selected >= 0 ) { QString removedText = m_listBox->currentText(); 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() diff --git a/libopie2/qt3/opieui/olineedit.cpp b/libopie2/qt3/opieui/olineedit.cpp index 6f66fc7..b150987 100644 --- a/libopie2/qt3/opieui/olineedit.cpp +++ b/libopie2/qt3/opieui/olineedit.cpp @@ -84,255 +84,255 @@ OLineEdit::OLineEdit( QWidget *parent, const char *name ) { init(); } OLineEdit::~OLineEdit () { delete d; } void OLineEdit::init() { d = new OLineEditPrivate; possibleTripleClick = false; // Enable the context menu by default. setContextMenuEnabled( true ); //OCursor::setAutoHideCursor( this, true, true ); installEventFilter( this ); } void OLineEdit::setCompletionMode( OGlobalSettings::Completion mode ) { OGlobalSettings::Completion oldMode = completionMode(); if ( oldMode != mode && oldMode == OGlobalSettings::CompletionPopup && d->completionBox && d->completionBox->isVisible() ) d->completionBox->hide(); // If the widgets echo mode is not Normal, no completion // feature will be enabled even if one is requested. if ( echoMode() != QLineEdit::Normal ) mode = OGlobalSettings::CompletionNone; // Override the request. OCompletionBase::setCompletionMode( mode ); } void OLineEdit::setCompletedText( const QString& t, bool marked ) { QString txt = text(); if ( t != txt ) { int curpos = marked ? txt.length() : t.length(); validateAndSet( t, curpos, curpos, t.length() ); } } void OLineEdit::setCompletedText( const QString& text ) { OGlobalSettings::Completion mode = completionMode(); bool marked = ( mode == OGlobalSettings::CompletionAuto || mode == OGlobalSettings::CompletionMan || mode == OGlobalSettings::CompletionPopup ); setCompletedText( text, marked ); } void OLineEdit::rotateText( OCompletionBase::KeyBindingType type ) { OCompletion* comp = compObj(); if ( comp && (type == OCompletionBase::PrevCompletionMatch || type == OCompletionBase::NextCompletionMatch ) ) { QString input = (type == OCompletionBase::PrevCompletionMatch) ? comp->previousMatch() : comp->nextMatch(); // Skip rotation if previous/next match is null or the same text if ( input.isNull() || input == displayText() ) return; - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 setCompletedText( input, hasSelectedText() ); #else setCompletedText( input, hasMarkedText() ); #endif } } void OLineEdit::makeCompletion( const QString& text ) { OCompletion *comp = compObj(); if ( !comp ) return; // No completion object... QString match = comp->makeCompletion( text ); OGlobalSettings::Completion mode = completionMode(); if ( mode == OGlobalSettings::CompletionPopup ) { if ( match.isNull() ) { if ( d->completionBox ) { d->completionBox->hide(); d->completionBox->clear(); } } else setCompletedItems( comp->allMatches() ); } else { // all other completion modes // If no match or the same match, simply return without completing. if ( match.isNull() || match == text ) return; setCompletedText( match ); } } void OLineEdit::setReadOnly(bool readOnly) { QPalette p = palette(); if (readOnly) { QColor color = p.color(QPalette::Disabled, QColorGroup::Background); p.setColor(QColorGroup::Base, color); p.setColor(QColorGroup::Background, color); } else { QColor color = p.color(QPalette::Normal, QColorGroup::Base); p.setColor(QColorGroup::Base, color); p.setColor(QColorGroup::Background, color); } setPalette(p); QLineEdit::setReadOnly (readOnly); } void OLineEdit::keyPressEvent( QKeyEvent *e ) { qDebug( "OLineEdit::keyPressEvent()" ); /* KKey key( e ); if ( KStdAccel::copy().contains( key ) ) { copy(); return; } else if ( KStdAccel::paste().contains( key ) ) { paste(); return; } else if ( KStdAccel::cut().contains( key ) ) { cut(); return; } else if ( KStdAccel::undo().contains( key ) ) { undo(); return; } else if ( KStdAccel::redo().contains( key ) ) { redo(); return; } else if ( KStdAccel::deleteWordBack().contains( key ) ) { cursorWordBackward(TRUE); if ( hasSelectedText() ) del(); e->accept(); return; } else if ( KStdAccel::deleteWordForward().contains( key ) ) { // Workaround for QT bug where cursorWordForward(TRUE); if ( hasSelectedText() ) del(); e->accept(); return; } */ // Filter key-events if EchoMode is normal & // completion mode is not set to CompletionNone if ( echoMode() == QLineEdit::Normal && completionMode() != OGlobalSettings::CompletionNone ) { KeyBindingMap keys = getKeyBindings(); OGlobalSettings::Completion mode = completionMode(); bool noModifier = (e->state() == NoButton || e->state()== ShiftButton); if ( (mode == OGlobalSettings::CompletionAuto || mode == OGlobalSettings::CompletionMan) && noModifier ) { QString keycode = e->text(); if ( !keycode.isNull() && keycode.unicode()->isPrint() ) { QLineEdit::keyPressEvent ( e ); QString txt = text(); int len = txt.length(); - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 if ( !hasSelectedText() && len && cursorPosition() == len ) #else if ( !hasMarkedText() && len && cursorPosition() == len ) #endif { if ( emitSignals() ) emit completion( txt ); if ( handleSignals() ) makeCompletion( txt ); e->accept(); } return; } } else if ( mode == OGlobalSettings::CompletionPopup && noModifier ) { qDebug( "OLineEdit::keyPressEvent() - global settings = CompletionPopup & noModifier" ); QString old_txt = text(); QLineEdit::keyPressEvent ( e ); QString txt = text(); int len = txt.length(); QString keycode = e->text(); if ( txt != old_txt && len && cursorPosition() == len && ( (!keycode.isNull() && keycode.unicode()->isPrint()) || e->key() == Key_Backspace ) ) { if ( emitSignals() ) emit completion( txt ); // emit when requested... if ( handleSignals() ) makeCompletion( txt ); // handle when requested... e->accept(); } else if (!len && d->completionBox && d->completionBox->isVisible()) d->completionBox->hide(); return; } /*else if ( mode == OGlobalSettings::CompletionShell ) { // Handles completion. KShortcut cut; if ( keys[TextCompletion].isNull() ) cut = KStdAccel::shortcut(KStdAccel::TextCompletion); else cut = keys[TextCompletion]; if ( cut.contains( key ) ) { // Emit completion if the completion mode is CompletionShell // and the cursor is at the end of the string. QString txt = text(); int len = txt.length(); if ( cursorPosition() == len && len != 0 ) { if ( emitSignals() ) emit completion( txt ); if ( handleSignals() ) makeCompletion( txt ); return; @@ -375,129 +375,129 @@ void OLineEdit::keyPressEvent( QKeyEvent *e ) rotateText( OCompletionBase::NextCompletionMatch ); return; } } // substring completion if ( compObj() ) { KShortcut cut; if ( keys[SubstringCompletion].isNull() ) cut = KStdAccel::shortcut(KStdAccel::SubstringCompletion); else cut = keys[SubstringCompletion]; if ( cut.contains( key ) ) { if ( emitSignals() ) emit substringCompletion( text() ); if ( handleSignals() ) { setCompletedItems( compObj()->substringCompletion(text())); e->accept(); } return; } } */ } // Let QLineEdit handle any other keys events. QLineEdit::keyPressEvent ( e ); } void OLineEdit::mouseDoubleClickEvent( QMouseEvent* e ) { if ( e->button() == Qt::LeftButton ) { possibleTripleClick=true; QTimer::singleShot( QApplication::doubleClickInterval(),this, SLOT(tripleClickTimeout()) ); } QLineEdit::mouseDoubleClickEvent( e ); } void OLineEdit::mousePressEvent( QMouseEvent* e ) { if ( possibleTripleClick && e->button() == Qt::LeftButton ) { selectAll(); return; } QLineEdit::mousePressEvent( e ); } void OLineEdit::tripleClickTimeout() { possibleTripleClick=false; } QPopupMenu *OLineEdit::createPopupMenu() { // Return if popup menu is not enabled !! if ( !m_bEnableMenu ) return 0; - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 QPopupMenu *popup = QLineEdit::createPopupMenu(); #else QPopupMenu *popup = new QPopupMenu(); #warning OLineEdit is not fully functional on Qt2 #endif // completion object is present. if ( compObj() ) { QPopupMenu *subMenu = new QPopupMenu( popup ); connect( subMenu, SIGNAL( activated(int) ), this, SLOT( completionMenuActivated(int) ) ); popup->insertSeparator(); //popup->insertItem( SmallIconSet("completion"), i18n("Text Completion"), // subMenu ); popup->insertItem( tr("Text Completion"), subMenu ); subMenu->insertItem( tr("None"), NoCompletion ); subMenu->insertItem( tr("Manual"), ShellCompletion ); subMenu->insertItem( tr("Automatic"), AutoCompletion ); subMenu->insertItem( tr("Dropdown List"), PopupCompletion ); subMenu->insertItem( tr("Short Automatic"), SemiAutoCompletion ); //subMenu->setAccel( KStdAccel::completion(), ShellCompletion ); subMenu->setAccel( Key_Tab, ShellCompletion ); OGlobalSettings::Completion mode = completionMode(); subMenu->setItemChecked( NoCompletion, mode == OGlobalSettings::CompletionNone ); subMenu->setItemChecked( ShellCompletion, mode == OGlobalSettings::CompletionShell ); subMenu->setItemChecked( PopupCompletion, mode == OGlobalSettings::CompletionPopup ); subMenu->setItemChecked( AutoCompletion, mode == OGlobalSettings::CompletionAuto ); subMenu->setItemChecked( SemiAutoCompletion, mode == OGlobalSettings::CompletionMan ); if ( mode != OGlobalSettings::completionMode() ) { subMenu->insertSeparator(); subMenu->insertItem( tr("Default"), Default ); } } // ### do we really need this? Yes, Please do not remove! This // allows applications to extend the popup menu without having to // inherit from this class! (DA) emit aboutToShowContextMenu( popup ); return popup; } void OLineEdit::completionMenuActivated( int id ) { OGlobalSettings::Completion oldMode = completionMode(); switch ( id ) { case Default: setCompletionMode( OGlobalSettings::completionMode() ); break; case NoCompletion: setCompletionMode( OGlobalSettings::CompletionNone ); break; case AutoCompletion: |