7 #include <QStringBuilder>
20 CActionModel::CActionModel(
QObject *parent)
31 m_rootItem->getColumnCount();
39 Q_ASSERT_X(item, Q_FUNC_INFO,
"Missing item");
41 if (role == ActionRole) {
return item->
getAction(); }
53 const bool selectable = item && !item->
hasChildren();
75 if (parentItem == m_rootItem.data()) {
return {}; }
82 if (
parent.column() > 0) {
return 0; }
88 void CActionModel::setupModelData()
97 for (
const QString &actionPath : std::as_const(keys))
102 for (
const auto &token : tokens)
104 currentPath += u
'/' % token;
106 if (child ==
nullptr)
108 const bool isAction = currentPath == actionPath;
110 isAction ? availableActionsAndIcons[actionPath] : CIcons::StandardIconEmpty16;
111 child =
new CActionItem(isAction ? actionPath :
"", token, icon, parentItem);
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
CInputManager * getInputManager() const
The input manager, if available.
One single action item in a tree.
QString getAction() const
Returns the stored action.
int getRow() const
Get row of this item.
bool hasChildren() const
Has children?
int getChildCount() const
Number of children.
void appendChild(CActionItem *child)
Append a new child.
CActionItem * getParentItem() const
Get parent item.
CActionItem * getChildByRow(int row) const
Get child by row.
CActionItem * findChildByName(const QString &name) const
Find child by its name.
QString getActionName() const
Get action name.
const QPixmap & getIcon() const
Icon.
QVariant data(const QModelIndex &index, int role) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Qt::ItemFlags flags(const QModelIndex &index) const
int rowCount(const QModelIndex &parent=QModelIndex()) const
virtual ~CActionModel()
Destructor.
int columnCount(const QModelIndex &parent=QModelIndex()) const
IconIndex
Index for each icon, allows to send them via DBus, efficiently store them, etc.
Backend services of the swift project, like dealing with the network or the simulators.
Models to be used with views, mainly QTableView.
Free functions in swift::misc.
QModelIndex createIndex(int row, int column, const void *ptr) const const
virtual Qt::ItemFlags flags(const QModelIndex &index) const const
bool hasIndex(int row, int column, const QModelIndex &parent) const const
QList< Key > keys() const const
void * internalPointer() const const
bool isValid() const const
QObject * parent() const const
void sort(Qt::CaseSensitivity cs)