summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-02 17:24:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-02 17:24:17 +0000
commitf4ab8d1b8466efaed401a75a1d181fc45ff43d5e (patch)
treef15641c117669cc761b96f57e080b40b444f098e /src/modules
parent91c7f53e2c4182100a9c8392652780dc3cd31094 (diff)
minus std::string & 3 std::vectors
git-svn-id: http://svn.miranda-ng.org/main/trunk@7461 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extraicons/ExtraIcon.cpp4
-rw-r--r--src/modules/extraicons/ExtraIcon.h4
-rw-r--r--src/modules/extraicons/ExtraIconGroup.cpp45
-rw-r--r--src/modules/extraicons/IcolibExtraIcon.cpp10
-rw-r--r--src/modules/extraicons/extraicons.cpp64
-rw-r--r--src/modules/extraicons/extraicons.h4
-rw-r--r--src/modules/extraicons/options_ei.cpp66
7 files changed, 98 insertions, 99 deletions
diff --git a/src/modules/extraicons/ExtraIcon.cpp b/src/modules/extraicons/ExtraIcon.cpp
index 7354a8ad6b..197da8976f 100644
--- a/src/modules/extraicons/ExtraIcon.cpp
+++ b/src/modules/extraicons/ExtraIcon.cpp
@@ -24,7 +24,7 @@ Boston, MA 02111-1307, USA.
#include "extraicons.h"
ExtraIcon::ExtraIcon(const char *name) :
- name(name), slot(-1), position(1000), hLangpack(0)
+ szName(mir_strdup(name)), slot(-1), position(1000), hLangpack(0)
{
}
@@ -34,7 +34,7 @@ ExtraIcon::~ExtraIcon()
const char *ExtraIcon::getName() const
{
- return name.c_str();
+ return szName;
}
int ExtraIcon::getSlot() const
diff --git a/src/modules/extraicons/ExtraIcon.h b/src/modules/extraicons/ExtraIcon.h
index 29aa687c95..31ec96a490 100644
--- a/src/modules/extraicons/ExtraIcon.h
+++ b/src/modules/extraicons/ExtraIcon.h
@@ -60,7 +60,7 @@ public:
int hLangpack;
protected:
- std::string name;
+ ptrA szName;
int slot;
int position;
@@ -165,7 +165,7 @@ public:
virtual int getPosition() const;
virtual void setSlot(int slot);
- std::vector<BaseExtraIcon*> items;
+ LIST<BaseExtraIcon> items;
virtual int ClistSetExtraIcon(HANDLE hContact, HANDLE hImage);
diff --git a/src/modules/extraicons/ExtraIconGroup.cpp b/src/modules/extraicons/ExtraIconGroup.cpp
index 5d21599ba1..e2127ebb87 100644
--- a/src/modules/extraicons/ExtraIconGroup.cpp
+++ b/src/modules/extraicons/ExtraIconGroup.cpp
@@ -24,22 +24,23 @@ Boston, MA 02111-1307, USA.
#include "extraicons.h"
ExtraIconGroup::ExtraIconGroup(const char *_name) :
- ExtraIcon(_name), setValidExtraIcon(false), insideApply(false)
+ ExtraIcon(_name), setValidExtraIcon(false), insideApply(false),
+ items(1)
{
db_set_resident(MODULE_NAME, _name);
}
ExtraIconGroup::~ExtraIconGroup()
{
- items.clear();
+ items.destroy();
}
void ExtraIconGroup::addExtraIcon(BaseExtraIcon *extra)
{
- items.push_back(extra);
+ items.insert(extra);
CMString description;
- for (unsigned int i = 0; i < items.size(); i++) {
+ for (int i = 0; i < items.getCount(); i++) {
if (i > 0)
description += _T(" / ");
description += items[i]->getDescription();
@@ -50,7 +51,7 @@ void ExtraIconGroup::addExtraIcon(BaseExtraIcon *extra)
void ExtraIconGroup::rebuildIcons()
{
- for (unsigned int i = 0; i < items.size(); i++)
+ for (int i = 0; i < items.getCount(); i++)
items[i]->rebuildIcons();
}
@@ -63,8 +64,8 @@ void ExtraIconGroup::applyIcon(HANDLE hContact)
insideApply = true;
- unsigned int i;
- for (i = 0; i < items.size(); i++) {
+ int i;
+ for (i = 0; i < items.getCount(); i++) {
items[i]->applyIcon(hContact);
if (setValidExtraIcon)
break;
@@ -72,13 +73,13 @@ void ExtraIconGroup::applyIcon(HANDLE hContact)
insideApply = false;
- db_set_dw(hContact, MODULE_NAME, name.c_str(), setValidExtraIcon ? items[i]->getID() : 0);
+ db_set_dw(hContact, MODULE_NAME, szName, setValidExtraIcon ? items[i]->getID() : 0);
}
int ExtraIconGroup::getPosition() const
{
int pos = INT_MAX;
- for (unsigned int i = 0; i < items.size(); i++)
+ for (int i = 0; i < items.getCount(); i++)
pos = MIN(pos, items[i]->getPosition());
return pos;
}
@@ -87,17 +88,17 @@ void ExtraIconGroup::setSlot(int slot)
{
ExtraIcon::setSlot(slot);
- for (unsigned int i = 0; i < items.size(); i++)
+ for (int i = 0; i < items.getCount(); i++)
items[i]->setSlot(slot);
}
ExtraIcon * ExtraIconGroup::getCurrentItem(HANDLE hContact) const
{
- int id = (int)db_get_dw(hContact, MODULE_NAME, name.c_str(), 0);
+ int id = (int)db_get_dw(hContact, MODULE_NAME, szName, 0);
if (id < 1)
return NULL;
- for (unsigned int i = 0; i < items.size(); i++)
+ for (int i = 0; i < items.getCount(); i++)
if (id == items[i]->getID())
return items[i];
@@ -124,7 +125,7 @@ int ExtraIconGroup::setIconByName(int id, HANDLE hContact, const char *value)
int ExtraIconGroup::internalSetIcon(int id, HANDLE hContact, void *value, bool bByName)
{
if (insideApply) {
- for (unsigned int i=0; i < items.size(); i++)
+ for (int i=0; i < items.getCount(); i++)
if (items[i]->getID() == id) {
if (bByName)
return items[i]->setIconByName(id, hContact, (const char*)value);
@@ -135,9 +136,9 @@ int ExtraIconGroup::internalSetIcon(int id, HANDLE hContact, void *value, bool b
}
ExtraIcon *current = getCurrentItem(hContact);
- int currentPos = (int)items.size();
- int storePos = (int)items.size();
- for (unsigned int i = 0; i < items.size(); i++) {
+ int currentPos = items.getCount();
+ int storePos = items.getCount();
+ for (int i=0; i < items.getCount(); i++) {
if (items[i]->getID() == id)
storePos = i;
@@ -145,7 +146,7 @@ int ExtraIconGroup::internalSetIcon(int id, HANDLE hContact, void *value, bool b
currentPos = i;
}
- if (storePos == items.size())
+ if (storePos == items.getCount())
return -1;
if (storePos > currentPos) {
@@ -165,15 +166,15 @@ int ExtraIconGroup::internalSetIcon(int id, HANDLE hContact, void *value, bool b
if (storePos < currentPos) {
if (setValidExtraIcon)
- db_set_dw(hContact, MODULE_NAME, name.c_str(), items[storePos]->getID());
+ db_set_dw(hContact, MODULE_NAME, szName, items[storePos]->getID());
}
else if (storePos == currentPos) {
if (!setValidExtraIcon) {
- db_set_dw(hContact, MODULE_NAME, name.c_str(), 0);
+ db_set_dw(hContact, MODULE_NAME, szName, 0);
insideApply = true;
- for (++storePos; storePos < (int)items.size(); ++storePos) {
+ for (++storePos; storePos < items.getCount(); ++storePos) {
items[storePos]->applyIcon(hContact);
if (setValidExtraIcon)
break;
@@ -182,7 +183,7 @@ int ExtraIconGroup::internalSetIcon(int id, HANDLE hContact, void *value, bool b
insideApply = false;
if (setValidExtraIcon)
- db_set_dw(hContact, MODULE_NAME, name.c_str(), items[storePos]->getID());
+ db_set_dw(hContact, MODULE_NAME, szName, items[storePos]->getID());
}
}
@@ -196,7 +197,7 @@ const TCHAR *ExtraIconGroup::getDescription() const
const char *ExtraIconGroup::getDescIcon() const
{
- for (unsigned int i = 0; i < items.size(); i++)
+ for (int i = 0; i < items.getCount(); i++)
if (!IsEmpty(items[i]->getDescIcon()))
return items[i]->getDescIcon();
diff --git a/src/modules/extraicons/IcolibExtraIcon.cpp b/src/modules/extraicons/IcolibExtraIcon.cpp
index 8b77e29cb5..78c020ce3a 100644
--- a/src/modules/extraicons/IcolibExtraIcon.cpp
+++ b/src/modules/extraicons/IcolibExtraIcon.cpp
@@ -53,7 +53,7 @@ void IcolibExtraIcon::applyIcon(HANDLE hContact)
HANDLE hImage = INVALID_HANDLE_VALUE;
- ptrA szIconName(db_get_sa(hContact, MODULE_NAME, name.c_str()));
+ ptrA szIconName(db_get_sa(hContact, MODULE_NAME, szName));
if (!IsEmpty(szIconName))
hImage = GetIcon(szIconName);
@@ -69,7 +69,7 @@ int IcolibExtraIcon::setIcon(int id, HANDLE hContact, HANDLE hIcoLib)
hIcoLib = NULL;
if (isEnabled()) {
- ptrA szIconName(db_get_sa(hContact, MODULE_NAME, name.c_str()));
+ ptrA szIconName(db_get_sa(hContact, MODULE_NAME, szName));
if (!IsEmpty(szIconName))
RemoveIcon(szIconName);
}
@@ -93,7 +93,7 @@ int IcolibExtraIcon::setIconByName(int id, HANDLE hContact, const char *icon)
icon = NULL;
if (isEnabled()) {
- ptrA szIconName(db_get_sa(hContact, MODULE_NAME, name.c_str()));
+ ptrA szIconName(db_get_sa(hContact, MODULE_NAME, szName));
if (!IsEmpty(szIconName))
RemoveIcon(szIconName);
}
@@ -113,7 +113,7 @@ void IcolibExtraIcon::storeIcon(HANDLE hContact, void *icon)
const char *icolibName = (const char *)icon;
if (IsEmpty(icolibName))
- db_unset(hContact, MODULE_NAME, name.c_str());
+ db_unset(hContact, MODULE_NAME, szName);
else
- db_set_s(hContact, MODULE_NAME, name.c_str(), icolibName);
+ db_set_s(hContact, MODULE_NAME, szName, icolibName);
}
diff --git a/src/modules/extraicons/extraicons.cpp b/src/modules/extraicons/extraicons.cpp
index 332d6f92f4..c96dd3629f 100644
--- a/src/modules/extraicons/extraicons.cpp
+++ b/src/modules/extraicons/extraicons.cpp
@@ -128,10 +128,10 @@ BaseExtraIcon* GetExtraIconByName(const char *name)
return NULL;
}
-static void LoadGroups(vector<ExtraIconGroup *> &groups)
+static void LoadGroups(LIST<ExtraIconGroup> &groups)
{
- unsigned int count = db_get_w(NULL, MODULE_NAME "Groups", "Count", 0);
- for (unsigned int i = 0; i < count; i++) {
+ int count = db_get_w(NULL, MODULE_NAME "Groups", "Count", 0);
+ for (int i=0; i < count; i++) {
char setting[512];
mir_snprintf(setting, SIZEOF(setting), "%d_count", i);
unsigned int items = db_get_w(NULL, MODULE_NAME "Groups", setting, 0);
@@ -143,36 +143,33 @@ static void LoadGroups(vector<ExtraIconGroup *> &groups)
for (unsigned int j = 0; j < items; j++) {
mir_snprintf(setting, SIZEOF(setting), "%d_%d", i, j);
+ ptrA szIconName(db_get_sa(NULL, MODULE_NAME "Groups", setting));
+ if (IsEmpty(szIconName))
+ continue;
+
+ BaseExtraIcon *extra = GetExtraIconByName(szIconName);
+ if (extra == NULL)
+ continue;
- DBVARIANT dbv;
- if (!db_get_s(NULL, MODULE_NAME "Groups", setting, &dbv)) {
- if (!IsEmpty(dbv.pszVal)) {
- BaseExtraIcon *extra = GetExtraIconByName(dbv.pszVal);
- if (extra != NULL) {
- group->items.push_back(extra);
-
- if (extra->getSlot() >= 0)
- group->setSlot(extra->getSlot());
- }
- }
- db_free(&dbv);
- }
+ group->items.insert(extra);
+ if (extra->getSlot() >= 0)
+ group->setSlot(extra->getSlot());
}
- if (group->items.size() < 2) {
+ if (group->items.getCount() < 2) {
delete group;
continue;
}
- groups.push_back(group);
+ groups.insert(group);
}
}
-static ExtraIconGroup* IsInGroup(vector<ExtraIconGroup *> &groups, BaseExtraIcon *extra)
+static ExtraIconGroup* IsInGroup(LIST<ExtraIconGroup> &groups, BaseExtraIcon *extra)
{
- for (unsigned int i = 0; i < groups.size(); i++) {
+ for (int i = 0; i < groups.getCount(); i++) {
ExtraIconGroup *group = groups[i];
- for (unsigned int j = 0; j < group->items.size(); j++) {
+ for (int j = 0; j < group->items.getCount(); j++) {
if (extra == group->items[j])
return group;
}
@@ -180,31 +177,30 @@ static ExtraIconGroup* IsInGroup(vector<ExtraIconGroup *> &groups, BaseExtraIcon
return NULL;
}
-void RebuildListsBasedOnGroups(vector<ExtraIconGroup *> &groups)
+void RebuildListsBasedOnGroups(LIST<ExtraIconGroup> &groups)
{
extraIconsByHandle.destroy();
- int k;
- for (k=0; k < registeredExtraIcons.getCount(); k++)
- extraIconsByHandle.insert(registeredExtraIcons[k]);
- for (k=0; k < extraIconsBySlot.getCount(); k++) {
+ for (int i=0; i < registeredExtraIcons.getCount(); i++)
+ extraIconsByHandle.insert(registeredExtraIcons[i]);
+
+ for (int k=0; k < extraIconsBySlot.getCount(); k++) {
ExtraIcon *extra = extraIconsBySlot[k];
if (extra->getType() == EXTRAICON_TYPE_GROUP)
delete extra;
}
extraIconsBySlot.destroy();
- unsigned int i;
- for (i = 0; i < groups.size(); i++) {
+ for (int i=0; i < groups.getCount(); i++) {
ExtraIconGroup *group = groups[i];
- for (unsigned int j = 0; j < group->items.size(); j++)
+ for (int j = 0; j < group->items.getCount(); j++)
extraIconsByHandle.put(group->items[j]->getID()-1, group);
extraIconsBySlot.insert(group);
}
- for (k = 0; k < extraIconsByHandle.getCount(); k++) {
+ for (int k=0; k < extraIconsByHandle.getCount(); k++) {
ExtraIcon *extra = extraIconsByHandle[k];
if (extra->getType() != EXTRAICON_TYPE_GROUP)
extraIconsBySlot.insert(extra);
@@ -228,9 +224,10 @@ void KillModuleExtraIcons(int hLangpack)
if (arDeleted.getCount() == 0)
return;
- vector<ExtraIconGroup*> groups;
+ LIST<ExtraIconGroup> groups(1);
LoadGroups(groups);
RebuildListsBasedOnGroups(groups);
+ groups.destroy();
for (int k=0; k < arDeleted.getCount(); k++)
delete arDeleted[k];
@@ -429,14 +426,14 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam)
registeredExtraIcons.insert(extra);
extraIconsByHandle.insert(extra);
- vector<ExtraIconGroup *> groups;
+ LIST<ExtraIconGroup> groups(1);
LoadGroups(groups);
ExtraIconGroup *group = IsInGroup(groups, extra);
if (group != NULL)
RebuildListsBasedOnGroups(groups);
else {
- for (unsigned int i = 0; i < groups.size(); i++)
+ for (int i = 0; i < groups.getCount(); i++)
delete groups[i];
extraIconsBySlot.insert(extra);
@@ -460,6 +457,7 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam)
}
}
+ groups.destroy();
return id;
}
diff --git a/src/modules/extraicons/extraicons.h b/src/modules/extraicons/extraicons.h
index e2c15572bf..3926cdc963 100644
--- a/src/modules/extraicons/extraicons.h
+++ b/src/modules/extraicons/extraicons.h
@@ -22,7 +22,7 @@ Boston, MA 02111-1307, USA.
#ifndef __COMMONS_H__
# define __COMMONS_H__
-#define MODULE_NAME "ExtraIcons"
+#define MODULE_NAME "ExtraIcons"
// Global Variables
extern HINSTANCE hInst;
@@ -35,7 +35,7 @@ extern HINSTANCE hInst;
extern LIST<BaseExtraIcon> registeredExtraIcons;
extern LIST<ExtraIcon> extraIconsByHandle, extraIconsBySlot;
-void RebuildListsBasedOnGroups(vector<ExtraIconGroup *> &groups);
+void RebuildListsBasedOnGroups(LIST<ExtraIconGroup> &groups);
ExtraIcon * GetExtraIconBySlot(int slot);
int GetNumberOfSlots();
diff --git a/src/modules/extraicons/options_ei.cpp b/src/modules/extraicons/options_ei.cpp
index 369efa6315..7529f29153 100644
--- a/src/modules/extraicons/options_ei.cpp
+++ b/src/modules/extraicons/options_ei.cpp
@@ -445,13 +445,13 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
ExtraIcon *extra = extraIconsBySlot[k];
if (extra->getType() == EXTRAICON_TYPE_GROUP) {
- ExtraIconGroup *group = (ExtraIconGroup *) extra;
+ ExtraIconGroup *group = (ExtraIconGroup *)extra;
vector<int> ids;
- for (unsigned int j = 0; j < group->items.size(); j++)
+ for (int j = 0; j < group->items.getCount(); j++)
ids.push_back(group->items[j]->getID());
Tree_AddExtraIconGroup(tree, ids, extra->isEnabled());
}
- else Tree_AddExtraIcon(tree, (BaseExtraIcon *) extra, extra->isEnabled());
+ else Tree_AddExtraIcon(tree, (BaseExtraIcon *)extra, extra->isEnabled());
}
TVSORTCB sort = { 0 };
@@ -481,7 +481,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
lastUsedSlot = MIN(lastUsedSlot, GetNumberOfSlots());
// Get user data and create new groups
- vector<ExtraIconGroup *> groups;
+ LIST<ExtraIconGroup> groups(1);
BYTE pos = 0;
int firstEmptySlot = 0;
@@ -509,7 +509,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
else {
char name[128];
- mir_snprintf(name, SIZEOF(name), "__group_%d", groups.size());
+ mir_snprintf(name, SIZEOF(name), "__group_%d", groups.getCount());
ExtraIconGroup *group = new ExtraIconGroup(name);
@@ -521,7 +521,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
group->setSlot(slot);
- groups.push_back(group);
+ groups.insert(group);
}
ht = TreeView_GetNextSibling(tree, ht);
@@ -540,15 +540,15 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
CallService(MS_DB_MODULE_DELETE, 0, (LPARAM) MODULE_NAME "Groups");
- db_set_w(NULL, MODULE_NAME "Groups", "Count", (WORD)groups.size());
- for (unsigned k = 0; k < groups.size(); k++) {
+ db_set_w(NULL, MODULE_NAME "Groups", "Count", groups.getCount());
+ for (int k = 0; k < groups.getCount(); k++) {
ExtraIconGroup *group = groups[k];
char setting[512];
mir_snprintf(setting, SIZEOF(setting), "%d_count", k);
- db_set_w(NULL, MODULE_NAME "Groups", setting, (WORD)group->items.size());
+ db_set_w(NULL, MODULE_NAME "Groups", setting, (WORD)group->items.getCount());
- for (unsigned j = 0; j < group->items.size(); j++) {
+ for (int j = 0; j < group->items.getCount(); j++) {
BaseExtraIcon *extra = group->items[j];
mir_snprintf(setting, SIZEOF(setting), "%d_%d", k, j);
@@ -573,6 +573,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
delete[] oldSlots;
+ groups.destroy();
return TRUE;
}
@@ -600,8 +601,9 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM) hwndDlg, 0);
}
}
- break;
}
+ break;
+
case TVN_KEYDOWN:
{
TV_KEYDOWN *nmkd = (TV_KEYDOWN *) lpnmhdr;
@@ -611,34 +613,32 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (hItem != NULL)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM) hwndDlg, 0);
}
- break;
}
+ break;
+
case NM_RCLICK:
- {
- HTREEITEM hSelected = (HTREEITEM) SendMessage(tree, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0);
- if (hSelected != NULL && !IsSelected(tree, hSelected)) {
- UnselectAll(tree);
- TreeView_SelectItem(tree, hSelected);
- }
+ HTREEITEM hSelected = (HTREEITEM) SendMessage(tree, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0);
+ if (hSelected != NULL && !IsSelected(tree, hSelected)) {
+ UnselectAll(tree);
+ TreeView_SelectItem(tree, hSelected);
+ }
- int sels = GetNumSelected(tree);
- if (sels > 1) {
- if (ShowPopup(hwndDlg, 0) == ID_GROUP) {
- GroupSelectedItems(tree);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM) hwndDlg, 0);
- }
+ int sels = GetNumSelected(tree);
+ if (sels > 1) {
+ if (ShowPopup(hwndDlg, 0) == ID_GROUP) {
+ GroupSelectedItems(tree);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM) hwndDlg, 0);
}
- else if (sels == 1) {
- HTREEITEM hItem = TreeView_GetSelection(tree);
- vector<int>*ids = Tree_GetIDs(tree, hItem);
- if (ids->size() > 1) {
- if (ShowPopup(hwndDlg, 1) == ID_UNGROUP) {
- UngroupSelectedItems(tree);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM) hwndDlg, 0);
- }
+ }
+ else if (sels == 1) {
+ HTREEITEM hItem = TreeView_GetSelection(tree);
+ vector<int>*ids = Tree_GetIDs(tree, hItem);
+ if (ids->size() > 1) {
+ if (ShowPopup(hwndDlg, 1) == ID_UNGROUP) {
+ UngroupSelectedItems(tree);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM) hwndDlg, 0);
}
}
- break;
}
}
}