Cppcheck
applicationlist.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 APPLICATIONLIST_H
20 #define APPLICATIONLIST_H
21 
22 #include "application.h"
23 
24 #include <QList>
25 #include <QObject>
26 #include <QString>
27 
28 /// @addtogroup GUI
29 /// @{
30 
31 
32 /**
33  * @brief List of applications user has specified to open errors with.
34  */
35 class ApplicationList : public QObject {
36  Q_OBJECT
37 public:
38 
39  explicit ApplicationList(QObject *parent = nullptr);
40  ~ApplicationList() override;
41 
42  /**
43  * @brief Load all applications
44  *
45  * @return true if loading succeeded, false if there is problem with
46  * application list. Most probably because of older version settings need
47  * to be upgraded.
48  */
49  bool loadSettings();
50 
51  /**
52  * @brief Save all applications
53  */
54  void saveSettings() const;
55 
56  /**
57  * @brief Get the amount of applications in the list
58  * @return The count of applications
59  */
60  int getApplicationCount() const;
61 
62  /**
63  * @brief Get specific application's name
64  *
65  * @param index Index of the application whose name to get
66  * @return Name of the application
67  */
68  const Application& getApplication(const int index) const;
69  Application& getApplication(const int index);
70 
71  /**
72  * @brief Return the default application.
73  * @return Index of the default application.
74  */
75  int getDefaultApplication() const {
77  }
78 
79  /**
80  * @brief Add a new application
81  *
82  * @param app Application to add.
83  */
84  void addApplication(const Application &app);
85 
86  /**
87  * @brief Remove an application from the list
88  *
89  * @param index Index of the application to remove.
90  */
91  void removeApplication(const int index);
92 
93  /**
94  * @brief Set application as default application.
95  * @param index Index of the application to make the default one
96  */
97  void setDefault(const int index);
98 
99  /**
100  * @brief Remove all applications from this list and copy all applications from
101  * list given as a parameter.
102  * @param list Copying source
103  */
104  void copy(const ApplicationList *list);
105 
106 protected:
107 
108  /**
109  * @brief Clear the list
110  *
111  */
112  void clear();
113 
114 #ifdef _WIN32
115  /**
116  * @brief Find editor used by default in Windows.
117  * Check if Notepad++ is installed and use it. If not, use Notepad.
118  */
119  bool findDefaultWindowsEditor();
120 #endif
121 
122 private:
123 
124  bool checkAndAddApplication(const QString& appPath, const QString& name, const QString& parameters);
125 
126  /**
127  * @brief List of applications
128  *
129  */
130  QList<Application> mApplications;
131 
132  /**
133  * @brief Index of the default application.
134  *
135  */
137 };
138 /// @}
139 #endif // APPLICATIONLIST_H
List of applications user has specified to open errors with.
int mDefaultApplicationIndex
Index of the default application.
QList< Application > mApplications
List of applications.
bool loadSettings()
Load all applications.
void copy(const ApplicationList *list)
Remove all applications from this list and copy all applications from list given as a parameter.
void setDefault(const int index)
Set application as default application.
void clear()
Clear the list.
void saveSettings() const
Save all applications.
ApplicationList(QObject *parent=nullptr)
int getApplicationCount() const
Get the amount of applications in the list.
const Application & getApplication(const int index) const
Get specific application's name.
void removeApplication(const int index)
Remove an application from the list.
~ApplicationList() override
void addApplication(const Application &app)
Add a new application.
int getDefaultApplication() const
Return the default application.
bool checkAndAddApplication(const QString &appPath, const QString &name, const QString &parameters)
A class containing information of the application to execute.
Definition: application.h:43