1 /*
2  *  Copyright (c) 2016 Dmitry Kazakov <dimula73@gmail.com>
3  *
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.
8  *
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.
13  *
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 02110-1301, USA.
17  */
18 
19 #include "kis_brush_hud_properties_list.h"
20 
21 
22 struct KisBrushHudPropertiesList::Private
23 {
24 };
25 
KisBrushHudPropertiesList(QWidget * parent)26 KisBrushHudPropertiesList::KisBrushHudPropertiesList(QWidget *parent)
27     : QListWidget(parent),
28       m_d(new Private)
29 {
30     setDragDropMode(QAbstractItemView::DragDrop);
31     setDefaultDropAction(Qt::MoveAction);
32 }
33 
~KisBrushHudPropertiesList()34 KisBrushHudPropertiesList::~KisBrushHudPropertiesList()
35 {
36 }
37 
addProperties(const QList<KisUniformPaintOpPropertySP> & properties)38 void KisBrushHudPropertiesList::addProperties(const QList<KisUniformPaintOpPropertySP> &properties)
39 {
40     int index = 0;
41     Q_FOREACH (KisUniformPaintOpPropertySP prop, properties) {
42         QListWidgetItem *item = new QListWidgetItem(prop->name(), this);
43         item->setData(Qt::UserRole, prop->id());
44         addItem(item);
45         index++;
46     }
47 }
48 
selectedPropertiesIds() const49 QList<QString> KisBrushHudPropertiesList::selectedPropertiesIds() const
50 {
51     QList<QString> ids;
52 
53     for (int i = 0; i < count(); i++) {
54         ids << item(i)->data(Qt::UserRole).toString();
55     }
56 
57     return ids;
58 }
59 
supportedDropActions() const60 Qt::DropActions KisBrushHudPropertiesList::supportedDropActions() const
61 {
62     // we cannot change drop actions to Move only! It stops working
63     // for some reason :(
64     return QListWidget::supportedDropActions();
65 }
66