• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeaccessibility API Reference
  • KDE Home
  • Contact Us
 

jovie

  • sources
  • kde-4.12
  • kdeaccessibility
  • jovie
  • filters
  • xmltransformer
xmltransformerconf.cpp
Go to the documentation of this file.
1 /***************************************************** vim:set ts=4 sw=4 sts=4:
2  Generic XML Transformation Filter Configuration class.
3  -------------------
4  Copyright:
5  (C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
6  -------------------
7  Original author: Gary Cramblitt <garycramblitt@comcast.net>
8 
9  This program is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22  ******************************************************************************/
23 
24 // XmlTransformer includes.
25 #include "xmltransformerconf.h"
26 #include "xmltransformerconf.moc"
27 
28 // Qt includes.
29 
30 
31 // KDE includes.
32 #include <klocale.h>
33 #include <klineedit.h>
34 #include <kconfig.h>
35 #include <kdialog.h>
36 #include <kurlrequester.h>
37 #include <kstandarddirs.h>
38 
39 // KTTS includes.
40 #include "filterconf.h"
41 
45 XmlTransformerConf::XmlTransformerConf( QWidget *parent, const QVariantList &args) :
46  KttsFilterConf(parent, args)
47 {
48  Q_UNUSED(args);
49  kDebug() << "XmlTransformerConf::XmlTransformerConf: Running";
50 
51  // Create configuration widget.
52  setupUi(this);
53 
54  // Set up defaults.
55  kDebug() << "XmlTransformerConf:: setting up defaults";
56  defaults();
57 
58  // Connect signals.
59  connect( nameLineEdit, SIGNAL(textChanged(QString)),
60  this, SLOT(configChanged()));
61  connect( xsltPath, SIGNAL(textChanged(QString)),
62  this, SLOT(configChanged()) );
63  connect( xsltprocPath, SIGNAL(textChanged(QString)),
64  this, SLOT(configChanged()) );
65  connect( rootElementLineEdit, SIGNAL(textChanged(QString)),
66  this, SLOT(configChanged()) );
67  connect( doctypeLineEdit, SIGNAL(textChanged(QString)),
68  this, SLOT(configChanged()) );
69  connect( appIdLineEdit, SIGNAL(textChanged(QString)),
70  this, SLOT(configChanged()) );
71 }
72 
76 XmlTransformerConf::~XmlTransformerConf(){
77  // kDebug() << "XmlTransformerConf::~XmlTransformerConf: Running";
78 }
79 
80 void XmlTransformerConf::load(KConfig* c, const QString& configGroup){
81  // kDebug() << "XmlTransformerConf::load: Running";
82  KConfigGroup config( c, configGroup );
83  nameLineEdit->setText( config.readEntry( "UserFilterName", nameLineEdit->text() ) );
84  xsltPath->setUrl( KUrl::fromPath( config.readEntry( "XsltFilePath", xsltPath->url().path() ) ) );
85  xsltprocPath->setUrl( KUrl::fromPath( config.readEntry( "XsltprocPath", xsltprocPath->url().path() ) ) );
86  rootElementLineEdit->setText(
87  config.readEntry( "RootElement", rootElementLineEdit->text() ) );
88  doctypeLineEdit->setText(
89  config.readEntry( "DocType", doctypeLineEdit->text() ) );
90  appIdLineEdit->setText(
91  config.readEntry( "AppID", appIdLineEdit->text() ) );
92 }
93 
94 void XmlTransformerConf::save(KConfig* c, const QString& configGroup){
95  // kDebug() << "XmlTransformerConf::save: Running";
96  KConfigGroup config( c, configGroup );
97  config.writeEntry( "UserFilterName", nameLineEdit->text() );
98  config.writeEntry( "XsltFilePath", realFilePath( xsltPath->url().path() ) );
99  config.writeEntry( "XsltprocPath", realFilePath( xsltprocPath->url().path() ) );
100  config.writeEntry( "RootElement", rootElementLineEdit->text() );
101  config.writeEntry( "DocType", doctypeLineEdit->text() );
102  config.writeEntry( "AppID", appIdLineEdit->text().remove(QLatin1Char( ' ' )) );
103 }
104 
112 void XmlTransformerConf::defaults(){
113  // kDebug() << "XmlTransformerConf::defaults: Running";
114  // Default name.
115  nameLineEdit->setText(i18n( "XML Transformer" ));
116  // Default XSLT path to installed xsl files.
117  xsltPath->setUrl( KUrl::fromPath( KStandardDirs::locate("data", QLatin1String( "kttsd/xmltransformer/" )) ) );
118  // Default path to xsltproc.
119  xsltprocPath->setUrl( KUrl("xsltproc") );
120  // Default root element to "html".
121  rootElementLineEdit->setText( QLatin1String( "html" ) );
122  // Default doctype to blank.
123  doctypeLineEdit->clear();
124  // Default App ID to blank.
125  appIdLineEdit->clear();
126  // kDebug() << "XmlTransformerConf::defaults: Exiting";
127 }
128 
134 bool XmlTransformerConf::supportsMultiInstance() { return true; }
135 
144 QString XmlTransformerConf::userPlugInName()
145 {
146  QString filePath = realFilePath(xsltprocPath->url().path());
147  if (filePath.isEmpty()) return QString();
148  if (getLocation(filePath).isEmpty()) return QString();
149 
150  filePath = realFilePath(xsltPath->url().path());
151  if (filePath.isEmpty()) return QString();
152  if (getLocation(filePath).isEmpty()) return QString();
153  if (!QFileInfo(filePath).isFile()) return QString();
154 
155  return nameLineEdit->text();
156 }
XmlTransformerConf::XmlTransformerConf
XmlTransformerConf(QWidget *parent, const QVariantList &args)
Constructor.
Definition: xmltransformerconf.cpp:45
QWidget
filterconf.h
XmlTransformerConf::~XmlTransformerConf
virtual ~XmlTransformerConf()
Destructor.
Definition: xmltransformerconf.cpp:76
xmltransformerconf.h
KttsFilterConf::realFilePath
static QString realFilePath(const QString &filename)
Definition: filterconf.cpp:154
XmlTransformerConf::supportsMultiInstance
virtual bool supportsMultiInstance()
Indicates whether the plugin supports multiple instances.
Definition: xmltransformerconf.cpp:134
XmlTransformerConf::defaults
virtual void defaults()
This function is called to set the settings in the module to sensible default values.
Definition: xmltransformerconf.cpp:112
KttsFilterConf::configChanged
void configChanged()
This slot is used internally when the configuration is changed.
Definition: filterconf.h:122
KttsFilterConf
Definition: filterconf.h:36
XmlTransformerConf::load
virtual void load(KConfig *c, const QString &configGroup)
This method is invoked whenever the module should read its configuration (most of the times from a co...
Definition: xmltransformerconf.cpp:80
XmlTransformerConf::userPlugInName
virtual QString userPlugInName()
Returns the name of the plugin.
Definition: xmltransformerconf.cpp:144
XmlTransformerConf::save
virtual void save(KConfig *c, const QString &configGroup)
This function gets called when the user wants to save the settings in the user interface, updating the config files or wherever the configuration is stored.
Definition: xmltransformerconf.cpp:94
KttsFilterConf::getLocation
QString getLocation(const QString &name)
Searches the $PATH variable for any file.
Definition: filterconf.cpp:130
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:32:25 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

jovie

Skip menu "jovie"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeaccessibility API Reference

Skip menu "kdeaccessibility API Reference"
  • jovie

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal