refs #640, value object orderable interface (same as ITimestampBased ..)

* interface and list
* added Q_DECLARE_INTERFACE
This commit is contained in:
Klaus Basan
2016-04-18 23:24:39 +02:00
parent 5d39c906e4
commit 5f2110b81a
11 changed files with 392 additions and 11 deletions

68
src/blackmisc/orderable.h Normal file
View File

@@ -0,0 +1,68 @@
/* 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 BLACKMISC_ORDERABLE_H
#define BLACKMISC_ORDERABLE_H
#include "blackmiscexport.h"
#include "propertyindex.h"
namespace BlackMisc
{
//! Entity with timestamp
class BLACKMISC_EXPORT IOrderable
{
public:
//! Properties by index
enum ColumnIndex
{
IndexOrder = BlackMisc::CPropertyIndex::GlobalIndexIOrderable,
IndexOrderString
};
//! Order
int getOrder() const { return m_order; }
//! Order as string
QString getOrderAsString() const;
//! Set order
void setOrder(int order) { m_order = order; }
//! Valid order set?
bool hasValidOrder() const;
//! Can given index be handled
static bool canHandleIndex(const BlackMisc::CPropertyIndex &index);
protected:
//! Constructor
IOrderable();
//! Constructor
IOrderable(int order);
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
//! Compare for index
int comparePropertyByIndex(const IOrderable &compareValue, const CPropertyIndex &index) const;
int m_order = -1; //!< order number
};
} // namespace
Q_DECLARE_INTERFACE(BlackMisc::IOrderable, "org.swift-project.blackmisc.iorderable")
#endif // guard