Macros | Functions
expert.cpp File Reference
#include "expert.h"
#include "inputbool.h"
#include "inputstring.h"
#include "inputint.h"
#include "inputstrlist.h"
#include "config.h"
#include "version.h"
#include "configdoc.h"
#include "settings.h"
#include <QTreeWidget>
#include <QStackedWidget>
#include <QTextBrowser>
#include <QSplitter>
#include <QGridLayout>
#include <QPushButton>
#include <QScrollArea>
#include <QFile>
#include <QMessageBox>
#include <QSettings>
#include <QTextStream>
#include <QTextCodec>
#include <QFileInfo>

Go to the source code of this file.

Macros

#define SA(x)   QString::fromLatin1(x)
 

Functions

static QString convertToComment (const QString &s)
 
static QString getDocsForNode (const QDomElement &child)
 
static bool stringVariantToBool (const QVariant &v)
 
static bool getBoolOption (const QHash< QString, Input * > &model, const QString &name)
 
static QString getStringOption (const QHash< QString, Input * > &model, const QString &name)
 

Macro Definition Documentation

#define SA (   x)    QString::fromLatin1(x)

Definition at line 26 of file expert.cpp.

Function Documentation

static QString convertToComment ( const QString s)
static

Definition at line 29 of file expert.cpp.

30 {
31  if (s.isEmpty())
32  {
33  return QString();
34  }
35  else
36  {
37  return SA("# ")+
38  s.trimmed().replace(SA("\n"),SA("\n# ")).replace(SA("# \n"), SA("#\n"))+
39  SA("\n");
40  }
41 }
bool isEmpty() const
Definition: qstring.h:682
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
#define SA(x)
Definition: expert.cpp:26
QString & replace(uint index, uint len, const QString &)
Definition: qstring.cpp:13665
static bool getBoolOption ( const QHash< QString, Input * > &  model,
const QString name 
)
static

Definition at line 881 of file expert.cpp.

883 {
884  Input *option = model[name];
885  Q_ASSERT(option!=0);
886  return stringVariantToBool(option->value());
887 }
static QCString name
Definition: declinfo.cpp:673
virtual QVariant & value()=0
static bool stringVariantToBool(const QVariant &v)
Definition: expert.cpp:875
Definition: model.py:1
Definition: input.h:9
static QString getDocsForNode ( const QDomElement &  child)
static

Definition at line 145 of file expert.cpp.

