8 #include <QIntValidator>
11 #include <QWidgetAction>
13 #include "gui/menus/menuaction.h"
33 using namespace swift::gui::menus;
47 return this->container().latestObject();
53 return this->container().oldestObject();
60 return this->selectDbKeys(set) > 0;
67 this->clearSelection();
73 if (!obj.hasValidDbKey()) {
continue; }
76 return this->selectRows(rows);
84 return selected.toDbKeySet();
90 if (keys.
isEmpty()) {
return 0; }
91 if (this->isEmpty()) {
return 0; }
94 int delta = newObjects.removeObjectsWithKeys(keys);
95 if (delta > 0) { this->updateContainerMaybeAsync(newObjects); }
102 if (container.isEmpty()) {
return 0; }
104 int c = copy.replaceOrAddObjectsByKey(container);
105 if (c == 0) {
return 0; }
106 this->updateContainerMaybeAsync(copy);
113 if (selectedObjects.isEmpty()) {
return; }
114 this->selectDbKeys(selectedObjects.toDbKeySet());
136 const int maxOrder = this->rowCount() - 1;
138 if (m_menuActions.isEmpty())
143 if (!m_menuActions[0])
145 m_frame =
new QFrame(
this);
148 m_frame->setLayout(layout);
158 m_leOrder->setValidator(m_validator);
163 m_menuActions[0] = orderAction;
167 m_validator->setRange(0, maxOrder);
168 m_leOrder->setPlaceholderText(
"New order 0-" +
QString::number(maxOrder));
170 menuActions.
addAction(m_menuActions[0], CMenuAction::pathViewOrder());
172 menuActions.
addAction(CIcons::arrowMediumNorth16(),
"To top", CMenuAction::pathViewOrder(),
175 menuActions.
addAction(CIcons::arrowMediumSouth16(),
"To bottom", CMenuAction::pathViewOrder(),
178 menuActions.
addAction(CIcons::arrowMediumWest16(),
"Freeze current order", CMenuAction::pathViewOrder(),
187 if (selectedObjects.isEmpty()) {
return; }
188 this->selectDbKeys(selectedObjects.toDbKeySet());
194 if (this->isEmpty()) {
return; }
196 if (objs.isEmpty()) {
return; }
197 this->m_model->moveItems(objs, order);
203 this->moveSelectedItems(0);
209 int c = this->model()->rowCount() - 1;
210 if (c >= 0) { this->moveSelectedItems(c); }
216 if (this->isEmpty()) {
return; }
218 if (!le || le->
text().isEmpty()) {
return; }
219 const int order = le->
text().toInt();
220 this->moveSelectedItems(order);
227 objects.freezeOrder();
228 this->updateContainerAsync(objects,
false);
Base class for views with DB objects also orderable (based on swift::misc::IOrderableList )
virtual void customMenu(swift::gui::menus::CMenuActions &menuActions)
Method creating the menu.
virtual 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.
typename T::ObjectType ObjectType
Model container element type.
typename T::ContainerType ContainerType
Model container type.
virtual void customMenu(menus::CMenuActions &menuActions)
Method creating the menu.
bool m_enabledLoadIndicator
loading indicator enabled/disabled
@ MenuOrderable
items can be ordered (if container is swift::misc::IOrderableList
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)
virtual void selectObjects(const ContainerType &selectedObjects)
Select by DB keys.
bool selectDbKey(const KeyType &key)
Select given DB key.
int selectDbKeys(const QSet< KeyType > &keys)
Select given DB keys.
ObjectType latestObject() const
Get latest object.
QSet< KeyType > selectedDbKeys() const
Get selected DB keys.
virtual void customMenu(swift::gui::menus::CMenuActions &menuActions)
Method creating the menu.
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
Free functions in swift::misc.
void setPixmap(const QPixmap &)
void setText(const QString &)
void setContentsMargins(const QMargins &margins)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
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)