mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #454 Improve hotkey settings component
This commit is contained in:
committed by
Mathew Sutcliffe
parent
6644c73703
commit
5a82e2e6bf
71
src/blackgui/models/actionitem.cpp
Normal file
71
src/blackgui/models/actionitem.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
#include "actionitem.h"
|
||||
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
|
||||
ActionItem::ActionItem(const QString &action, const QString &name, ActionItem *parent) :
|
||||
m_action(action), m_actionName(name), m_parentItem(parent)
|
||||
{
|
||||
}
|
||||
|
||||
ActionItem::~ActionItem()
|
||||
{
|
||||
qDeleteAll(m_childItems);
|
||||
}
|
||||
|
||||
void ActionItem::appendChild(ActionItem *item)
|
||||
{
|
||||
m_childItems.append(item);
|
||||
}
|
||||
|
||||
ActionItem *ActionItem::findChildByName(const QString &name)
|
||||
{
|
||||
for (auto child : m_childItems)
|
||||
{
|
||||
if (child->getActionName() == name) return child;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ActionItem *ActionItem::getChildByRow(int row)
|
||||
{
|
||||
return m_childItems.value(row);
|
||||
}
|
||||
|
||||
int ActionItem::getChildCount() const
|
||||
{
|
||||
return m_childItems.count();
|
||||
}
|
||||
|
||||
int ActionItem::getColumnCount() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString ActionItem::getAction() const
|
||||
{
|
||||
return m_action;
|
||||
}
|
||||
|
||||
QString ActionItem::getActionName() const
|
||||
{
|
||||
return m_actionName;
|
||||
}
|
||||
|
||||
ActionItem *ActionItem::getParentItem()
|
||||
{
|
||||
return m_parentItem;
|
||||
}
|
||||
|
||||
int ActionItem::getRow() const
|
||||
{
|
||||
if (m_parentItem) { return m_parentItem->m_childItems.indexOf(const_cast<ActionItem *>(this)); }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user