Cppcheck
platforms.cpp
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 #include "platforms.h"
20 
21 Platforms::Platforms(QObject *parent)
22  : QObject(parent)
23 {
24  init();
25 }
26 
27 void Platforms::add(const QString &title, Platform::Type platform)
28 {
29  PlatformData plat;
30  plat.mTitle = title;
31  plat.mType = platform;
32  plat.mActMainWindow = nullptr;
33  mPlatforms << plat;
34 }
35 
37 {
38  add(tr("Native"), Platform::Type::Native);
39  add(tr("Unix 32-bit"), Platform::Type::Unix32);
40  add(tr("Unix 64-bit"), Platform::Type::Unix64);
41  add(tr("Windows 32-bit ANSI"), Platform::Type::Win32A);
42  add(tr("Windows 32-bit Unicode"), Platform::Type::Win32W);
43  add(tr("Windows 64-bit"), Platform::Type::Win64);
44 }
45 
47 {
48  return mPlatforms.count();
49 }
50 
52 {
53  QList<PlatformData>::iterator iter = mPlatforms.begin();
54  while (iter != mPlatforms.end()) {
55  if (iter->mType == platform) {
56  return *iter;
57  }
58  ++iter;
59  }
60  return mPlatforms.first();
61 }
void init()
Definition: platforms.cpp:36
void add(const QString &title, Platform::Type platform)
Definition: platforms.cpp:27
int getCount() const
Definition: platforms.cpp:46
Platforms(QObject *parent=nullptr)
Definition: platforms.cpp:21
QList< PlatformData > mPlatforms
Definition: platforms.h:55
PlatformData & get(Platform::Type platform)
Definition: platforms.cpp:51
Checked platform GUI-data.
Definition: platforms.h:36
Platform::Type mType
Type in the core.
Definition: platforms.h:38
QString mTitle
Text visible in the GUI.
Definition: platforms.h:37
QAction * mActMainWindow
Pointer to main window action item.
Definition: platforms.h:39