LibrePCB Developers Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
windowsection.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_EDITOR_WINDOWSECTION_H
21#define LIBREPCB_EDITOR_WINDOWSECTION_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "appwindow.h"
27#include "utils/uiobjectlist.h"
28
30
31#include <QtCore>
32
33#include <memory>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39namespace editor {
40
41class GuiApplication;
42class WindowTab;
43
44/*******************************************************************************
45 * Class WindowSection
46 ******************************************************************************/
47
51class WindowSection final : public QObject {
52 Q_OBJECT
53
54public:
55 // Signals
57
58 // Constructors / Destructor
59 WindowSection() = delete;
60 WindowSection(const WindowSection& other) = delete;
61 explicit WindowSection(GuiApplication& app,
62 QObject* parent = nullptr) noexcept;
63 ~WindowSection() noexcept;
64
65 // General Methods
66 const ui::WindowSectionData& getUiData() const noexcept { return mUiData; }
67 void setUiData(const ui::WindowSectionData& data) noexcept;
68 void setHomeTabVisible(bool visible) noexcept;
69 void addTab(std::shared_ptr<WindowTab> tab, int index = -1) noexcept;
70 std::shared_ptr<WindowTab> removeTab(int index) noexcept;
71
72 template <typename T>
73 bool switchToTab() noexcept {
74 for (int i = 0; i < mTabs->count(); ++i) {
75 if (std::dynamic_pointer_cast<T>(mTabs->value(i))) {
77 highlight();
78 return true;
79 }
80 }
81 return false;
82 }
83
84 // Operator Overloadings
85 WindowSection& operator=(const WindowSection& rhs) = delete;
86
87signals:
88 void panelPageRequested(ui::PanelPage p);
91 void derivedUiDataChanged(std::size_t index);
92 void statusBarMessageChanged(const QString& message, int timeoutMs);
93
94private:
95 void setCurrentTab(int index) noexcept;
96 void trigger(ui::Action a) noexcept;
97 void highlight() noexcept;
98 void tabCloseRequested() noexcept;
99
100 typedef UiObjectList<WindowTab, ui::TabData> TabList;
101
103 std::shared_ptr<TabList> mTabs;
104 ui::WindowSectionData mUiData;
105};
106
107/*******************************************************************************
108 * End of File
109 ******************************************************************************/
110
111} // namespace editor
112} // namespace librepcb
113
114#endif
The Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
The GuiApplication class.
Definition guiapplication.h:60
The UiObjectList class.
Definition uiobjectlist.h:47
The WindowSection class.
Definition windowsection.h:51
void setCurrentTab(int index) noexcept
Definition windowsection.cpp:130
void highlight() noexcept
Definition windowsection.cpp:161
void derivedUiDataChanged(std::size_t index)
UiObjectList< WindowTab, ui::TabData > TabList
Definition windowsection.h:100
WindowSection & operator=(const WindowSection &rhs)=delete
void trigger(ui::Action a) noexcept
Definition windowsection.cpp:146
void setHomeTabVisible(bool visible) noexcept
Definition windowsection.cpp:79
void addTab(std::shared_ptr< WindowTab > tab, int index=-1) noexcept
Definition windowsection.cpp:89
ui::WindowSectionData mUiData
Definition windowsection.h:104
void statusBarMessageChanged(const QString &message, int timeoutMs)
void tabCloseRequested() noexcept
Definition windowsection.cpp:171
std::shared_ptr< WindowTab > removeTab(int index) noexcept
Definition windowsection.cpp:107
void panelPageRequested(ui::PanelPage p)
void setUiData(const ui::WindowSectionData &data) noexcept
Definition windowsection.cpp:68
const ui::WindowSectionData & getUiData() const noexcept
Definition windowsection.h:66
bool switchToTab() noexcept
Definition windowsection.h:73
Signal< WindowSection > onUiDataChanged
Definition windowsection.h:56
std::shared_ptr< TabList > mTabs
Definition windowsection.h:103
GuiApplication & mApp
Definition windowsection.h:102
WindowSection(const WindowSection &other)=delete
The WindowTab class.
Definition windowtab.h:47
Definition occmodel.cpp:77
Definition uuid.h:186