+#include "uilistelement.h"
+
+uiListElement::uiListElement(QString name,QString file,QObject *parent): QObject(parent)
+{
+ m_name=name;
+ m_file=file;
+}
+/*
+uiListElement::uiListElement(const uiListElement &ui)
+{
+ m_name=ui.m_name;
+ m_file=ui.m_file;
+}
+*/
+uiListElement::uiListElement(QObject *parent): QObject(parent)
+{
+}
+
+uiListModel::uiListModel(QObject *parent)
+ : QAbstractListModel(parent)
+ {
+ QHash<int, QByteArray> roles;
+ roles[NameRole] = "name";
+ roles[FileRole] = "file";
+ roles[ModelDataRole] = "modelData";
+ setRoleNames(roles);
+ }
+
+ void uiListModel::addUI(uiListElement *ui)
+ {
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ m_uiList.append(ui);
+ endInsertRows();
+ }
+
+ int uiListModel::rowCount(const QModelIndex & parent) const {
+ return m_uiList.count();
+ }
+ int uiListModel::count()
+{
+ qDebug() <<"Count:" << m_uiList.count();
+ return m_uiList.count();
+ }
+
+ QVariant uiListModel::data(const QModelIndex & index, int role) const {
+ if (index.row() < 0 || index.row() > m_uiList.count())
+ return QVariant();
+
+ const uiListElement *ui = m_uiList[index.row()];
+ if (role == NameRole)
+ return ui->name();
+ else if (role == FileRole)
+ return ui->file();
+ else if (role == ModelDataRole)
+ return ui->modelData();
+ return QVariant();
+ }