2 Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include "ProfileListWidget.h"
25 #include <QtGui/QDrag>
26 #include <QtGui/QKeyEvent>
27 #include <QtCore/QMimeData>
29 static const char* konsoleSessionMimeFormat
= "konsole/session";
31 ProfileListWidget::ProfileListWidget(QWidget
* parent
)
34 // use large icons so that there is a big area for the user to click
35 // on to switch between sessions
36 setIconSize( QSize(32,32) );
39 setFrameStyle( QFrame::NoFrame
);
41 QPalette p
= palette();
42 p
.setBrush( QPalette::Base
, QColor(220,220,220) );
46 void ProfileListWidget::startDrag(Qt::DropActions
/*supportedActions*/)
48 kDebug() << "drag and drop started in session list widget";
50 QMimeData
* mimeData
= new QMimeData();
54 mimeData
->setData(konsoleSessionMimeFormat
,data
);
56 QDrag
* drag
= new QDrag(this);
57 drag
->setMimeData(mimeData
);
59 Qt::DropAction action
= drag
->start( Qt::MoveAction
);
61 if ( action
& Qt::MoveAction
)
63 emit
takeSessionEvent(currentRow());
67 void ProfileListWidget::dragEnterEvent(QDragEnterEvent
* event
)
69 if ( event
->mimeData()->hasFormat(konsoleSessionMimeFormat
) )
75 void ProfileListWidget::dragMoveEvent(QDragMoveEvent
* event
)
77 if ( event
->mimeData()->hasFormat(konsoleSessionMimeFormat
) )
79 event
->setDropAction(Qt::MoveAction
);
84 void ProfileListWidget::dropEvent(QDropEvent
* event
)
86 if ( event
->mimeData()->hasFormat(konsoleSessionMimeFormat
) )
88 event
->setDropAction(Qt::MoveAction
);
91 emit
dropSessionEvent( event
->mimeData()->data(konsoleSessionMimeFormat
).toInt() );
96 #include "ProfileListWidget.moc"