/*
* ResourceBox.hpp
*
* Created on: 12-Sep-2008
* Author: Terabyte
*/
#ifndef RESOURCEBOX_HPP_
#define RESOURCEBOX_HPP_
#include <string>
#include <iostream>
#include <QObject>
using namespace std;
class ResourceBox
: public QObject{ Q_OBJECT
public slots:
virtual void execute()=0;
public:
ResourceBox();
virtual ~ResourceBox();
virtual string value() = 0;
};
#endif /* RESOURCEBOX_HPP_ */
/*
* ResourceBox.hpp
*
* Created on: 12-Sep-2008
* Author: Terabyte
*/
#ifndef RESOURCEBOX_HPP_
#define RESOURCEBOX_HPP_
#include <string>
#include <iostream>
#include <QObject>
using namespace std;
class ResourceBox : public QObject{
Q_OBJECT
public slots:
virtual void execute()=0;
public:
ResourceBox();
virtual ~ResourceBox();
virtual string value() = 0;
};
#endif /* RESOURCEBOX_HPP_ */
To copy to clipboard, switch view to plain text mode
/*
* SvgBox.hpp
*
* Created on: 12-Sep-2008
* Author: Terabyte
*/
#ifndef SVGBOX_HPP_
#define SVGBOX_HPP_
/*
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
*/
#include "XMLBox.hpp"
#include "ResourceBox.hpp"
using namespace xercesc_2_8;
using namespace std;
class SvgBox: public ResourceBox {
Q_OBJECT
public slots:
void execute();
private:
XMLBox* xmlBox;
DOMNode* node;
public:
SvgBox(XMLBox *box,DOMNode *domNode);
virtual ~SvgBox();
string value();
};
#endif /* SVGBOX_HPP_ */
/*
* SvgBox.hpp
*
* Created on: 12-Sep-2008
* Author: Terabyte
*/
#ifndef SVGBOX_HPP_
#define SVGBOX_HPP_
/*
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
*/
#include "XMLBox.hpp"
#include "ResourceBox.hpp"
using namespace xercesc_2_8;
using namespace std;
class SvgBox: public ResourceBox {
Q_OBJECT
public slots:
void execute();
private:
XMLBox* xmlBox;
DOMNode* node;
public:
SvgBox(XMLBox *box,DOMNode *domNode);
virtual ~SvgBox();
string value();
};
#endif /* SVGBOX_HPP_ */
To copy to clipboard, switch view to plain text mode
/*
* TreeModel.cpp
*
* Created on: 26-Jul-2008
* Author: Terabyte
*/
#include <QtGui>
#include "TreeItem.hpp"
#include "TreeModel.hpp"
#include <iostream>
#include <QAbstractItemView>
using namespace std;
{
this->view = gview;
this->rootItem = NULL;
}
TreeModel::~TreeModel() {
// TODO Auto-generated destructor stub
delete rootItem;
}
int TreeModel
::columnCount(const QModelIndex &parent
) const {
if (parent.isValid())
return static_cast<TreeItem*>(parent.internalPointer())->columnCount();
else
return rootItem->columnCount();
}
{
if (!index.isValid())
if (role != Qt::DisplayRole)
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->data(index.column());
}
Qt
::ItemFlags TreeModel
::flags(const QModelIndex &index
) const {
if (!index.isValid())
return Qt::ItemIsEnabled;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
QVariant TreeModel
::headerData(int section, Qt
::Orientation orientation,
int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
return rootItem->data(section);
}
const
{
TreeItem *parentItem;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<TreeItem*>(parent.internalPointer());
TreeItem *childItem = parentItem->child(row);
if (childItem)
return createIndex(row, column, childItem);
else
}
{
if (!index.isValid())
TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
TreeItem *parentItem = childItem->parent();
if (parentItem == rootItem)
return createIndex(parentItem->row(), 0, parentItem);
}
int TreeModel
::rowCount(const QModelIndex &parent
) const {
TreeItem *parentItem;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<TreeItem*>(parent.internalPointer());
return parentItem->childCount();
}
void TreeModel
::setupModelData(const QStringList &lines, TreeItem
*parent
) {
}
void TreeModel::startTag(ResourceBox *resourcebox){
//create item, passing resourcebox, calling resourcebox display.
//add to parent stack
char x;
if (rootItem == NULL) {
cout << "root added";
cin >> x;
TreeItem *item = new TreeItem(resourcebox);
cin >> x;
rootItem = item;
cin >> x;
parents.push_back(item);
} else {
cin >> x;
cout << "non root added";
cin >> x;
TreeItem *item = new TreeItem(resourcebox,parents.last());
cin >> x;
parents.last()->appendChild(item);
cin >> x;
parents.push_back(item);
}
cin >> x;
this
->view
->connect
(this
->view,
SIGNAL(QTreeView::DoubleClicked()),resourcebox,
SLOT(execute
()));
resourcebox,SLOT(extecute())
);
cin >> x;
cout << "success";
}
void TreeModel::endTag(){
parents.pop_back();
}
void TreeModel::debug(){
cout << "Parents " << this->parents.size() << endl;
for (int i = 0; i < this->parents.size(); i++){
this->parents.at(i)->debug();
}
}
/*
* TreeModel.cpp
*
* Created on: 26-Jul-2008
* Author: Terabyte
*/
#include <QtGui>
#include "TreeItem.hpp"
#include "TreeModel.hpp"
#include <iostream>
#include <QAbstractItemView>
using namespace std;
TreeModel::TreeModel(QTreeView *gview,/*const QString &data,*/ QObject *parent) : QAbstractItemModel(parent)
{
this->view = gview;
this->rootItem = NULL;
}
TreeModel::~TreeModel() {
// TODO Auto-generated destructor stub
delete rootItem;
}
int TreeModel::columnCount(const QModelIndex &parent) const
{
if (parent.isValid())
return static_cast<TreeItem*>(parent.internalPointer())->columnCount();
else
return rootItem->columnCount();
}
QVariant TreeModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole)
return QVariant();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->data(index.column());
}
Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return Qt::ItemIsEnabled;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
return rootItem->data(section);
return QVariant();
}
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent)
const
{
TreeItem *parentItem;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<TreeItem*>(parent.internalPointer());
TreeItem *childItem = parentItem->child(row);
if (childItem)
return createIndex(row, column, childItem);
else
return QModelIndex();
}
QModelIndex TreeModel::parent(const QModelIndex &index) const
{
if (!index.isValid())
return QModelIndex();
TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
TreeItem *parentItem = childItem->parent();
if (parentItem == rootItem)
return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem);
}
int TreeModel::rowCount(const QModelIndex &parent) const
{
TreeItem *parentItem;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<TreeItem*>(parent.internalPointer());
return parentItem->childCount();
}
void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
{
}
void TreeModel::startTag(ResourceBox *resourcebox){
//create item, passing resourcebox, calling resourcebox display.
//add to parent stack
char x;
if (rootItem == NULL) {
cout << "root added";
cin >> x;
TreeItem *item = new TreeItem(resourcebox);
cin >> x;
rootItem = item;
cin >> x;
parents.push_back(item);
} else {
cin >> x;
cout << "non root added";
cin >> x;
TreeItem *item = new TreeItem(resourcebox,parents.last());
cin >> x;
parents.last()->appendChild(item);
cin >> x;
parents.push_back(item);
}
cin >> x;
this->view->connect(this->view,SIGNAL(QTreeView::DoubleClicked()),resourcebox,SLOT(execute()));
QObject::connect(this->view,
SIGNAL(QTreeView::DoubleClicked()),
resourcebox,SLOT(extecute())
);
cin >> x;
cout << "success";
}
void TreeModel::endTag(){
parents.pop_back();
}
void TreeModel::debug(){
cout << "Parents " << this->parents.size() << endl;
for (int i = 0; i < this->parents.size(); i++){
this->parents.at(i)->debug();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks