forked from qt-creator/qt-creator
Improve item model templates
* Add missing "return true" in insert/remove Rows/Columns * Use C++11 syntax for a vector of ints containing just "role" * Make items not only editable, but also enabled+selectable, as expected by default Change-Id: I8ed529d2534a495f2c924906fe51ada474f9347e Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -84,7 +84,7 @@ bool %{CN}::setData(const QModelIndex &index, const QVariant &value, int role)
|
|||||||
{
|
{
|
||||||
if (data(index, role) != value) {
|
if (data(index, role) != value) {
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
emit dataChanged(index, index, QVector<int>() << role);
|
emit dataChanged(index, index, {role});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -95,7 +95,7 @@ Qt::ItemFlags %{CN}::flags(const QModelIndex &index) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
|
|
||||||
return Qt::ItemIsEditable; // FIXME: Implement me!
|
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; // FIXME: Implement me!
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
@if %{AddData}
|
@if %{AddData}
|
||||||
@@ -105,6 +105,7 @@ bool %{CN}::insertRows(int row, int count, const QModelIndex &parent)
|
|||||||
beginInsertRows(parent, row, row + count - 1);
|
beginInsertRows(parent, row, row + count - 1);
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool %{CN}::insertColumns(int column, int count, const QModelIndex &parent)
|
bool %{CN}::insertColumns(int column, int count, const QModelIndex &parent)
|
||||||
@@ -112,6 +113,7 @@ bool %{CN}::insertColumns(int column, int count, const QModelIndex &parent)
|
|||||||
beginInsertColumns(parent, column, column + count - 1);
|
beginInsertColumns(parent, column, column + count - 1);
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
endInsertColumns();
|
endInsertColumns();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
@if %{RemoveData}
|
@if %{RemoveData}
|
||||||
@@ -121,6 +123,7 @@ bool %{CN}::removeRows(int row, int count, const QModelIndex &parent)
|
|||||||
beginRemoveRows(parent, row, row + count - 1);
|
beginRemoveRows(parent, row, row + count - 1);
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool %{CN}::removeColumns(int column, int count, const QModelIndex &parent)
|
bool %{CN}::removeColumns(int column, int count, const QModelIndex &parent)
|
||||||
@@ -128,6 +131,7 @@ bool %{CN}::removeColumns(int column, int count, const QModelIndex &parent)
|
|||||||
beginRemoveColumns(parent, column, column + count - 1);
|
beginRemoveColumns(parent, column, column + count - 1);
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
endRemoveColumns();
|
endRemoveColumns();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
%{JS: Cpp.closeNamespaces('%{Class}')}\
|
%{JS: Cpp.closeNamespaces('%{Class}')}\
|
||||||
|
@@ -68,7 +68,7 @@ bool %{CN}::setData(const QModelIndex &index, const QVariant &value, int role)
|
|||||||
{
|
{
|
||||||
if (data(index, role) != value) {
|
if (data(index, role) != value) {
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
emit dataChanged(index, index, QVector<int>() << role);
|
emit dataChanged(index, index, {role});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -79,7 +79,7 @@ Qt::ItemFlags %{CN}::flags(const QModelIndex &index) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
|
|
||||||
return Qt::ItemIsEditable; // FIXME: Implement me!
|
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; // FIXME: Implement me!
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
@if %{AddData}
|
@if %{AddData}
|
||||||
@@ -89,6 +89,7 @@ bool %{CN}::insertRows(int row, int count, const QModelIndex &parent)
|
|||||||
beginInsertRows(parent, row, row + count - 1);
|
beginInsertRows(parent, row, row + count - 1);
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
@if %{RemoveData}
|
@if %{RemoveData}
|
||||||
@@ -98,6 +99,7 @@ bool %{CN}::removeRows(int row, int count, const QModelIndex &parent)
|
|||||||
beginRemoveRows(parent, row, row + count - 1);
|
beginRemoveRows(parent, row, row + count - 1);
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
%{JS: Cpp.closeNamespaces('%{Class}')}\
|
%{JS: Cpp.closeNamespaces('%{Class}')}\
|
||||||
|
@@ -75,7 +75,7 @@ bool %{CN}::setData(const QModelIndex &index, const QVariant &value, int role)
|
|||||||
{
|
{
|
||||||
if (data(index, role) != value) {
|
if (data(index, role) != value) {
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
emit dataChanged(index, index, QVector<int>() << role);
|
emit dataChanged(index, index, {role});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -86,7 +86,7 @@ Qt::ItemFlags %{CN}::flags(const QModelIndex &index) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
|
|
||||||
return Qt::ItemIsEditable; // FIXME: Implement me!
|
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; // FIXME: Implement me!
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
@if %{AddData}
|
@if %{AddData}
|
||||||
@@ -96,6 +96,7 @@ bool %{CN}::insertRows(int row, int count, const QModelIndex &parent)
|
|||||||
beginInsertRows(parent, row, row + count - 1);
|
beginInsertRows(parent, row, row + count - 1);
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool %{CN}::insertColumns(int column, int count, const QModelIndex &parent)
|
bool %{CN}::insertColumns(int column, int count, const QModelIndex &parent)
|
||||||
@@ -103,6 +104,7 @@ bool %{CN}::insertColumns(int column, int count, const QModelIndex &parent)
|
|||||||
beginInsertColumns(parent, column, column + count - 1);
|
beginInsertColumns(parent, column, column + count - 1);
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
endInsertColumns();
|
endInsertColumns();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
@if %{RemoveData}
|
@if %{RemoveData}
|
||||||
@@ -112,6 +114,7 @@ bool %{CN}::removeRows(int row, int count, const QModelIndex &parent)
|
|||||||
beginRemoveRows(parent, row, row + count - 1);
|
beginRemoveRows(parent, row, row + count - 1);
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool %{CN}::removeColumns(int column, int count, const QModelIndex &parent)
|
bool %{CN}::removeColumns(int column, int count, const QModelIndex &parent)
|
||||||
@@ -119,6 +122,7 @@ bool %{CN}::removeColumns(int column, int count, const QModelIndex &parent)
|
|||||||
beginRemoveColumns(parent, column, column + count - 1);
|
beginRemoveColumns(parent, column, column + count - 1);
|
||||||
// FIXME: Implement me!
|
// FIXME: Implement me!
|
||||||
endRemoveColumns();
|
endRemoveColumns();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
%{JS: Cpp.closeNamespaces('%{Class}')}\
|
%{JS: Cpp.closeNamespaces('%{Class}')}\
|
||||||
|
Reference in New Issue
Block a user