From kde-commits Wed Jan 26 16:00:27 2011 From: Tobias Koenig Date: Wed, 26 Jan 2011 16:00:27 +0000 To: kde-commits Subject: KDE/kdepimlibs/akonadi Message-Id: <20110126160027.63AACAC8BA () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129605767324690 SVN commit 1217304 by tokoe: Fix the input after opening CollectionDialog from CollectionComboBox in MOBILE_UI mode. M +21 -18 collectioncombobox.cpp A collectioncombobox_p.h [License: LGPL (v2+)] --- trunk/KDE/kdepimlibs/akonadi/collectioncombobox.cpp #1217303:1217304 @@ -20,6 +20,7 @@ */ #include "collectioncombobox.h" +#include "collectioncombobox_p.h" #include "asyncselectionhandler_p.h" #include "collectiondialog.h" @@ -36,6 +37,7 @@ #include #include +#include using namespace Akonadi; @@ -107,10 +109,7 @@ mParent->setCurrentIndex( index.row() ); } -class MobileEventHandler : public QObject -{ - public: - MobileEventHandler( CollectionComboBox *comboBox, CollectionFilterProxyModel *mimeTypeFilter, +MobileEventHandler::MobileEventHandler( CollectionComboBox *comboBox, CollectionFilterProxyModel *mimeTypeFilter, EntityRightsFilterModel *accessRightsFilter, QAbstractItemModel *customModel ) : QObject( comboBox ), mComboBox( comboBox ), @@ -120,10 +119,25 @@ { } - protected: - virtual bool eventFilter( QObject *object, QEvent *event ) +bool MobileEventHandler::eventFilter( QObject *object, QEvent *event ) { if ( object == mComboBox && mComboBox->isEnabled() && event->type() == QEvent::MouseButtonPress ) { + + const QMouseEvent *mouseEvent = static_cast( event ); + + // we receive mouse events from other widgets as well, so check for ours + if ( mComboBox->rect().contains( mouseEvent->pos() ) ) { + QMetaObject::invokeMethod( this, "openDialog", Qt::QueuedConnection ); + } + + return true; + } + + return QObject::eventFilter( object, event ); +} + +void MobileEventHandler::openDialog() +{ Akonadi::CollectionDialog dialog( mCustomModel ); dialog.setMimeTypeFilter( mMimeTypeFilter->mimeTypeFilters() ); dialog.setAccessRightsFilter( mAccessRightsFilter->accessRights() ); @@ -133,21 +147,9 @@ const QModelIndex index = Akonadi::EntityTreeModel::modelIndexForCollection( mComboBox->model(), collection ); mComboBox->setCurrentIndex( index.row() ); } - - return true; } - return QObject::eventFilter( object, event ); - } - private: - CollectionComboBox *mComboBox; - CollectionFilterProxyModel *mMimeTypeFilter; - EntityRightsFilterModel *mAccessRightsFilter; - QAbstractItemModel *mCustomModel; -}; - - CollectionComboBox::CollectionComboBox( QWidget *parent ) : KComboBox( parent ), d( new Private( 0, this ) ) { @@ -211,3 +213,4 @@ } #include "collectioncombobox.moc" +#include "collectioncombobox_p.moc"