mirror of
https://github.com/YACReader/yacreader
synced 2025-07-14 02:54:46 -04:00
Update russian translation. Need to subtract and to bring the terminology to a common denominator
This commit is contained in:
86
shortcuts_management/actions_groups_model.cpp
Normal file
86
shortcuts_management/actions_groups_model.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
#include "actions_groups_model.h"
|
||||
|
||||
ActionsGroupsModel::ActionsGroupsModel(QObject *parent) :
|
||||
QAbstractItemModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
int ActionsGroupsModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
|
||||
return groups.length();
|
||||
}
|
||||
|
||||
int ActionsGroupsModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
QModelIndex ActionsGroupsModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
return createIndex(row, column);
|
||||
}
|
||||
|
||||
QVariant ActionsGroupsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DecorationRole)
|
||||
return QVariant(groups.at(index.row()).getIcon());
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
return QVariant(groups[index.row()].getName());
|
||||
}
|
||||
|
||||
QModelIndex ActionsGroupsModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
void ActionsGroupsModel::addActionsGroup(const ActionsGroup &group)
|
||||
{
|
||||
beginInsertRows(QModelIndex(),groups.length(),groups.length());
|
||||
groups.push_back(group);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
QList<QAction *> ActionsGroupsModel::getActions(const QModelIndex &mi)
|
||||
{
|
||||
if(mi.isValid())
|
||||
return groups[mi.row()].getActions();
|
||||
return QList<QAction *>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
ActionsGroup::ActionsGroup(const QString &name, const QIcon &icon, QList<QAction *> &actions)
|
||||
:name(name), icon(icon), actions(actions)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString ActionsGroup::getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
QIcon ActionsGroup::getIcon() const
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
QList<QAction *> ActionsGroup::getActions() const
|
||||
{
|
||||
return actions;
|
||||
}
|
Reference in New Issue
Block a user