Warning, file /office/kile/src/usermenu/usermenudata.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /***********************************************************************************
0002   Copyright (C) 2011-2012 by Holger Danielsson (holger.danielsson@versanet.de)
0003             (C) 2018 by Michel Ludwig (michel.ludwig@gmail.com)
0004  ***********************************************************************************/
0005 
0006 /***************************************************************************
0007  *                                                                         *
0008  *   This program is free software; you can redistribute it and/or modify  *
0009  *   it under the terms of the GNU General Public License as published by  *
0010  *   the Free Software Foundation; either version 2 of the License, or     *
0011  *   (at your option) any later version.                                   *
0012  *                                                                         *
0013  ***************************************************************************/
0014 
0015 
0016 #include "usermenu/usermenudata.h"
0017 
0018 #include "kiledebug.h"
0019 
0020 
0021 namespace KileMenu {
0022 
0023 UserMenuData::UserMenuData()
0024 {
0025     clear();
0026 }
0027 
0028 void UserMenuData::clear()
0029 {
0030     menutype  = Text;
0031     menutitle.clear();
0032     filename.clear();
0033     parameter.clear();
0034     text.clear();
0035     icon.clear();
0036     shortcut.clear();
0037 
0038     needsSelection   = false;
0039     useContextMenu   = false;
0040     replaceSelection = false;
0041     insertOutput     = false;
0042     selectInsertion  = false;
0043 }
0044 
0045 // static list for xml menu attributes
0046 QStringList UserMenuData::xmlMenuAttrList = QStringList() << "text" << "file" << "program" << "separator" << "submenu";
0047 
0048 // static list for xml menu tags
0049 QStringList UserMenuData::xmlMenuTagList = QStringList() << "text" << "filename" << "parameter"
0050         << "icon" << "shortcut"
0051         << "needsSelection"     << "useContextMenu" << "replaceSelection"
0052         << "selectInsertion"    << "insertOutput"   << "title";
0053 
0054 // static methods  for xml menu attributes
0055 UserMenuData::MenuType UserMenuData::xmlMenuType(const QString &name)
0056 {
0057     int index = xmlMenuAttrList.indexOf(name);
0058     return ( index >= 0 ) ? (UserMenuData::MenuType)index : UserMenuData::Text;
0059 }
0060 
0061 QString UserMenuData::xmlMenuTypeName(int index)
0062 {
0063     return xmlMenuAttrList[index];
0064 }
0065 
0066 // static methods  for xml menu tags
0067 int UserMenuData::xmlMenuTag(const QString &tag)
0068 {
0069     return xmlMenuTagList.indexOf(tag);
0070 }
0071 
0072 QString UserMenuData::xmlMenuTagName(int index)
0073 {
0074     return xmlMenuTagList[index];
0075 }
0076 
0077 
0078 // first, every backslash is replaced with the string "\\;" (backslash, followed by ':')
0079 // then, every line feed character '\n' is replaced with the string "\\n" (backslash, followed by 'n')
0080 QString UserMenuData::encodeLineFeed(const QString& string)
0081 {
0082     QString toReturn = string;
0083     toReturn = toReturn.replace(QLatin1Char('\\'), QLatin1String("\\;"));
0084     toReturn = toReturn.replace(QLatin1Char('\n'), QLatin1String("\\n"));
0085 
0086     return toReturn;
0087 }
0088 
0089 QString UserMenuData::decodeLineFeed(const QString& string)
0090 {
0091     QString toReturn = string;
0092     toReturn = toReturn.replace(QLatin1String("\\n"), QLatin1String("\n"));
0093     toReturn = toReturn.replace(QLatin1String("\\;"), QLatin1String("\\"));
0094 
0095     return toReturn;
0096 }
0097 
0098 }
0099