• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

editlist.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library 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 GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "editlist.h"
00021 
00022 #include <tdelistbox.h>
00023 #include <kpushbutton.h>
00024 #include <tqlayout.h>
00025 #include <tdelocale.h>
00026 #include <kiconloader.h>
00027 #include <kguiitem.h>
00028 
00029 EditList::EditList(TQWidget *parent, const char *name)
00030     : TQWidget(parent, name)
00031 {
00032     list_ = new TDEListBox(this);
00033     addbtn_ = new KPushButton(KGuiItem(i18n("Add..."), "document-new"), this);
00034     editbtn_ = new KPushButton(KGuiItem(i18n("Edit..."), "edit"), this);
00035     delbtn_ = new KPushButton(KGuiItem(i18n("Delete"), "edit-delete"), this);
00036     defbtn_ = new KPushButton(KGuiItem(i18n("Default List"), "history"), this);
00037 
00038     TQGridLayout *m1 = new TQGridLayout(this, 4, 2, 0, 0);
00039     m1->setColStretch(0, 1);
00040     m1->addMultiCellWidget(list_, 0, 3, 0, 1);
00041     m1->addWidget(addbtn_, 0, 1);
00042     m1->addWidget(editbtn_, 1, 1);
00043     m1->addWidget(delbtn_, 2, 1);
00044     m1->addWidget(defbtn_, 3, 1);
00045 
00046     connect(addbtn_, TQT_SIGNAL(clicked()), TQT_SIGNAL(add()));
00047     connect(editbtn_, TQT_SIGNAL(clicked()), TQT_SLOT(slotEdit()));
00048     connect(delbtn_, TQT_SIGNAL(clicked()), TQT_SLOT(slotDelete()));
00049     connect(defbtn_, TQT_SIGNAL(clicked()), TQT_SIGNAL(defaultList()));
00050     connect(list_, TQT_SIGNAL(highlighted(int)), TQT_SLOT(slotSelected(int)));
00051     slotSelected(-1);
00052 }
00053 
00054 void EditList::slotEdit()
00055 {
00056     int index = list_->currentItem();
00057     if (index >= 0)
00058         emit edit(index);
00059 }
00060 
00061 void EditList::slotDelete()
00062 {
00063     int index = list_->currentItem();
00064     list_->removeItem(index);
00065     slotSelected((list_->count() > 0 ? list_->currentItem() : -1));
00066     emit deleted(index);
00067 }
00068 
00069 void EditList::slotSelected(int index)
00070 {
00071     editbtn_->setEnabled(index >= 0);
00072     delbtn_->setEnabled(index >= 0);
00073 }
00074 
00075 TQString EditList::text(int index)
00076 {
00077     return list_->text(index);
00078 }
00079 
00080 void EditList::setText(int index, const TQString& s)
00081 {
00082     if (list_->text(index) != s)
00083     {
00084         TQListBoxItem   *it = list_->findItem(s, TQt::ExactMatch);
00085         if (!it)
00086             list_->changeItem(s, index);
00087         else
00088             list_->removeItem(index);
00089     }
00090 }
00091 
00092 void EditList::clear()
00093 {
00094     list_->clear();
00095     slotSelected(-1);
00096 }
00097 
00098 void EditList::insertItem(const TQString& s)
00099 {
00100     if (!list_->findItem(s, TQt::ExactMatch))
00101         list_->insertItem(s);
00102 }
00103 
00104 void EditList::insertItem(const TQPixmap& icon, const TQString& s)
00105 {
00106     if (!list_->findItem(s, TQt::ExactMatch))
00107         list_->insertItem(icon, s);
00108 }
00109 
00110 void EditList::insertItems(const TQStringList& l)
00111 {
00112     for (TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it)
00113         insertItem(*it);
00114 }
00115 
00116 TQStringList EditList::items()
00117 {
00118     TQStringList l;
00119     for (uint i=0; i<list_->count(); i++)
00120         l << list_->text(i);
00121     return l;
00122 }
00123 
00124 #include "editlist.moc"

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.7.1
This website is maintained by Timothy Pearson.