File indexing completed on 2024-04-21 15:55:47

0001 /***************************************************************************
0002   Copyright (C) 2012 by Michel Ludwig (michel.ludwig@kdemail.net)
0003  ***************************************************************************/
0004 
0005 /***************************************************************************
0006  *                                                                         *
0007  *   This program is free software; you can redistribute it and/or modify  *
0008  *   it under the terms of the GNU General Public License as published by  *
0009  *   the Free Software Foundation; either version 2 of the License, or     *
0010  *   (at your option) any later version.                                   *
0011  *                                                                         *
0012  ***************************************************************************/
0013 
0014 #ifndef TOOL_UTILS_H
0015 #define TOOL_UTILS_H
0016 
0017 #include <QMetaType>
0018 #include <QPair>
0019 #include <QString>
0020 
0021 #define DEFAULT_TOOL_CONFIGURATION "Default"
0022 
0023 namespace KileTool
0024 {
0025 
0026 class ToolConfigPair : public QPair<QString, QString>
0027 {
0028 public:
0029     ToolConfigPair();
0030     ToolConfigPair(const QString& toolName, const QString& configName);
0031 
0032     inline bool isValid() const
0033     {
0034         return !first.isEmpty();
0035     }
0036 
0037     /** If the first components are equal, we compare the second one but
0038      * an empty config name or the default tool config name should precede all others.
0039      **/
0040     bool operator<(const ToolConfigPair& p2) const;
0041 
0042     static QString userStringRepresentation(const QString& toolName, const QString& toolConfig);
0043     inline QString userStringRepresentation() const
0044     {
0045         return userStringRepresentation(first, second);
0046     }
0047 
0048     static QString configStringRepresentation(const QString& toolName, const QString& toolConfig);
0049     QString configStringRepresentation() const
0050     {
0051         return configStringRepresentation(first, second);
0052     }
0053 
0054     static ToolConfigPair fromConfigStringRepresentation(const QString& s);
0055 };
0056 
0057 }
0058 
0059 Q_DECLARE_METATYPE(KileTool::ToolConfigPair)
0060 
0061 #endif