diff options
author | Treeki <treeki@gmail.com> | 2010-10-14 20:17:20 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2010-10-14 20:17:20 +0200 |
commit | ebcc95da4c26369511caa90d89c5ed06e1e4853a (patch) | |
tree | 6ed445f0204a6e6615088d135c4b29c4309077a4 /lyt/materials/materialcontainer.h | |
parent | fdf8cfec2b795393d7ee901abaf747575067068b (diff) | |
download | LayoutStudio-ebcc95da4c26369511caa90d89c5ed06e1e4853a.tar.gz LayoutStudio-ebcc95da4c26369511caa90d89c5ed06e1e4853a.zip |
brlyt packing added, plus some changes in the existing API (mostly for const correctness). brlyt writing may still need some testing (especially for the material structs)
Diffstat (limited to '')
-rw-r--r-- | lyt/materials/materialcontainer.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/lyt/materials/materialcontainer.h b/lyt/materials/materialcontainer.h new file mode 100644 index 0000000..4787bfc --- /dev/null +++ b/lyt/materials/materialcontainer.h @@ -0,0 +1,76 @@ +/******************************************************************************* + This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio) + Copyright (c) 2010 Treeki (treeki@gmail.com) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 2.0. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License 2.0 for more details. + + You should have received a copy of the GNU General Public License 2.0 + along with this program. If not, see <http://www.gnu.org/licenses/>. +*******************************************************************************/ + +#ifndef LYTMATERIALCONTAINER_H +#define LYTMATERIALCONTAINER_H + +#include <QtCore/QList> +#include <QtCore/QPair> +#include "material.h" + +typedef QPair<QString, LYTMaterial *> LYTMaterialContainerEntry; + +class LYTMaterialContainer { +public: + LYTMaterialContainer() { }; + + QList<LYTMaterialContainerEntry> list; + + + void addMaterial(QString name, LYTMaterial *material) { + LYTMaterialContainerEntry entry; + entry.first = name; + entry.second = material; + this->list.append(entry); + } + + void clear() { this->list.clear(); } + int count() const { return this->list.count(); } + + + LYTMaterial *getMaterialByName(QString name) const { + foreach (LYTMaterialContainerEntry entry, this->list) { + if (entry.first == name) + return entry.second; + } + + return 0; + } + + LYTMaterial *getMaterialByIndex(int index) const { + return this->list.at(index).second; + } + + int getIndexOfName(QString name) const { + int i = 0; + + foreach (LYTMaterialContainerEntry entry, this->list) { + if (entry.first == name) + return i; + i += 1; + } + + return -1; + } + + + QString getNameOfIndex(int index) const { + return this->list.at(index).first; + } +}; + +#endif // LYTMATERIALCONTAINER_H |