chalk

kis_cmb_idlist.cpp
1/*
2 * kis_cmb_idlist.cpp - part of KImageShop/Krayon/Chalk
3 *
4 * Copyright (c) 2005 Boudewijn Rempt (boud@valdyas.org)
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#include <tqcombobox.h>
22
23#include <tdelocale.h>
24#include <kdebug.h>
25
26#include "kis_id.h"
27#include "kis_cmb_idlist.h"
28
29KisCmbIDList::KisCmbIDList(TQWidget * parent, const char * name)
30 : super( false, parent, name )
31{
32 connect(this, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotIDActivated(int)));
33 connect(this, TQ_SIGNAL(highlighted(int)), this, TQ_SLOT(slotIDHighlighted(int)));
34}
35
36KisCmbIDList::~KisCmbIDList()
37{
38}
39
40
41void KisCmbIDList::setIDList(const KisIDList & list)
42{
43 m_list = list;
44 KisIDList::iterator it;
45 for( it = m_list.begin(); it != m_list.end(); ++it )
46 insertItem((*it).name());
47}
48
49
50KisID KisCmbIDList::currentItem() const
51{
52 TQ_UINT32 i = super::currentItem();
53 if (i > m_list.count()) return KisID();
54
55 return m_list[i];
56}
57
58void KisCmbIDList::setCurrent(const KisID id)
59{
60 if (m_list.find(id) != m_list.end())
61 super::setCurrentText(id.name());
62 else {
63 m_list.push_back(id);
64 insertItem(id.name());
65 super::setCurrentText(id.name());
66 }
67}
68
69void KisCmbIDList::setCurrentText(const TQString & s)
70{
71 KisIDList::iterator it;
72 for( it = m_list.begin(); it != m_list.end(); ++it )
73 if ((*it).id() == s) {
74 super::setCurrentText((*it).name());
75 }
76}
77
78void KisCmbIDList::slotIDActivated(int i)
79{
80 if ((uint)i > m_list.count()) return;
81
82 emit activated(m_list[i]);
83
84}
85
86void KisCmbIDList::slotIDHighlighted(int i)
87{
88 if ((uint)i > m_list.count()) return;
89
90 emit highlighted(m_list[i]);
91
92}
93
94
95
96#include "kis_cmb_idlist.moc"
97
Chalk has a large number of extensible resources.
Definition kis_id.h:57