-rw-r--r-- | libopie2/qt3/opieui/ocombobox.cpp | 20 | ||||
-rw-r--r-- | libopie2/qt3/opieui/ocompletionbox.cpp | 10 | ||||
-rw-r--r-- | libopie2/qt3/opieui/ojanuswidget.cpp | 10 | ||||
-rw-r--r-- | libopie2/qt3/opieui/olineedit.cpp | 24 |
4 files changed, 32 insertions, 32 deletions
diff --git a/libopie2/qt3/opieui/ocombobox.cpp b/libopie2/qt3/opieui/ocombobox.cpp index 8dbda8f..bd330e0 100644 --- a/libopie2/qt3/opieui/ocombobox.cpp +++ b/libopie2/qt3/opieui/ocombobox.cpp @@ -283,110 +283,110 @@ 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 ); 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( 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 )) ); + SIGNAL( textRotation(OCompletionBase::KeyBindingType)), + SIGNAL( textRotation(OCompletionBase::KeyBindingType)) ); connect( d->olineEdit, - SIGNAL( completionModeChanged( OGlobalSettings::Completion )), - SIGNAL( completionModeChanged( OGlobalSettings::Completion))); + SIGNAL( completionModeChanged(OGlobalSettings::Completion)), + SIGNAL( completionModeChanged(OGlobalSettings::Completion))); connect( d->olineEdit, - SIGNAL( aboutToShowContextMenu( QPopupMenu * )), - SIGNAL( aboutToShowContextMenu( QPopupMenu * )) ); + 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 diff --git a/libopie2/qt3/opieui/ocompletionbox.cpp b/libopie2/qt3/opieui/ocompletionbox.cpp index b594b8e..b36123e 100644 --- a/libopie2/qt3/opieui/ocompletionbox.cpp +++ b/libopie2/qt3/opieui/ocompletionbox.cpp @@ -22,104 +22,104 @@ ++= -. .` .: 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. */ #include <qapplication.h> #include <qevent.h> #include <qstyle.h> #include <opie2/ocompletionbox.h> #define OListBox QListBox class OCompletionBox::OCompletionBoxPrivate { public: QWidget *m_parent; // necessary to set the focus back QString cancelText; bool tabHandling; bool down_workaround; }; OCompletionBox::OCompletionBox( QWidget *parent, const char *name ) :OListBox( parent, name, WType_Popup ) { d = new OCompletionBoxPrivate; d->m_parent = parent; d->tabHandling = true; d->down_workaround = false; setColumnMode( 1 ); setLineWidth( 1 ); setFrameStyle( QFrame::Box | QFrame::Plain ); if ( parent ) setFocusProxy( parent ); else setFocusPolicy( NoFocus ); setVScrollBarMode( Auto ); setHScrollBarMode( AlwaysOff ); - connect( this, SIGNAL( doubleClicked( QListBoxItem * )), - SLOT( slotActivated( QListBoxItem * )) ); + connect( this, SIGNAL( doubleClicked(QListBoxItem*)), + SLOT( slotActivated(QListBoxItem*)) ); // grmbl, just QListBox workarounds :[ Thanks Volker. - connect( this, SIGNAL( currentChanged( QListBoxItem * )), + connect( this, SIGNAL( currentChanged(QListBoxItem*)), SLOT( slotCurrentChanged() )); - connect( this, SIGNAL( clicked( QListBoxItem * )), - SLOT( slotItemClicked( QListBoxItem * )) ); + connect( this, SIGNAL( clicked(QListBoxItem*)), + SLOT( slotItemClicked(QListBoxItem*)) ); } OCompletionBox::~OCompletionBox() { d->m_parent = 0L; delete d; } QStringList OCompletionBox::items() const { QStringList list; for ( uint i = 0; i < count(); i++ ) { list.append( text( i ) ); } return list; } void OCompletionBox::slotActivated( QListBoxItem *item ) { if ( !item ) return; hide(); emit activated( item->text() ); } bool OCompletionBox::eventFilter( QObject *o, QEvent *e ) { int type = e->type(); if ( o == d->m_parent ) { if ( isVisible() ) { if ( type == QEvent::KeyPress ) { QKeyEvent *ev = static_cast<QKeyEvent *>( e ); switch ( ev->key() ) { case Key_BackTab: if ( d->tabHandling ) { up(); ev->accept(); return true; } break; case Key_Tab: if ( d->tabHandling ) { down(); // Only on TAB!! ev->accept(); return true; } diff --git a/libopie2/qt3/opieui/ojanuswidget.cpp b/libopie2/qt3/opieui/ojanuswidget.cpp index 0a037ff..063e393 100644 --- a/libopie2/qt3/opieui/ojanuswidget.cpp +++ b/libopie2/qt3/opieui/ojanuswidget.cpp @@ -64,148 +64,148 @@ class OJanusWidget::IconListItem : public QListBoxItem public: IconListItem( QListBox *listbox, const QPixmap &pixmap, const QString &text ); virtual int height( const QListBox *lb ) const; virtual int width( const QListBox *lb ) const; int expandMinimumWidth( int width ); protected: const QPixmap &defaultPixmap(); void paint( QPainter *painter ); private: QPixmap mPixmap; int mMinimumWidth; }; template class QPtrList<QListViewItem>; /*====================================================================================== * OJanusWidget *======================================================================================*/ OJanusWidget::OJanusWidget( QWidget *parent, const char *name, int face ) : QWidget( parent, name, 0 ), mValid(false), mPageList(0), mTitleList(0), mFace(face), mTitleLabel(0), mActivePageWidget(0), mShowIconsInTreeList(false), d(0) { QVBoxLayout *topLayout = new QVBoxLayout( this ); if( mFace == TreeList || mFace == IconList ) { mPageList = new QPtrList<QWidget>; mTitleList = new QStringList(); QFrame *page; if( mFace == TreeList ) { QSplitter *splitter = new QSplitter( this ); topLayout->addWidget( splitter, 10 ); mTreeListResizeMode = QSplitter::KeepSize; mTreeList = new QListView( splitter ); mTreeList->addColumn( QString::fromLatin1("") ); mTreeList->header()->hide(); mTreeList->setRootIsDecorated(true); mTreeList->setSorting( -1 ); connect( mTreeList, SIGNAL(selectionChanged()), SLOT(slotShowPage()) ); - connect( mTreeList, SIGNAL(clicked(QListViewItem *)), SLOT(slotItemClicked(QListViewItem *))); + connect( mTreeList, SIGNAL(clicked(QListViewItem*)), SLOT(slotItemClicked(QListViewItem*))); // // Page area. Title at top with a separator below and a pagestack using // all available space at bottom. // QFrame *p = new QFrame( splitter ); QHBoxLayout *hbox = new QHBoxLayout( p, 0, 0 ); hbox->addSpacing( ODialog::spacingHint() ); page = new QFrame( p ); hbox->addWidget( page, 10 ); } else { QHBoxLayout *hbox = new QHBoxLayout( topLayout ); mIconList = new IconListBox( this ); QFont listFont( mIconList->font() ); listFont.setBold( true ); mIconList->setFont( listFont ); mIconList->verticalScrollBar()->installEventFilter( this ); hbox->addWidget( mIconList ); connect( mIconList, SIGNAL(selectionChanged()), SLOT(slotShowPage())); hbox->addSpacing( ODialog::spacingHint() ); page = new QFrame( this ); hbox->addWidget( page, 10 ); } // // Rest of page area. Title at top with a separator below and a // pagestack using all available space at bottom. // QVBoxLayout *vbox = new QVBoxLayout( page, 0, ODialog::spacingHint() ); mTitleLabel = new QLabel( QString::fromLatin1("Empty page"), page, "OJanusWidgetTitleLabel" ); vbox->addWidget( mTitleLabel ); QFont titleFont( mTitleLabel->font() ); titleFont.setBold( true ); mTitleLabel->setFont( titleFont ); mTitleSep = new OSeparator( page ); mTitleSep->setFrameStyle( QFrame::HLine|QFrame::Plain ); vbox->addWidget( mTitleSep ); mPageStack = new QWidgetStack( page ); - connect(mPageStack, SIGNAL(aboutToShow(QWidget *)), - this, SIGNAL(aboutToShowPage(QWidget *))); + connect(mPageStack, SIGNAL(aboutToShow(QWidget*)), + this, SIGNAL(aboutToShowPage(QWidget*))); vbox->addWidget( mPageStack, 10 ); } else if( mFace == Tabbed ) { mPageList = new QPtrList<QWidget>; mTabControl = new QTabWidget( this ); mTabControl->setMargin (ODialog::marginHint()); topLayout->addWidget( mTabControl, 10 ); } else if( mFace == Swallow ) { mSwallowPage = new QWidget( this ); topLayout->addWidget( mSwallowPage, 10 ); } else { mFace = Plain; mPlainPage = new QFrame( this ); topLayout->addWidget( mPlainPage, 10 ); } /* FIXME: Revise for Opie if ( kapp ) connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged())); */ mValid = true; setSwallowedWidget(0); // Set default size if 'mFace' is Swallow. } OJanusWidget::~OJanusWidget() { delete mPageList; mPageList = 0; delete mTitleList; mTitleList = 0; } bool OJanusWidget::isValid() const { return( mValid ); } @@ -818,99 +818,99 @@ QSize OJanusWidget::minimumSizeHint() const } } QSize OJanusWidget::sizeHint() const { return( minimumSizeHint() ); } void OJanusWidget::setTreeListAutoResize( bool state ) { if( mFace == TreeList ) { mTreeListResizeMode = state == false ? QSplitter::KeepSize : QSplitter::Stretch; QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget()); splitter->setResizeMode( mTreeList, mTreeListResizeMode ); } } void OJanusWidget::setIconListAllVisible( bool state ) { if( mFace == IconList ) { mIconList->setShowAll( state ); } } void OJanusWidget::setShowIconsInTreeList( bool state ) { mShowIconsInTreeList = state; } void OJanusWidget::setRootIsDecorated( bool state ) { if( mFace == TreeList ) { mTreeList->setRootIsDecorated(state); } } void OJanusWidget::unfoldTreeList( bool persist ) { if( mFace == TreeList ) { if( persist ) - connect( mTreeList, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( slotReopen( QListViewItem * ) ) ); + connect( mTreeList, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( slotReopen(QListViewItem*) ) ); else - disconnect( mTreeList, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( slotReopen( QListViewItem * ) ) ); + disconnect( mTreeList, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( slotReopen(QListViewItem*) ) ); for( QListViewItem * item = mTreeList->firstChild(); item; item = item->itemBelow() ) item->setOpen( true ); } } void OJanusWidget::showEvent( QShowEvent * ) { if( mFace == TreeList ) { QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget()); splitter->setResizeMode( mTreeList, mTreeListResizeMode ); } } // // 2000-13-02 Espen Sand // It should be obvious that this eventfilter must only be // be installed on the vertical scrollbar of the mIconList. // bool OJanusWidget::eventFilter( QObject *o, QEvent *e ) { if( e->type() == QEvent::Show ) { IconListItem *item = (IconListItem*)mIconList->item(0); if( item != 0 ) { int lw = item->width( mIconList ); int sw = mIconList->verticalScrollBar()->sizeHint().width(); mIconList->setFixedWidth( lw+sw+mIconList->frameWidth()*2 ); } } else if( e->type() == QEvent::Hide ) { IconListItem *item = (IconListItem*)mIconList->item(0); if( item != 0 ) { int lw = item->width( mIconList ); mIconList->setFixedWidth( lw+mIconList->frameWidth()*2 ); } } return QWidget::eventFilter( o, e ); } // diff --git a/libopie2/qt3/opieui/olineedit.cpp b/libopie2/qt3/opieui/olineedit.cpp index 9cb0cff..6f66fc7 100644 --- a/libopie2/qt3/opieui/olineedit.cpp +++ b/libopie2/qt3/opieui/olineedit.cpp @@ -402,98 +402,98 @@ void OLineEdit::keyPressEvent( QKeyEvent *e ) // 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 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 ) ) ); + 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: @@ -571,159 +571,159 @@ bool OLineEdit::eventFilter( QObject* o, QEvent* ev ) emit returnPressed( displayText() ); if ( trap ) d->completionBox->hide(); // Eat the event if the user asked for it, or if a completionbox was visible return d->grabReturnKeyEvents || trap; } } } return QLineEdit::eventFilter( o, ev ); } void OLineEdit::setURLDropsEnabled(bool enable) { d->handleURLDrops=enable; } bool OLineEdit::isURLDropsEnabled() const { return d->handleURLDrops; } void OLineEdit::setTrapReturnKey( bool grab ) { d->grabReturnKeyEvents = grab; } bool OLineEdit::trapReturnKey() const { return d->grabReturnKeyEvents; } /*void OLineEdit::setURL( const KURL& url ) { QLineEdit::setText( url.prettyURL() ); }*/ void OLineEdit::makeCompletionBox() { if ( d->completionBox ) return; d->completionBox = new OCompletionBox( this, "completion box" ); if ( handleSignals() ) { - connect( d->completionBox, SIGNAL(highlighted( const QString& )), - SLOT(setText( const QString& )) ); - connect( d->completionBox, SIGNAL(userCancelled( const QString& )), - SLOT(setText( const QString& )) ); + connect( d->completionBox, SIGNAL(highlighted(const QString&)), + SLOT(setText(const QString&)) ); + connect( d->completionBox, SIGNAL(userCancelled(const QString&)), + SLOT(setText(const QString&)) ); // Nice lil' hacklet ;) KComboBox doesn't know when the completionbox // is created (childEvent() is even more hacky, IMHO), so we simply // forward the completionbox' activated signal from here. if ( parentWidget() && parentWidget()->inherits("KComboBox") ) - connect( d->completionBox, SIGNAL( activated( const QString& )), - parentWidget(), SIGNAL( activated( const QString & ))); + connect( d->completionBox, SIGNAL( activated(const QString&)), + parentWidget(), SIGNAL( activated(const QString&))); } } /*bool OLineEdit::overrideAccel (const QKeyEvent* e) { KShortcut scKey; KKey key( e ); KeyBindingMap keys = getKeyBindings(); if (keys[TextCompletion].isNull()) scKey = KStdAccel::shortcut(KStdAccel::TextCompletion); else scKey = keys[TextCompletion]; if (scKey.contains( key )) return true; if (keys[NextCompletionMatch].isNull()) scKey = KStdAccel::shortcut(KStdAccel::NextCompletion); else scKey = keys[NextCompletionMatch]; if (scKey.contains( key )) return true; if (keys[PrevCompletionMatch].isNull()) scKey = KStdAccel::shortcut(KStdAccel::PrevCompletion); else scKey = keys[PrevCompletionMatch]; if (scKey.contains( key )) return true; if (KStdAccel::deleteWordBack().contains( key )) return true; if (KStdAccel::deleteWordForward().contains( key )) return true; if (d->completionBox && d->completionBox->isVisible ()) if (e->key () == Key_Backtab) return true; return false; }*/ void OLineEdit::setCompletedItems( const QStringList& items ) { QString txt = text(); if ( !items.isEmpty() && !(items.count() == 1 && txt == items.first()) ) { if ( !d->completionBox ) makeCompletionBox(); if ( !txt.isEmpty() ) d->completionBox->setCancelledText( txt ); d->completionBox->setItems( items ); d->completionBox->popup(); } else { if ( d->completionBox && d->completionBox->isVisible() ) d->completionBox->hide(); } } OCompletionBox * OLineEdit::completionBox( bool create ) { if ( create ) makeCompletionBox(); return d->completionBox; } void OLineEdit::setCompletionObject( OCompletion* comp, bool hsig ) { OCompletion *oldComp = compObj(); if ( oldComp && handleSignals() ) - disconnect( oldComp, SIGNAL( matches( const QStringList& )), - this, SLOT( setCompletedItems( const QStringList& ))); + disconnect( oldComp, SIGNAL( matches(const QStringList&)), + this, SLOT( setCompletedItems(const QStringList&))); if ( comp && hsig ) - connect( comp, SIGNAL( matches( const QStringList& )), - this, SLOT( setCompletedItems( const QStringList& ))); + connect( comp, SIGNAL( matches(const QStringList&)), + this, SLOT( setCompletedItems(const QStringList&))); OCompletionBase::setCompletionObject( comp, hsig ); } // QWidget::create() turns off mouse-Tracking which would break auto-hiding void OLineEdit::create( WId id, bool initializeWindow, bool destroyOldWindow ) { QLineEdit::create( id, initializeWindow, destroyOldWindow ); //OCursor::setAutoHideCursor( this, true, true ); } void OLineEdit::clear() { setText( QString::null ); } |