chalk

kis_itemchooser.cpp
1/*
2 * Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
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#include <tqvbox.h>
19#include <tdeinstance.h>
20#include <tdelocale.h>
21#include <kstandarddirs.h>
22#include <koIconChooser.h>
23
24#include "kis_itemchooser.h"
25#include "kis_global.h"
26#include "kis_icon_item.h"
27
28KisItemChooser::KisItemChooser(TQWidget *parent, const char *name) : super(parent, name)
29{
30/* m_frame = new TQVBox(this);
31 m_frame->setFrameStyle(TQFrame::Panel | TQFrame::Sunken);*/
32 m_chooser = new KoIconChooser(TQSize(30,30), this, "icon_chooser", true);
33 TQObject::connect(m_chooser, TQ_SIGNAL(selected(KoIconItem*)), this, TQ_SLOT(slotItemSelected(KoIconItem*)));
34}
35
36KisItemChooser::~KisItemChooser()
37{
38}
39
40void KisItemChooser::setCurrent(KoIconItem *item)
41{
42 m_chooser->setCurrentItem(item);
43 update(item);
44}
45
46void KisItemChooser::setCurrent(int index)
47{
48 setCurrent(m_chooser->itemAt(index));
49}
50
51KoIconItem* KisItemChooser::currentItem()
52{
53 return m_chooser->currentItem();
54}
55
56void KisItemChooser::slotItemSelected(KoIconItem *item)
57{
58 update(item);
59 emit selected(currentItem());
60}
61
62void KisItemChooser::addItem(KoIconItem *item)
63{
64 m_chooser->addItem(item);
65}
66
67void KisItemChooser::addItems(const vKoIconItem& items)
68{
69 TQPtrListIterator<KoIconItem> itr(items);
70
71 for (itr.toFirst(); itr.current(); ++itr)
72 m_chooser->addItem(itr.current());
73}
74
75TQWidget *KisItemChooser::chooserWidget() const
76{
77 return m_chooser;
78}
79
80#include "kis_itemchooser.moc"
81