chalk

kis_cmb_composite.cpp
1/*
2 * kis_cmb_composite.cpp - part of KImageShop/Krayon/Chalk
3 *
4 * Copyright (c) 2004 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_cmb_composite.h"
27
28KisCmbComposite::KisCmbComposite(TQWidget * parent, const char * name)
29 : super( false, parent, name )
30{
31 connect(this, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotOpActivated(int)));
32 connect(this, TQ_SIGNAL(highlighted(int)), this, TQ_SLOT(slotOpHighlighted(int)));
33}
34
35KisCmbComposite::~KisCmbComposite()
36{
37}
38
39void KisCmbComposite::setCompositeOpList(const KisCompositeOpList & list)
40{
41 super::clear();
42 m_list = list;
43 KisCompositeOpList::iterator it;
44 for( it = m_list.begin(); it != m_list.end(); ++it )
45 insertItem((*it).id().name());
46}
47
48KisCompositeOp KisCmbComposite::currentItem() const
49{
50 TQ_UINT32 i = super::currentItem();
51 if (i > m_list.count()) return KisCompositeOp();
52
53 return m_list[i];
54}
55
56void KisCmbComposite::setCurrentItem(const KisCompositeOp& op)
57{
58 if (m_list.find(op) != m_list.end()) {
59 super::setCurrentText(op.id().name());
60 }
61}
62
63void KisCmbComposite::setCurrentText(const TQString & s)
64{
65 KisCompositeOpList::iterator it;
66 for( it = m_list.begin(); it != m_list.end(); ++it )
67 if ((*it).id().id() == s) {
68 super::setCurrentText((*it).id().name());
69 }
70}
71
72void KisCmbComposite::slotOpActivated(int i)
73{
74 if ((TQ_UINT32)i > m_list.count()) return;
75
76 emit activated(m_list[i]);
77}
78
79void KisCmbComposite::slotOpHighlighted(int i)
80{
81 if ((TQ_UINT32)i > m_list.count()) return;
82
83 emit highlighted(m_list[i]);
84}
85
86
87#include "kis_cmb_composite.moc"
88