Warning, file /multimedia/amarok/src/widgets/EditDeleteComboBoxView.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #include "EditDeleteComboBoxView.h" 0018 0019 #include "core/support/Debug.h" 0020 #include "EditDeleteDelegate.h" 0021 0022 #include <QModelIndex> 0023 #include <QMouseEvent> 0024 0025 EditDeleteComboBoxView::EditDeleteComboBoxView( QWidget* parent ) 0026 : QListView( parent ) 0027 { 0028 } 0029 0030 void EditDeleteComboBoxView::mousePressEvent( QMouseEvent *event ) 0031 { 0032 DEBUG_BLOCK 0033 0034 QModelIndex index = indexAt( event->pos() ); 0035 QPoint mousePressPos = event->pos(); 0036 mousePressPos.rx() += horizontalOffset(); 0037 mousePressPos.ry() += verticalOffset(); 0038 0039 if ( EditDeleteDelegate::hitsEdit( mousePressPos, rectForIndex( index ) ) ) 0040 Q_EMIT( editItem( index.data().toString() ) ); 0041 else if ( EditDeleteDelegate::hitsDelete( mousePressPos, rectForIndex( index ) ) ) 0042 Q_EMIT( deleteItem( index.data().toString() ) ); 0043 0044 QListView::mousePressEvent( event ); 0045 } 0046