void MenuFile::removeMenu(const QString &menuName) { m_bDirty = true; QDomElement elem = findMenu(m_doc.documentElement(), menuName, true); purgeDeleted(elem); elem.appendChild(m_doc.createElement(MF_DELETED)); }
void MenuFile::moveMenu(const QString &oldMenu, const QString &newMenu) { m_bDirty = true; // Undelete the new menu QDomElement elem = findMenu(m_doc.documentElement(), newMenu, true); purgeDeleted(elem); elem.appendChild(m_doc.createElement(MF_NOTDELETED)); // TODO: GET RID OF COMMON PART, IT BREAKS STUFF // Find common part QStringList oldMenuParts = QStringList::split('/', oldMenu); QStringList newMenuParts = QStringList::split('/', newMenu); QString commonMenuName; uint max = QMIN(oldMenuParts.count(), newMenuParts.count()); uint i = 0; for(; i < max; i++) { if(oldMenuParts[i] != newMenuParts[i]) break; commonMenuName += '/' + oldMenuParts[i]; } QString oldMenuName; for(uint j = i; j < oldMenuParts.count(); j++) { if(i != j) oldMenuName += '/'; oldMenuName += oldMenuParts[j]; } QString newMenuName; for(uint j = i; j < newMenuParts.count(); j++) { if(i != j) newMenuName += '/'; newMenuName += newMenuParts[j]; } if(oldMenuName == newMenuName) return; // Can happen elem = findMenu(m_doc.documentElement(), commonMenuName, true); // Add instructions for moving QDomElement moveNode = m_doc.createElement(MF_MOVE); QDomElement node = m_doc.createElement(MF_OLD); node.appendChild(m_doc.createTextNode(oldMenuName)); moveNode.appendChild(node); node = m_doc.createElement(MF_NEW); node.appendChild(m_doc.createTextNode(newMenuName)); moveNode.appendChild(node); elem.appendChild(moveNode); }