diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-01-17 12:33:55 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-01-26 07:35:30 +0000 |
commit | ec3dcfd6ad6719baa96aae26e0b775db1408e6e3 (patch) | |
tree | d94e31536f6c78033bd3881eccc12aeaa28d91c7 /src/plugins/cppeditor/cppminimizableinfobars.h | |
parent | 3080bda0661989e88dfa62101b4c3f5d5e6754a1 (diff) | |
download | qt-creator-ec3dcfd6ad6719baa96aae26e0b775db1408e6e3.tar.gz |
CppEditor: Show info bar for project-less file
While at it, centralize the code for handling the info bars and actions.
Change-Id: Ied62e3db268aaff3ef87e246bfe2b50399341be3
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppminimizableinfobars.h')
-rw-r--r-- | src/plugins/cppeditor/cppminimizableinfobars.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/plugins/cppeditor/cppminimizableinfobars.h b/src/plugins/cppeditor/cppminimizableinfobars.h new file mode 100644 index 0000000000..624433d86f --- /dev/null +++ b/src/plugins/cppeditor/cppminimizableinfobars.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QAction> +#include <QHash> +#include <QObject> + +#include <functional> + +namespace Core { +class Id; +class InfoBar; +} + +namespace CppEditor { +namespace Internal { + +class MinimizableInfoBars : public QObject +{ + Q_OBJECT + +public: + using DiagnosticWidgetCreator = std::function<QWidget *()>; + using ActionCreator = std::function<QAction *(QWidget *widget)>; + using Actions = QHash<Core::Id, QAction *>; + + static Actions createShowInfoBarActions(const ActionCreator &actionCreator); + +public: + explicit MinimizableInfoBars(Core::InfoBar &infoBar, QObject *parent = 0); + + // Expected call order: processHasProjectPart(), processHeaderDiagnostics() + void processHasProjectPart(bool hasProjectPart); + void processHeaderDiagnostics(const DiagnosticWidgetCreator &diagnosticWidgetCreator); + +signals: + void showAction(const Core::Id &id, bool show); + +private: + void updateNoProjectConfiguration(); + void updateHeaderErrors(); + + void addNoProjectConfigurationEntry(const Core::Id &id); + void addHeaderErrorEntry(const Core::Id &id, + const DiagnosticWidgetCreator &diagnosticWidgetCreator); + +private: + Core::InfoBar &m_infoBar; + + bool m_hasProjectPart = true; + DiagnosticWidgetCreator m_diagnosticWidgetCreator; +}; + +} // namespace Internal +} // namespace CppEditor |