Commit 670edda4 authored by Marco Bubke's avatar Marco Bubke Committed by Tim Jenssen
Browse files

QMlDesigner: Rename ItemLibrarySortedModel in ItemLibrarySectionModel



Change-Id: I8c4d6fe661d75cfc93c6dd4500f67c0810e1b1e2
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent b3ed42d8
......@@ -29,7 +29,7 @@
#include "itemlibrarymodel.h"
#include "itemlibraryinfo.h"
#include "itemlibrarysectionmodel.h"
#include "itemlibrarysection.h"
#include "itemlibraryitem.h"
#include "itemlibrarysection.h"
......@@ -44,7 +44,7 @@
#include <qdebug.h>
static bool inline registerItemLibrarySortedModel() {
qmlRegisterType<QmlDesigner::ItemLibrarySortedModel>();
qmlRegisterType<QmlDesigner::ItemLibrarySectionModel>();
return true;
}
......@@ -89,7 +89,7 @@ QVariant ItemLibraryModel::data(const QModelIndex &index, int role) const
if (m_roleNames.contains(role)) {
QVariant value = visibleSections().at(index.row())->property(m_roleNames.value(role));
ItemLibrarySortedModel* model = qobject_cast<ItemLibrarySortedModel *>(value.value<QObject*>());
ItemLibrarySectionModel* model = qobject_cast<ItemLibrarySectionModel *>(value.value<QObject*>());
if (model)
return QVariant::fromValue(model);
......@@ -291,7 +291,7 @@ void ItemLibraryModel::clearSections()
void ItemLibraryModel::registerQmlTypes()
{
qmlRegisterType<QmlDesigner::ItemLibrarySortedModel>();
qmlRegisterType<QmlDesigner::ItemLibrarySectionModel>();
qmlRegisterType<QmlDesigner::ItemLibraryModel>();
}
......
......@@ -68,7 +68,7 @@ signals:
void sectionEntriesChanged();
private:
ItemLibrarySortedModel m_sectionEntries;
ItemLibrarySectionModel m_sectionEntries;
QString m_name;
int m_sectionLibraryId;
bool m_sectionExpanded;
......
......@@ -33,22 +33,22 @@
namespace QmlDesigner {
ItemLibrarySortedModel::ItemLibrarySortedModel(QObject *parent) :
ItemLibrarySectionModel::ItemLibrarySectionModel(QObject *parent) :
QAbstractListModel(parent)
{
}
ItemLibrarySortedModel::~ItemLibrarySortedModel()
ItemLibrarySectionModel::~ItemLibrarySectionModel()
{
clearItems();
}
int ItemLibrarySortedModel::rowCount(const QModelIndex &) const
int ItemLibrarySectionModel::rowCount(const QModelIndex &) const
{
return m_privList.count();
}
QVariant ItemLibrarySortedModel::data(const QModelIndex &index, int role) const
QVariant ItemLibrarySectionModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.row()+1 > m_privList.count()) {
qDebug() << Q_FUNC_INFO << "invalid index requested";
......@@ -58,7 +58,7 @@ QVariant ItemLibrarySortedModel::data(const QModelIndex &index, int role) const
if (m_roleNames.contains(role)) {
QVariant value = m_privList.at(index.row())->property(m_roleNames.value(role));
if (ItemLibrarySortedModel* model = qobject_cast<ItemLibrarySortedModel *>(value.value<QObject*>()))
if (ItemLibrarySectionModel* model = qobject_cast<ItemLibrarySectionModel *>(value.value<QObject*>()))
return QVariant::fromValue(model);
return m_privList.at(index.row())->property(m_roleNames.value(role));
......@@ -69,7 +69,7 @@ QVariant ItemLibrarySortedModel::data(const QModelIndex &index, int role) const
return QVariant();
}
void ItemLibrarySortedModel::clearItems()
void ItemLibrarySectionModel::clearItems()
{
beginResetModel();
while (m_itemOrder.count() > 0)
......@@ -84,7 +84,7 @@ static bool compareFunction(QObject *first, QObject *second)
return first->property(sortRoleName).toString() < second->property(sortRoleName).toString();
}
void ItemLibrarySortedModel::addItem(ItemLibraryItem *element, int libId)
void ItemLibrarySectionModel::addItem(ItemLibraryItem *element, int libId)
{
struct order_struct orderEntry;
orderEntry.libId = libId;
......@@ -101,7 +101,7 @@ void ItemLibrarySortedModel::addItem(ItemLibraryItem *element, int libId)
setItemVisible(libId, true);
}
void ItemLibrarySortedModel::removeItem(int libId)
void ItemLibrarySectionModel::removeItem(int libId)
{
QObject *element = m_itemModels.value(libId);
int pos = findItem(libId);
......@@ -114,13 +114,13 @@ void ItemLibrarySortedModel::removeItem(int libId)
delete element;
}
bool ItemLibrarySortedModel::itemVisible(int libId) const
bool ItemLibrarySectionModel::itemVisible(int libId) const
{
int pos = findItem(libId);
return m_itemOrder.at(pos).visible;
}
bool ItemLibrarySortedModel::setItemVisible(int libId, bool visible)
bool ItemLibrarySectionModel::setItemVisible(int libId, bool visible)
{
int pos = findItem(libId);
if (m_itemOrder.at(pos).visible == visible)
......@@ -136,7 +136,7 @@ bool ItemLibrarySortedModel::setItemVisible(int libId, bool visible)
return true;
}
void ItemLibrarySortedModel::privateInsert(int pos, QObject *element)
void ItemLibrarySectionModel::privateInsert(int pos, QObject *element)
{
QObject *object = element;
......@@ -148,27 +148,27 @@ void ItemLibrarySortedModel::privateInsert(int pos, QObject *element)
m_privList.insert(pos, element);
}
void ItemLibrarySortedModel::privateRemove(int pos)
void ItemLibrarySectionModel::privateRemove(int pos)
{
m_privList.removeAt(pos);
}
const QMap<int, ItemLibraryItem*> &ItemLibrarySortedModel::items() const
const QMap<int, ItemLibraryItem*> &ItemLibrarySectionModel::items() const
{
return m_itemModels;
}
const QList<ItemLibraryItem *> ItemLibrarySortedModel::itemList() const
const QList<ItemLibraryItem *> ItemLibrarySectionModel::itemList() const
{
return m_itemModels.values();
}
ItemLibraryItem *ItemLibrarySortedModel::item(int libId)
ItemLibraryItem *ItemLibrarySectionModel::item(int libId)
{
return m_itemModels.value(libId);
}
int ItemLibrarySortedModel::findItem(int libId) const
int ItemLibrarySectionModel::findItem(int libId) const
{
int i = 0;
QListIterator<struct order_struct> it(m_itemOrder);
......@@ -182,7 +182,7 @@ int ItemLibrarySortedModel::findItem(int libId) const
return -1;
}
int ItemLibrarySortedModel::visibleItemPosition(int libId) const
int ItemLibrarySectionModel::visibleItemPosition(int libId) const
{
int i = 0;
QListIterator<struct order_struct> it(m_itemOrder);
......@@ -198,13 +198,13 @@ int ItemLibrarySortedModel::visibleItemPosition(int libId) const
return -1;
}
void ItemLibrarySortedModel::resetModel()
void ItemLibrarySectionModel::resetModel()
{
beginResetModel();
endResetModel();
}
void ItemLibrarySortedModel::addRoleName(const QByteArray &roleName)
void ItemLibrarySectionModel::addRoleName(const QByteArray &roleName)
{
if (m_roleNames.values().contains(roleName))
return;
......
......@@ -38,13 +38,13 @@ namespace QmlDesigner {
class ItemLibraryItem;
class ItemLibrarySortedModel: public QAbstractListModel {
class ItemLibrarySectionModel: public QAbstractListModel {
Q_OBJECT
public:
ItemLibrarySortedModel(QObject *parent = 0);
~ItemLibrarySortedModel();
ItemLibrarySectionModel(QObject *parent = 0);
~ItemLibrarySectionModel();
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
......@@ -87,6 +87,6 @@ private:
} // namespace QmlDesigner
QML_DECLARE_TYPE(QmlDesigner::ItemLibrarySortedModel)
QML_DECLARE_TYPE(QmlDesigner::ItemLibrarySectionModel)
#endif // QMLDESIGNER_ITEMLIBRARYSECTIONMODEL_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment