mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #640, value object orderable interface (same as ITimestampBased ..)
* interface and list * added Q_DECLARE_INTERFACE
This commit is contained in:
78
src/blackmisc/orderablelist.h
Normal file
78
src/blackmisc/orderablelist.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/* 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 BLACKMISC_ORDERABLELIST_H
|
||||
#define BLACKMISC_ORDERABLELIST_H
|
||||
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
//! List of orderable IOrderable objects
|
||||
template<class OBJ, class CONTAINER>
|
||||
class IOrderableList
|
||||
{
|
||||
public:
|
||||
//! Sort ascending
|
||||
void sortAscendingByOrder();
|
||||
|
||||
//! Sort descending
|
||||
void sortDescendingByOrder();
|
||||
|
||||
//! Set order member to current order
|
||||
void resetOrder(int offset = 0);
|
||||
|
||||
//! All order values set or missing some?
|
||||
bool needsOrder() const;
|
||||
|
||||
//! All order values IOrderable::order
|
||||
QList<int> orderValues() const;
|
||||
|
||||
//! Items with order will not be included
|
||||
CONTAINER withoutItemsOfSameOrder(const CONTAINER &items) const;
|
||||
|
||||
//! Remove the items based on their order IOrderable::order
|
||||
void removeItemsWithSameOrder(const CONTAINER &items);
|
||||
|
||||
//! Move items to given order
|
||||
void moveTo(const CONTAINER &items, int targetOrder);
|
||||
|
||||
//! Current order of list will be new order values
|
||||
void freezeOrder();
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IOrderableList();
|
||||
|
||||
//! Container
|
||||
const CONTAINER &container() const;
|
||||
|
||||
//! Container
|
||||
CONTAINER &container();
|
||||
};
|
||||
|
||||
//! \cond PRIVATE
|
||||
namespace Simulation
|
||||
{
|
||||
class CDistributor;
|
||||
class CDistributorList;
|
||||
class CAircraftModel;
|
||||
class CAircraftModelList;
|
||||
}
|
||||
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE IOrderableList<BlackMisc::Simulation::CAircraftModel, BlackMisc::Simulation::CAircraftModelList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE IOrderableList<BlackMisc::Simulation::CDistributor, BlackMisc::Simulation::CDistributorList>;
|
||||
|
||||
//! \endcond
|
||||
} //namespace
|
||||
|
||||
#endif //guard
|
||||
Reference in New Issue
Block a user