refs #300, moved components in own namespace and directory

This commit is contained in:
Klaus Basan
2014-07-27 14:56:51 +02:00
parent c500a561be
commit 3d41414d9e
64 changed files with 4104 additions and 3476 deletions

View File

@@ -0,0 +1,129 @@
/* Copyright (C) 2013
* 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.
*/
#ifndef BLACKGUI_TEXTMESSAGECOMPONENT_H
#define BLACKGUI_TEXTMESSAGECOMPONENT_H
//! \file
#include "blackgui/components/runtimebasedcomponent.h"
#include "blackgui/components/timerbasedcomponent.h"
#include "blackmisc/nwtextmessage.h"
#include "blackmisc/avaircraft.h"
#include <QTabWidget>
#include <QLineEdit>
#include <QTextEdit>
namespace Ui { class CTextMessageComponent; }
namespace BlackGui
{
namespace Components
{
//! Text message widget
class CTextMessageComponent : public QTabWidget, public CRuntimeBasedComponent
{
Q_OBJECT
public:
//! Tabs
enum Tab
{
TextMessagesAll,
TextMessagesUnicom,
TextMessagesCom1,
TextMessagesCom2
};
//! Constructor
explicit CTextMessageComponent(QWidget *parent = nullptr);
//! Destructor
~CTextMessageComponent();
//! SELCAL callback, SELCAL is obtained by that
void setSelcalCallback(const std::function<const QString(void)> &selcalCallback) { this->m_selcalCallback = selcalCallback; }
signals:
//! Message to be displayed in info window
void displayInInfoWindow(const BlackMisc::CVariant &message, int displayDurationMs) const;
public slots:
//! Command entered
void commandEntered();
/*!
* \brief Append text messages (received, to be sent) to GUI
* \param messages
* \param sending
*/
void appendTextMessagesToGui(const BlackMisc::Network::CTextMessageList &messages, bool sending = false);
//! Cockpit values changed, used to updated some components
void changedAircraftCockpit();
protected:
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
void runtimeHasBeenSet() override;
private:
Ui::CTextMessageComponent *ui;
QWidget *getTab(Tab tab); //!< enum to widget
std::function<const QString(void)> m_selcalCallback; //!< obtain SELCAL by that
QAction *m_clearTextEditAction;
QTextEdit *m_currentTextEdit;
/*!
* \brief Add new text message tab
* \param tabName name of the new tab, usually the channel name
* \return
*/
QWidget *addNewTextMessageTab(const QString &tabName);
//! Find text message tab by its name
QWidget *findTextMessageTabByName(const QString &name) const;
/*!
* \brief Private channel text message
* \param textMessage
* \param sending sending or receiving
*/
void addPrivateChannelTextMessage(const BlackMisc::Network::CTextMessage &textMessage, bool sending = false);
/*!
* Stub for sending a text message (eihter radio or private message).
* Sets sender / receiver depending on frequency / channel situation.
*/
BlackMisc::Network::CTextMessage getTextMessageStubForChannel();
//! own aircraft
const BlackMisc::Aviation::CAircraft getOwnAircraft() const { Q_ASSERT(this->getIContextOwnAircraft()); return this->getIContextOwnAircraft()->getOwnAircraft(); }
//! For this text message's recepient, is the current tab selected?
bool isCorrespondingTextMessageTabSelected(BlackMisc::Network::CTextMessage textMessage) const;
//! Network connected?
bool isNetworkConnected() const { return this->getIContextNetwork() && this->getIContextNetwork()->isConnected() ; }
//! Show current frequencies
void showCurrentFrequenciesFromCockpit();
private slots:
//! Close text message tab
void closeTextMessageTab();
//! Context menu for text edit including clear
void showContextMenuForTextEdit(const QPoint &pt);
//! Clear text edit
void clearTextEdit();
};
}
}
#endif // guard