diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-05-25 21:17:56 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-05-25 21:17:56 +0000 |
| commit | 7e3bf1853184f96eb5be47dd78ebe21fdc170a01 (patch) | |
| tree | 7c937aa87fa165fc62bb49d71983e1512f2371c2 /pokemod | |
| parent | dec252e25fc63fe1bb321dd87772181fc76e998f (diff) | |
[ADD] More documentation
[FIX] Cleaned out some code from the models
[FIX] Matrix should now work a lot better now
[FIX] Opening/Saving/Closing PokéMods should be much cleaner now
[FIX] currentPokemod code is now in the tree class
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@173 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod')
| -rw-r--r-- | pokemod/CoinListObject.cpp | 2 | ||||
| -rw-r--r-- | pokemod/Matrix.h | 47 |
2 files changed, 36 insertions, 13 deletions
diff --git a/pokemod/CoinListObject.cpp b/pokemod/CoinListObject.cpp index ff2b8d80..2e0d4066 100644 --- a/pokemod/CoinListObject.cpp +++ b/pokemod/CoinListObject.cpp @@ -22,7 +22,7 @@ #include "CoinList.h" #include "Pokemod.h" -const QStringList CoinListObject::TypeStr = QStringList() << "Item" << "Pokémon"; +const QStringList CoinListObject::TypeStr = QStringList() << "Item" << QString::fromUtf8("Pokémon"); CoinListObject::CoinListObject(const CoinListObject& object) : Object("CoinListObject", object.parent(), object.id()) diff --git a/pokemod/Matrix.h b/pokemod/Matrix.h index 15b70ff0..3e007e07 100644 --- a/pokemod/Matrix.h +++ b/pokemod/Matrix.h @@ -85,7 +85,10 @@ template<class T> class Matrix return; m_matrix.remove(row); if (!(--m_height)) - m_width = 0; + { + while (m_width) + deleteColumn(0); + } } void deleteColumn(const int column) { @@ -94,7 +97,10 @@ template<class T> class Matrix foreach (QVector<T> row, m_matrix) row.remove(column); if (!(--m_width)) - m_height = 0; + { + while (m_height) + deleteRow(0); + } } void clear() { @@ -111,18 +117,35 @@ template<class T> class Matrix } void resize(const int height, const int width, const T& value = T()) { - // FIXME: destructive to data even when expanding - clear(); - m_width = width; - m_height = height; - if (!m_width ^ !m_height) + int newHeight = height; + int newWidth = width; + if (!newWidth ^ !newHeight) + { + if (newWidth) + ++newHeight; + if (newHeight) + ++newWidth; + } + if (m_height < newHeight) + { + while (m_height < newHeight) + addRow(value); + } + else + { + while (newHeight < m_height) + deleteRow(newHeight); + } + if (m_height < newHeight) + { + while (m_width < newWidth) + addColumn(value); + } + else { - if (m_width) - ++m_height; - if (m_height) - ++m_width; + while (newWidth < m_width) + deleteColumn(newWidth); } - m_matrix = QVector< QVector<T> >(m_height, QVector<T>(m_width, value)); } T at(const int row, const int column) const |
