mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
67 lines
1.8 KiB
C++
67 lines
1.8 KiB
C++
// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
|
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
|
|
|
//! \file
|
|
|
|
#ifndef SWIFT_MISC_ORDERABLE_H
|
|
#define SWIFT_MISC_ORDERABLE_H
|
|
|
|
#include <QString>
|
|
#include <QVariant>
|
|
|
|
#include "misc/propertyindexref.h"
|
|
#include "misc/swiftmiscexport.h"
|
|
|
|
namespace swift::misc
|
|
{
|
|
//! Entity with order attribute (can be manually ordered in views)
|
|
class SWIFT_MISC_EXPORT IOrderable
|
|
{
|
|
public:
|
|
//! Properties by index
|
|
enum ColumnIndex
|
|
{
|
|
IndexOrder = CPropertyIndexRef::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;
|
|
|
|
//! Any order index
|
|
static bool isAnyOrderIndex(int index);
|
|
|
|
protected:
|
|
//! Can given index be handled
|
|
static bool canHandleIndex(CPropertyIndexRef index);
|
|
|
|
//! Constructor
|
|
IOrderable() = default;
|
|
|
|
//! Constructor
|
|
IOrderable(int order);
|
|
|
|
//! \copydoc swift::misc::mixin::Index::propertyByIndex
|
|
QVariant propertyByIndex(CPropertyIndexRef index) const;
|
|
|
|
//! \copydoc swift::misc::mixin::Index::setPropertyByIndex
|
|
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
|
|
|
|
//! \copydoc swift::misc::mixin::Index::comparePropertyByIndex
|
|
int comparePropertyByIndex(CPropertyIndexRef index, const IOrderable &compareValue) const;
|
|
|
|
int m_order = -1; //!< order number
|
|
};
|
|
} // namespace swift::misc
|
|
|
|
#endif // SWIFT_MISC_ORDERABLE_H
|