From 08a1de995a6621c56abca9f5f062bcffae9e629c Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Thu, 3 Sep 2015 16:34:04 +0000 Subject: [PATCH] refs #454 #455 #458 Remove obsolete code --- src/blackcore/context_audio_impl.cpp | 1 - src/blackgui/models/allmodelcontainers.h | 1 - src/blackgui/models/allmodels.h | 2 +- src/blackgui/models/keyboardkeylistmodel.cpp | 157 ---------- src/blackgui/models/keyboardkeylistmodel.h | 104 ------- src/blackgui/models/listmodelbase.cpp | 1 - src/blackgui/views/keyboardkeyview.cpp | 26 -- src/blackgui/views/keyboardkeyview.h | 34 -- src/blackgui/views/viewbase.cpp | 2 - src/blackmisc/blackmisc.pro | 2 - src/blackmisc/blackmiscfreefunctions.cpp | 7 - src/blackmisc/eventallclasses.h | 15 - src/blackmisc/eveventhotkeyfunction.cpp | 32 -- src/blackmisc/eveventhotkeyfunction.h | 61 ---- src/blackmisc/hardware/hardware.h | 16 - src/blackmisc/hardware/joystickbutton.cpp | 94 ------ src/blackmisc/hardware/joystickbutton.h | 87 ------ src/blackmisc/hardware/keyboardkey.cpp | 310 ------------------- src/blackmisc/hardware/keyboardkey.h | 222 ------------- src/blackmisc/hardware/keyboardkeylist.cpp | 25 -- src/blackmisc/hardware/keyboardkeylist.h | 48 --- src/blackmisc/hotkeyfunction.cpp | 46 --- src/blackmisc/hotkeyfunction.h | 107 ------- src/blackmisc/setkeyboardhotkey.cpp | 111 ------- src/blackmisc/setkeyboardhotkey.h | 105 ------- src/blackmisc/setkeyboardhotkeylist.cpp | 62 ---- src/blackmisc/setkeyboardhotkeylist.h | 59 ---- src/blackmisc/settingsblackmiscclasses.h | 1 - src/swiftgui_standard/swiftguistd_init.cpp | 5 +- tests/blackmisc/testblackmiscmain.cpp | 3 - tests/blackmisc/testhardware.cpp | 68 ---- tests/blackmisc/testhardware.h | 36 --- 32 files changed, 2 insertions(+), 1848 deletions(-) delete mode 100644 src/blackgui/models/keyboardkeylistmodel.cpp delete mode 100644 src/blackgui/models/keyboardkeylistmodel.h delete mode 100644 src/blackgui/views/keyboardkeyview.cpp delete mode 100644 src/blackgui/views/keyboardkeyview.h delete mode 100644 src/blackmisc/eventallclasses.h delete mode 100644 src/blackmisc/eveventhotkeyfunction.cpp delete mode 100644 src/blackmisc/eveventhotkeyfunction.h delete mode 100644 src/blackmisc/hardware/hardware.h delete mode 100644 src/blackmisc/hardware/joystickbutton.cpp delete mode 100644 src/blackmisc/hardware/joystickbutton.h delete mode 100644 src/blackmisc/hardware/keyboardkey.cpp delete mode 100644 src/blackmisc/hardware/keyboardkey.h delete mode 100644 src/blackmisc/hardware/keyboardkeylist.cpp delete mode 100644 src/blackmisc/hardware/keyboardkeylist.h delete mode 100644 src/blackmisc/hotkeyfunction.cpp delete mode 100644 src/blackmisc/hotkeyfunction.h delete mode 100644 src/blackmisc/setkeyboardhotkey.cpp delete mode 100644 src/blackmisc/setkeyboardhotkey.h delete mode 100644 src/blackmisc/setkeyboardhotkeylist.cpp delete mode 100644 src/blackmisc/setkeyboardhotkeylist.h delete mode 100644 tests/blackmisc/testhardware.cpp delete mode 100644 tests/blackmisc/testhardware.h diff --git a/src/blackcore/context_audio_impl.cpp b/src/blackcore/context_audio_impl.cpp index aa678ccbf..4afd38c21 100644 --- a/src/blackcore/context_audio_impl.cpp +++ b/src/blackcore/context_audio_impl.cpp @@ -17,7 +17,6 @@ #include "blacksound/soundgenerator.h" #include "blackmisc/notificationsounds.h" #include "blackmisc/audio/voiceroomlist.h" -#include "blackmisc/hotkeyfunction.h" #include "blackmisc/logmessage.h" #include "blackmisc/simplecommandparser.h" diff --git a/src/blackgui/models/allmodelcontainers.h b/src/blackgui/models/allmodelcontainers.h index 6c6a138e9..cc557b10f 100644 --- a/src/blackgui/models/allmodelcontainers.h +++ b/src/blackgui/models/allmodelcontainers.h @@ -19,7 +19,6 @@ #include "blackmisc/network/clientlist.h" #include "blackmisc/network/textmessagelist.h" #include "blackmisc/network/aircraftmappinglist.h" -#include "blackmisc/setkeyboardhotkeylist.h" #include "blackmisc/input/actionhotkeylist.h" #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/simulation/aircraftmodellist.h" diff --git a/src/blackgui/models/allmodels.h b/src/blackgui/models/allmodels.h index 3e92e167c..01daa65f2 100644 --- a/src/blackgui/models/allmodels.h +++ b/src/blackgui/models/allmodels.h @@ -24,7 +24,7 @@ #include "blackgui/models/simulatedaircraftlistmodel.h" #include "blackgui/models/liverylistmodel.h" #include "blackgui/models/distributorlistmodel.h" -#include "blackgui/models/keyboardkeylistmodel.h" #include "blackgui/models/actionhotkeylistmodel.h" + #endif // guard diff --git a/src/blackgui/models/keyboardkeylistmodel.cpp b/src/blackgui/models/keyboardkeylistmodel.cpp deleted file mode 100644 index 1006e876d..000000000 --- a/src/blackgui/models/keyboardkeylistmodel.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* 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. - */ - -#include "keyboardkeylistmodel.h" -#include "blackmisc/blackmiscfreefunctions.h" -#include -#include -#include -#include -#include - -using namespace BlackMisc::Settings; -using namespace BlackMisc::Hardware; - -namespace BlackGui -{ - namespace Models - { - /* - * Constructor - */ - CKeyboardKeyListModel::CKeyboardKeyListModel(QObject *parent) : - CListModelBase("ViewKeyboardKeyList", parent) - { - const bool editable = true; - this->m_columns.addColumn(CColumn("key", CSettingKeyboardHotkey::IndexKeyAsStringRepresentation, new CStringFormatter(), editable)); - this->m_columns.addColumn(CColumn("modifier 1", CSettingKeyboardHotkey::IndexModifier1AsString, new CStringFormatter(), editable)); - this->m_columns.addColumn(CColumn("modifier 2", CSettingKeyboardHotkey::IndexModifier2AsString, new CStringFormatter(), editable)); - this->m_columns.addColumn(CColumn::standardString("function", CSettingKeyboardHotkey::IndexFunctionAsString)); - - this->setSortColumnByPropertyIndex(CSettingKeyboardHotkey::IndexFunctionAsString); - this->m_sortOrder = Qt::AscendingOrder; - - // force strings for translation in resource files - (void)QT_TRANSLATE_NOOP("ViewKeyboardKeyList", "modifier 1"); - (void)QT_TRANSLATE_NOOP("ViewKeyboardKeyList", "modifier 2"); - (void)QT_TRANSLATE_NOOP("ViewKeyboardKeyList", "function"); - (void)QT_TRANSLATE_NOOP("ViewKeyboardKeyList", "key"); - } - - /* - * Display icons - */ - QVariant CKeyboardKeyListModel::data(const QModelIndex &modelIndex, int role) const - { - // shortcut, fast check - return CListModelBase::data(modelIndex, role); - } - - bool CKeyboardKeyListModel::setData(const QModelIndex &index, const QVariant &value, int role) - { - if (role == Qt::EditRole) - { - CSettingKeyboardHotkey::ColumnIndex pi = this->modelIndexToPropertyIndex(index).frontCasted(); - if (pi == CSettingKeyboardHotkey::IndexModifier1 || pi == CSettingKeyboardHotkey::IndexModifier2 || pi == CSettingKeyboardHotkey::IndexModifier1AsString || pi == CSettingKeyboardHotkey::IndexModifier2AsString) - { - if (index.row() >= this->m_container.size()) return true; - CSettingKeyboardHotkey key = this->m_container[index.row()]; - key.setPropertyByIndex(value, pi); - key.cleanup(); - this->m_container[index.row()] = key; - return true; - } - else if (pi == CSettingKeyboardHotkey::IndexKey || pi == CSettingKeyboardHotkey::IndexKeyAsString || pi == CSettingKeyboardHotkey::IndexKeyAsStringRepresentation) - { - Q_ASSERT(value.canConvert()); - if (index.row() >= this->m_container.size()) return true; - CSettingKeyboardHotkey key = this->m_container[index.row()]; - key.setPropertyByIndex(value, CSettingKeyboardHotkey::IndexObject); - key.cleanup(); - this->m_container[index.row()] = key; - return true; - } - } - return CListModelBase::setData(index, value, role); - } - - QWidget *CKeyboardKeyItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const - { - const CKeyboardKeyListModel *model = this->model(); - Q_ASSERT(model); - - if (index.row() < model->rowCount()) - { - CSettingKeyboardHotkey::ColumnIndex pi = model->modelIndexToPropertyIndex(index).frontCasted(); - if (pi == CSettingKeyboardHotkey::IndexModifier1 || pi == CSettingKeyboardHotkey::IndexModifier2 || pi == CSettingKeyboardHotkey::IndexModifier1AsString || pi == CSettingKeyboardHotkey::IndexModifier2AsString) - { - CSettingKeyboardHotkey key = model->at(index); - QString v = (pi == CSettingKeyboardHotkey::IndexModifier1 || pi == CSettingKeyboardHotkey::IndexModifier1AsString) ? key.getModifier1AsString() : key.getModifier2AsString(); - QComboBox *edit = new QComboBox(parent); - edit->addItems(CSettingKeyboardHotkey::modifiers()); - edit->setCurrentText(v); - return edit; - } - else if (pi == CSettingKeyboardHotkey::IndexKey || pi == CSettingKeyboardHotkey::IndexKeyAsString || pi == CSettingKeyboardHotkey::IndexKeyAsStringRepresentation) - { - CSettingKeyboardHotkey hotkey = model->at(index); - CKeyboardLineEdit *edit = new CKeyboardLineEdit(hotkey, parent); - edit->setText(hotkey.getKey().getKeyAsString()); - return edit; - } - } - return QItemDelegate::createEditor(parent, option, index); - } - - void CKeyboardKeyItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const - { - QItemDelegate::setEditorData(editor, index); - } - - void CKeyboardKeyItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const - { - // with our own line edit we have a special treatment - // otherwise (comboboxes) standard handling via QItemDelegate - CKeyboardLineEdit *lineEdit = qobject_cast(editor); - if (lineEdit) - model->setData(index, QVariant::fromValue(lineEdit->getKey()) , Qt::EditRole); - else - QItemDelegate::setModelData(editor, model, index); - } - - void CKeyboardKeyItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const - { - QItemDelegate::updateEditorGeometry(editor, option, index); - } - - const CKeyboardKeyListModel *CKeyboardKeyItemDelegate::model() const - { - if (this->parent()) - { - QTableView *tableView = dynamic_cast(this->parent()); - if (tableView) - { - return dynamic_cast(tableView->model()); - } - } - return nullptr; - } - - void CKeyboardLineEdit::keyPressEvent(QKeyEvent *event) - { - const Qt::Key k = static_cast(event->key()); - if (k == Qt::Key_Shift || k == Qt::Key_Control || k == Qt::Key_Meta || k == Qt::Key_Alt || k == Qt::Key_CapsLock || k == Qt::Key_NumLock || k == Qt::Key_ScrollLock) return; - BlackMisc::Hardware::CKeyboardKey key; - key.setKey(k); - this->m_hotkey.setKey(key); - this->setText(CSettingKeyboardHotkey::toStringRepresentation(event->key())); - } - - } -} // namespace diff --git a/src/blackgui/models/keyboardkeylistmodel.h b/src/blackgui/models/keyboardkeylistmodel.h deleted file mode 100644 index 3e3a60e1b..000000000 --- a/src/blackgui/models/keyboardkeylistmodel.h +++ /dev/null @@ -1,104 +0,0 @@ -/* 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. - */ - -//! \file - -#ifndef BLACKGUI_KEYBOARDKEYLISTMODEL_H -#define BLACKGUI_KEYBOARDKEYLISTMODEL_H - -#include "blackgui/blackguiexport.h" -#include "blackmisc/hardware/keyboardkeylist.h" -#include "blackmisc/setkeyboardhotkeylist.h" -#include "blackgui/models/listmodelbase.h" -#include -#include -#include -#include - -namespace BlackGui -{ - namespace Models - { - /*! - * Keyboard key list model - */ - class BLACKGUI_EXPORT CKeyboardKeyListModel : public CListModelBase - { - - public: - - //! Constructor - explicit CKeyboardKeyListModel(QObject *parent = nullptr); - - //! Destructor - virtual ~CKeyboardKeyListModel() {} - - //! \copydoc CListModelBase::data - QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const override; - - //! \copydoc CKeyboardKeyList::initAsHotkeyList(bool reset) - void initAsHotkeyList() { this->m_container.initAsHotkeyList(); } - - //! \copydoc QAbstractTableModel::setData - virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override; - }; - - /*! - * Special edit delegate for key sequence - */ - class BLACKGUI_EXPORT CKeyboardKeyItemDelegate : public QItemDelegate - { - Q_OBJECT - - public: - //! Constructor - explicit CKeyboardKeyItemDelegate(QObject *parent = nullptr) : - QItemDelegate(parent) {} - - //! \copydoc QItemDelegate::createEditor - virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; - - //! \copydoc QItemDelegate::setEditorData - virtual void setEditorData(QWidget *editor, const QModelIndex &index) const override; - - //! \copydoc QItemDelegate::setModelData - virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; - - //! \copydoc QItemDelegate::updateEditorGeometry - virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override; - - //! correspondig model - const CKeyboardKeyListModel *model() const; - }; - - /*! - * Special edit widget for key sequence - */ - class BLACKGUI_EXPORT CKeyboardLineEdit : public QLineEdit - { - Q_OBJECT - - public: - //! Constructor - CKeyboardLineEdit(const BlackMisc::Settings::CSettingKeyboardHotkey &hotkey, QWidget *parent = nullptr) : - QLineEdit(parent), m_hotkey(hotkey) { } - - //! get key - const BlackMisc::Settings::CSettingKeyboardHotkey &getKey() const { return this->m_hotkey; } - - protected: - //! Overriding and handling key press - virtual void keyPressEvent(QKeyEvent *event) override; - - private: - BlackMisc::Settings::CSettingKeyboardHotkey m_hotkey; - }; - } -} -#endif // guard diff --git a/src/blackgui/models/listmodelbase.cpp b/src/blackgui/models/listmodelbase.cpp index f49c90e5e..c2b11d792 100644 --- a/src/blackgui/models/listmodelbase.cpp +++ b/src/blackgui/models/listmodelbase.cpp @@ -461,7 +461,6 @@ namespace BlackGui template class CListModelBase; template class CListModelBase; template class CListModelBase; - template class CListModelBase; } // namespace } // namespace diff --git a/src/blackgui/views/keyboardkeyview.cpp b/src/blackgui/views/keyboardkeyview.cpp deleted file mode 100644 index 3ab6dc53f..000000000 --- a/src/blackgui/views/keyboardkeyview.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* 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. - */ - -#include "keyboardkeyview.h" -#include - -using namespace BlackMisc; -using namespace BlackGui::Models; - -namespace BlackGui -{ - namespace Views - { - CKeyboardKeyView::CKeyboardKeyView(QWidget *parent) : CViewBase(parent) - { - this->standardInit(new CKeyboardKeyListModel(this)); - this->setItemDelegate(new CKeyboardKeyItemDelegate(this)); // for editing - } - } -} diff --git a/src/blackgui/views/keyboardkeyview.h b/src/blackgui/views/keyboardkeyview.h deleted file mode 100644 index a585b7170..000000000 --- a/src/blackgui/views/keyboardkeyview.h +++ /dev/null @@ -1,34 +0,0 @@ -/* 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_KEYBOARDKEYVIEW_H -#define BLACKGUI_KEYBOARDKEYVIEW_H - -//! \file - -#include "blackgui/blackguiexport.h" -#include "viewbase.h" -#include "../models/keyboardkeylistmodel.h" - -namespace BlackGui -{ - namespace Views - { - //! Keyboard key view - class BLACKGUI_EXPORT CKeyboardKeyView : public CViewBase - { - - public: - - //! Constructor - explicit CKeyboardKeyView(QWidget *parent = nullptr); - }; - } -} -#endif // guard diff --git a/src/blackgui/views/viewbase.cpp b/src/blackgui/views/viewbase.cpp index 898b97cf0..7b4357234 100644 --- a/src/blackgui/views/viewbase.cpp +++ b/src/blackgui/views/viewbase.cpp @@ -405,7 +405,5 @@ namespace BlackGui template class CViewBase; template class CViewBase; - template class CViewBase; - } // namespace } // namespace diff --git a/src/blackmisc/blackmisc.pro b/src/blackmisc/blackmisc.pro index fd0a16c4f..e53472340 100644 --- a/src/blackmisc/blackmisc.pro +++ b/src/blackmisc/blackmisc.pro @@ -34,7 +34,6 @@ HEADERS += *.h \ $$PWD/network/*.h \ $$PWD/geo/*.h \ $$PWD/input/*.h \ - $$PWD/hardware/*.h \ $$PWD/audio/*.h \ $$PWD/simulation/*.h \ $$PWD/simulation/fscommon/*.h \ @@ -47,7 +46,6 @@ SOURCES += *.cpp \ $$PWD/math/*.cpp \ $$PWD/network/*.cpp \ $$PWD/input/*.cpp \ - $$PWD/hardware/*.cpp \ $$PWD/geo/*.cpp \ $$PWD/audio/*.cpp \ $$PWD/simulation/*.cpp \ diff --git a/src/blackmisc/blackmiscfreefunctions.cpp b/src/blackmisc/blackmiscfreefunctions.cpp index 1fdab65a5..ffbafbf93 100644 --- a/src/blackmisc/blackmiscfreefunctions.cpp +++ b/src/blackmisc/blackmiscfreefunctions.cpp @@ -11,7 +11,6 @@ #include "math/math.h" #include "geo/geo.h" #include "audio/audio.h" -#include "hardware/hardware.h" #include "input/input.h" #include "settingsblackmiscclasses.h" #include "propertyindexlist.h" @@ -23,7 +22,6 @@ #include "pixmap.h" #include "iconlist.h" #include "identifierlist.h" -#include "eventallclasses.h" #include #include #include @@ -44,8 +42,6 @@ void BlackMisc::Geo::registerMetadata() void BlackMisc::Settings::registerMetadata() { CSettingsAudio::registerMetadata(); - CSettingKeyboardHotkey::registerMetadata(); - CSettingKeyboardHotkeyList::registerMetadata(); } void BlackMisc::Audio::registerMetadata() @@ -82,7 +78,6 @@ void BlackMisc::registerMetadata() CStatusMessageList::registerMetadata(); CIcon::registerMetadata(); CIconList::registerMetadata(); - CHotkeyFunction::registerMetadata(); CLogCategory::registerMetadata(); CLogCategoryList::registerMetadata(); CPixmap::registerMetadata(); @@ -98,8 +93,6 @@ void BlackMisc::registerMetadata() Settings::registerMetadata(); Simulation::registerMetadata(); Audio::registerMetadata(); - Hardware::registerMetadata(); - Event::registerMetadata(); Weather::registerMetadata(); Input::registerMetadata(); diff --git a/src/blackmisc/eventallclasses.h b/src/blackmisc/eventallclasses.h deleted file mode 100644 index e27303021..000000000 --- a/src/blackmisc/eventallclasses.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (C) 2014 - * 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 BLACKMISC_EVENT_ALLCLASSES_H -#define BLACKMISC_EVENT_ALLCLASSES_H - -#include "blackmisc/eveventhotkeyfunction.h" - -#endif // guard diff --git a/src/blackmisc/eveventhotkeyfunction.cpp b/src/blackmisc/eveventhotkeyfunction.cpp deleted file mode 100644 index 05d9d9f61..000000000 --- a/src/blackmisc/eveventhotkeyfunction.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 2014 - * 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. - */ - -#include "eveventhotkeyfunction.h" - -namespace BlackMisc -{ - namespace Event - { - CEventHotkeyFunction::CEventHotkeyFunction(CHotkeyFunction func, bool argument) - : m_hotkeyFunc(func), m_hotkeyFuncArgument(argument) - { - } - - /* - * Convert to string - */ - QString CEventHotkeyFunction::convertToQString(bool i18n) const - { - QString s; - s.append(m_eventOriginator.toQString(i18n)); - s.append(" ").append(m_hotkeyFunc.toQString(i18n)); - return s; - } - } -} diff --git a/src/blackmisc/eveventhotkeyfunction.h b/src/blackmisc/eveventhotkeyfunction.h deleted file mode 100644 index 6165b5be6..000000000 --- a/src/blackmisc/eveventhotkeyfunction.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2014 - * 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 BLACKMISC_EVENT_HOTKEYFUNCTION_H -#define BLACKMISC_EVENT_HOTKEYFUNCTION_H - -//! \file - -#include "blackmiscexport.h" -#include "valueobject.h" -#include "identifier.h" -#include "hotkeyfunction.h" -#include "blackmiscfreefunctions.h" - -namespace BlackMisc -{ - namespace Event - { - //! Value object encapsulating a hotkey function for distribution - class BLACKMISC_EXPORT CEventHotkeyFunction : public CValueObject - { - public: - //! Default constructor. - CEventHotkeyFunction() = default; - - //! Constructor. - CEventHotkeyFunction(CHotkeyFunction func, bool argument); - - //! Get the event originator - const CIdentifier &getEventOriginator() const {return m_eventOriginator;} - - //! Get the event key - const BlackMisc::CHotkeyFunction &getFunction() const {return m_hotkeyFunc;} - - //! Get boolean hotkey function argument - bool getFunctionArgument() const { return m_hotkeyFuncArgument; } - - //! \copydoc CValueObject::convertToQString - QString convertToQString(bool i18n = false) const; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CEventHotkeyFunction) - CIdentifier m_eventOriginator; - CHotkeyFunction m_hotkeyFunc; - - // This is the required argument to call a registered function per CHotkeyFunction - bool m_hotkeyFuncArgument = false; - }; - } -} - -BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Event::CEventHotkeyFunction, (attr(o.m_eventOriginator, flags()), o.m_hotkeyFunc)) -Q_DECLARE_METATYPE(BlackMisc::Event::CEventHotkeyFunction) - -#endif // BLACKMISC_EVENTHOTKEY_H diff --git a/src/blackmisc/hardware/hardware.h b/src/blackmisc/hardware/hardware.h deleted file mode 100644 index be06b0a12..000000000 --- a/src/blackmisc/hardware/hardware.h +++ /dev/null @@ -1,16 +0,0 @@ -/* 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 BLACKMISC_HARDWARE_HARDWAREALL_H -#define BLACKMISC_HARDWARE_HARDWAREALL_H - -#include "blackmisc/hardware/keyboardkeylist.h" -#include "blackmisc/hardware/joystickbutton.h" - -#endif // guard diff --git a/src/blackmisc/hardware/joystickbutton.cpp b/src/blackmisc/hardware/joystickbutton.cpp deleted file mode 100644 index bb3275273..000000000 --- a/src/blackmisc/hardware/joystickbutton.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright (C) 2014 - * 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. - */ - -#include "blackmisc/hardware/joystickbutton.h" -#include "blackmisc/blackmiscfreefunctions.h" -#include "blackmisc/variant.h" -#include - -namespace BlackMisc -{ - namespace Hardware - { - CJoystickButton::CJoystickButton(int buttonIndex) : - m_buttonIndex(buttonIndex) - {} - - void CJoystickButton::setButtonIndex(int buttonIndex) - { - m_buttonIndex = buttonIndex; - } - - void CJoystickButton::setButtonObject(const CJoystickButton &button) - { - this->m_buttonIndex = button.m_buttonIndex; - } - - void CJoystickButton::setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index) - { - if (index.isMyself()) { (*this) = variant.to(); return; } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexButton: - case IndexButtonAsString: - this->setButtonIndex(buttonIndexFromString(variant.value())); - break; - case IndeButtonObject: - this->setButtonObject(variant.value()); - break; - default: - Q_ASSERT_X(false, "CJoystickButton", "index unknown (setter)"); - break; - } - } - - CVariant CJoystickButton::propertyByIndex(const BlackMisc::CPropertyIndex &index) const - { - if (index.isMyself()) { return CVariant::from(*this); } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexButton: - return CVariant::from(this->getButtonIndex()); - case IndexButtonAsString: - return CVariant::from(this->getButtonAsString()); - default: - break; - } - - Q_ASSERT_X(false, "CJoystickButton", "index unknown"); - QString m = QString("no property, index ").append(index.toQString()); - return CVariant::fromValue(m); - } - - QString CJoystickButton::buttonIndexToString(qint32 buttonIndex) - { - QString buttonString("Button"); - return buttonString.append(QString("%1").arg(buttonIndex)); - } - - qint32 CJoystickButton::buttonIndexFromString(const QString &buttonName) - { - QString name("Button"); - if (!buttonName.startsWith(name)) return getInvalidIndex(); - - name.remove("Button"); - return name.toInt(); - } - - QString CJoystickButton::convertToQString(bool /* i18n */) const - { - QString s = getButtonAsString(); - return s.trimmed(); - } - - } // namespace Hardware - -} // BlackMisc diff --git a/src/blackmisc/hardware/joystickbutton.h b/src/blackmisc/hardware/joystickbutton.h deleted file mode 100644 index 1d3119344..000000000 --- a/src/blackmisc/hardware/joystickbutton.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright (C) 2014 - * 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 BLACKMISC_HARDWARE_JOYSTICKBUTTON_H -#define BLACKMISC_HARDWARE_JOYSTICKBUTTON_H - -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/valueobject.h" -#include "blackmisc/propertyindex.h" -#include "blackmisc/blackmiscfreefunctions.h" - -namespace BlackMisc -{ - namespace Hardware - { - //! Value object representing a joystick button - class BLACKMISC_EXPORT CJoystickButton : public CValueObject - { - public: - //! Properties by index - enum ColumnIndex - { - IndexButton = 0, - IndexButtonAsString, - IndeButtonObject, // just for updates - }; - - //! Default constructor - CJoystickButton() = default; - - //! Constructor - CJoystickButton(int buttonIndex); - - //! Get button index - int getButtonIndex() const { return m_buttonIndex; } - - //! Get button as String - QString getButtonAsString() const { return buttonIndexToString(m_buttonIndex); } - - //! Set button index - void setButtonIndex(int buttonIndex); - - //! Is valid? - bool isValid() const { return m_buttonIndex >= 0 ? true : false; } - - //! Set button object - void setButtonObject(const BlackMisc::Hardware::CJoystickButton &button); - - //! \copydoc CValueObject::setPropertyByIndex - void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index); - - //! \copydoc CValueObject::propertyByIndex - CVariant propertyByIndex(const CPropertyIndex &index) const; - - //! Button index to string - static QString buttonIndexToString(qint32 buttonIndex); - - //! Button index from string - static qint32 buttonIndexFromString(const QString &button); - - //! Invalid button index - static qint32 getInvalidIndex() { return m_invalidIndex; } - - //! \copydoc CValueObject::convertToQString - QString convertToQString(bool i18n = false) const; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CJoystickButton) - int m_buttonIndex = m_invalidIndex; //!< code similar to Qt::Key - - static const int m_invalidIndex = -1; - }; - } -} - -BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Hardware::CJoystickButton, (o.m_buttonIndex)) -Q_DECLARE_METATYPE(BlackMisc::Hardware::CJoystickButton) - -#endif // guard diff --git a/src/blackmisc/hardware/keyboardkey.cpp b/src/blackmisc/hardware/keyboardkey.cpp deleted file mode 100644 index 5af5c5665..000000000 --- a/src/blackmisc/hardware/keyboardkey.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* 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. - */ - -#include "blackmisc/hardware/keyboardkey.h" -#include "blackmisc/blackmiscfreefunctions.h" -#include "blackmisc/propertyindex.h" -#include "blackmisc/variant.h" -#include - -namespace BlackMisc -{ - namespace Hardware - { - CKeyboardKey::CKeyboardKey() : - m_qtKey(Qt::Key_unknown), m_modifier1(ModifierNone), m_modifier2(ModifierNone) - {} - - CKeyboardKey::CKeyboardKey(Qt::Key keyCode, Modifier modifier1, Modifier modifier2) : - m_qtKey(keyCode), m_modifier1(modifier1), m_modifier2(modifier2) - {} - - QString CKeyboardKey::convertToQString(bool /* i18n */) const - { - QString s = this->getModifier1AsString(); - s.append(" ").append(this->getModifier2AsString()).append(" "); - if (this->m_qtKey != 0) s.append(" ").append(this->getKeyAsStringRepresentation()); - return s.trimmed(); - } - - QString CKeyboardKey::modifierToString(CKeyboardKey::Modifier modifier) - { - switch (modifier) - { - case ModifierNone: return ""; - case ModifierAltAny: return "Alt"; - case ModifierAltLeft: return "Alt Left"; - case ModifierAltRight: return "Alt Right"; - case ModifierShiftAny: return "Shift"; - case ModifierShiftLeft: return "Shift Left"; - case ModifierShiftRight: return "Shift Right"; - case ModifierCtrlAny: return "Ctrl"; - case ModifierCtrlLeft: return "Ctrl Left"; - case ModifierCtrlRight: return "Ctrl Right"; - case ModifierMeta: return "Meta"; - default: - qFatal("Wrong modifier"); - return ""; - } - } - - CKeyboardKey::Modifier CKeyboardKey::modifierFromString(const QString &modifier) - { - QString mod = modifier.toLower().replace('&', ' '); - if (mod == "ctrl" || mod == "ctl") return ModifierCtrlAny; - if (mod.startsWith("ctrl l") || mod.startsWith("ctl l")) return ModifierCtrlLeft; - if (mod.startsWith("ctrl r") || mod.startsWith("ctl r")) return ModifierCtrlRight; - - if (mod == "shift") return ModifierShiftAny; - if (mod.startsWith("shift l")) return ModifierShiftLeft; - if (mod.startsWith("shift r")) return ModifierShiftRight; - - if (mod == "alt") return ModifierAltAny; - if (mod.startsWith("alt l")) return ModifierAltLeft; - if (mod.startsWith("alt r")) return ModifierAltRight; - - if (mod == "meta") return ModifierMeta; - - return ModifierNone; - } - - CKeyboardKey::Modifier CKeyboardKey::modifierFromQtModifier(Qt::Modifier qtModifier) - { - switch (qtModifier) - { - case Qt::META : return ModifierMeta; - case Qt::SHIFT : return ModifierShiftAny; - case Qt::CTRL: return ModifierShiftAny; - case Qt::ALT: return ModifierAltAny; - default: - return ModifierNone; - } - } - - const QStringList &CKeyboardKey::modifiers() - { - static QStringList modifiers; - if (modifiers.isEmpty()) - { - modifiers << modifierToString(ModifierNone); - modifiers << modifierToString(ModifierCtrlAny); - modifiers << modifierToString(ModifierCtrlLeft); - modifiers << modifierToString(ModifierCtrlRight); - modifiers << modifierToString(ModifierShiftAny); - modifiers << modifierToString(ModifierShiftLeft); - modifiers << modifierToString(ModifierShiftRight); - modifiers << modifierToString(ModifierAltAny); - modifiers << modifierToString(ModifierAltLeft); - modifiers << modifierToString(ModifierAltRight); - modifiers << modifierToString(ModifierMeta); - } - return modifiers; - } - - void CKeyboardKey::cleanup() - { - if (!this->hasModifier()) return; - if (this->m_modifier1 == ModifierNone) qSwap(this->m_modifier1, this->m_modifier2); - if (this->numberOfModifiers() == 1) return; - if (this->m_modifier1 == this->m_modifier2) - { - // redundant - this->m_modifier2 = ModifierNone; - return; - } - - // order - if (static_cast(this->m_modifier1) < static_cast(this->m_modifier2)) - qSwap(this->m_modifier1, this->m_modifier2); - } - - int CKeyboardKey::numberOfModifiers() const - { - if (!this->hasModifier()) return 0; - if (this->m_modifier1 == ModifierNone || this->m_modifier2 == ModifierNone) return 1; - return 2; - } - - void CKeyboardKey::setKey(const QString &key) - { - if (key.isEmpty()) - this->m_qtKey = Qt::Key_unknown; - - QKeySequence sequence(key); - m_qtKey = static_cast(sequence[0]); - } - - void CKeyboardKey::setKey(const QChar &key) - { - if (key.isNull()) - this->m_qtKey = Qt::Key_unknown; - else - { - QKeySequence sequence(key); - m_qtKey = static_cast(sequence[0]); - } - } - - bool CKeyboardKey::addModifier(const Modifier &modifier) - { - bool added = false; - - // Don't add the same modifier twice - if (hasModifier(modifier)) - return false; - - if (m_modifier1 == ModifierNone) - { - m_modifier1 = modifier; - added = true; - } - else if (m_modifier2 == ModifierNone) - { - m_modifier2 = modifier; - added = true; - } - - if (added) this->cleanup(); - return added; - } - - bool CKeyboardKey::addModifier(const QString &modifier) - { - return addModifier(modifierFromString(modifier)); - } - - bool CKeyboardKey::removeModifier(const Modifier &modifier) - { - bool removed = false; - - if (m_modifier1 == modifier) - { - m_modifier1 = ModifierNone; - removed = true; - } - if (m_modifier2 == modifier) - { - m_modifier2 = ModifierNone; - removed = true; - } - cleanup(); - return removed; - } - - bool CKeyboardKey::removeModifier(const QString &modifier) - { - return removeModifier(modifierFromString(modifier)); - } - - bool CKeyboardKey::equalsModifierReleaxed(CKeyboardKey::Modifier m1, CKeyboardKey::Modifier m2) - { - if (m1 == m2) return true; - if (m1 == ModifierAltAny && (m2 == ModifierAltLeft || m2 == ModifierAltRight)) return true; - if (m1 == ModifierCtrlAny && (m2 == ModifierCtrlLeft || m2 == ModifierCtrlRight)) return true; - if (m1 == ModifierShiftAny && (m2 == ModifierShiftLeft || m2 == ModifierShiftRight)) return true; - - if (m2 == ModifierAltAny && (m1 == ModifierAltLeft || m1 == ModifierAltRight)) return true; - if (m2 == ModifierCtrlAny && (m1 == ModifierCtrlLeft || m1 == ModifierCtrlRight)) return true; - if (m2 == ModifierShiftAny && (m1 == ModifierShiftLeft || m1 == ModifierShiftRight)) return true; - - return false; - } - - void CKeyboardKey::setKeyObject(const CKeyboardKey &key) - { - this->m_modifier1 = key.m_modifier1; - this->m_modifier2 = key.m_modifier2; - this->m_qtKey = key.m_qtKey; - } - - bool CKeyboardKey::equalsWithRelaxedModifiers(const CKeyboardKey &key) const - { - if (key == (*this)) return true; // fully equal, not need to bother - - // this can never be true - if (key.m_qtKey != this->m_qtKey) return false; - if (this->numberOfModifiers() != key.numberOfModifiers()) return false; - - // special modifiers - if (this->getModifier1() != key.getModifier1()) - { - if (!CKeyboardKey::equalsModifierReleaxed(this->getModifier1(), key.getModifier1())) return false; - } - return CKeyboardKey::equalsModifierReleaxed(this->getModifier1(), key.getModifier1()); - } - - QString CKeyboardKey::toStringRepresentation(int key) - { - if (key == 0) return ""; - QString ks = QKeySequence(key).toString(); - return ks; - } - - CVariant CKeyboardKey::propertyByIndex(const BlackMisc::CPropertyIndex &index) const - { - if (index.isMyself()) { return CVariant::from(*this); } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexModifier1: - return CVariant::from(static_cast(this->m_modifier1)); - case IndexModifier2: - return CVariant::from(static_cast(this->m_modifier2)); - case IndexModifier1AsString: - return CVariant::from(this->getModifier1AsString()); - case IndexModifier2AsString: - return CVariant::from(this->getModifier2AsString()); - case IndexKey: - return CVariant::from(static_cast(this->m_qtKey)); - case IndexKeyAsString: - return CVariant::from(QString(QChar(this->m_qtKey))); - case IndexKeyAsStringRepresentation: - return CVariant::from(this->getKeyAsStringRepresentation()); - default: - break; - } - - Q_ASSERT_X(false, "CKeyboardKey", "index unknown"); - QString m = QString("no property, index ").append(index.toQString()); - return CVariant::fromValue(m); - } - - void CKeyboardKey::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) - { - if (index.isMyself()) { (*this) = variant.to(); return; } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexKey: - case IndexKeyAsString: - case IndexKeyAsStringRepresentation: - { - // static_cast see docu of variant.type() - if (static_cast(variant.type()) == QMetaType::QChar) - this->setKey(variant.value()); - else - this->setKey(variant.value()); - break; - } - case IndexModifier1AsString: - this->setModifier1(variant.value()); - break; - case IndexModifier2AsString: - this->setModifier2(variant.value()); - break; - case IndexKeyObject: - this->setKeyObject(variant.value()); - break; - default: - Q_ASSERT_X(false, "CKeyboardKey", "index unknown (setter)"); - break; - } - } - } // namespace Hardware -} // BlackMisc diff --git a/src/blackmisc/hardware/keyboardkey.h b/src/blackmisc/hardware/keyboardkey.h deleted file mode 100644 index 51fa8e527..000000000 --- a/src/blackmisc/hardware/keyboardkey.h +++ /dev/null @@ -1,222 +0,0 @@ -/* 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. - */ - -//! \file - -#ifndef BLACKMISC_HARDWARE_KEYBOARDKEY_H -#define BLACKMISC_HARDWARE_KEYBOARDKEY_H - -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/propertyindex.h" -#include "blackmisc/valueobject.h" -#include "blackmisc/blackmiscfreefunctions.h" -#include -#include - -namespace BlackMisc -{ - namespace Hardware - { - //! Value object representing a keyboard key. - class BLACKMISC_EXPORT CKeyboardKey : public CValueObject - { - public: - //! Properties by index - enum ColumnIndex - { - IndexKey = 0, - IndexKeyAsString, - IndexKeyAsStringRepresentation, - IndexModifier1, - IndexModifier2, - IndexModifier1AsString, - IndexModifier2AsString, - IndexKeyObject, // just for updates - }; - - //! Modifier - enum Modifier - { - ModifierNone, - ModifierCtrlLeft, - ModifierCtrlRight, - ModifierCtrlAny, - ModifierAltLeft, - ModifierAltRight, - ModifierAltAny, - ModifierShiftLeft, - ModifierShiftRight, - ModifierShiftAny, - ModifierMeta, - ModifierNum - }; - - //! Default constructor - CKeyboardKey(); - - //! Constructor - CKeyboardKey(Qt::Key keyCode, Modifier modifier1 = ModifierNone, Modifier modifier2 = ModifierNone); - - //! Get key code - Qt::Key getKey() const { return this->m_qtKey; } - - //! Get key code - QString getKeyAsString() const { return QString(this->getKey()); } - - //! Get key code - QString getKeyAsStringRepresentation() const { return CKeyboardKey::toStringRepresentation(this->m_qtKey); } - - //! As Qt::Key - Qt::Key getKeyAsQtKey() const { return static_cast(this->m_qtKey);} - - //! Set key code - void setKey(const QString &key); - - //! Set key code - void setKey(const QChar &key); - - //! Set key code - void setKey(const Qt::Key key) { this->m_qtKey = key; } - - //! Set key code - void setKey(int key) { this->m_qtKey = static_cast(key); } - - /*! - * Add modifier - * \param modifier - * \return True if modifier was added - */ - bool addModifier(const Modifier &modifier); - - /*! - * add modifier - * \param modifier - * \return True if modifier was added - */ - bool addModifier(const QString &modifier); - - //! number of modifiers - int numberOfModifiers() const; - - //! Modifier 1 - Modifier getModifier1() const { return this->m_modifier1; } - - //! Modifier 2 - Modifier getModifier2() const { return this->m_modifier2; } - - //! Modifier 1 - QString getModifier1AsString() const { return modifierToString(this->m_modifier1); } - - //! Modifier 2 - QString getModifier2AsString() const { return modifierToString(this->m_modifier2); } - - /*! - * Remove modifier from key - * \param modifier - * \return True if modifier was removed - */ - bool removeModifier(const Modifier &modifier); - - /*! - * Remove modifier from key - * \param modifier - * \return True if modifier was removed - */ - bool removeModifier(const QString &modifier); - - //! Set modifier 1 - void setModifier1(const QString &modifier) { this->m_modifier1 = modifierFromString(modifier); } - - //! Set modifier 1 - void setModifier1(const Modifier &modifier) { this->m_modifier1 = modifier; } - - //! Set modifier 2 - void setModifier2(const QString &modifier) { this->m_modifier2 = modifierFromString(modifier); } - - //! Set modifier 2 - void setModifier2(const Modifier &modifier) { this->m_modifier2 = modifier; } - - //! Is empty, (no key, no modifier)? - bool isEmpty() const { return !this->hasModifier() && !this->hasKey(); } - - //! Modifier? - bool hasModifier() const - { - return this->m_modifier1 != ModifierNone || this->m_modifier2 != ModifierNone; - } - - //! Do we have this modifier? - bool hasModifier(Modifier modifier) const - { - return m_modifier1 == modifier || m_modifier2 == modifier; - } - - //! ALT = ALT/R or ALT/L, CTRL = CTRL/R or left, ... - static bool equalsModifierReleaxed(Modifier m1, Modifier m2); - - //! with key? - bool hasKey() const - { - return !(this->m_qtKey == Qt::Key_unknown); - } - - //! Key + modifier? - bool hasKeyAndModifier() const - { - return this->hasKey() && this->hasModifier(); - } - - //! Order Modifiers - void cleanup(); - - //! Set key object - void setKeyObject(const BlackMisc::Hardware::CKeyboardKey &key); - - //! CTRL will be consider equal CTRL-left/reigt, ALT = ALT-left/right .. - bool equalsWithRelaxedModifiers(const CKeyboardKey &key) const; - - //! \copydoc CValueObject::setPropertyByIndex - void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index); - - //! \copydoc CValueObject::propertyByIndex - CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const; - - //! Modifier to string - static QString modifierToString(Modifier modifier); - - //! Modifier from string - static Modifier modifierFromString(const QString &modifier); - - //! Modifier from Qt::Modifier - static Modifier modifierFromQtModifier(Qt::Modifier qtModifier); - - //! all modifiers - static const QStringList &modifiers(); - - /*! - * CKeyboardKey::toStringRepresentation - */ - static QString toStringRepresentation(int key); - - //! \copydoc CValueObject::convertToQString - QString convertToQString(bool i18n = false) const; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CKeyboardKey) - Qt::Key m_qtKey; //!< code similar to Qt::Key - Modifier m_modifier1; - Modifier m_modifier2; - }; - } -} - -BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Hardware::CKeyboardKey, (o.m_qtKey, o.m_modifier1, o.m_modifier2)) -Q_DECLARE_METATYPE(BlackMisc::Hardware::CKeyboardKey) - -#endif // guard diff --git a/src/blackmisc/hardware/keyboardkeylist.cpp b/src/blackmisc/hardware/keyboardkeylist.cpp deleted file mode 100644 index a3f034ae4..000000000 --- a/src/blackmisc/hardware/keyboardkeylist.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* 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. - */ - -#include "blackmisc/hardware/keyboardkeylist.h" -#include "blackmisc/predicates.h" - -namespace BlackMisc -{ - namespace Hardware - { - - CKeyboardKeyList::CKeyboardKeyList() { } - - CKeyboardKeyList::CKeyboardKeyList(const CSequence &baseClass) : - CSequence(baseClass) - { } - - } // namespace -} // namespace diff --git a/src/blackmisc/hardware/keyboardkeylist.h b/src/blackmisc/hardware/keyboardkeylist.h deleted file mode 100644 index b533909b3..000000000 --- a/src/blackmisc/hardware/keyboardkeylist.h +++ /dev/null @@ -1,48 +0,0 @@ -/* 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. - */ - -//! \file - -#ifndef BLACKMISC_HARDWARE_KEYBOARDKEYLIST_H -#define BLACKMISC_HARDWARE_KEYBOARDKEYLIST_H - -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/hardware/keyboardkey.h" -#include "blackmisc/collection.h" -#include "blackmisc/sequence.h" -#include - -namespace BlackMisc -{ - namespace Hardware - { - //! Value object encapsulating a list of keyboard keys. - class BLACKMISC_EXPORT CKeyboardKeyList : - public CSequence, - public BlackMisc::Mixin::MetaType - { - public: - BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CKeyboardKeyList) - - //! Default constructor - CKeyboardKeyList(); - - //! Construct from a base class object. - CKeyboardKeyList(const CSequence &baseClass); - - }; - - } //namespace -} // namespace - -Q_DECLARE_METATYPE(BlackMisc::Hardware::CKeyboardKeyList) -Q_DECLARE_METATYPE(BlackMisc::CCollection) -Q_DECLARE_METATYPE(BlackMisc::CSequence) - -#endif //guard diff --git a/src/blackmisc/hotkeyfunction.cpp b/src/blackmisc/hotkeyfunction.cpp deleted file mode 100644 index d25c51739..000000000 --- a/src/blackmisc/hotkeyfunction.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2014 - * 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. - */ - -#include "hotkeyfunction.h" -#include "QCoreApplication" - -namespace BlackMisc -{ - CHotkeyFunction::CHotkeyFunction() - : m_function(HotkeyNone) - { - } - - CHotkeyFunction::CHotkeyFunction(Function function) - : m_function(function) - { - } - - QString CHotkeyFunction::getFunctionAsString() const - { - switch (m_function) - { - case HotkeyNone: return ""; - case HotkeyPtt: return qApp->translate("CHotkeyFunction", "PTT"); - case HotkeyOpacity50: return qApp->translate("CHotkeyFunction", "Opacity 50%"); - case HotkeyOpacity100: return qApp->translate("CHotkeyFunction", "Opacity 100%"); - case HotkeyToggleCom1: return qApp->translate("CHotkeyFunction", "Toggle COM1"); - case HotkeyToggleCom2: return qApp->translate("CHotkeyFunction", "Toggle COM2"); - case HotkeyToogleWindowsStayOnTop: return qApp->translate("CHotkeyFunction", "Toogle Window on top"); - default: - qFatal("Wrong function"); - return ""; - } - } - - QString CHotkeyFunction::convertToQString(bool /* i18n */) const - { - return getFunctionAsString(); - } -} diff --git a/src/blackmisc/hotkeyfunction.h b/src/blackmisc/hotkeyfunction.h deleted file mode 100644 index c8835a7ec..000000000 --- a/src/blackmisc/hotkeyfunction.h +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (C) 2014 - * 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 BLACKMISC_HOTKEYFUNCTION_H -#define BLACKMISC_HOTKEYFUNCTION_H - -#include "blackmiscexport.h" -#include "propertyindex.h" -#include "valueobject.h" -#include "blackmiscfreefunctions.h" - -namespace BlackMisc -{ - //! Value object representing a hotkey function. - class BLACKMISC_EXPORT CHotkeyFunction : public CValueObject - { - public: - //! Function type - enum Function - { - HotkeyNone, - HotkeyPtt, - HotkeyToggleCom1, - HotkeyToggleCom2, - HotkeyOpacity50, - HotkeyOpacity100, - HotkeyToogleWindowsStayOnTop - }; - - //! Default constructor - CHotkeyFunction(); - - //! Constructor by function - CHotkeyFunction(Function function); - - //! Get function as string - QString getFunctionAsString() const; - - //! Function - Function getFunction() const { return m_function; } - - //! Set function - void setFunction(const Function &function) { m_function = function; } - - //! Hotkey function is Ptt - static const CHotkeyFunction &Ptt() - { - static CHotkeyFunction hotkeyFunction(HotkeyPtt); - return hotkeyFunction; - } - - //! Hotkey function is toggle Com1 - static const CHotkeyFunction &ToggleCom1() - { - static CHotkeyFunction hotkeyFunction(HotkeyToggleCom1); - return hotkeyFunction; - } - - //! Hotkey function is toggle Com2 - static const CHotkeyFunction &ToggleCom2() - { - static CHotkeyFunction hotkeyFunction(HotkeyToggleCom2); - return hotkeyFunction; - } - - //! Hotkey function is opacity 50 - static const CHotkeyFunction &Opacity50() - { - static CHotkeyFunction hotkeyFunction(HotkeyOpacity50); - return hotkeyFunction; - } - - //! Hotkey function is opacity 100 - static const CHotkeyFunction &Opacity100() - { - static CHotkeyFunction hotkeyFunction(HotkeyOpacity100); - return hotkeyFunction; - } - - //! Hotkey function is toggle windows on top - static const CHotkeyFunction &ToogleWindowsStayOnTop() - { - static CHotkeyFunction hotkeyFunction(HotkeyToogleWindowsStayOnTop); - return hotkeyFunction; - } - - //! \copydoc CValueObject::convertToQString - QString convertToQString(bool i18n = false) const; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CHotkeyFunction) - Function m_function; - }; -} - -BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::CHotkeyFunction, (o.m_function)) -Q_DECLARE_METATYPE(BlackMisc::CHotkeyFunction) - -#endif //BLACKMISC_HOTKEYFUNCTION_H diff --git a/src/blackmisc/setkeyboardhotkey.cpp b/src/blackmisc/setkeyboardhotkey.cpp deleted file mode 100644 index 519540656..000000000 --- a/src/blackmisc/setkeyboardhotkey.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright (C) 2014 - * 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. - */ - -#include "setkeyboardhotkey.h" -#include "blackmiscfreefunctions.h" -#include "variant.h" -#include - -namespace BlackMisc -{ - namespace Settings - { - CSettingKeyboardHotkey::CSettingKeyboardHotkey(const CHotkeyFunction &function) : - m_hotkeyFunction(function) - {} - - CSettingKeyboardHotkey::CSettingKeyboardHotkey(const Hardware::CKeyboardKey &key, const CHotkeyFunction &function) : - m_key(key), m_hotkeyFunction(function) - {} - - QString CSettingKeyboardHotkey::convertToQString(bool /* i18n */) const - { - return m_key.toQString(); - } - - void CSettingKeyboardHotkey::setKey(const Hardware::CKeyboardKey &key) - { - m_key = key; - } - - void CSettingKeyboardHotkey::setObject(const CSettingKeyboardHotkey &obj) - { - m_hotkeyFunction = obj.m_hotkeyFunction; - m_key = obj.m_key; - } - - CVariant CSettingKeyboardHotkey::propertyByIndex(const BlackMisc::CPropertyIndex &index) const - { - if (index.isMyself()) { return CVariant::from(*this); } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexFunction: - return CVariant::from(static_cast(m_hotkeyFunction.getFunction())); - case IndexFunctionAsString: - return CVariant::from(m_hotkeyFunction.getFunctionAsString()); - case IndexModifier1: - return CVariant::from(static_cast(m_key.getModifier1())); - case IndexModifier2: - return CVariant::from(static_cast(m_key.getModifier2())); - case IndexModifier1AsString: - return CVariant::from(m_key.getModifier1AsString()); - case IndexModifier2AsString: - return CVariant::from(m_key.getModifier2AsString()); - case IndexKey: - return CVariant::from(static_cast(m_key.getKeyAsQtKey())); - case IndexKeyAsString: - return CVariant::from(QString(QChar(m_key.getKeyAsQtKey()))); - case IndexKeyAsStringRepresentation: - return CVariant::from(m_key.getKeyAsStringRepresentation()); - default: - return CValueObject::propertyByIndex(index); - } - } - - void CSettingKeyboardHotkey::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) - { - if (index.isMyself()) { (*this) = variant.to(); return; } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexFunction: - { - uint f = variant.value(); - m_hotkeyFunction.setFunction(static_cast(f)); - break; - } - case IndexKey: - case IndexKeyAsString: - case IndexKeyAsStringRepresentation: - { - // static_cast see docu of variant.type() - if (static_cast(variant.type()) == QMetaType::QChar) - m_key.setKey(variant.value()); - else - m_key.setKey(variant.value()); - break; - } - case IndexModifier1AsString: - m_key.setModifier1(variant.value()); - break; - case IndexModifier2AsString: - m_key.setModifier2(variant.value()); - break; - case IndexObject: - this->setObject(variant.value()); - break; - default: - CValueObject::setPropertyByIndex(variant, index); - break; - } - } - - } // namespace Hardware -} // BlackMisc diff --git a/src/blackmisc/setkeyboardhotkey.h b/src/blackmisc/setkeyboardhotkey.h deleted file mode 100644 index 73a43a0fd..000000000 --- a/src/blackmisc/setkeyboardhotkey.h +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright (C) 2014 - * 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 BLACKMISC_SETTINGS_KEYBOARDHOTKEY_H -#define BLACKMISC_SETTINGS_KEYBOARDHOTKEY_H - -#include "blackmiscexport.h" -#include "propertyindex.h" -#include "hardware/keyboardkey.h" -#include "hotkeyfunction.h" -#include "blackmiscfreefunctions.h" -#include -#include - -namespace BlackMisc -{ - namespace Settings - { - //! Value object encapsulating the keyboard hotkey assignment - class BLACKMISC_EXPORT CSettingKeyboardHotkey : public CValueObject - { - public: - //! Properties by index - enum ColumnIndex - { - IndexKey = BlackMisc::CPropertyIndex::GlobalIndexCSettingKeyboardHotkey, - IndexKeyAsString, - IndexKeyAsStringRepresentation, - IndexModifier1, - IndexModifier2, - IndexModifier1AsString, - IndexModifier2AsString, - IndexFunction, - IndexFunctionAsString, - IndexObject, // just for updates - }; - - //! Default constructor - CSettingKeyboardHotkey() = default; - - //! Constructor - CSettingKeyboardHotkey(const CHotkeyFunction &function); - - //! Constructor - CSettingKeyboardHotkey(const Hardware::CKeyboardKey &key, const CHotkeyFunction &function); - - //! Get key code - const Hardware::CKeyboardKey &getKey() const { return m_key; } - - //! Set key code - void setKey(const Hardware::CKeyboardKey &key); - - //! Function - CHotkeyFunction getFunction() const { return m_hotkeyFunction; } - - //! Set function - void setFunction(const CHotkeyFunction &function) { this->m_hotkeyFunction = function; } - - //! Set object - void setObject(const CSettingKeyboardHotkey &obj); - - //! Cleanup key - void cleanup() { m_key.cleanup(); } - - //! Get modifier1 as string - QString getModifier1AsString() const { return m_key.getModifier1AsString(); } - - //! Get modifier2 as string - QString getModifier2AsString() const { return m_key.getModifier1AsString(); } - - //! Modifiers - static QStringList modifiers() { return Hardware::CKeyboardKey::modifiers(); } - - //! Create string representation - static QString toStringRepresentation(int key) { return Hardware::CKeyboardKey::toStringRepresentation(key); } - - //! \copydoc CValueObject::setPropertyByIndex - void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index); - - //! \copydoc CValueObject::propertyByIndex - CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const; - - //! \copydoc CValueObject::convertToQString - QString convertToQString(bool i18n = false) const; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CSettingKeyboardHotkey) - Hardware::CKeyboardKey m_key; //!< code similar to Qt::Key - CHotkeyFunction m_hotkeyFunction; //!< hotkey function - }; - } -} - -BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Settings::CSettingKeyboardHotkey, (o.m_key, o.m_hotkeyFunction)) -Q_DECLARE_METATYPE(BlackMisc::Settings::CSettingKeyboardHotkey) - -#endif // guard diff --git a/src/blackmisc/setkeyboardhotkeylist.cpp b/src/blackmisc/setkeyboardhotkeylist.cpp deleted file mode 100644 index c3d00f19a..000000000 --- a/src/blackmisc/setkeyboardhotkeylist.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* 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. - */ - -#include "setkeyboardhotkeylist.h" -#include "predicates.h" - -namespace BlackMisc -{ - using namespace Hardware; - - namespace Settings - { - /* - * Constructor - */ - CSettingKeyboardHotkeyList::CSettingKeyboardHotkeyList() { } - - /* - * Construct from base class object - */ - CSettingKeyboardHotkeyList::CSettingKeyboardHotkeyList(const CSequence &baseClass) : - CSequence(baseClass) - { } - - /* - * Contains this hotkey function? - */ - bool CSettingKeyboardHotkeyList::containsFunction(const CHotkeyFunction &function) const - { - return CSequence::contains(&CSettingKeyboardHotkey::getFunction, function); - } - - /* - * Key for function - */ - CSettingKeyboardHotkey CSettingKeyboardHotkeyList::keyForFunction(const CHotkeyFunction &function) const - { - return this->findBy(&CSettingKeyboardHotkey::getFunction, function).frontOrDefault(); - } - - /* - * Hotkey list - */ - void CSettingKeyboardHotkeyList::initAsHotkeyList(bool reset) - { - if (reset) this->clear(); - if (!this->containsFunction(CHotkeyFunction::Ptt())) push_back(CSettingKeyboardHotkey(CHotkeyFunction::Ptt())); - if (!this->containsFunction(CHotkeyFunction::ToggleCom1())) push_back(CSettingKeyboardHotkey(CHotkeyFunction::ToggleCom1())); - if (!this->containsFunction(CHotkeyFunction::ToggleCom2())) push_back(CSettingKeyboardHotkey(CHotkeyFunction::ToggleCom2())); - if (!this->containsFunction(CHotkeyFunction::Opacity50())) push_back(CSettingKeyboardHotkey(CHotkeyFunction::Opacity50())); - if (!this->containsFunction(CHotkeyFunction::Opacity100())) push_back(CSettingKeyboardHotkey(CHotkeyFunction::Opacity100())); - if (!this->containsFunction(CHotkeyFunction::ToogleWindowsStayOnTop())) push_back(CSettingKeyboardHotkey(CHotkeyFunction::ToogleWindowsStayOnTop())); - } - - } // namespace -} // namespace diff --git a/src/blackmisc/setkeyboardhotkeylist.h b/src/blackmisc/setkeyboardhotkeylist.h deleted file mode 100644 index fa72dadfc..000000000 --- a/src/blackmisc/setkeyboardhotkeylist.h +++ /dev/null @@ -1,59 +0,0 @@ -/* 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. - */ - -//! \file - -#ifndef BLACKMISC_SETTINGS_KEYBOARDHOTKEYLIST_H -#define BLACKMISC_SETTINGS_KEYBOARDHOTKEYLIST_H - -#include "blackmiscexport.h" -#include "hardware/keyboardkey.h" -#include "setkeyboardhotkey.h" -#include "collection.h" -#include "sequence.h" -#include - -namespace BlackMisc -{ - namespace Settings - { - //! Value object encapsulating a list of keyboard keys. - class BLACKMISC_EXPORT CSettingKeyboardHotkeyList : - public CSequence, - public BlackMisc::Mixin::MetaType - { - public: - BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CSettingKeyboardHotkeyList) - - //! Default constructor - CSettingKeyboardHotkeyList(); - - //! Construct from a base class object. - CSettingKeyboardHotkeyList(const CSequence &baseClass); - - //! Contains given hotkey function? - bool containsFunction(const CHotkeyFunction &function) const; - - //! Key for given function - BlackMisc::Settings::CSettingKeyboardHotkey keyForFunction(const CHotkeyFunction &function) const; - - //! Fill the list with hotkeys - //! \param reset true, list will be be reset, otherwise values will not be overridde - void initAsHotkeyList(bool reset = true); - - }; - - } //namespace -} // namespace - -Q_DECLARE_METATYPE(BlackMisc::Settings::CSettingKeyboardHotkeyList) -Q_DECLARE_METATYPE(BlackMisc::CCollection) -Q_DECLARE_METATYPE(BlackMisc::CSequence) - -#endif //guard diff --git a/src/blackmisc/settingsblackmiscclasses.h b/src/blackmisc/settingsblackmiscclasses.h index 0780fa56e..336028ae8 100644 --- a/src/blackmisc/settingsblackmiscclasses.h +++ b/src/blackmisc/settingsblackmiscclasses.h @@ -2,6 +2,5 @@ #define BLACKMISC_SETTINGSBLACKMISCCLASSES_H #include "blackmisc/setaudio.h" -#include "blackmisc/setkeyboardhotkeylist.h" #endif // guard diff --git a/src/swiftgui_standard/swiftguistd_init.cpp b/src/swiftgui_standard/swiftguistd_init.cpp index b8ca73f06..786526524 100644 --- a/src/swiftgui_standard/swiftguistd_init.cpp +++ b/src/swiftgui_standard/swiftguistd_init.cpp @@ -15,11 +15,9 @@ #include "blackgui/guiutility.h" #include "blackgui/components/allmaininfoareacomponents.h" #include "blackgui/models/atcstationlistmodel.h" -#include "blackgui/models/keyboardkeylistmodel.h" #include "blackmisc/icons.h" #include "blackmisc/aviation/selcal.h" #include "blackmisc/project.h" -#include "blackmisc/hotkeyfunction.h" #include "blackmisc/logmessage.h" #include #include @@ -27,7 +25,7 @@ using namespace BlackCore; using namespace BlackMisc; -using namespace BlackMisc::Hardware; +using namespace BlackMisc::Input; using namespace BlackGui; using namespace BlackGui::Components; @@ -101,7 +99,6 @@ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig) connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &SwiftGuiStd::ps_onConnectionStatusChanged); connect(this->getIContextNetwork(), &IContextNetwork::textMessagesReceived, this->ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::onTextMessageReceived); connect(this->getIContextNetwork(), &IContextNetwork::textMessageSent, this->ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::onTextMessageSent); - connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &SwiftGuiStd::ps_onChangedSetttings); connect(this->m_timerContextWatchdog, &QTimer::timeout, this, &SwiftGuiStd::ps_handleTimerBasedUpdates); // log messages diff --git a/tests/blackmisc/testblackmiscmain.cpp b/tests/blackmisc/testblackmiscmain.cpp index e6d35ce8f..3490a0426 100644 --- a/tests/blackmisc/testblackmiscmain.cpp +++ b/tests/blackmisc/testblackmiscmain.cpp @@ -14,7 +14,6 @@ #include "testcontainers.h" #include "testvariantandmap.h" #include "testinput.h" -#include "testhardware.h" #include "testvaluecache.h" #include "testblackmiscmain.h" #include "testweather.h" @@ -34,7 +33,6 @@ namespace BlackMiscTest CTestContainers containerTests; CTestVariantAndMap variantAndMap; CTestInput inputTests; - CTestHardware hardwareTests; CTestIdentifier identifierTests; CTestValueCache valueCacheTests; CTestWeather weatherTests; @@ -45,7 +43,6 @@ namespace BlackMiscTest status |= QTest::qExec(&containerTests, argc, argv); status |= QTest::qExec(&variantAndMap, argc, argv); status |= QTest::qExec(&inputTests, argc, argv); - status |= QTest::qExec(&hardwareTests, argc, argv); status |= QTest::qExec(&valueCacheTests, argc, argv); status |= QTest::qExec(&weatherTests, argc, argv); } diff --git a/tests/blackmisc/testhardware.cpp b/tests/blackmisc/testhardware.cpp deleted file mode 100644 index a194e2b16..000000000 --- a/tests/blackmisc/testhardware.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* 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. - */ - -#include "testhardware.h" -#include "blackmisc/hardware/keyboardkey.h" - -using namespace BlackMisc::Hardware; - -namespace BlackMiscTest -{ - - /* - * Constructor - */ - CTestHardware::CTestHardware(QObject *parent): QObject(parent) - { - // void - } - - // CKeyboardKey tests - void CTestHardware::keyboardKey() - { - // Test equal operator - CKeyboardKey key = CKeyboardKey(Qt::Key_5, CKeyboardKey::ModifierAltLeft, CKeyboardKey::ModifierCtrlLeft); - CKeyboardKey key2; - key2.setKey(Qt::Key_5); - key2.setModifier1(CKeyboardKey::ModifierAltLeft); - key2.setModifier2(CKeyboardKey::ModifierCtrlLeft); - QVERIFY2(key == key2, "CKeyboardKey::operator== failed!"); - - key = CKeyboardKey(); - key.setKey(QString("A")); - QVERIFY2(key.getKey() == Qt::Key_A, "CKeyboardKey::setKey(const QString &key) failed"); - - key.setKey(QChar('B')); - QVERIFY2(key.getKey() == Qt::Key_B, "CKeyboardKey::setKey(const QChar key) failed"); - - key.setKey(Qt::Key_C); - QVERIFY2(key.getKey() == Qt::Key_C, "CKeyboardKey::setKey(const QChar &key) failed"); - - key.setKey('D'); - QVERIFY2(key.getKey() == Qt::Key_D, "CKeyboardKey::setKey(const int key) failed"); - - key = CKeyboardKey(); - QVERIFY2(key.addModifier(CKeyboardKey::ModifierAltLeft), "CKeyboardKey::addModifier() returned wrong result"); - QVERIFY2(key.numberOfModifiers() == 1, "Expected number of modifiers to be equal to 1"); - QVERIFY2(key.getModifier1() == CKeyboardKey::ModifierAltLeft, "Expected modifier to be ModifierAltLeft"); - // Add same modifier again. This should not change the status - QVERIFY2(!key.addModifier(CKeyboardKey::ModifierAltLeft), "CKeyboardKey::addModifier() returned wrong result"); - QVERIFY2(key.numberOfModifiers() == 1, "Expected number of modifiers to be equal to 1"); - QVERIFY2(key.getModifier1() == CKeyboardKey::ModifierAltLeft, "Expected modifier to be ModifierAltLeft"); - QVERIFY2(key.getModifier2() == CKeyboardKey::ModifierNone, "Expected modifier to be ModifierAltLeft"); - - // relaxed checks - key = CKeyboardKey(Qt::Key_1, CKeyboardKey::ModifierCtrlLeft, CKeyboardKey::ModifierNone); - key2 = key; - key2.setModifier1(CKeyboardKey::ModifierCtrlAny); - QVERIFY2(key != key2, "Modifiers differs, values shall be unequal"); - QVERIFY2(key.equalsWithRelaxedModifiers(key2), "Modifiers are relaxed easy, values shall be equal"); - } - -} // namespace diff --git a/tests/blackmisc/testhardware.h b/tests/blackmisc/testhardware.h deleted file mode 100644 index f38482084..000000000 --- a/tests/blackmisc/testhardware.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (C) 2014 - * 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 BLACKMISCTEST_TESTHARDWARE_H -#define BLACKMISCTEST_TESTHARDWARE_H - -#include - -namespace BlackMiscTest -{ - //! Hardware classes basic tests - class CTestHardware : public QObject - { - Q_OBJECT - public: - //! Standard test case constructor - explicit CTestHardware(QObject *parent = nullptr); - - signals: - - private slots: - - //! CKeyboardKey basic tests - void keyboardKey(); - }; -} // namespace - -#endif // guard