Files
pilotclient/src/blackgui/components/aircraftmodelstringcompleter.h
Klaus Basan bf390f592a Ref T171, formatting of some existing completers
* private slots -> private
* this->m_ -> m_
* removed unused utility function (model string completer)
2017-10-18 22:58:57 +02:00

102 lines
3.0 KiB
C++

/* Copyright (C) 2016
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKGUI_COMPLETER_AIRCRAFTMODELSTRINGCOMPLETER_H
#define BLACKGUI_COMPLETER_AIRCRAFTMODELSTRINGCOMPLETER_H
#include "blackmisc/simulation/data/modelcaches.h"
#include "blackmisc/simulation/aircraftmodel.h"
#include <QFrame>
#include <QScopedPointer>
#include <QCompleter>
#include <QFlags>
namespace Ui { class CAircraftModelStringCompleter; }
namespace BlackGui
{
namespace Components
{
/*!
* Completer for model strings
*/
class CAircraftModelStringCompleter : public QFrame
{
Q_OBJECT
public:
//! Sources for string completion
enum CompleterSourceFlag
{
None = 0, //!< normally used to indicate nothing was loaded
DB = 1 << 0,
ModelSet = 1 << 1,
OwnModels = 1 << 2
};
Q_DECLARE_FLAGS(CompleterSource, CompleterSourceFlag)
//! Constructor
explicit CAircraftModelStringCompleter(QWidget *parent = nullptr);
//! Destructor
virtual ~CAircraftModelStringCompleter();
//! The model string
QString getModelString() const;
//! Show the selection buttons
void showSourceSelection(bool show);
//! Set text
void setText(const QString &completersString);
//! Set model
void setModel(const BlackMisc::Simulation::CAircraftModel &model);
//! Show/hide radio buttons
void setSourceVisible(CompleterSource source, bool visible);
//! Set the currently selected source
void selectSource(CompleterSourceFlag source);
//! Clear
void clear();
signals:
//! Model has been changed
void modelStringChanged();
private:
//! Set the completer
void setCompleter();
//! Init the GUI
void initGui();
//! Value has been changed
void onTextChanged();
//! Simulator connected
void onSimulatorConnected(int status);
//! All swift data have been read
void onSwiftModelDataRead();
private:
QScopedPointer <Ui::CAircraftModelStringCompleter> ui;
BlackMisc::Simulation::Data::CModelCaches m_modelCaches { false, this }; //!< all models, works locally only
CompleterSourceFlag m_currentSourceWithData = None;
};
} // ns
} // ns
#endif // guard