umbrello/umbrello
idchangelog.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "idchangelog.h"
00012
00013 #include <kdebug.h>
00014
00018 IDChangeLog::IDChangeLog()
00019 {
00020 }
00021
00025 IDChangeLog::IDChangeLog(const IDChangeLog& Other)
00026 {
00027 m_LogArray = Other.m_LogArray;
00028 }
00029
00033 IDChangeLog::~IDChangeLog()
00034 {
00035 for (uint i = 0; i < m_LogArray.size(); i++) {
00036 delete m_LogArray.point(i);
00037 }
00038 }
00039
00043 IDChangeLog& IDChangeLog::operator=(const IDChangeLog& Other)
00044 {
00045 m_LogArray = Other.m_LogArray;
00046
00047 return *this;
00048 }
00049
00053 bool IDChangeLog::operator==(const IDChangeLog& Other)
00054 {
00055 Q_UNUSED(Other);
00056
00057 return false;
00058 }
00059
00064 Uml::IDType IDChangeLog::findNewID(Uml::IDType OldID)
00065 {
00066 for (uint i = 0; i < m_LogArray.size(); i++) {
00067 if ((m_LogArray.point(i))->y() == OldID) {
00068 return (m_LogArray.point(i))->x();
00069 }
00070 }
00071
00072 return Uml::id_None;
00073 }
00074
00079 IDChangeLog& IDChangeLog::operator+=(const IDChangeLog& Other)
00080 {
00081
00082 uint count = Other.m_LogArray.size();
00083 for (uint i = 0; i < count; i++) {
00084 addIDChange((Other.m_LogArray.point(i))->y(), (Other.m_LogArray.point(i))->x());
00085 }
00086
00087 return *this;
00088 }
00089
00090 void IDChangeLog::addIDChange(Uml::IDType OldID, Uml::IDType NewID)
00091 {
00092 uint pos = 0;
00093 if (!findIDChange(OldID, NewID, pos)) {
00094 pos = m_LogArray.size();
00095 m_LogArray.resize(pos + 1);
00096 m_LogArray.setPoint(pos, NewID, OldID);
00097 } else {
00098 m_LogArray.setPoint(pos, NewID, OldID);
00099 }
00100 }
00101
00102 Uml::IDType IDChangeLog::findOldID(Uml::IDType NewID)
00103 {
00104 uint count = m_LogArray.size();
00105 for (uint i = 0; i < count; i++) {
00106 if ((m_LogArray.point(i))->x() == NewID) {
00107 return (m_LogArray.point(i))->y();
00108 }
00109 }
00110
00111 return Uml::id_None;
00112 }
00113
00114 bool IDChangeLog::findIDChange(Uml::IDType OldID, Uml::IDType NewID, uint& pos)
00115 {
00116 uint count = m_LogArray.size();
00117 for (uint i = 0; i < count; i++) {
00118 if (((m_LogArray.point(i))->y() == OldID) && ((m_LogArray.point(i))->x() == NewID)) {
00119 pos = i;
00120 return true;
00121 }
00122 }
00123
00124 return false;
00125 }
00126
00127 void IDChangeLog::removeChangeByNewID(Uml::IDType OldID)
00128 {
00129 uint count = m_LogArray.size();
00130 for (uint i = 0; i < count; i++) {
00131 if ((m_LogArray.point(i))->y() == OldID) {
00132 m_LogArray.setPoint(i, Uml::id_None, OldID);
00133 }
00134 }
00135 }