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