• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KDEPrint

driveritem.cpp

Go to the documentation of this file.
00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@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 "driveritem.h"
00021 #include "driver.h"
00022 
00023 #include <QtGui/QPainter>
00024 #include <kiconloader.h>
00025 #include <kdebug.h>
00026 
00027 DriverItem::DriverItem(QTreeWidget *parent, DrBase *item)
00028         : QTreeWidgetItem(parent), m_item(item), m_conflict(false)
00029 {
00030     setIcon(0, SmallIcon("document-print"));
00031     updateText();
00032 }
00033 
00034 DriverItem::DriverItem(QTreeWidgetItem *parent, QTreeWidgetItem *after, DrBase *item)
00035         : QTreeWidgetItem(parent, after), m_item(item), m_conflict(false)
00036 {
00037     if (item) setIcon(0, SmallIcon((item->isOption() ? "document" : "folder")));
00038     updateText();
00039 }
00040 
00041 void DriverItem::updateText()
00042 {
00043     if (m_item) {
00044         QString s(m_item->get("text"));
00045         if (m_item->isOption())
00046             s.append(QString::fromLatin1(": <%1>").arg(m_item->prettyText()));
00047         if (m_item->type() == DrBase::List) {
00048             // remove all children: something has changed (otherwise this
00049             // function would not be called), so it make sense to remove
00050             // those children in all cases.
00051             while (child(0))
00052                 delete child(0);
00053             DrBase *ch = static_cast<DrListOption*>(m_item)->currentChoice();
00054             if (ch && ch->type() == DrBase::ChoiceGroup) {
00055                 // add new children
00056                 static_cast<DrChoiceGroup*>(ch)->createItem(this);
00057             }
00058         }
00059         setText(0, s);
00060     } else
00061         setText(0, "ERROR");
00062 }
00063 
00064 bool DriverItem::updateConflict()
00065 {
00066     m_conflict = false;
00067     if (m_item) {
00068         if (!m_item->isOption()) {
00069             for (int i = 0; i < childCount(); ++i) {
00070                 DriverItem *item = (DriverItem*)child(i);
00071                 if (item->updateConflict())
00072                     m_conflict = true;
00073             }
00074         } else {
00075             m_conflict = (m_item->conflict());
00076         }
00077     }
00078     return m_conflict;
00079 }
00080 
00081 void DriverItem::updateTextRecursive()
00082 {
00083     if (m_item->isOption())
00084         updateText();
00085 
00086     for (int i = 0; i < childCount(); ++i) {
00087         DriverItem *item = (DriverItem*)child(i);
00088         item->updateTextRecursive();
00089     }
00090 }

KDEPrint

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

API Reference

Skip menu "API Reference"
  •   KDEPrint
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal