Files
pilotclient/src/blackgui/views/viewdbobjects.h
Klaus Basan bf36a69be0 Stashed data file can be dropped to model view
* utility functions
* style changes / renamings / slots -> normal functions
* extra flag to enable file drop (and changed signatures)
* split view load function into 2 parts, one can use passed file parameter
2018-07-25 02:37:02 +02:00

104 lines
3.3 KiB
C++

/* Copyright (C) 2015
* 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_VIEWS_VIEWDBOBJECTS_H
#define BLACKGUI_VIEWS_VIEWDBOBJECTS_H
#include "blackgui/views/viewbase.h"
#include <QSet>
#include <QObject>
#include <QString>
#include <QtGlobal>
class QAction;
class QIntValidator;
class QFrame;
class QLineEdit;
class QWidget;
namespace BlackGui
{
namespace Menus { class CMenuActions; }
namespace Views
{
//! Base class for views with DB objects
template <class ModelClass, class ContainerType, class ObjectType, class KeyType> class CViewWithDbObjects :
public CViewBase<ModelClass, ContainerType, ObjectType>
{
public:
//! Get latest object
ObjectType latestObject() const;
//! Get oldets object
ObjectType oldestObject() const;
//! Select given DB key
void selectDbKey(const KeyType &key);
//! Select given DB keys
void selectDbKeys(const QSet<KeyType> &keys);
//! Get selected DB keys
QSet<KeyType> selectedDbKeys() const;
//! Remove keys
int removeDbKeys(const QSet<KeyType> &keys);
//! Update or insert data (based on DB key)
int replaceOrAddObjectsByKey(const ContainerType &container);
protected:
//! Constructor
explicit CViewWithDbObjects(QWidget *parent = nullptr);
//! \copydoc BlackGui::Views::CViewBaseNonTemplate::customMenu
virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
};
//! Base class for views with DB objects also orderable (based on BlackMisc::IOrderableList )
template <class ModelClass, class ContainerType, class ObjectType, class KeyType> class COrderableViewWithDbObjects :
public CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>
{
protected:
//! Constructor
explicit COrderableViewWithDbObjects(QWidget *parent = nullptr);
//! \copydoc BlackGui::Views::CViewBaseNonTemplate::customMenu
virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
//! Reselect by DB keys
virtual void selectObjects(const ContainerType &selectedObjects) override;
//! Move selected items
void moveSelectedItems(int order);
//! Order to top
void orderToTop();
//! Order to bottom
void orderToBottom();
//! Order to line edit
void orderToLineEdit();
//! Current order set as order
void freezeCurrentOrder();
private:
QList<QAction *> m_menuActions;
QLineEdit *m_leOrder = nullptr;
QFrame *m_frame = nullptr;
QIntValidator *m_validator = nullptr;
};
} // namespace
} // namespace
#endif // guard