diff options
author | George Hazan <george.hazan@gmail.com> | 2012-11-25 14:40:02 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-11-25 14:40:02 +0000 |
commit | 65a5f40baaae20a733da94df023221159b334e2b (patch) | |
tree | 5771f98d03384669e288f58dc10db4aa1b1a80fc /plugins/WhenWasIt/src/birthdays.cpp | |
parent | 81464df93124380cecbf7e5dace914f1c06aaf5d (diff) |
WhenWasIt - correct work with icons & extra icons
git-svn-id: http://svn.miranda-ng.org/main/trunk@2484 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/WhenWasIt/src/birthdays.cpp')
-rw-r--r-- | plugins/WhenWasIt/src/birthdays.cpp | 97 |
1 files changed, 39 insertions, 58 deletions
diff --git a/plugins/WhenWasIt/src/birthdays.cpp b/plugins/WhenWasIt/src/birthdays.cpp index d69207b444..4d4242e265 100644 --- a/plugins/WhenWasIt/src/birthdays.cpp +++ b/plugins/WhenWasIt/src/birthdays.cpp @@ -25,8 +25,8 @@ CBirthdays &birthdays = CBirthdays(); CBirthdays::CBirthdays(int initialSize)
{
- int count = 0;
- int size = 0;
+ count = 0;
+ size = 0;
birthdays = NULL;
advancedIcon = CLIST_ICON;
@@ -40,21 +40,18 @@ CBirthdays::~CBirthdays() void CBirthdays::Destroy()
{
- if (birthdays)
- {
- Clear();
- free(birthdays);
- birthdays = NULL;
- }
+ if (birthdays) {
+ Clear();
+ free(birthdays);
+ birthdays = NULL;
+ }
}
void CBirthdays::Clear()
{
- int i;
- for (i = 0; i < Count(); i++)
- {
- ClearItem(i);
- }
+ for (int i = 0; i < Count(); i++)
+ ClearItem(i);
+
count = 0;
}
@@ -77,9 +74,7 @@ int CBirthdays::Size() const void CBirthdays::EnsureCapacity()
{
if (count >= size)
- {
- Realloc(size / 2);
- }
+ Realloc(size / 2);
}
void CBirthdays::Realloc(int increaseCapacity)
@@ -90,62 +85,49 @@ void CBirthdays::Realloc(int increaseCapacity) int CBirthdays::Add(HANDLE hContact, HANDLE hClistIcon)
{
- if ( !Contains(hContact))
- {
- EnsureCapacity();
- TBirthdayContact *item = (TBirthdayContact *) malloc(sizeof(TBirthdayContact));
- item->hContact = hContact;
- item->hClistIcon = hClistIcon;
- birthdays[count++] = item;
- return 0;
- }
+ if ( !Contains(hContact)) {
+ EnsureCapacity();
+ TBirthdayContact *item = (TBirthdayContact *) malloc(sizeof(TBirthdayContact));
+ item->hContact = hContact;
+ item->hClistIcon = hClistIcon;
+ birthdays[count++] = item;
+ return 0;
+ }
return -1;
}
int CBirthdays::Remove(int index)
{
- if ((index >= 0) && (index < count))
- {
- int i;
- for (i = index + 1; i < count; i++)
- {
- birthdays[i - 1] = birthdays[i];
- }
- ClearItem(count--);
- return 0;
- }
+ if ((index >= 0) && (index < count)) {
+ for (int i = index + 1; i < count; i++)
+ birthdays[i - 1] = birthdays[i];
+
+ ClearItem(count--);
+ return 0;
+ }
return -1;
}
int CBirthdays::Remove(HANDLE hContact)
{
- int index = Index(hContact);
- return Remove(index);
+ return Remove( Index(hContact));
}
int CBirthdays::Contains(HANDLE hContact) const
{
- int i;
- for (i = 0; i < count; i++)
- {
- if (birthdays[i]->hContact == hContact)
- {
- return TRUE;
- }
- }
+ for (int i = 0; i < count; i++)
+ if (birthdays[i]->hContact == hContact)
+ return TRUE;
+
return FALSE;
}
int CBirthdays::Index(HANDLE hContact) const
{
- int i;
- for (i = 0; i < count; i++)
- {
- if (birthdays[i]->hContact == hContact)
- {
- return i;
- }
- }
+ for (int i = 0; i < count; i++)
+ if (birthdays[i]->hContact == hContact)
+ return i;
+
return -1;
}
@@ -163,8 +145,7 @@ HANDLE CBirthdays::GetClistIcon(HANDLE hContact) const {
int index = Index(hContact);
if ((index >= 0) && (index < count))
- {
- return birthdays[index]->hClistIcon;
- }
- return (HANDLE) -1;
-}
\ No newline at end of file + return birthdays[index]->hClistIcon;
+
+ return INVALID_HANDLE_VALUE;
+}
|