12 #include <QTreeWidget> 13 #include <QStackedWidget> 14 #include <QTextBrowser> 16 #include <QGridLayout> 17 #include <QPushButton> 18 #include <QScrollArea> 20 #include <QMessageBox> 22 #include <QTextStream> 26 #define SA(x) QString::fromLatin1(x) 69 QDomDocument configXml;
70 if (file.
open(QIODevice::ReadOnly))
72 if (!configXml.setContent(&file,
false,&err,&errLine,&errCol))
74 QString msg = tr(
"Error parsing internal config.xml at line %1 column %2.\n%3").
75 arg(errLine).arg(errCol).arg(err);
85 m_helper->setOpenExternalLinks(
true);
90 QWidget *rightSide =
new QWidget;
91 QGridLayout *grid =
new QGridLayout(rightSide);
92 m_prev =
new QPushButton(tr(
"Previous"));
94 m_next =
new QPushButton(tr(
"Next"));
98 grid->setColumnStretch(0,1);
99 grid->setRowStretch(0,1);
102 addWidget(rightSide);
112 QHashIterator<QString,Input*> i(
m_options);
123 QDomElement childElem = rootElem.firstChildElement();
124 while (!childElem.isNull())
126 if (childElem.tagName()==
SA(
"group"))
135 childElem = childElem.nextSiblingElement();
140 SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)),
150 QDomElement docsVal = child.firstChildElement();
151 while (!docsVal.isNull())
153 if (docsVal.tagName()==
SA(
"docs") &&
154 docsVal.attribute(
SA(
"doxywizard")) !=
SA(
"0"))
156 for (QDomNode
n = docsVal.firstChild(); !
n.isNull();
n =
n.nextSibling())
158 QDomText
t =
n.toText();
159 if (!t.isNull()) docs+=t.
data();
163 docsVal = docsVal.nextSiblingElement();
167 if (type==
SA(
"enum"))
170 docs +=
SA(
"Possible values are: ");
172 docsVal = child.firstChildElement();
173 while (!docsVal.isNull())
175 if (docsVal.tagName()==
SA(
"value"))
179 docsVal = docsVal.nextSiblingElement();
182 docsVal = child.firstChildElement();
183 while (!docsVal.isNull())
185 if (docsVal.tagName()==
SA(
"value"))
188 docs +=
SA(
"<code>") + docsVal.attribute(
SA(
"name")) +
SA(
"</code>");
198 else if (i==numValues)
207 docsVal = docsVal.nextSiblingElement();
211 docs+=
SA(
" The default value is: <code>")+
212 child.attribute(
SA(
"defval"))+
216 else if (type==
SA(
"int"))
219 docs+=
SA(
"Minimum value: ")+child.attribute(
SA(
"minval"))+
SA(
", ");
220 docs+=
SA(
"maximum value: ")+child.attribute(
SA(
"maxval"))+
SA(
", ");
221 docs+=
SA(
"default value: ")+child.attribute(
SA(
"defval"))+
SA(
".");
224 else if (type==
SA(
"bool"))
227 if (child.hasAttribute(
SA(
"altdefval")))
229 docs+=
SA(
" The default value is: system dependent.");
233 QString defval = child.attribute(
SA(
"defval"));
234 docs+=
SA(
" The default value is: <code>")+
235 (defval==
SA(
"1")?
SA(
"YES"):
SA(
"NO"))+
240 else if (type==
SA(
"list"))
242 if (child.attribute(
SA(
"format"))==
SA(
"string"))
245 docsVal = child.firstChildElement();
246 while (!docsVal.isNull())
248 if (docsVal.tagName()==
SA(
"value"))
251 if (docsVal.hasAttribute(
SA(
"show_docu")))
253 showDocu = docsVal.attribute(
SA(
"show_docu")).toLower();
255 if ((showDocu !=
SA(
"no")) && (docsVal.attribute(
SA(
"name"))!=
SA(
""))) numValues++;
257 docsVal = docsVal.nextSiblingElement();
262 docsVal = child.firstChildElement();
263 while (!docsVal.isNull())
265 if (docsVal.tagName()==
SA(
"value"))
268 if (docsVal.hasAttribute(
SA(
"show_docu")))
270 showDocu = docsVal.attribute(
SA(
"show_docu")).toLower();
272 if ((showDocu !=
SA(
"no")) && (docsVal.attribute(
SA(
"name"))!=
SA(
"")))
275 docs +=
SA(
"<code>") + docsVal.attribute(
SA(
"name")) +
SA(
"</code>");
285 else if (i==numValues)
295 docsVal = docsVal.nextSiblingElement();
301 else if (type==
SA(
"string"))
303 QString defval = child.attribute(
SA(
"defval"));
304 if (child.attribute(
SA(
"format")) ==
SA(
"dir"))
306 if (defval !=
SA(
""))
309 docs +=
SA(
" The default directory is: <code>") + defval +
SA(
"</code>.");
313 else if (child.attribute(
SA(
"format")) ==
SA(
"file"))
315 QString abspath = child.attribute(
SA(
"abspath"));
316 if (defval !=
SA(
""))
319 if (abspath !=
SA(
"1"))
321 docs +=
SA(
" The default file is: <code>") + defval +
SA(
"</code>.");
325 docs +=
SA(
" The default file (with absolute path) is: <code>") + defval +
SA(
"</code>.");
331 if (abspath ==
SA(
"1"))
334 docs +=
SA(
" The file has to be specified with full path.");
339 else if (child.attribute(
SA(
"format")) ==
SA(
"image"))
341 QString abspath = child.attribute(
SA(
"abspath"));
342 if (defval !=
SA(
""))
345 if (abspath !=
SA(
"1"))
347 docs +=
SA(
" The default image is: <code>") + defval +
SA(
"</code>.");
351 docs +=
SA(
" The default image (with absolute path) is: <code>") + defval +
SA(
"</code>.");
357 if (abspath ==
SA(
"1"))
360 docs +=
SA(
" The image has to be specified with full path.");
367 if (defval !=
SA(
""))
370 docs +=
SA(
" The default value is: <code>") + defval +
SA(
"</code>.");
376 if (child.hasAttribute(
SA(
"depends")))
378 QString dependsOn = child.attribute(
SA(
"depends"));
380 docs+=
SA(
" This tag requires that the tag \\ref cfg_");
381 docs+= dependsOn.toLower();
383 docs+= dependsOn.toUpper();
384 docs+=
SA(
"\" is set to <code>YES</code>.");
398 docs.
replace(regexp,
SA(
"<code>\\1</code>)"));
401 docs.
replace(regexp,
SA(
"<code>\\1</code>,"));
404 docs.
replace(regexp,
SA(
"<code>\\1</code>."));
407 docs.
replace(regexp,
SA(
"<code>\\1</code> "));
411 docs.
replace(regexp,
SA(
"<code>\\1</code>"));
413 regexp.
setPattern(
SA(
"\\\\ref[ ]+[^ ]+[ ]+\"([^ ]+)\""));
414 docs.
replace(regexp,
SA(
"<code>\\1</code> "));
418 docs.
replace(regexp,
SA(
"\"Doxygen usage\""));
420 docs.
replace(regexp,
SA(
"\"External Indexing and Searching\""));
422 docs.
replace(regexp,
SA(
"\"Linking to external documentation\""));
430 docs.
replace(regexp,
SA(
"<em>\\1</em> "));
464 docs.
replace(regexp,
SA(
" <a href=\"\\1\">\\1</a>\\2"));
466 regexp.
setPattern(
SA(
"\\\\f\\$\\\\mbox\\{\\\\LaTeX\\}\\\\f\\$"));
469 regexp.
setPattern(
SA(
"\\\\f\\$2\\^\\{\\(16\\+\\\\mbox\\{LOOKUP\\\\_CACHE\\\\_SIZE\\}\\)\\}\\\\f\\$"));
470 docs.
replace(regexp,
SA(
"2^(16+LOOKUP_CACHE_SIZE)"));
471 regexp.
setPattern(
SA(
"\\\\f\\$2\\^\\{16\\} = 65536\\\\f\\$"));
474 return docs.trimmed();
479 QScrollArea *area =
new QScrollArea;
480 QWidget *topic =
new QWidget;
481 QGridLayout *layout =
new QGridLayout(topic);
482 QDomElement child = elem.firstChildElement();
484 while (!child.isNull())
486 QString setting = child.attribute(
SA(
"setting"));
491 if (type==
SA(
"bool"))
496 child.attribute(
SA(
"id")),
497 child.attribute(
SA(
"defval"))==
SA(
"1"),
501 child.attribute(
SA(
"id")),
507 else if (type==
SA(
"string"))
511 if (format==
SA(
"dir"))
515 else if (format==
SA(
"file"))
519 else if (format==
SA(
"image"))
530 child.attribute(
SA(
"id")),
531 child.attribute(
SA(
"defval")),
534 child.attribute(
SA(
"abspath"))
537 child.attribute(
SA(
"id")),
543 else if (type==
SA(
"enum"))
547 child.attribute(
SA(
"id")),
548 child.attribute(
SA(
"defval")),
552 QDomElement enumVal = child.firstChildElement();
553 while (!enumVal.isNull())
555 if (enumVal.tagName()==
SA(
"value"))
557 enumList->
addValue(enumVal.attribute(
SA(
"name")));
559 enumVal = enumVal.nextSiblingElement();
563 m_options.insert(child.attribute(
SA(
"id")),enumList);
567 else if (type==
SA(
"int"))
572 child.attribute(
SA(
"id")),
573 child.attribute(
SA(
"defval")).toInt(),
574 child.attribute(
SA(
"minval")).toInt(),
575 child.attribute(
SA(
"maxval")).toInt(),
579 child.attribute(
SA(
"id")),
585 else if (type==
SA(
"list"))
589 if (format==
SA(
"dir"))
593 else if (format==
SA(
"file"))
597 else if (format==
SA(
"filedir"))
606 QDomElement listVal = child.firstChildElement();
607 while (!listVal.isNull())
609 if (listVal.tagName()==
SA(
"value"))
611 sl.
append(listVal.attribute(
SA(
"name")));
613 listVal = listVal.nextSiblingElement();
618 child.attribute(
SA(
"id")),
624 child.attribute(
SA(
"id")),
630 else if (type==
SA(
"obsolete"))
636 printf(
"Unsupported type %s\n",qPrintable(child.attribute(
SA(
"type"))));
639 child = child.nextSiblingElement();
643 child = elem.firstChildElement();
644 while (!child.isNull())
646 QString setting = child.attribute(
SA(
"setting"));
647 QString dependsOn = child.attribute(
SA(
"depends"));
655 printf(
"%s has depends=%s that is not valid\n",
656 qPrintable(
id),qPrintable(dependsOn));
659 Q_ASSERT(parentOption);
660 Q_ASSERT(thisOption);
661 if (parentOption && thisOption)
669 child = child.nextSiblingElement();
673 QHashIterator<QString,Input*> i(
m_options);
679 i.value()->updateDependencies();
683 layout->setRowStretch(row,1);
684 layout->setColumnStretch(1,2);
685 layout->setSpacing(5);
686 topic->setLayout(layout);
687 area->setWidget(topic);
688 area->setWidgetResizable(
true);
705 QHashIterator<QString,Input*> i(
m_options);
709 QVariant
var = s->value(
SA(
"config/")+i.key());
713 i.value()->value() =
var;
721 QHashIterator<QString,Input*> i(
m_options);
728 s->setValue(
SA(
"config/")+i.key(),i.value()->value());
746 t <<
"#---------------------------------------------------------------------------" <<
endl;
747 t <<
"# " << elem.attribute(
SA(
"docs")) <<
endl;
748 t <<
"#---------------------------------------------------------------------------" <<
endl;
750 QDomElement childElem = elem.firstChildElement();
751 while (!childElem.isNull())
753 QString setting = childElem.attribute(
SA(
"setting"));
762 if (option && !brief)
776 childElem = childElem.nextSiblingElement();
800 while (!childElem.isNull())
802 if (childElem.tagName()==
SA(
"group"))
806 childElem = childElem.nextSiblingElement();
831 replace(QChar::fromLatin1(
'\n'),QChar::fromLatin1(
' '))+
864 QHashIterator<QString,Input*> i(
m_options);
894 return option->
value().toString();
901 if (!generateHtml || workingDir.
isEmpty())
return false;
913 QString indexFile = workingDir;
916 indexFile = outputDir;
922 if (
QFileInfo(htmlOutputDir).isAbsolute())
924 indexFile = htmlOutputDir;
938 if (!generateLatex || !pdfLatex)
return false;
void activateTopic(QTreeWidgetItem *, QTreeWidgetItem *)
void setHeader(const char *name)
QTreeWidget * m_treeWidget
void saveTopic(QTextStream &t, QDomElement &elem, QTextCodec *codec, bool brief)
Iterator append(const T &x)
bool writeConfig(QTextStream &t, bool brief)
QWidget * createTopicWidget(QDomElement &elem)
The QRegExp class provides pattern matching using regular expressions or wildcards.
void msg(const char *fmt,...)
static bool stringVariantToBool(const QVariant &v)
bool htmlOutputPresent(const QString &workingDir) const
void append(const type *d)
QByteArray saveInnerState() const
QHash< QString, Input * > m_options
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
void addConfigDocs(DocIntf *doc)
QString getHtmlOutputIndex(const QString &workingDir) const
void setPattern(const QCString &pattern)
static QString fromLatin1(const char *, int len=-1)
def connect(nxgraph, k1, k2, p1=0, p2=0, kwds)
void add(const char *name, const char *doc)
void createTopics(const QDomElement &)
const char * data() const
static bool getBoolOption(const QHash< QString, Input * > &model, const QString &name)
QStackedWidget * m_topicStack
static QString getStringOption(const QHash< QString, Input * > &model, const QString &name)
static QString getDocsForNode(const QDomElement &child)
bool parseConfig(const QString &fileName, const QHash< QString, Input * > &options)
QString & replace(uint index, uint len, const QString &)
void saveSettings(QSettings *)
bool restoreInnerState(const QByteArray &state)
void err(const char *fmt,...)
The QFile class is an I/O device that operates on files.
The QTextStream class provides basic functions for reading and writing text using a QIODevice...
static QTextCodec * codecForName(const char *hint, int accuracy=0)
void loadSettings(QSettings *)
QDomElement m_rootElement
void loadConfig(const QString &fileName)
Provides conversion between text encodings.
QHash< QString, QWidget * > m_topics
The QFileInfo class provides system-independent file information.
bool pdfOutputPresent(const QString &workingDir) const
QCString & replace(uint index, uint len, const char *s)
QTextStream & endl(QTextStream &s)
static QString convertToComment(const QString &s)