---
GScribo/GScribo.pro.user | 38 +++++++++++++---------------
GScribo/PagesViewer/listmodel.cpp | 8 +++---
GScribo/xml.cpp | 49 +++++++++++++++++++------------------
GScribo/xml.h | 5 ++++
GScribo/xmlwidget.cpp | 13 +++++++---
5 files changed, 61 insertions(+), 52 deletions(-)
diff --git a/GScribo/GScribo.pro.user b/GScribo/GScribo.pro.user
index fdf1f0c..5c5dcd4 100644
--- a/GScribo/GScribo.pro.user
+++ b/GScribo/GScribo.pro.user
@@ -67,36 +67,35 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName"
type="QString">Debug</value>
<valuelist key="abstractProcess.Environment"
type="QVariantList">
- <value
type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-OdVBhpC8Q3,guid=12f5a3829adfbb5c05f6273d007125c0</value>
+ <value
type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-VUZT78qyIG,guid=a51566d968c6324fbe10159500728107</value>
<value type="QString">DESKTOP_SESSION=fluxbox</value>
<value type="QString">DISPLAY=:0.0</value>
<value type="QString">GDMSESSION=fluxbox</value>
<value type="QString">GDM_LANG=fr_FR.UTF-8</value>
<value type="QString">GDM_XSERVER_LOCATION=local</value>
- <value
type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-epygWB</value>
- <value type="QString">GNOME_KEYRING_PID=7156</value>
+ <value
type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-E8RI9F</value>
+ <value type="QString">GNOME_KEYRING_PID=8443</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/lrde/home/stage/froger_a</value>
<value type="QString">LANG=fr_FR.UTF-8</value>
- <value type="QString">LANGUAGE=</value>
<value
type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
<value type="QString">LOGNAME=froger_a</value>
- <value type="QString">OLDPWD=/lrde/home/stage/froger_a</value>
+ <value
type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value>
<value
type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value>
<value
type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SHLVL=2</value>
- <value type="QString">SSH_AGENT_PID=7231</value>
- <value
type="QString">SSH_AUTH_SOCK=/tmp/ssh-poGlEz7165/agent.7165</value>
+ <value type="QString">SSH_AGENT_PID=8518</value>
+ <value
type="QString">SSH_AUTH_SOCK=/tmp/ssh-FvhujW8452/agent.8452</value>
<value type="QString">TERM=xterm</value>
<value type="QString">USER=froger_a</value>
<value type="QString">USERNAME=froger_a</value>
<value type="QString">WINDOWID=10485796</value>
- <value
type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value>
- <value type="QString">XAUTHORITY=/tmp/.gdmH3DGRW</value>
+ <value
type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value>
+ <value type="QString">XAUTHORITY=/tmp/.gdmOKGZRW</value>
<value
type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value>
- <value
type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359463044.389005-635867443</value>
+ <value
type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359551947.439559-1116819102</value>
<value type="QString">XPSERVERLIST=:64 </value>
<value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value>
<value type="QString">XTERM_SHELL=/bin/bash</value>
@@ -120,36 +119,35 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName"
type="QString">Debug</value>
<valuelist key="abstractProcess.Environment"
type="QVariantList">
- <value
type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-OdVBhpC8Q3,guid=12f5a3829adfbb5c05f6273d007125c0</value>
+ <value
type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-VUZT78qyIG,guid=a51566d968c6324fbe10159500728107</value>
<value type="QString">DESKTOP_SESSION=fluxbox</value>
<value type="QString">DISPLAY=:0.0</value>
<value type="QString">GDMSESSION=fluxbox</value>
<value type="QString">GDM_LANG=fr_FR.UTF-8</value>
<value type="QString">GDM_XSERVER_LOCATION=local</value>
- <value
type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-epygWB</value>
- <value type="QString">GNOME_KEYRING_PID=7156</value>
+ <value
type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-E8RI9F</value>
+ <value type="QString">GNOME_KEYRING_PID=8443</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/lrde/home/stage/froger_a</value>
<value type="QString">LANG=fr_FR.UTF-8</value>
- <value type="QString">LANGUAGE=</value>
<value
type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
<value type="QString">LOGNAME=froger_a</value>
- <value type="QString">OLDPWD=/lrde/home/stage/froger_a</value>
+ <value
type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value>
<value
type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value>
<value
type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SHLVL=2</value>
- <value type="QString">SSH_AGENT_PID=7231</value>
- <value
type="QString">SSH_AUTH_SOCK=/tmp/ssh-poGlEz7165/agent.7165</value>
+ <value type="QString">SSH_AGENT_PID=8518</value>
+ <value
type="QString">SSH_AUTH_SOCK=/tmp/ssh-FvhujW8452/agent.8452</value>
<value type="QString">TERM=xterm</value>
<value type="QString">USER=froger_a</value>
<value type="QString">USERNAME=froger_a</value>
<value type="QString">WINDOWID=10485796</value>
- <value
type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value>
- <value type="QString">XAUTHORITY=/tmp/.gdmH3DGRW</value>
+ <value
type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value>
+ <value type="QString">XAUTHORITY=/tmp/.gdmOKGZRW</value>
<value
type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value>
- <value
type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359463044.389005-635867443</value>
+ <value
type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359551947.439559-1116819102</value>
<value type="QString">XPSERVERLIST=:64 </value>
<value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value>
<value type="QString">XTERM_SHELL=/bin/bash</value>
diff --git a/GScribo/PagesViewer/listmodel.cpp b/GScribo/PagesViewer/listmodel.cpp
index 9748e76..0a57f97 100644
--- a/GScribo/PagesViewer/listmodel.cpp
+++ b/GScribo/PagesViewer/listmodel.cpp
@@ -12,7 +12,7 @@ QStringList ListModel::filenames() const
int ListModel::rowCount(const QModelIndex&) const
{
- return pixmaps.size();
+ return pixmaps.count();
}
QVariant ListModel::data(const QModelIndex& index, int role) const
@@ -25,18 +25,18 @@ QVariant ListModel::data(const QModelIndex& index, int role)
const
// Store the original pixmap in a custom place.
if(role == Qt::UserRole)
- return pixmaps.value(index.row());
+ return pixmaps[index.row()];
// Store the path of the pixmap in an other custom place.
if(role == Qt::UserRole+1)
- return paths.value(index.row());
+ return paths[index.row()];
return QVariant();
}
void ListModel::addPixmap(const QString& filename, const QPixmap& pixmap)
{
- int row = pixmaps.size();
+ int row = rowCount();
beginInsertRows(QModelIndex(), row, row);
diff --git a/GScribo/xml.cpp b/GScribo/xml.cpp
index 23ac2b6..143e4a7 100644
--- a/GScribo/xml.cpp
+++ b/GScribo/xml.cpp
@@ -3,17 +3,17 @@
static const GraphicRegion::Data itemsData[] =
{
/* COLOR | NAME |
REGION | ZVALUE */
- { QColor::fromRgb(255, 0, 0, 90), "Line",
(int)GraphicRegion::Line, 2 },
- { QColor::fromRgb(0, 100, 0, 90), "TextRegion",
(int)GraphicRegion::Text, 1 },
- { QColor::fromRgb(0, 0, 255, 90), "VerticalSeparatorRegion",
(int)GraphicRegion::VerticalSeparator, 2 },
- { QColor::fromRgb(0, 0, 255, 90), "HorizontalSeparatorRegion",
(int)GraphicRegion::HorizontalSeparator, 2 },
- { QColor::fromRgb(0, 0, 128, 90), "WhitespaceSeparatorRegion",
(int)GraphicRegion::WhiteSpaceSeparator, 2 },
- { QColor::fromRgb(255, 120, 0, 90), "ImageRegion",
(int)GraphicRegion::Image, 1 },
- { QColor::fromRgb(43, 39, 128, 90), "NoiseRegion",
(int)GraphicRegion::Noise, 2 },
- { QColor::fromRgb(220, 246, 0, 90), "TableRegion",
(int)GraphicRegion::Table, 2 },
- { QColor::fromRgb(170, 0, 255, 90), "MathsRegion",
(int)GraphicRegion::Maths, 2 },
- { QColor::fromRgb(255, 0, 144, 90), "GraphicRegion",
(int)GraphicRegion::Graphic, 2 },
- { QColor::fromRgb(0, 204, 255, 90), "ChartRegion",
(int)GraphicRegion::Chart, 2 }
+ { QColor::fromRgb(255, 0, 0, 90), "Line",
(int)GraphicRegion::Line, 2 },
+ { QColor::fromRgb(0, 100, 0, 90), "TextRegion",
(int)GraphicRegion::Text, 1 },
+ { QColor::fromRgb(0, 0, 255, 90), "VerticalSeparatorRegion",
(int)GraphicRegion::VerticalSeparator, 2 },
+ { QColor::fromRgb(0, 0, 255, 90), "HorizontalSeparatorRegion",
(int)GraphicRegion::HorizontalSeparator, 2 },
+ { QColor::fromRgb(0, 0, 128, 90), "WhitespaceSeparatorRegion",
(int)GraphicRegion::WhiteSpaceSeparator, 2 },
+ { QColor::fromRgb(255, 120, 0, 90), "ImageRegion",
(int)GraphicRegion::Image, 1 },
+ { QColor::fromRgb(43, 39, 128, 90), "NoiseRegion",
(int)GraphicRegion::Noise, 2 },
+ { QColor::fromRgb(220, 246, 0, 90), "TableRegion",
(int)GraphicRegion::Table, 2 },
+ { QColor::fromRgb(170, 0, 255, 90), "MathsRegion",
(int)GraphicRegion::Maths, 2 },
+ { QColor::fromRgb(255, 0, 144, 90), "GraphicRegion",
(int)GraphicRegion::Graphic, 2 },
+ { QColor::fromRgb(0, 204, 255, 90), "ChartRegion",
(int)GraphicRegion::Chart, 2 }
};
Xml::Xml(const QString &filename)
@@ -32,18 +32,18 @@ void Xml::load(const QString &filename)
QFile xmlFile(filename);
xmlFile.open(QIODevice::ReadOnly);
- QDomDocument xml;
+ xml.clear();
xml.setContent(&xmlFile);
xmlFile.close();
QDomElement root = xml.documentElement();
tItem->setText(0, root.tagName());
- tItem->setData(0, Qt::UserRole,
VariantPointer<QDomElement>::toQVariant(&root));
+ tItem->setData(1, Qt::UserRole,
VariantPointer<QDomNamedNodeMap>::toQVariant(new
QDomNamedNodeMap(root.attributes())));
root = root.firstChild().toElement();
QTreeWidgetItem *parentTreeItem = init(root, tItem);
- parentTreeItem->setData(0, Qt::UserRole,
VariantPointer<QDomElement>::toQVariant(&root));
+ parentTreeItem->setData(1, Qt::UserRole,
VariantPointer<QDomNamedNodeMap>::toQVariant(0));
// Run through the xml file structure by structure.
root = root.nextSibling().firstChild().toElement();
@@ -59,19 +59,19 @@ QTreeWidgetItem *Xml::init(const QDomElement& root,
QTreeWidgetItem *rootTreeIte
QTreeWidgetItem *parentTreeItem = new QTreeWidgetItem(rootTreeItem);
parentTreeItem->setText(0, root.tagName());
- parentTreeItem->setData(0, Qt::UserRole,
VariantPointer<QDomElement>::toQVariant(&node));
+ parentTreeItem->setData(0, Qt::UserRole,
VariantPointer<QDomNamedNodeMap>::toQVariant(0));
QString nodeText;
QTreeWidgetItem *treeItem, *childTreeItem;
// Run through "METADATA" node and subnodes.
- node = root.firstChild().toElement();
+ node = node.firstChild().toElement();
while(!node.isNull())
{
treeItem = new QTreeWidgetItem(parentTreeItem, treeItem);
treeItem->setText(0, node.tagName());
// Store the xml node in the item.
- treeItem->setData(0, Qt::UserRole,
VariantPointer<QDomElement>::toQVariant(&node));
+ treeItem->setData(0, Qt::UserRole,
VariantPointer<QDomNamedNodeMap>::toQVariant(0));
// Add widget item child with text content.
nodeText = node.text();
@@ -84,6 +84,7 @@ QTreeWidgetItem *Xml::init(const QDomElement& root, QTreeWidgetItem
*rootTreeIte
// Add "PAGE" root node and return it.
parentTreeItem = new QTreeWidgetItem(rootTreeItem, parentTreeItem);
parentTreeItem->setText(0, root.nextSibling().toElement().tagName());
+ parentTreeItem->setData(0, Qt::UserRole,
VariantPointer<QDomNamedNodeMap>::toQVariant(new
QDomNamedNodeMap(root.nextSibling().attributes())));
return parentTreeItem;
}
@@ -96,14 +97,14 @@ void Xml::processNode(const QDomElement& root, const
GraphicRegion::Data& data,
// Create corresponding tree item.
QTreeWidgetItem *parentTreeItem = fillWidgetItem(root.tagName(), rootTreeItem);
- parentTreeItem->setData(0, Qt::UserRole,
VariantPointer<QDomElement>::toQVariant(&node));
+ parentTreeItem->parent()->setData(0, Qt::UserRole,
VariantPointer<QDomNamedNodeMap>::toQVariant(new
QDomNamedNodeMap(root.attributes())));
QTreeWidgetItem *treeItem;
QPolygon polygon;
QString sx, sy;
// Run through all points data.
- node = root.firstChild().firstChild().toElement();
+ node = node.firstChild().firstChild().toElement();
while(!node.isNull())
{
sx = node.attribute("x", "null");
@@ -112,7 +113,7 @@ void Xml::processNode(const QDomElement& root, const
GraphicRegion::Data& data,
treeItem = new QTreeWidgetItem(parentTreeItem, treeItem);
treeItem->setText(0, node.tagName() + " = " + sx + ",
" + sy);
// Store the xml node in the item.
- treeItem->setData(0, Qt::UserRole,
VariantPointer<QDomElement>::toQVariant(&node));
+ treeItem->setData(0, Qt::UserRole,
VariantPointer<QDomNamedNodeMap>::toQVariant(new
QDomNamedNodeMap(node.attributes())));
polygon << QPoint(sx.toInt(), sy.toInt());
node = node.nextSibling().toElement();
@@ -122,7 +123,7 @@ void Xml::processNode(const QDomElement& root, const
GraphicRegion::Data& data,
PolygonItem *polygonItem = new PolygonItem(polygon, gItem);
polygonItem->loadData(data);
// Store tree object in the graphical object.
- polygonItem->setData(1,
VariantPointer<QTreeWidgetItem>::toQVariant(parentTreeItem));
+ polygonItem->setData(0,
VariantPointer<QTreeWidgetItem>::toQVariant(parentTreeItem));
if(data.region == GraphicRegion::Text)
processLineNode(root.firstChild().nextSiblingElement("Line"),
polygonItem, parentTreeItem->parent());
@@ -140,7 +141,7 @@ void Xml::processLineNode(const QDomElement& root, PolygonItem
*parentPolygonIte
// Create corresponding tree item.
QTreeWidgetItem *parentTreeItem = fillWidgetItem(root.tagName(), rootTreeItem);
- parentTreeItem->setData(0, Qt::UserRole,
VariantPointer<QDomElement>::toQVariant(&node));
+ parentTreeItem->parent()->setData(0, Qt::UserRole,
VariantPointer<QDomNamedNodeMap>::toQVariant(new
QDomNamedNodeMap(node.attributes())));
QTreeWidgetItem *treeItem;
QPolygon polygon;
@@ -151,7 +152,7 @@ void Xml::processLineNode(const QDomElement& root, PolygonItem
*parentPolygonIte
int xMax = INT_MIN;
// Run through all points data.
- node = root.firstChild().firstChild().toElement();
+ node = node.firstChild().firstChild().toElement();
while(!node.isNull())
{
sx = node.attribute("x", "null");
@@ -160,7 +161,7 @@ void Xml::processLineNode(const QDomElement& root, PolygonItem
*parentPolygonIte
treeItem = new QTreeWidgetItem(parentTreeItem, treeItem);
treeItem->setText(0, node.tagName() + " = " + sx + ",
" + sy);
// Store xml node attributes in the item.
- treeItem->setData(0, Qt::UserRole,
VariantPointer<QDomElement>::toQVariant(&node));
+ treeItem->setData(0, Qt::UserRole,
VariantPointer<QDomNamedNodeMap>::toQVariant(new
QDomNamedNodeMap(node.attributes())));
x = sx.toInt();
y = sy.toInt();
diff --git a/GScribo/xml.h b/GScribo/xml.h
index d60abd6..3141eb3 100644
--- a/GScribo/xml.h
+++ b/GScribo/xml.h
@@ -23,6 +23,7 @@ class Xml :
void load(const QString& filename);
inline QTreeWidgetItem *treeItem();
inline QGraphicsItem *graphicItem();
+ inline QDomDocument xmlDocument() const;
private:
QTreeWidgetItem *init(const QDomElement& root, QTreeWidgetItem
*rootTreeItem);
@@ -33,6 +34,7 @@ class Xml :
QGraphicsPolygonItem *gItem;
QTreeWidgetItem *tItem;
+ QDomDocument xml;
};
inline QTreeWidgetItem *Xml::treeItem()
@@ -41,6 +43,9 @@ inline QTreeWidgetItem *Xml::treeItem()
inline QGraphicsItem *Xml::graphicItem()
{ return gItem; }
+inline QDomDocument Xml::xmlDocument() const
+{ return xml; }
+
inline QTreeWidgetItem *Xml::fillWidgetItem(const QString& tagName, QTreeWidgetItem
*rootTreeItem)
{
QTreeWidgetItem *treeItem = new QTreeWidgetItem(rootTreeItem, QStringList(tagName));
diff --git a/GScribo/xmlwidget.cpp b/GScribo/xmlwidget.cpp
index b5299c1..9c4c867 100644
--- a/GScribo/xmlwidget.cpp
+++ b/GScribo/xmlwidget.cpp
@@ -25,12 +25,15 @@ void XmlWidget::fillProperty(QTreeWidgetItem *treeItem)
property.clear();
// Get node from the tree item.
- QDomElement *node =
VariantPointer<QDomElement>::fromQVariant(treeItem->data(0, Qt::UserRole));
- QStringList values;
+ QDomNamedNodeMap *node =
VariantPointer<QDomNamedNodeMap>::fromQVariant(treeItem->data(0, Qt::UserRole));
- if(node->hasAttributes())
+ if(node)
{
- QDomNamedNodeMap attributes = node->attributes();
+ QStringList values;
+
+ //if(node.hasAttributes())
+ //{
+ QDomNamedNodeMap attributes = *node;/*.attributes();*/
for(int i = 0; i < attributes.count(); i++)
{
@@ -38,6 +41,8 @@ void XmlWidget::fillProperty(QTreeWidgetItem *treeItem)
property.addTopLevelItem(new QTreeWidgetItem(values));
values.clear();
}
+ //}
}
+
property.resizeColumnToContents(0);
}
--
1.7.2.5