1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
/***************************************************************************
** xIrcNickBox.cpp $Revision: 1.8 $ - $Name: V2-0 $
** xComboBox for Handling Nicks and addresses
** kk
** Copyright (C) 1995, 1996 Joseph Croft <jcroft@unicomp.net>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 1, or (at your option)
** any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
***************************************************************************/
#include <stdio.h>
#include "xIrcNickCombo.h"
static int dbg = 0;
xIrcNickCombo::xIrcNickCombo(xWidgetResInfo *pPRes, QWidget *pParent,
const char *pName, int type) :
xEditList(pPRes, pParent, pName), xIrcNickList()
{
wdtRes = new xWidgetResInfo(pPRes, QString(""), QString(""));
setDefPallet(this, wdtRes);
setDefFont(this, wdtRes);
xIrcNickList::pList = NULL;
nameType = type;
connect(this, SIGNAL(gotEntry(const char *)),
this, SLOT(gotSelected(const char *)));
}
xIrcNickCombo::~xIrcNickCombo()
{
// disconnect(this);
if (dbg) fprintf(stdout, "xIrcNickCombo::~xIrcNickCombo():Here\n");
if (dbg) fflush(stdout);
}
void xIrcNickCombo::merge(const char *pNick, char delim)
{
if (dbg) fprintf(stdout, "xIrcNickCombo::merge(char *):Enter\n");
if (dbg) fflush(stdout);
xIrcNickList::merge(pNick, delim);
xEditList::insertItemsSort(pNick);
if (dbg) fprintf(stdout, "xIrcNickCombo::merge(char *):Exit\n");
if (dbg) fflush(stdout);
}
void xIrcNickCombo::merge(xIrcNickListEntry *pEntry)
{
if (dbg) fprintf(stdout, "xIrcNickCombo::merge(pEntry):Enter\n");
if (dbg) fflush(stdout);
xIrcNickList::merge(pEntry);
xEditList::insertItemsSort(pEntry->getNick());
if (dbg) fprintf(stdout, "xIrcNickCombo::merge(pEntry):Exit\n");
if (dbg) fflush(stdout);
}
void xIrcNickCombo::remove(const char *pNick, bool delflag, char delim)
{
int idx;
if ((idx = getIndex(pNick)) >= 0)
removeItem(idx);
xIrcNickList::remove(pNick, delflag, delim);
}
void xIrcNickCombo::remove(xIrcNickListEntry *pEntry, bool delflag)
{
int idx;
if ((idx = getIndex(pEntry->getNick())) >= 0)
removeItem(idx);
xIrcNickList::remove(pEntry, delflag);
}
void xIrcNickCombo::clearList()
{
xIrcNickListEntry *pEntry, *pEntry1;
if (dbg) fprintf(stdout, "xIrcNickCombo::clearList():Enter\n");
if (dbg) fflush(stdout);
for (pEntry = xIrcNickList::pList; pEntry; pEntry = pEntry1)
{
pEntry1 = pEntry->next();
pEntry->unlink();
delete pEntry;
}
xIrcNickList::pList = NULL;
xEditList::clear();
if (dbg) fprintf(stdout, "xIrcNickCombo::clearList():Exit\n");
if (dbg) fflush(stdout);
}
void xIrcNickCombo::purgeList()
{
const char *cp;
int x;
for (x = 0; (unsigned int)x < xEditList::pList->count(); x++)
{
cp = xEditList::string(x);
if (cp)
{
if (!is(cp))
removeItem(x);
}
}
}
xIrcNickListEntry *xIrcNickCombo::selected()
{
xIrcNickListEntry *pEntry;
const char *cp;
int x;
if (dbg) fprintf(stdout, "xIrcNickCombo::selected():Enter\n");
if (dbg) fflush(stdout);
pEntry = NULL;
if (strlen(cp = pEdit->text()) == 0)
{
if (dbg) fprintf(stdout, "xIrcNickCombo::selected():No Edit Text getting current item\n");
if (dbg) fflush(stdout);
if ((x = xEditList::pList->currentItem()) >= 0)
{
if (dbg) fprintf(stdout, "xIrcNickCombo::selected():Have current item\n");
if (dbg) fflush(stdout);
cp = xEditList::string(x);
if (dbg) fprintf(stdout, "xIrcNickCombo::selected():name = |%s|\n", cp);
if (dbg) fflush(stdout);
pEdit->setText(cp);
pEntry = xIrcNickList::find(cp);
}
}
else
{
if (dbg) fprintf(stdout, "xIrcNickCombo::selected():Have Edit Text\n");
if (dbg) fflush(stdout);
pEdit->setText(cp);
pEntry = xIrcNickList::find(cp);
}
if (dbg) fprintf(stdout, "xIrcNickCombo::selected():Exit(%s)\n", pEntry ? "Found" : "Not Found" );
if (dbg) fflush(stdout);
return(pEntry);
};
void xIrcNickCombo::gotSelected(const char *pName)
{
xIrcNickListEntry *pEntry;
const char *cp;
cp = pName;
if ((pEntry = xIrcNickList::find(pName)) != NULL)
{
cp = pEntry->getNick();
pEdit->setText(cp);
}
emit nickSelected(cp);
}
void xIrcNickCombo::resize(int width, int height)
{
pEdit->QWidget::resize(width, pEdit->size().height());
xEditList::pList->resize(width, height);
fitFrame();
}
#include "xIrcNickCombo.moc"
|