8#include <QIntValidator>
11#include <QWidgetAction>
13#include "gui/menus/menuaction.h"
33using namespace swift::gui::menus;
76 if (!obj.hasValidDbKey())
85 return this->selectRows(rows);
95 const ContainerType selected(this->selectedObjects());
96 return selected.toDbKeySet();
112 int delta = newObjects.removeObjectsWithKeys(keys);
166 const int maxOrder = this->
rowCount() - 1;
168 if (m_menuActions.isEmpty())
173 if (!m_menuActions[0])
175 m_frame =
new QFrame(
this);
177 layout->setContentsMargins(2, 2, 2, 2);
178 m_frame->setLayout(
layout);
180 auto *icon =
new QLabel(m_frame);
183 auto *label =
new QLabel(m_frame);
184 label->setText(
"Order:");
186 layout->addWidget(m_leOrder);
188 m_leOrder->setValidator(m_validator);
190 orderAction->setDefaultWidget(m_frame);
193 m_menuActions[0] = orderAction;
197 m_validator->setRange(0, maxOrder);
198 m_leOrder->setPlaceholderText(
"New order 0-" +
QString::number(maxOrder));
236 this->
m_model->moveItems(objs, order);
248 int c = this->
model()->rowCount() - 1;
263 if (!le || le->text().isEmpty())
267 const int order = le->text().toInt();
275 objects.freezeOrder();
Base class for views with DB objects also orderable (based on swift::misc::IOrderableList ).
typename models::CAircraftModelListModel::ContainerType ContainerType
void customMenu(swift::gui::menus::CMenuActions &menuActions)
Method creating the menu.
void selectObjects(const ContainerType &selectedObjects)
Select by DB keys.
COrderableViewWithDbObjects(QWidget *parent=nullptr)
Constructor.
void orderToLineEdit()
Order to line edit.
void orderToTop()
Order to top.
void freezeCurrentOrder()
Current order set as order.
void moveSelectedItems(int order)
Move selected items.
void orderToBottom()
Order to bottom.
bool isEmpty() const
Empty?
void updateContainerMaybeAsync(const ContainerType &container, bool sort=true, bool resize=true)
ContainerType selectedObjects() const
Selected objects.
ModelClass * m_model
corresponding model
int rowCount() const
Elements in container.
CViewBase(QWidget *parent, ModelClass *model=nullptr)
Constructor.
swift::misc::CWorker * updateContainerAsync(const ContainerType &container, bool sort=true, bool resize=true)
Update whole container in background.
const ContainerType & container() const
Access to container.
const ContainerType & containerOrFilteredContainer(bool *filtered=nullptr) const
Full container or cached filtered container as approproiate.
void copy()
Clipboard cut/copy/paste.
void customMenu(menus::CMenuActions &menuActions)
Method creating the menu.
Menu m_menus
Default menu settings.
bool m_enabledLoadIndicator
loading indicator enabled/disabled
@ MenuOrderable
items can be ordered (if container is swift::misc::IOrderableList
bool hasSelection() const
Selection (selected rows).
Base class for views with DB objects.
int removeDbKeys(const QSet< KeyType > &keys)
Remove keys.
typename T::ObjectType ObjectType
Model container element type.
typename T::KeyType KeyType
Model DB key type.
ObjectType oldestObject() const
Get oldets object.
int replaceOrAddObjectsByKey(const ContainerType &container)
Update or insert data (based on DB key).
void selectObjects(const ContainerType &selectedObjects)
Select by DB keys.
typename T::ContainerType ContainerType
Model container type.
bool selectDbKey(const KeyType &key)
Select given DB key.
int selectDbKeys(const QSet< KeyType > &keys)
CViewWithDbObjects(QWidget *parent=nullptr)
Constructor.
ObjectType latestObject() const
Get latest object.
QSet< KeyType > selectedDbKeys() const
Get selected DB keys.
void customMenu(swift::gui::menus::CMenuActions &menuActions)
Method creating the menu.
static const QPixmap & arrowMediumSouth16()
Arrow.
static const QPixmap & arrowMediumWest16()
Arrow.
static const QPixmap & arrowMediumNorth16()
Arrow.
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
Free functions in swift::misc.
QAbstractItemModel * model() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
T qobject_cast(QObject *object)
QObject * sender() const const
bool contains(const QSet< T > &other) const const
QSet< T >::iterator insert(QSet< T >::const_iterator it, const T &value)
bool isEmpty() const const
QString number(double n, char format, int precision)