Commit 6b577c9a authored by Marco Bubke's avatar Marco Bubke Committed by Tim Jenssen

QmlDesigner: Remove ids in ItemLibrarySectionModel

Change-Id: I6d7e53fb5b034fc4c6b6fcc45f7f3a7b846b2487
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 9befa036
......@@ -133,34 +133,11 @@ void ItemLibraryModel::setItemIconSize(const QSize &itemIconSize)
}
}
int ItemLibraryModel::getItemSectionIndex(int itemLibId)
{
if (m_sections.contains(itemLibId))
return section(m_sections.value(itemLibId))->visibleItemIndex(itemLibId);
else
return -1;
}
int ItemLibraryModel::getSectionLibId(int itemLibId)
{
return m_sections.value(itemLibId);
}
bool ItemLibraryModel::isItemVisible(int itemLibId)
{
if (!m_sections.contains(itemLibId))
return false;
int sectionLibId = m_sections.value(itemLibId);
if (section(sectionLibId)->isVisible())
return false;
return section(sectionLibId)->isItemVisible(itemLibId);
}
Import entryToImport(const ItemLibraryEntry &entry)
{
if (entry.majorVersion() == -1 && entry.minorVersion() == -1)
......
......@@ -79,9 +79,7 @@ public slots:
void setSearchText(const QString &searchText);
void setItemIconSize(const QSize &itemIconSize);
int getItemSectionIndex(int itemLibId);
int getSectionLibId(int itemLibId);
bool isItemVisible(int itemLibId);
void setExpanded(bool, const QString &section);
signals:
......
......@@ -75,28 +75,11 @@ void ItemLibrarySection::addSectionEntry(ItemLibraryItem *sectionEntry)
m_sectionEntries.addItem(sectionEntry, sectionEntry->itemLibId());
}
void ItemLibrarySection::removeSectionEntry(int itemLibId)
{
m_sectionEntries.removeItem(itemLibId);
}
QObject *ItemLibrarySection::sectionEntries()
{
return &m_sectionEntries;
}
int ItemLibrarySection::visibleItemIndex(int itemLibId)
{
return m_sectionEntries.item(itemLibId)->isVisible();
}
bool ItemLibrarySection::isItemVisible(int itemLibId)
{
return m_sectionEntries.itemVisible(itemLibId);
}
bool ItemLibrarySection::updateSectionVisibility(const QString &searchText, bool *changed)
{
bool haveVisibleItems = false;
......@@ -105,11 +88,13 @@ bool ItemLibrarySection::updateSectionVisibility(const QString &searchText, bool
QMap<int, ItemLibraryItem*>::const_iterator itemIterator = m_sectionEntries.items().constBegin();
while (itemIterator != m_sectionEntries.items().constEnd()) {
ItemLibraryItem *itemLibraryItem = itemIterator.value();
bool itemVisible = m_sectionEntries.item(itemIterator.key())->itemName().toLower().contains(searchText);
bool itemVisible = itemLibraryItem->itemName().toLower().contains(searchText);
bool itemChanged = false;
itemChanged = m_sectionEntries.setItemVisible(itemIterator.key(), itemVisible);
itemChanged = itemLibraryItem->setVisible(itemVisible);
*changed |= itemChanged;
......
......@@ -52,12 +52,8 @@ public:
QVariant sortingRole() const;
void addSectionEntry(ItemLibraryItem *sectionEntry);
void removeSectionEntry(int itemLibId);
QObject *sectionEntries();
int visibleItemIndex(int itemLibId);
bool isItemVisible(int itemLibId);
bool updateSectionVisibility(const QString &searchText, bool *changed);
void updateItemIconSize(const QSize &itemIconSize);
......
......@@ -92,29 +92,6 @@ void ItemLibrarySectionModel::addItem(ItemLibraryItem *element, int libId)
element->setVisible(true);
}
void ItemLibrarySectionModel::removeItem(int libId)
{
ItemLibraryItem *itemLibraryItem = m_itemModels.value(libId);
itemLibraryItem->setVisible(false);
m_itemModels.remove(libId);
delete itemLibraryItem;
}
bool ItemLibrarySectionModel::itemVisible(int libId) const
{
ItemLibraryItem *itemLibraryItem = m_itemModels.value(libId);
return itemLibraryItem->isVisible();
}
bool ItemLibrarySectionModel::setItemVisible(int libId, bool visible)
{
ItemLibraryItem *itemLibraryItem = m_itemModels.value(libId);
return itemLibraryItem->setVisible(visible);
}
void ItemLibrarySectionModel::privateInsert(int pos, QObject *element)
{
m_privList.insert(pos, element);
......@@ -135,11 +112,6 @@ const QList<ItemLibraryItem *> ItemLibrarySectionModel::itemList() const
return m_itemModels.values();
}
ItemLibraryItem *ItemLibrarySectionModel::item(int libId)
{
return m_itemModels.value(libId);
}
void ItemLibrarySectionModel::resetModel()
{
beginResetModel();
......
......@@ -52,10 +52,6 @@ public:
void clearItems();
void addItem(ItemLibraryItem *item, int libId);
void removeItem(int libId);
bool itemVisible(int libId) const;
bool setItemVisible(int libId, bool visible);
void privateInsert(int pos, QObject *item);
void privateRemove(int pos);
......@@ -63,8 +59,6 @@ public:
const QMap<int, ItemLibraryItem*> &items() const;
const QList<ItemLibraryItem *> itemList() const;
ItemLibraryItem* item(int libId);
void resetModel();
private: // functions
......
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