Commit 436c02fa authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.itemLibrary: allow entry names used twice

Use name + category for identification needed some refactoring.
parent 1daebd7c
......@@ -178,7 +178,8 @@ void ItemCreatorTool::createAtItem(const QRectF &rect)
return;
if (list.first() == "item") {
RewriterTransaction transaction = view()->beginRewriterTransaction();
ItemLibraryEntry itemLibraryEntry = view()->model()->metaInfo().itemLibraryInfo()->entry(list.at(1));
Q_ASSERT(false); //this code is out of date
ItemLibraryEntry itemLibraryEntry; //= view()->model()->metaInfo().itemLibraryInfo()->entry(list.at(1));
QmlItemNode newNode = view()->createQmlItemNode(itemLibraryEntry, pos, parentNode);
newNode.modelNode().variantProperty("width") = rect.width();
newNode.modelNode().variantProperty("height") = rect.height();
......
......@@ -104,7 +104,7 @@ public:
ItemLibraryEntry entry(const QString &name) const;
void addEntry(const ItemLibraryEntry &entry);
bool removeEntry(const QString &name);
bool containsEntry(const ItemLibraryEntry &entry);
void clearEntries();
signals:
......
......@@ -283,25 +283,25 @@ QList<ItemLibraryEntry> ItemLibraryInfo::entries() const
return list;
}
static inline QString keyForEntry(const ItemLibraryEntry &entry)
{
return entry.name() + entry.category();
}
void ItemLibraryInfo::addEntry(const ItemLibraryEntry &entry)
{
if (m_d->nameToEntryHash.contains(entry.name()))
const QString key = keyForEntry(entry);
if (m_d->nameToEntryHash.contains(key))
throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__);
m_d->nameToEntryHash.insert(entry.name(), entry);
m_d->nameToEntryHash.insert(key, entry);
emit entriesChanged();
}
bool ItemLibraryInfo::removeEntry(const QString &name)
bool ItemLibraryInfo::containsEntry(const ItemLibraryEntry &entry)
{
if (m_d->nameToEntryHash.remove(name)) {
emit entriesChanged();
return true;
}
if (m_d->baseInfo)
return m_d->baseInfo->removeEntry(name);
return false;
const QString key = keyForEntry(entry);
return m_d->nameToEntryHash.contains(key);
}
void ItemLibraryInfo::clearEntries()
......
......@@ -347,7 +347,7 @@ void SubComponentManagerPrivate::registerQmlFile(const QFileInfo &fileInfo, cons
itemLibraryEntry.setName(componentName);
itemLibraryEntry.setCategory("QML Components");
if (m_metaInfo.itemLibraryInfo()->entry(componentName).name() != componentName)
if (!m_metaInfo.itemLibraryInfo()->containsEntry(itemLibraryEntry))
m_metaInfo.itemLibraryInfo()->addEntry(itemLibraryEntry);
}
}
......
<metainfo>
<node name="Label" icon=":/meegoplugin/images/label16.png">
<itemlibraryentry name="Label (MeeGo)" category="Components MeeGo" libraryIcon=":/meegoplugin/images/label.png" requiredImport="com.Meego">
<itemlibraryentry name="Label" category="Components MeeGo" libraryIcon=":/meegoplugin/images/label.png" requiredImport="com.Meego">
<property name="text" type="QString" value="Label"/>
</itemlibraryentry>
</node>
<node name="Button" icon=":/meegoplugin/images/button16.png">
<itemlibraryentry name="Button (MeeGo)" category="Components MeeGo" libraryIcon=":/meegoplugin/images/button.png" requiredImport="com.Meego">
<itemlibraryentry name="Button" category="Components MeeGo" libraryIcon=":/meegoplugin/images/button.png" requiredImport="com.Meego">
</itemlibraryentry>
</node>
<node name="Slider" icon=":/meegoplugin/images/slider16.png">
<itemlibraryentry name="Slider (MeeGo)" category="Components MeeGo" libraryIcon=":/meegoplugin/images/slider.png" requiredImport="com.Meego">
<itemlibraryentry name="Slider" category="Components MeeGo" libraryIcon=":/meegoplugin/images/slider.png" requiredImport="com.Meego">
</itemlibraryentry>
</node>
<node name="CheckBox" icon=":/meegoplugin/images/checkbox16.png">
<itemlibraryentry name="CheckBox (MeeGo)" category="Components MeeGo" libraryIcon=":/meegoplugin/images/checkbox.png" requiredImport="com.Meego">
<itemlibraryentry name="CheckBox" category="Components MeeGo" libraryIcon=":/meegoplugin/images/checkbox.png" requiredImport="com.Meego">
</itemlibraryentry>
</node>
<node name="Spinner" icon=":/meegoplugin/images/item-icon16.png">
<itemlibraryentry name="Spinner (MeeGo)" category="Components MeeGo" libraryIcon=":/meegoplugin/images/item-icon.png" requiredImport="com.Meego">
<itemlibraryentry name="Spinner" category="Components MeeGo" libraryIcon=":/meegoplugin/images/item-icon.png" requiredImport="com.Meego">
</itemlibraryentry>
</node>
<node name="LineEdit" icon=":/meegoplugin/images/lineedit16.png">
<itemlibraryentry name="LineEdit (MeeGo)" category="Components MeeGo" libraryIcon=":/meegoplugin/images/lineedit.png" requiredImport="com.Meego">
<itemlibraryentry name="LineEdit" category="Components MeeGo" libraryIcon=":/meegoplugin/images/lineedit.png" requiredImport="com.Meego">
</itemlibraryentry>
</node>
</metainfo>
......@@ -6,6 +6,7 @@
<file>images/button.png</file>
<file>images/button16.png</file>
<file>images/checkbox.png</file>
<file>images/checkbox16.png</file>
<file>images/label.png</file>
<file>images/label16.png</file>
<file>images/lineedit.png</file>
......
<metainfo>
<node name="Label" icon=":/symbianplugin/images/label16.png">
<itemlibraryentry name="Label (Symbian)" category="Components Symbian" libraryIcon=":/symbianplugin/images/label.png" version="1.0" requiredImport="Qt.labs.Symbian">
<itemlibraryentry name="Label" category="Components Symbian" libraryIcon=":/symbianplugin/images/label.png" version="1.0" requiredImport="Qt.labs.Symbian">
<property name="width" type="int" value="100"/>
<property name="height" type="int" value="30"/>
<property name="text" type="QString" value="Label"/>
</itemlibraryentry>
</node>
<node name="Button" icon=":/symbianplugin/images/button16.png">
<itemlibraryentry name="Button (Symbian)" category="Components Symbian" libraryIcon=":/symbianplugin/images/button.png" version="1.0" requiredImport="Qt.labs.Symbian">
<itemlibraryentry name="Button" category="Components Symbian" libraryIcon=":/symbianplugin/images/button.png" version="1.0" requiredImport="Qt.labs.Symbian">
<property name="width" type="int" value="100"/>
<property name="height" type="int" value="30"/>
<property name="text" type="QString" value="Button"/>
......@@ -16,14 +16,14 @@
<node name="Slider" icon=":/symbianplugin/images/slider16.png">
</node>
<node name="CheckBox" icon=":/symbianplugin/images/checkbox16.png">
<itemlibraryentry name="CheckBox (Symbian)" category="Components Symbian" libraryIcon=":/symbianplugin/images/checkbox.png" version="1.0" requiredImport="Qt.labs.Symbian">
<itemlibraryentry name="CheckBox" category="Components Symbian" libraryIcon=":/symbianplugin/images/checkbox.png" version="1.0" requiredImport="Qt.labs.Symbian">
<property name="width" type="int" value="180"/>
<property name="height" type="int" value="30"/>
<property name="text" type="QString" value="CheckBox"/>
</itemlibraryentry>
</node>
<node name="RadioButton" icon=":/symbianplugin/images/radiobutton16.png">
<itemlibraryentry name="RadioButton (Symbian)" category="Components Symbian" libraryIcon=":/symbianplugin/images/radiobutton.png" version="1.0" requiredImport="Qt.labs.Symbian">
<itemlibraryentry name="RadioButton" category="Components Symbian" libraryIcon=":/symbianplugin/images/radiobutton.png" version="1.0" requiredImport="Qt.labs.Symbian">
<property name="width" type="int" value="180"/>
<property name="height" type="int" value="30"/>
<property name="text" type="QString" value="RadioButton"/>
......@@ -34,14 +34,14 @@
<node name="Switch" icon=":/symbianplugin/images/item-icon16.png">
</node>
<node name="LineEdit" icon=":/symbianplugin/images/lineedit16.png">
<itemlibraryentry name="LineEdit (Symbian)" category="Components Symbian" libraryIcon=":/symbianplugin/images/lineedit.png" version="1.0" requiredImport="Qt.labs.Symbian">
<itemlibraryentry name="LineEdit" category="Components Symbian" libraryIcon=":/symbianplugin/images/lineedit.png" version="1.0" requiredImport="Qt.labs.Symbian">
<property name="width" type="int" value="100"/>
<property name="height" type="int" value="30"/>
<property name="text" type="QString" value="LineEdit"/>
</itemlibraryentry>
</node>
<node name="ProgressBar" icon=":/symbianplugin/images/progressbar16.png">
<itemlibraryentry name="ProgressBar (Symbian)" category="Components Symbian" libraryIcon=":/symbianplugin/images/progressbar.png" version="1.0" requiredImport="Qt.labs.Symbian">
<itemlibraryentry name="ProgressBar" category="Components Symbian" libraryIcon=":/symbianplugin/images/progressbar.png" version="1.0" requiredImport="Qt.labs.Symbian">
<property name="width" type="int" value="100"/>
<property name="height" type="int" value="30"/>
</itemlibraryentry>
......
......@@ -5,6 +5,7 @@
<file>images/item-icon.png</file>
<file>images/button.png</file>
<file>images/button16.png</file>
<file>images/checkbox16.png</file>
<file>images/checkbox.png</file>
<file>images/label.png</file>
<file>images/label16.png</file>
......
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