summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2NameList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/T2NameList.cpp')
-rw-r--r--src/T2DLL/T2NameList.cpp137
1 files changed, 126 insertions, 11 deletions
diff --git a/src/T2DLL/T2NameList.cpp b/src/T2DLL/T2NameList.cpp
index cee243a..44ee91f 100644
--- a/src/T2DLL/T2NameList.cpp
+++ b/src/T2DLL/T2NameList.cpp
@@ -1,43 +1,158 @@
+#include "T2Archive.h"
+#include "T2Mover.h"
+#include "T2MoverModule.h"
+#include "T2Name.h"
+#include "T2NameComparator.h"
#include "T2NameList.h"
+#include "T2People.h"
+#include "T2Tenant.h"
-T2NameList::T2NameList() {
+T2NameList::T2NameList()
+ : LArray(sizeof(T2Name *))
+{
+ SetComparator(T2NameComparator::GetComparator());
+ mOwnsComparator = false;
+
+ SetKeepSorted(true);
}
/*virtual*/ T2NameList::~T2NameList() {
+ LArrayIterator iterator(*this);
+ T2Name *name;
+ while (iterator.Next(&name))
+ delete name;
}
unsigned int T2NameList::GetItemCount() {
+ return GetCount();
}
void T2NameList::Clear() {
+ RemoveItemsAt(mItemCount, 1);
}
-void T2NameList::Add(T2Name*) {
+void T2NameList::Add(T2Name* name) {
+ InsertItemsAt(1, mItemCount + 1, &name);
}
-void T2NameList::RemoveName(T2Name*) {
+void T2NameList::RemoveName(T2Name* name) {
+ Remove(&name);
}
-T2Name* T2NameList::Search(const T2Tenant*, int) const {
+T2Name* T2NameList::Search(const T2Tenant* tenant, BOOL isFavorite) const {
+ LArrayIterator iterator(*this);
+ T2Name *name;
+
+ while (iterator.Next(&name)) {
+ if (
+ name->IsFavorite() == isFavorite &&
+ name->GetType() == kTenantNameType &&
+ name->GetID() == tenant->GetEquipID()
+ )
+ return name;
+ }
+
+ return NULL;
}
-T2Name* T2NameList::Search(const T2Mover*, int) const {
+T2Name* T2NameList::Search(const T2Mover* mover, BOOL isFavorite) const {
+ LArrayIterator iterator(*this);
+ T2Name *name;
+
+ while (iterator.Next(&name)) {
+ if (
+ name->IsFavorite() == isFavorite &&
+ name->GetType() == kMoverNameType &&
+ name->GetID() == mover->GetEquipID()
+ )
+ return name;
+ }
+
+ return NULL;
}
-T2Name* T2NameList::Search(const T2MoverModule*, int) const {
+T2Name* T2NameList::Search(const T2MoverModule* moverModule, BOOL isFavorite) const {
+ LArrayIterator iterator(*this);
+ T2Name *name;
+
+ while (iterator.Next(&name)) {
+ if (
+ name->IsFavorite() == isFavorite &&
+ name->GetType() == kMoverModuleNameType &&
+ name->GetID() == moverModule->GetModuleID()
+ )
+ return name;
+ }
+
+ return NULL;
}
-T2Name* T2NameList::Search(const T2People*, int) const {
+T2Name* T2NameList::Search(const T2People* people, BOOL isFavorite) const {
+ LArrayIterator iterator(*this);
+ T2Name *name;
+
+ while (iterator.Next(&name)) {
+ if (
+ name->IsFavorite() == isFavorite &&
+ name->GetType() == kPeopleNameType &&
+ name->GetID() == people->mMatterID
+ )
+ return name;
+ }
+
+ return NULL;
}
-T2Name* T2NameList::Search(const CString&, int) const {
+T2Name* T2NameList::Search(const CString& str, BOOL isFavorite) const {
+ LArrayIterator iterator(*this);
+ T2Name *result = NULL;
+ T2Name *name = NULL;
+
+ while (iterator.Next(&name)) {
+ if (name->IsFavorite() == isFavorite && *name == str) {
+ result = name;
+ break;
+ }
+ }
+
+ return result;
}
-T2Name* T2NameList::FullNameSearch(T2TowerDoc*, const CString&, int) const {
+T2Name* T2NameList::FullNameSearch(T2TowerDoc* towerDoc, const CString& str, BOOL isFavorite) const {
+ LArrayIterator iterator(*this);
+ T2Name *result = NULL;
+ T2Name *name = NULL;
+
+ while (iterator.Next(&name)) {
+ CString fullName;
+ name->MakeFullName(towerDoc, fullName);
+ BOOL nameMatches = (fullName == str);
+ if (name->IsFavorite() == isFavorite && nameMatches) {
+ result = name;
+ break;
+ }
+ }
+
+ return result;
}
-void T2NameList::Read(T2Archive&) {
+void T2NameList::Read(T2Archive& archive) {
+ int count;
+ archive >> count;
+
+ for (int i = 0; i < count; i++) {
+ T2Name *name = new T2Name(archive);
+ Add(name);
+ }
}
-void T2NameList::Write(T2Archive&) const {
+void T2NameList::Write(T2Archive& archive) const {
+ int count = GetCount();
+ archive << count;
+
+ LArrayIterator iterator(*this);
+ T2Name *name;
+
+ while (iterator.Next(&name))
+ name->Write(archive);
}