• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • @topname@
  • Sitemap
  • Contact Us
 

kdeprint

printcapentry.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001,2002 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 "printcapentry.h"
00021 
00022 QString Field::toString() const
00023 {
00024     QString s = name;
00025     switch (type)
00026     {
00027         case String:
00028             s += ("=" + value);
00029             break;
00030         case Integer:
00031             s += ("#" + value);
00032             break;
00033         case Boolean:
00034             if (!value.toInt())
00035                 s += "@";
00036             break;
00037     }
00038     return s;
00039 }
00040 
00041 bool PrintcapEntry::writeEntry(QTextStream& t)
00042 {
00043     t << comment << endl;
00044     t << name;
00045     if (aliases.count() > 0)
00046         t << '|' << aliases.join("|");
00047     t << ':';
00048     for (QMap<QString,Field>::ConstIterator it=fields.begin(); it!=fields.end(); ++it)
00049     {
00050         t << '\\' << endl << "    :";
00051         t << (*it).name;
00052         switch ((*it).type)
00053         {
00054             case Field::String:
00055                 t << '=' << (*it).value << ':';
00056                 break;
00057             case Field::Integer:
00058                 t << '#' << (*it).value << ':';
00059                 break;
00060             case Field::Boolean:
00061                 t << ':';
00062                 break;
00063             default:
00064                 t << endl << endl;
00065                 return false;
00066         }
00067     }
00068     t << endl;
00069     if (!postcomment.isEmpty())
00070         t << postcomment << endl;
00071     t << endl;
00072     return true;
00073 }
00074 
00075 void PrintcapEntry::addField(const QString& name, Field::Type type, const QString& value)
00076 {
00077     Field   f;
00078     f.name = name;
00079     f.type = type;
00080     f.value = value;
00081     fields[name] = f;
00082 }

kdeprint

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

@topname@

Skip menu "@topname@"
  •     kdnssd-avahi
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for @topname@ by doxygen 1.5.5
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