Cppcheck
common.h
Go to the documentation of this file.
1 /*
2  * Cppcheck - A tool for static C/C++ code analysis
3  * Copyright (C) 2007-2023 Cppcheck team.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef COMMON_H
20 #define COMMON_H
21 
22 #include <QMap>
23 #include <QString>
24 
25 /// @addtogroup GUI
26 /// @{
27 
28 #define CLANG_ANALYZER "clang-analyzer"
29 #define CLANG_TIDY "clang-tidy"
30 
31 /**
32  * QSetting value names
33  */
34 
35 // Window/dialog sizes
36 #define SETTINGS_WINDOW_MAXIMIZED "Window maximized"
37 #define SETTINGS_WINDOW_WIDTH "Window width"
38 #define SETTINGS_WINDOW_HEIGHT "Window height"
39 #define SETTINGS_MAINWND_SPLITTER_STATE "Mainwindow/Vertical splitter state"
40 #define SETTINGS_CHECK_DIALOG_WIDTH "Check dialog width"
41 #define SETTINGS_CHECK_DIALOG_HEIGHT "Check dialog height"
42 #define SETTINGS_PROJECT_DIALOG_WIDTH "Project dialog width"
43 #define SETTINGS_PROJECT_DIALOG_HEIGHT "Project dialog height"
44 
45 // Main window settings
46 #define SETTINGS_RESULT_COLUMN_WIDTH "Result column %1 width"
47 #define SETTINGS_TOOLBARS_MAIN_SHOW "Toolbars/ShowStandard"
48 #define SETTINGS_TOOLBARS_VIEW_SHOW "Toolbars/ShowView"
49 #define SETTINGS_TOOLBARS_FILTER_SHOW "Toolbars/ShowFilter"
50 
51 // Show * states
52 #define SETTINGS_SHOW_STYLE "Show style"
53 #define SETTINGS_SHOW_ERRORS "Show errors"
54 #define SETTINGS_SHOW_WARNINGS "Show warnings"
55 #define SETTINGS_SHOW_PERFORMANCE "Show performance"
56 #define SETTINGS_SHOW_INFORMATION "Show information"
57 #define SETTINGS_SHOW_PORTABILITY "Show portability"
58 
59 // Standards support
60 #define SETTINGS_STD_CPP "Standard CPP"
61 #define SETTINGS_STD_C "Standard C"
62 
63 // Language enforcement
64 #define SETTINGS_ENFORCED_LANGUAGE "Enforced language"
65 
66 // Other settings
67 #define SETTINGS_CHECK_FORCE "Check force"
68 #define SETTINGS_CHECK_THREADS "Check threads"
69 #define SETTINGS_SHOW_FULL_PATH "Show full path"
70 #define SETTINGS_SHOW_NO_ERRORS "Show no errors message"
71 #define SETTINGS_SHOW_DEBUG_WARNINGS "Show debug warnings"
72 #define SETTINGS_SAVE_ALL_ERRORS "Save all errors"
73 #define SETTINGS_SAVE_FULL_PATH "Save full path"
74 #define SETTINGS_APPLICATION_NAMES "Application names"
75 #define SETTINGS_APPLICATION_PATHS "Application paths"
76 #define SETTINGS_APPLICATION_PARAMS "Application parameters"
77 #define SETTINGS_APPLICATION_DEFAULT "Default Application"
78 #define SETTINGS_LANGUAGE "Application language"
79 #define SETTINGS_GLOBAL_INCLUDE_PATHS "Global include paths"
80 #define SETTINGS_PYTHON_PATH "Python path"
81 #define SETTINGS_MISRA_FILE "MISRA C 2012 file"
82 #define SETTINGS_CLANG_PATH "Clang path"
83 #define SETTINGS_VS_INCLUDE_PATHS "VS include paths"
84 #define SETTINGS_INLINE_SUPPRESSIONS "Inline suppressions"
85 #define SETTINGS_INCONCLUSIVE_ERRORS "Inconclusive errors"
86 #define SETTINGS_MRU_PROJECTS "MRU Projects"
87 #define SETTINGS_SHOW_ERROR_ID "Show error Id"
88 #define SETTINGS_SHOW_STATISTICS "Show statistics"
89 #define SETTINGS_OPEN_PROJECT "Open Project"
90 #define SETTINGS_CHECK_VERSION "Check Version"
91 #define SETTINGS_CHECK_FOR_UPDATES "Check for updates"
92 
93 // The maximum value for the progress bar
94 #define PROGRESS_MAX 1024.0
95 
96 #define SETTINGS_CHECKED_PLATFORM "Checked platform"
97 
98 #define SETTINGS_LAST_CHECK_PATH "Last check path"
99 #define SETTINGS_LAST_PROJECT_PATH "Last project path"
100 #define SETTINGS_LAST_RESULT_PATH "Last result path"
101 #define SETTINGS_LAST_SOURCE_PATH "Last source path"
102 #define SETTINGS_LAST_APP_PATH "Last application path"
103 
104 #define SETTINGS_LAST_ANALYZE_FILES_FILTER "Last analyze files filter"
105 
106 /**
107  * @brief Obtains the path of specified type
108  * Returns the path of specified type if not empty. Otherwise returns last check
109  * path if valid or user's home directory.
110  * @param type Type of path to obtain
111  * @return Best path for provided type
112  */
113 QString getPath(const QString &type);
114 
115 /**
116  * @brief Stores last used path of specified type
117  * Stores provided path as last used path for specified type.
118  * @param type Type of the path to store
119  * @param value Path to store
120  */
121 void setPath(const QString &type, const QString &value);
122 
123 /**
124  * @brief Creates a string suitable for passing as the filter argument to
125  * methods like QFileDialog::getOpenFileName.
126  * @param filters A map of filter descriptions to the associated file name
127  * patterns.
128  * @param addAllSupported If set to true (the default), the function will
129  * include a filter entry containing all the file name patterns found in
130  * \p filters. This entry will be the first in the resulting filter string.
131  * @param addAll If set to true (the default), the function will
132  * include a filter entry displaying all files. This entry will be placed
133  * after the entry for \p addAllSupported files.
134  *
135  * Example usage:
136  *
137  * @code
138  * QMap<QString,QString> filters;
139  * filters[tr("Supported images")] = "*.bmp *.jpg *.png";
140  * filters[tr("Plain text")] = "*.txt";
141  *
142  * const QString filterString = toFilterString(filters);
143  *
144  * // filterString contains "All supported files (*.txt *.bmp *.jpg *.png);;All files (*.*);;Plain text (*.txt);;Supported images (*.bmp *.jpg *.png)"
145  * @endcode
146  */
147 QString toFilterString(const QMap<QString,QString>& filters, bool addAllSupported=true, bool addAll=true);
148 
149 /**
150  * Get configured data dir. If not configured then it will try to determine that from exe path.
151  */
152 QString getDataDir();
153 
154 /// @}
155 #endif
QString getPath(const QString &type)
Obtains the path of specified type Returns the path of specified type if not empty.
Definition: common.cpp:32
QString getDataDir()
Get configured data dir.
Definition: common.cpp:75
QString toFilterString(const QMap< QString, QString > &filters, bool addAllSupported=true, bool addAll=true)
Creates a string suitable for passing as the filter argument to methods like QFileDialog::getOpenFile...
Definition: common.cpp:52
void setPath(const QString &type, const QString &value)
Stores last used path of specified type Stores provided path as last used path for specified type.
Definition: common.cpp:46