krita

kis_itemchooser.cc

00001 /*
00002  *  Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 #include <qvbox.h>
00019 #include <kinstance.h>
00020 #include <klocale.h>
00021 #include <kstandarddirs.h>
00022 #include <koIconChooser.h>
00023 
00024 #include "kis_itemchooser.h"
00025 #include "kis_global.h"
00026 #include "kis_icon_item.h"
00027 
00028 KisItemChooser::KisItemChooser(QWidget *parent, const char *name) : super(parent, name)
00029 {
00030 /*    m_frame = new QVBox(this);
00031     m_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);*/
00032     m_chooser = new KoIconChooser(QSize(30,30), this, "icon_chooser", true);
00033     QObject::connect(m_chooser, SIGNAL(selected(KoIconItem*)), this, SLOT(slotItemSelected(KoIconItem*)));
00034 }
00035 
00036 KisItemChooser::~KisItemChooser()
00037 {
00038 }
00039 
00040 void KisItemChooser::setCurrent(KoIconItem *item)
00041 {
00042     m_chooser->setCurrentItem(item);
00043     update(item);
00044 }
00045 
00046 void KisItemChooser::setCurrent(int index)
00047 {
00048     setCurrent(m_chooser->itemAt(index));
00049 }
00050 
00051 KoIconItem* KisItemChooser::currentItem()
00052 {
00053     return m_chooser->currentItem();
00054 }
00055 
00056 void KisItemChooser::slotItemSelected(KoIconItem *item)
00057 {
00058     update(item);
00059     emit selected(currentItem());
00060 }
00061 
00062 void KisItemChooser::addItem(KoIconItem *item)
00063 {
00064     m_chooser->addItem(item);
00065 }
00066 
00067 void KisItemChooser::addItems(const vKoIconItem& items)
00068 {
00069     QPtrListIterator<KoIconItem> itr(items);
00070 
00071     for (itr.toFirst(); itr.current(); ++itr)
00072         m_chooser->addItem(itr.current());
00073 }
00074 
00075 QWidget *KisItemChooser::chooserWidget() const
00076 {
00077     return m_chooser;
00078 }
00079 
00080 #include "kis_itemchooser.moc"
00081 
KDE Home | KDE Accessibility Home | Description of Access Keys