kxmlcommand.h

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 #ifndef KXMLCOMMAND_H
00021 #define KXMLCOMMAND_H
00022 
00023 #include <qdom.h>
00024 #include <qmap.h>
00025 #include <qobject.h>
00026 
00027 #include <kdelibs_export.h>
00028 
00029 class DrMain;
00030 class DrGroup;
00031 class DrBase;
00032 
00033 class KDEPRINT_EXPORT KXmlCommand : public QObject
00034 {
00035     friend class KXmlCommandManager;
00036 
00037 public:
00038     ~KXmlCommand();
00039 
00040     QString name() const;
00041     void setName(const QString&);
00042     QString command();
00043     void setCommand(const QString&);
00044     DrMain* driver();
00045     DrMain* takeDriver();
00046     void setDriver(DrMain*);
00047     QString io(bool io_input = true, bool io_pipe = false);
00048     void setIo(const QString&, bool io_input = true, bool io_pipe = false);
00049     QString description();
00050     void setDescription(const QString&);
00051     QString mimeType();
00052     void setMimeType(const QString&);
00053     bool acceptMimeType(const QString&);
00054     QStringList inputMimeTypes();
00055     void setInputMimeTypes(const QStringList&);
00056     QStringList requirements();
00057     void setRequirements(const QStringList&);
00058     QString comment();
00059     void setComment( const QString& );
00060     bool isValid();
00061 
00062     QString buildCommand(const QMap<QString,QString>& opts, bool pipein = true, bool pipeout = true);
00063     void setOptions(const QMap<QString,QString>& opts);
00064     void getOptions(QMap<QString,QString>& opts, bool incldef = false);
00065 
00066 protected:
00067     void init();
00068     void loadXml();
00069     void saveXml();
00070     void loadDesktop();
00071     void saveDesktop();
00072     void check(bool use_xml = false);
00073     DrGroup* parseGroup(const QDomElement& e, DrGroup *grp = 0);
00074     DrBase* parseArgument(const QDomElement& e);
00075     void parseIO(const QDomElement& e, int n);
00076     QDomElement createIO(QDomDocument&, int, const QString&);
00077     QDomElement createGroup(QDomDocument&, DrGroup*);
00078     QDomElement createElement(QDomDocument&, DrBase*);
00079 
00080     // use protected constructor to only allow the manager to
00081     // create KXmlCommand object.
00082     KXmlCommand(const QString& xmlId = QString::null);
00083 
00084 private:
00085     class KXmlCommandPrivate;
00086     KXmlCommandPrivate  *d;
00087 };
00088 
00089 class KDEPRINT_EXPORT KXmlCommandManager : public QObject
00090 {
00091 public:
00092     enum IO_CheckType   { None = 0, Basic, Advanced };
00093 
00094     KXmlCommandManager();
00095     ~KXmlCommandManager();
00096 
00097     KXmlCommand* loadCommand(const QString& xmlId, bool check = false);
00098     void saveCommand(KXmlCommand *xmlCmd);
00099     QStringList commandList();
00100     QStringList commandListWithDescription();
00101     QString selectCommand(QWidget *parent = 0);
00102 
00103     QStringList autoConvert(const QString& mimesrc, const QString& mimedest);
00104     int insertCommand(QStringList& list, const QString& filtername, bool defaultToStart = true);
00105     bool checkCommand(const QString&, int inputCheck = Advanced, int outputCheck = Advanced, QString *msg = 0);
00106     bool configure(KXmlCommand*, QWidget *parent = 0);
00107     void cleanUp();
00108 
00109     static KXmlCommandManager* self();
00110 
00111 protected:
00112     void preload();
00113     KXmlCommand* command(const QString&) const;
00114 
00115 private:
00116     class KXmlCommandManagerPrivate;
00117     KXmlCommandManagerPrivate   *d;
00118     static KXmlCommandManager   *m_self;
00119 };
00120 
00121 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys