refs #661, added a label/icon to context order menu as proposed in the meeting

This commit is contained in:
Klaus Basan
2016-05-29 21:44:20 +02:00
parent 2281b2f030
commit 4b8ab847a0
4 changed files with 26 additions and 4 deletions

View File

@@ -14,6 +14,8 @@
#include <QAction>
#include <QIntValidator>
#include <QLineEdit>
#include <QHBoxLayout>
#include <QLabel>
#include <QWidgetAction>
using namespace BlackMisc;
@@ -125,6 +127,7 @@ namespace BlackGui
if (this->m_menus.testFlag(CViewBaseNonTemplate::MenuOrderable) && this->hasSelection())
{
const int maxOrder = this->rowCount() - 1;
CMenuAction menu = menuActions.addMenuViewOrder();
if (this->m_menuActions.isEmpty())
{
// predefine menus
@@ -132,21 +135,30 @@ namespace BlackGui
if (!this->m_menuActions[0])
{
this->m_leOrder = new QLineEdit(this);
this->m_frame = new QFrame(this);
QHBoxLayout *layout = new QHBoxLayout(this->m_frame);
layout->setMargin(2);
this->m_frame->setLayout(layout);
this->m_leOrder = new QLineEdit(this->m_frame);
QLabel *icon = new QLabel(this->m_frame);
icon->setPixmap(menu.getPixmap());
layout->addWidget(icon);
QLabel *label = new QLabel(this->m_frame);
label->setText("Order:");
layout->addWidget(label);
layout->addWidget(this->m_leOrder);
this->m_validator = new QIntValidator(0, maxOrder, this);
this->m_leOrder->setValidator(this->m_validator);
QWidgetAction *orderAction = new QWidgetAction(this);
orderAction->setDefaultWidget(this->m_leOrder);
orderAction->setDefaultWidget(this->m_frame);
QObject::connect(this->m_leOrder, &QLineEdit::returnPressed, this, &COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::ps_orderToLineEdit);
this->m_menuActions[0] = orderAction;
}
}
this->m_validator->setRange(0, maxOrder);
this->m_leOrder->setValidator(this->m_validator);
this->m_leOrder->setPlaceholderText("New order 0-" + QString::number(maxOrder));
menuActions.addMenuViewOrder();
menuActions.addAction(this->m_menuActions[0], CMenuAction::pathViewOrder());
this->m_menuActions[1] = menuActions.addAction(CIcons::arrowMediumNorth16(), "To top", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::ps_orderToTop });
this->m_menuActions[2] = menuActions.addAction(CIcons::arrowMediumSouth16(), "To bottom", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::ps_orderToBottom });