A new step to implement cff support

preferencesAboutTextFull
Ivan Ilin 13 years ago
parent 8bcabeca95
commit 6174a7833f
  1. 74
      src/adaptors/UBCFFSubsetAdaptor.cpp
  2. 13
      src/adaptors/UBCFFSubsetAdaptor.h
  3. 13
      src/board/UBBoardPaletteManager.cpp

@ -41,6 +41,7 @@
//tag names definition //tag names definition
//use them everiwhere! //use them everiwhere!
static QString tElement = "element"; static QString tElement = "element";
static QString tGroup = "group";
static QString tEllipse = "ellipse"; static QString tEllipse = "ellipse";
static QString tIwb = "iwb"; static QString tIwb = "iwb";
static QString tMeta = "meta"; static QString tMeta = "meta";
@ -78,25 +79,72 @@ static QString aFontweight = "font-weight";
static QString aTextalign = "text-align"; static QString aTextalign = "text-align";
static QString aPoints = "points"; static QString aPoints = "points";
static QString svgNS = "http://www.w3.org/2000/svg"; static QString svgNS = "http://www.w3.org/2000/svg";
static QString tId = "id"; static QString iwbNS = "http://www.becta.org.uk/iwb";
static QString aId = "id";
UBCFFSubsetAdaptor::UBCFFSubsetAdaptor() UBCFFSubsetAdaptor::UBCFFSubsetAdaptor()
{ {
} }
void UBCFFSubsetAdaptor::UBCFFSubsetReader::hashNode(QDomNode *parent, QString prefix)
void UBCFFSubsetAdaptor::UBCFFSubsetReader::hashSiblingIwbElements(QDomElement *parent, QDomElement *topGroup) {
QDomElement curExt = parent->firstChildElement(tElement);
while (!curExt.isNull()) {
QDomElement n = curExt;
if (curExt.namespaceURI() != iwbNS)
continue;
QHash<QString, IwbExt>::iterator iSvgElement = extProperties.find(curExt.attribute("ref"));
if (iSvgElement != extProperties.end()) {
IwbExt &svgElement = *iSvgElement;
svgElement.extAttr.push_back(curExt);
if (topGroup)
qDebug() << "made";
}
curExt = curExt.nextSiblingElement(tElement);
}
}
void UBCFFSubsetAdaptor::UBCFFSubsetReader::addExtentionsToHash(QDomElement *parent)
{
//add top level elements
QDomElement curGroup = parent->firstChildElement(tGroup);
QDomElement topGroup;
while (!curGroup.isNull()) {
if (curGroup.namespaceURI() != iwbNS)
continue;
// if (parent == mDOMdoc.documentElement())
// topGroup = curGroup;
// QHash<QString, IwbExt>::iterator iSvgElement = extProperties.find(curExt.attribute("ref"));
// if (iSvgElement != extProperties.end()) {
// IwbExt &svgElement = *iSvgElement;
// svgElement.group = curGroup;
// qDebug() << "made";
// }
hashSiblingIwbElements(&curGroup, &topGroup);
if (curGroup.hasChildNodes()) {
addExtentionsToHash(&curGroup);
}
curGroup = curGroup.nextSiblingElement(tGroup);
}
//add groups
}
void UBCFFSubsetAdaptor::UBCFFSubsetReader::hashSvg(QDomNode *parent, QString prefix)
{ {
QDomNode n = parent->firstChild(); QDomNode n = parent->firstChild();
while (!n.isNull()) { while (!n.isNull()) {
QDomElement e = n.toElement(); QDomElement e = n.toElement();
QString id = e.attribute(tId); QString id = e.attribute(aId);
if(!id.isNull()) { if(!id.isNull()) {
extProperties.insert(id, IwbExt(e)); extProperties.insert(id, IwbExt(e));
qDebug() << prefix + e.prefix() + ":" + e.tagName(); qDebug() << prefix + e.prefix() + ":" + e.tagName();
} }
if (n.hasChildNodes()) { if (n.hasChildNodes()) {
hashNode(&n, QString("| %1").arg(prefix)); hashSvg(&n, QString("| %1").arg(prefix));
} }
n = n.nextSibling(); n = n.nextSibling();
} }
@ -107,11 +155,21 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::hashElements()
QDomElement svgSection = mDOMdoc.elementsByTagNameNS(svgNS, tSvg).at(0).toElement(); QDomElement svgSection = mDOMdoc.elementsByTagNameNS(svgNS, tSvg).at(0).toElement();
Q_ASSERT(!svgSection.isNull()); Q_ASSERT(!svgSection.isNull());
hashNode(&svgSection); hashSvg(&svgSection);
QDomElement parElement = mDOMdoc.documentElement();
Q_ASSERT(!parElement.isNull());
qDebug() << "ext properties count " << extProperties.count(); addExtentionsToHash(&parElement);
qDebug() << extProperties.value("link1").element.toElement().tagName();
// qDebug() << "ext properties count " << extProperties.count();
// qDebug() << extProperties.value("link1").element.toElement().tagName();
foreach (IwbExt cur, extProperties) {
qDebug() << (cur.extAttr.count() ? cur.extAttr.first().toElement().tagName() : "count < 0") ;
}
// for (int i = 0; i < extProperties.count(); i++) {
// }
// QDomNode n = docElem.firstChild(); // QDomNode n = docElem.firstChild();
// int i = 0; // int i = 0;

@ -29,12 +29,14 @@ class UBGraphicsSvgItem;
class QTransform; class QTransform;
struct IwbExt { struct IwbExt {
IwbExt() : group(NULL) {;} IwbExt() {;}
IwbExt(QDomNode element) : group(NULL), element(element) {;} IwbExt(QDomNode element) : element(element), extAttr(*(new QVector<QDomNode>())) {;}
QDomNode *group; QDomNode group;
QDomNode element; QDomNode element;
QVector<QDomNode> extAttr;
QHash<QString, QString> textAttributes; QHash<QString, QString> textAttributes;
operator bool() const {return group.isNull() || !element.isNull();}
}; };
class UBCFFSubsetAdaptor class UBCFFSubsetAdaptor
@ -80,9 +82,10 @@ private:
QDomDocument mDOMdoc; QDomDocument mDOMdoc;
QHash<QString, IwbExt> extProperties; QHash<QString, IwbExt> extProperties;
bool hashElements(); bool hashElements();
void addExtentionsToHash(QDomElement *parent);
void hashNode(QDomNode *parent, QString prefix = ""); void hashSvg(QDomNode *parent, QString prefix = "");
void hashSiblingIwbElements(QDomElement *parent, QDomElement *topGroup = 0);
//methods to store current xml parse state //methods to store current xml parse state

@ -167,15 +167,16 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mpLibWidget = new UBLibWidget(); mpLibWidget = new UBLibWidget();
mpLibWidget ->registerMode(eUBDockPaletteWidget_BOARD); mpLibWidget ->registerMode(eUBDockPaletteWidget_BOARD);
mpLibWidget ->registerMode(eUBDockPaletteWidget_DESKTOP); mpLibWidget ->registerMode(eUBDockPaletteWidget_DESKTOP);
connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpLibWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode))); connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpLibWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
// mpCachePropWidget = new UBCachePropertiesWidget(); // mpCachePropWidget = new UBCachePropertiesWidget();
// mpCachePropWidget->registerMode(eUBDockPaletteWidget_BOARD); // mpCachePropWidget->registerMode(eUBDockPaletteWidget_BOARD);
// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpCachePropWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode))); // connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpCachePropWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
// mpTeacherBarWidget = new UBTeacherBarWidget(); mpTeacherBarWidget = new UBTeacherBarWidget();
// mpTeacherBarWidget->registerMode(eUBDockPaletteWidget_BOARD); mpTeacherBarWidget->registerMode(eUBDockPaletteWidget_BOARD);
// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpTeacherBarWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode))); connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpTeacherBarWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
//------------------------------------------------// //------------------------------------------------//
// Add the dock palettes // Add the dock palettes
@ -200,8 +201,8 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
// mRightPalette->addTabWidget(mpCachePropWidget); // mRightPalette->addTabWidget(mpCachePropWidget);
// // ??? // // ???
// mRightPalette->registerWidget(mpTeacherBarWidget); mRightPalette->registerWidget(mpTeacherBarWidget);
// mRightPalette->addTabWidget(mpTeacherBarWidget); mRightPalette->addTabWidget(mpTeacherBarWidget);
mRightPalette->connectSignals(); mRightPalette->connectSignals();
@ -443,8 +444,6 @@ void UBBoardPaletteManager::connectPalettes()
} }
void UBBoardPaletteManager::containerResized() void UBBoardPaletteManager::containerResized()
{ {
int innerMargin = UBSettings::boardMargin; int innerMargin = UBSettings::boardMargin;

Loading…
Cancel
Save