add more spacing
[personal-kdebase.git] / apps / konsole / src / ProfileListWidget.cpp
blob0cdc80d2211a7da89252ca16b4e5b9d79bfdd48b
1 /*
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
17 02110-1301 USA.
20 // Own
21 #include "ProfileListWidget.h"
23 // Qt
24 #include <KDebug>
25 #include <QtGui/QDrag>
26 #include <QtGui/QKeyEvent>
27 #include <QtCore/QMimeData>
29 static const char* konsoleSessionMimeFormat = "konsole/session";
31 ProfileListWidget::ProfileListWidget(QWidget* parent)
32 : QListWidget(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) );
38 // turn the frame off
39 setFrameStyle( QFrame::NoFrame );
41 QPalette p = palette();
42 p.setBrush( QPalette::Base , QColor(220,220,220) );
43 setPalette(p);
46 void ProfileListWidget::startDrag(Qt::DropActions /*supportedActions*/)
48 kDebug() << "drag and drop started in session list widget";
50 QMimeData* mimeData = new QMimeData();
52 QByteArray data;
53 data.setNum(42);
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) )
71 event->accept();
75 void ProfileListWidget::dragMoveEvent(QDragMoveEvent* event)
77 if ( event->mimeData()->hasFormat(konsoleSessionMimeFormat) )
79 event->setDropAction(Qt::MoveAction);
80 event->accept();
84 void ProfileListWidget::dropEvent(QDropEvent* event)
86 if ( event->mimeData()->hasFormat(konsoleSessionMimeFormat) )
88 event->setDropAction(Qt::MoveAction);
89 event->accept();
91 emit dropSessionEvent( event->mimeData()->data(konsoleSessionMimeFormat).toInt() );
96 #include "ProfileListWidget.moc"