146 {
147  QString type = child.attribute(SA("type"));
148  QString docs = SA("");
149  // read documentation text
150  QDomElement docsVal = child.firstChildElement();
151  while (!docsVal.isNull())
152  {
153  if (docsVal.tagName()==SA("docs") &&
154  docsVal.attribute(SA("doxywizard")) != SA("0"))
155  {
156  for (QDomNode n = docsVal.firstChild(); !n.isNull(); n = n.nextSibling())
157  {
158  QDomText t = n.toText();
159  if (!t.isNull()) docs+=t.data();
160  }
161  docs += SA("<br/>");
162  }
163  docsVal = docsVal.nextSiblingElement();
164  }
165 
166  // for an enum we list the values
167  if (type==SA("enum"))
168  {
169  docs += SA("<br/>");
170  docs += SA("Possible values are: ");
171  int numValues=0;
172  docsVal = child.firstChildElement();
173  while (!docsVal.isNull())
174  {
175  if (docsVal.tagName()==SA("value"))
176  {
177  numValues++;
178  }
179  docsVal = docsVal.nextSiblingElement();
180  }
181  int i=0;
182  docsVal = child.firstChildElement();
183  while (!docsVal.isNull())
184  {
185  if (docsVal.tagName()==SA("value"))
186  {
187  i++;
188  docs += SA("<code>") + docsVal.attribute(SA("name")) + SA("</code>");
189  QString desc = docsVal.attribute(SA("desc"));
190  if (!desc.isEmpty())
191  {
192  docs+= SA(" ")+desc;
193  }
194  if (i==numValues-1)
195  {
196  docs+=SA(" and ");
197  }
198  else if (i==numValues)
199  {
200  docs+=SA(".");
201  }
202  else
203  {
204  docs+=SA(", ");
205  }
206  }
207  docsVal = docsVal.nextSiblingElement();
208  }
209  docs+=SA("<br/>");
210  docs+=SA("<br/>");
211  docs+=SA(" The default value is: <code>")+
212  child.attribute(SA("defval"))+
213  SA("</code>.");
214  docs+= SA("<br/>");
215  }
216  else if (type==SA("int"))
217  {
218  docs+=SA("<br/>");
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(".");
222  docs+= SA("<br/>");
223  }
224  else if (type==SA("bool"))
225  {
226  docs+=SA("<br/>");
227  if (child.hasAttribute(SA("altdefval")))
228  {
229  docs+=SA(" The default value is: system dependent.");
230  }
231  else
232  {
233  QString defval = child.attribute(SA("defval"));
234  docs+=SA(" The default value is: <code>")+
235  (defval==SA("1")?SA("YES"):SA("NO"))+
236  SA("</code>.");
237  }
238  docs+= SA("<br/>");
239  }
240  else if (type==SA("list"))
241  {
242  if (child.attribute(SA("format"))==SA("string"))
243  {
244  int numValues = 0;
245  docsVal = child.firstChildElement();
246  while (!docsVal.isNull())
247  {
248  if (docsVal.tagName()==SA("value"))
249  {
250  QString showDocu = SA("");
251  if (docsVal.hasAttribute(SA("show_docu")))
252  {
253  showDocu = docsVal.attribute(SA("show_docu")).toLower();
254  }
255  if ((showDocu != SA("no")) && (docsVal.attribute(SA("name"))!=SA(""))) numValues++;
256  }
257  docsVal = docsVal.nextSiblingElement();
258  }
259  if (numValues>0)
260  {
261  int i = 0;
262  docsVal = child.firstChildElement();
263  while (!docsVal.isNull())
264  {
265  if (docsVal.tagName()==SA("value"))
266  {
267  QString showDocu = SA("");
268  if (docsVal.hasAttribute(SA("show_docu")))
269  {
270  showDocu = docsVal.attribute(SA("show_docu")).toLower();
271  }
272  if ((showDocu != SA("no")) && (docsVal.attribute(SA("name"))!=SA("")))
273  {
274  i++;
275  docs += SA("<code>") + docsVal.attribute(SA("name")) + SA("</code>");
276  QString desc = docsVal.attribute(SA("desc"));
277  if (desc != SA(""))
278  {
279  docs += SA(" ") + desc;
280  }
281  if (i==numValues-1)
282  {
283  docs += SA(" and ");
284  }
285  else if (i==numValues)
286  {
287  docs += SA(".");
288  }
289  else
290  {
291  docs += SA(", ");
292  }
293  }
294  }
295  docsVal = docsVal.nextSiblingElement();
296  }
297  }
298  // docs+= SA("<br/>");
299  }
300  }
301  else if (type==SA("string"))
302  {
303  QString defval = child.attribute(SA("defval"));
304  if (child.attribute(SA("format")) == SA("dir"))
305  {
306  if (defval != SA(""))
307  {
308  docs+=SA("<br/>");
309  docs += SA(" The default directory is: <code>") + defval + SA("</code>.");
310  docs += SA("<br/>");
311  }
312  }
313  else if (child.attribute(SA("format")) == SA("file"))
314  {
315  QString abspath = child.attribute(SA("abspath"));
316  if (defval != SA(""))
317  {
318  docs+=SA("<br/>");
319  if (abspath != SA("1"))
320  {
321  docs += SA(" The default file is: <code>") + defval + SA("</code>.");
322  }
323  else
324  {
325  docs += SA(" The default file (with absolute path) is: <code>") + defval + SA("</code>.");
326  }
327  docs += SA("<br/>");
328  }
329  else
330  {
331  if (abspath == SA("1"))
332  {
333  docs+=SA("<br/>");
334  docs += SA(" The file has to be specified with full path.");
335  docs += SA("<br/>");
336  }
337  }
338  }
339  else if (child.attribute(SA("format")) == SA("image"))
340  {
341  QString abspath = child.attribute(SA("abspath"));
342  if (defval != SA(""))
343  {
344  docs+=SA("<br/>");
345  if (abspath != SA("1"))
346  {
347  docs += SA(" The default image is: <code>") + defval + SA("</code>.");
348  }
349  else
350  {
351  docs += SA(" The default image (with absolute path) is: <code>") + defval + SA("</code>.");
352  }
353  docs += SA("<br/>");
354  }
355  else
356  {
357  if (abspath == SA("1"))
358  {
359  docs+=SA("<br/>");
360  docs += SA(" The image has to be specified with full path.");
361  docs += SA("<br/>");
362  }
363  }
364  }
365  else // if (child.attribute(SA("format")) == SA("string"))
366  {
367  if (defval != SA(""))
368  {
369  docs+=SA("<br/>");
370  docs += SA(" The default value is: <code>") + defval + SA("</code>.");
371  docs += SA("<br/>");
372  }
373  }
374  }
375 
376  if (child.hasAttribute(SA("depends")))
377  {
378  QString dependsOn = child.attribute(SA("depends"));
379  docs+=SA("<br/>");
380  docs+= SA(" This tag requires that the tag \\ref cfg_");
381  docs+= dependsOn.toLower();
382  docs+= SA(" \"");
383  docs+= dependsOn.toUpper();
384  docs+= SA("\" is set to <code>YES</code>.");
385  }
386 
387  // Remove / replace doxygen markup strings
388  // the regular expressions are hard to read so the intention will be given
389  QRegExp regexp;
390  // remove \n at end and replace by a space
391  regexp.setPattern(SA("\\n$"));
392  docs.replace(regexp,SA(" "));
393  // remove <br> at end
394  regexp.setPattern(SA("<br> *$"));
395  docs.replace(regexp,SA(" "));
396  // \c word -> <code>word</code>; word ends with ')', ',', '.' or ' '
397  regexp.setPattern(SA("\\\\c[ ]+([^ \\)]+)\\)"));
398  docs.replace(regexp,SA("<code>\\1</code>)"));
399 
400  regexp.setPattern(SA("\\\\c[ ]+([^ ,]+),"));
401  docs.replace(regexp,SA("<code>\\1</code>,"));
402 
403  regexp.setPattern(SA("\\\\c[ ]+([^ \\.]+)\\."));
404  docs.replace(regexp,SA("<code>\\1</code>."));
405 
406  regexp.setPattern(SA("\\\\c[ ]+([^ ]+) "));
407  docs.replace(regexp,SA("<code>\\1</code> "));
408  // `word` -> <code>word</code>
409  docs.replace(SA("``"),SA(""));
410  regexp.setPattern(SA("`([^`]+)`"));
411  docs.replace(regexp,SA("<code>\\1</code>"));
412  // \ref key "desc" -> <code>desc</code>
413  regexp.setPattern(SA("\\\\ref[ ]+[^ ]+[ ]+\"([^ ]+)\""));
414  docs.replace(regexp,SA("<code>\\1</code> "));
415  //\ref specials
416  // \ref <key> -> description
417  regexp.setPattern(SA("\\\\ref[ ]+doxygen_usage"));
418  docs.replace(regexp,SA("\"Doxygen usage\""));
419  regexp.setPattern(SA("\\\\ref[ ]+extsearch"));
420  docs.replace(regexp,SA("\"External Indexing and Searching\""));
421  regexp.setPattern(SA("\\\\ref[ ]+external"));
422  docs.replace(regexp,SA("\"Linking to external documentation\""));
423  // fallback for not handled
424  docs.replace(SA("\\\\ref"),SA(""));
425  // \b word -> <b>word<\b>
426  regexp.setPattern(SA("\\\\b[ ]+([^ ]+) "));
427  docs.replace(regexp,SA("<b>\\1</b> "));
428  // \e word -> <em>word<\em>
429  regexp.setPattern(SA("\\\\e[ ]+([^ ]+) "));
430  docs.replace(regexp,SA("<em>\\1</em> "));
431  // \note -> <br>Note:
432  // @note -> <br>Note:
433  docs.replace(SA("\\note"),SA("<br>Note:"));
434  docs.replace(SA("@note"),SA("<br>Note:"));
435  // \#include -> #include
436  // \#undef -> #undef
437  docs.replace(SA("\\#include"),SA("#include"));
438  docs.replace(SA("\\#undef"),SA("#undef"));
439  // -# -> <br>-
440  // " - " -> <br>-
441  docs.replace(SA("-#"),SA("<br>-"));
442  docs.replace(SA(" - "),SA("<br>-"));
443  // \verbatim -> <pre>
444  // \endverbatim -> </pre>
445  docs.replace(SA("\\verbatim"),SA("<pre>"));
446  docs.replace(SA("\\endverbatim"),SA("</pre>"));
447  // \sa -> <br>See also:
448  // \par -> <br>
449  docs.replace(SA("\\sa"),SA("<br>See also:"));
450  docs.replace(SA("\\par"),SA("<br>"));
451  // 2xbackslash -> backslash
452  // \@ -> @
453  docs.replace(SA("\\\\"),SA("\\"));
454  docs.replace(SA("\\@"),SA("@"));
455  // \& -> &
456  // \$ -> $
457  docs.replace(SA("\\&"),SA("&"));
458  docs.replace(SA("\\$"),SA("$"));
459  // < -> &lt;
460  // > -> &gt;
461  docs.replace(SA("\\<"),SA("&lt;"));
462  docs.replace(SA("\\>"),SA("&gt;"));
463  regexp.setPattern(SA(" (http:[^ \\)]*)([ \\)])"));
464  docs.replace(regexp,SA(" <a href=\"\\1\">\\1</a>\\2"));
465  // LaTeX name as formula -> LaTeX
466  regexp.setPattern(SA("\\\\f\\$\\\\mbox\\{\\\\LaTeX\\}\\\\f\\$"));
467  docs.replace(regexp,SA("LaTeX"));
468  // Other formula's (now just 2) so explicitly mentioned.
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\\$"));
472  docs.replace(regexp,SA("2^16=65536"));
473 
474  return docs.trimmed();
475 }
bool isEmpty() const
Definition: qstring.h:682
The QRegExp class provides pattern matching using regular expressions or wildcards.
Definition: qregexp.h:46
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
#define SA(x)
Definition: expert.cpp:26
void setPattern(const QCString &pattern)
Definition: qregexp.h:71
const char * data() const
Definition: qstring.h:542
std::void_t< T > n
QString & replace(uint index, uint len, const QString &)
Definition: qstring.cpp:13665
static QString getStringOption ( const QHash< QString, Input * > &  model,
const QString name 
)
static

Definition at line 889 of file expert.cpp.

891 {
892  Input *option = model[name];
893  Q_ASSERT(option!=0);
894  return option->value().toString();
895 }
static QCString name
Definition: declinfo.cpp:673
virtual QVariant & value()=0
Definition: model.py:1
Definition: input.h:9
static bool stringVariantToBool ( const QVariant &  v)
static

Definition at line 875 of file expert.cpp.

876 {
877  QString s = v.toString().toLower();
878  return s==QString::fromLatin1("yes") || s==QString::fromLatin1("true") || s==QString::fromLatin1("1");
879 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
static QCString * s
Definition: config.cpp:1042