|
@@ -99,23 +99,26 @@ QString FbScheme::info() const
|
|
|
QString FbScheme::type() const
|
|
|
{
|
|
|
if (isNull()) return QString();
|
|
|
+ if (attribute("name") == "last-name") {
|
|
|
+ QString result = attribute("type");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
QString result = attribute("type");
|
|
|
if (!result.isEmpty()) return result;
|
|
|
- FbScheme child = firstChildElement("xs:complexType");
|
|
|
- child = child.firstChildElement("xs:complexContent");
|
|
|
- child = child.firstChildElement("xs:extension");
|
|
|
- return child.attribute("base");
|
|
|
+ FbScheme child = firstChildElement("xs:complexType").firstChildElement();
|
|
|
+ while (!child.isNull()) {
|
|
|
+ QString tag = child.tagName();
|
|
|
+ if (tag == "xs:complexContent" || tag == "xs:simpleContent") {
|
|
|
+ return child.firstChildElement("xs:extension").attribute("base");
|
|
|
+ }
|
|
|
+ child = child.nextSiblingElement();
|
|
|
+ }
|
|
|
+ return QString();
|
|
|
}
|
|
|
|
|
|
-FbScheme FbScheme::element(const QString &name) const
|
|
|
+FbScheme FbScheme::item(const QString &name) const
|
|
|
{
|
|
|
- FbScheme parent = *this;
|
|
|
- if (parent.isNull()) {
|
|
|
- parent = fb2().documentElement();
|
|
|
- parent = parent.element("FictionBook");
|
|
|
- }
|
|
|
-
|
|
|
- FbScheme child = parent.firstChildElement();
|
|
|
+ FbScheme child = firstChildElement();
|
|
|
while (!child.isNull()) {
|
|
|
switch (toKeyword(child.tagName())) {
|
|
|
case XsElement: {
|
|
@@ -124,13 +127,26 @@ FbScheme FbScheme::element(const QString &name) const
|
|
|
case XsChoice:
|
|
|
case XsComplexType:
|
|
|
case XsSequence: {
|
|
|
- FbScheme result = child.element(name);
|
|
|
+ FbScheme result = child.item(name);
|
|
|
if (!result.isNull()) return result;
|
|
|
} break;
|
|
|
default: ;
|
|
|
}
|
|
|
child = child.nextSiblingElement();
|
|
|
}
|
|
|
+ return FbScheme();
|
|
|
+}
|
|
|
+
|
|
|
+FbScheme FbScheme::element(const QString &name) const
|
|
|
+{
|
|
|
+ FbScheme parent = *this;
|
|
|
+ if (parent.isNull()) {
|
|
|
+ parent = fb2().documentElement();
|
|
|
+ parent = parent.element("FictionBook");
|
|
|
+ }
|
|
|
+
|
|
|
+ FbScheme child = parent.item(name);
|
|
|
+ if (!child.isNull()) return child;
|
|
|
|
|
|
QString type = this->type();
|
|
|
if (type.isEmpty()) return *this;
|
|
@@ -579,11 +595,11 @@ void FbHeadView::appendNode()
|
|
|
|
|
|
FbNodeDlg dlg(this, item->scheme(), list);
|
|
|
if (dlg.exec()) {
|
|
|
- current = m->append(current, dlg.value());
|
|
|
- if (current.isValid()) {
|
|
|
- setCurrentIndex(current);
|
|
|
- scrollTo(current);
|
|
|
+ QModelIndex child = m->append(current, dlg.value());
|
|
|
+ if (child.isValid()) {
|
|
|
expand(current);
|
|
|
+ setCurrentIndex(child);
|
|
|
+ scrollTo(child);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -602,7 +618,7 @@ QModelIndex FbHeadModel::append(const QModelIndex &parent, const QString &name)
|
|
|
beginInsertRows(parent, row, row);
|
|
|
FbHeadItem * item = owner->append(name);
|
|
|
endInsertRows();
|
|
|
- return createIndex(row, 1, (void*)item);
|
|
|
+ return createIndex(row, 0, (void*)item);
|
|
|
}
|
|
|
|
|
|
void FbHeadModel::remove(const QModelIndex &index)
|