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. 21
      src/board/UBBoardPaletteManager.cpp

@ -41,6 +41,7 @@
//tag names definition
//use them everiwhere!
static QString tElement = "element";
static QString tGroup = "group";
static QString tEllipse = "ellipse";
static QString tIwb = "iwb";
static QString tMeta = "meta";
@ -78,25 +79,72 @@ static QString aFontweight = "font-weight";
static QString aTextalign = "text-align";
static QString aPoints = "points";
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()
{
}
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();
while (!n.isNull()) {
QDomElement e = n.toElement();
QString id = e.attribute(tId);
QString id = e.attribute(aId);
if(!id.isNull()) {
extProperties.insert(id, IwbExt(e));
qDebug() << prefix + e.prefix() + ":" + e.tagName();
}
if (n.hasChildNodes()) {
hashNode(&n, QString("| %1").arg(prefix));
hashSvg(&n, QString("| %1").arg(prefix));
}
n = n.nextSibling();
}
@ -107,11 +155,21 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::hashElements()
QDomElement svgSection = mDOMdoc.elementsByTagNameNS(svgNS, tSvg).at(0).toElement();
Q_ASSERT(!svgSection.isNull());
hashNode(&svgSection);
hashSvg(&svgSection);
QDomElement parElement = mDOMdoc.documentElement();
Q_ASSERT(!parElement.isNull());
qDebug() << "ext properties count " << extProperties.count();
qDebug() << extProperties.value("link1").element.toElement().tagName();
addExtentionsToHash(&parElement);
// 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();
// int i = 0;

@ -29,12 +29,14 @@ class UBGraphicsSvgItem;
class QTransform;
struct IwbExt {
IwbExt() : group(NULL) {;}
IwbExt(QDomNode element) : group(NULL), element(element) {;}
IwbExt() {;}
IwbExt(QDomNode element) : element(element), extAttr(*(new QVector<QDomNode>())) {;}
QDomNode *group;
QDomNode group;
QDomNode element;
QVector<QDomNode> extAttr;
QHash<QString, QString> textAttributes;
operator bool() const {return group.isNull() || !element.isNull();}
};
class UBCFFSubsetAdaptor
@ -80,9 +82,10 @@ private:
QDomDocument mDOMdoc;
QHash<QString, IwbExt> extProperties;
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

@ -162,20 +162,21 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mpPageNavigWidget = new UBPageNavigationWidget();
mpPageNavigWidget->registerMode(eUBDockPaletteWidget_BOARD);
connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpPageNavigWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpPageNavigWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
mpLibWidget = new UBLibWidget();
mpLibWidget ->registerMode(eUBDockPaletteWidget_BOARD);
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->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->registerMode(eUBDockPaletteWidget_BOARD);
// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpTeacherBarWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
mpTeacherBarWidget = new UBTeacherBarWidget();
mpTeacherBarWidget->registerMode(eUBDockPaletteWidget_BOARD);
connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpTeacherBarWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
//------------------------------------------------//
// Add the dock palettes
@ -200,8 +201,8 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
// mRightPalette->addTabWidget(mpCachePropWidget);
// // ???
// mRightPalette->registerWidget(mpTeacherBarWidget);
// mRightPalette->addTabWidget(mpTeacherBarWidget);
mRightPalette->registerWidget(mpTeacherBarWidget);
mRightPalette->addTabWidget(mpTeacherBarWidget);
mRightPalette->connectSignals();
@ -443,8 +444,6 @@ void UBBoardPaletteManager::connectPalettes()
}
void UBBoardPaletteManager::containerResized()
{
int innerMargin = UBSettings::boardMargin;

Loading…
Cancel
Save