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 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
/***************************************************************************
** xIrcBanDialog.cpp $Revision: 1.4 $ - $Name: V2-0 $
** Dialog box for Banning
**
** 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 <xMessageBox.h>
#include "xIrcBanDialog.h"
#include "xDefaults.h"
static int dbg = 0;
extern xDefaults Defaults;
xIrcBanDialog::xIrcBanDialog(xWidgetResInfo *pPRes, QWidget *pParent,
const char *pName) :
xDialog(wdtRes = new xWidgetResInfo(pPRes, QString("bandialog"),
QString("BanDialog")),
pParent, pName, TRUE)
{
char *cp;
if (dbg) fprintf(stdout, "xIrcBanDialog::xIrcBanDialog():Enter\n\r");
setDefPallet(this, wdtRes);
setDefFont(this, wdtRes);
if (pName)
setCaption(pName);
else
setCaption("Ban");
setAcceptFocus(TRUE);
pEditFrame = new xFrame(wdtRes, this);
pEditFrame->setFrameStyle(QFrame::Panel | QFrame::Raised);
pNick = new xLineEdit(wdtRes, pEditFrame);
pNick->setMargins(5, 5);
pNick->setLabel("Nick");
pChan = new xLineEdit(wdtRes, pEditFrame);
pChan->setMargins(5, 5);
pChan->setLabel("Channel");
pMask = new xLineEdit(wdtRes, pEditFrame);
pMask->setMargins(5, 5);
pMask->setLabel("Ban Mask");
pText = new xLineEdit(wdtRes, pEditFrame);
pText->setMargins(5, 5);
pText->setLabel("Message");
pEditFrame->addWidget(pText);
pEditFrame->addWidget(pMask);
pEditFrame->addWidget(pNick);
pEditFrame->addWidget(pChan);
pEditFrame->setFrameStyle(QFrame::Panel | QFrame::Raised);
pEditFrame->setAlignment(xALIGN_Horz);
// pEditFrame->setResizeMode(xSPACE_Resize);
pEditFrame->setMargins(0, 5);
pEditFrame->setWidgetSpacing(0);
pEditFrame->fitFrame();
if ((cp = (char *)Defaults.get("BANMESSAGE")) != NULL && strlen(cp) != 0)
pText->setText(cp);
pButtons = new xPshBtnFrame(wdtRes, this);
pButtons->setFrameStyle(QFrame::Panel | QFrame::Raised);
pButtons->setAlignment(xALIGN_Horz);
pButtons->addButton("Ban", Accepted);
pButtons->addButton("Kick", Kick);
pButtons->addButton("Unban", UnBan);
pButtons->addButton("Clear Kick Mesg", Clear);
pButtons->addButton("Default Kick Mesg", Default);
pButtons->addButton("Cancel", Rejected);
addWidget(pEditFrame);
addWidget(pButtons);
setMargins(0, 0);
setWidgetSpacing(0);
initFrame();
connect(pNick, SIGNAL(returnPressed()),
this, SLOT(gotReturn()));
connect(pButtons, SIGNAL(clicked(int)), this, SLOT(gotButton(int)));
if (dbg) fprintf(stdout, "xIrcBanDialog::xIrcBanDialog():Exit\n\r");
}
void xIrcBanDialog::gotButton(int btn)
{
QString tmpStr;
const char *cp;
if (dbg) fprintf(stdout, "xIrcBanDialog::gotButton(%d):Enter\n\r", btn);
switch((QryResults)btn)
{
case Clear:
if (dbg) fprintf(stdout, "xIrcBanDialog::gotButton():Clearing??\n\r");
pNick->setText("");
break;
case UnBan:
case Kick:
case Accepted:
if (dbg) fprintf(stdout, "xIrcBanDialog::gotButton():Accepting??\n\r");
if (strlen(pMask->text()) == 0)
{
xMessageBox::message("Error:", "No Ban Mask Specified");
return;
}
done(btn);
break;
case Rejected:
if (dbg) fprintf(stdout, "xIrcBanDialog::gotButton():Rejecting??\n\r");
reject();
break;
case Default:
if ((cp = (char *)Defaults.get("BANMESSAGE")) != NULL && strlen(cp) != 0)
pText->setText(cp);
break;
}
if (dbg) fprintf(stdout, "xIrcBanDialog::gotButton():Exit\n\r");
}
void xIrcBanDialog::accept()
{
QDialog::accept();
}
void xIrcBanDialog::reject()
{
QDialog::reject();
}
void xIrcBanDialog::gotReturn()
{
if (dbg) fprintf(stdout, "xIrcBanDialog::gotReturn():Enter\n\r");
QDialog::accept();
if (dbg) fprintf(stdout, "xIrcBanDialog::gotReturn():Exit\n\r");
}
xIrcBanDialog::~xIrcBanDialog()
{
/*
if (pNick)
{
if (dbg) fprintf(stdout, "xIrcBanDialog::~xIrcBanDialog():Deleting pNick\n");
if (dbg) fflush(stdout);
delete pNick;
}
if (pMask)
{
if (dbg) fprintf(stdout, "xIrcBanDialog::~xIrcBanDialog():Deleting pMask\n");
if (dbg) fflush(stdout);
delete pMask;
}
if (pChan)
{
if (dbg) fprintf(stdout, "xIrcBanDialog::~xIrcBanDialog():Deleting pChan\n");
if (dbg) fflush(stdout);
delete pChan;
}
if (pText)
{
if (dbg) fprintf(stdout, "xIrcBanDialog::~xIrcBanDialog():Deleting pText\n");
if (dbg) fflush(stdout);
delete pText;
}
*/
if (pEditFrame)
{
if (dbg) fprintf(stdout, "xIrcBanDialog::~xIrcBanDialog():Deleting pEditFrame\n");
if (dbg) fflush(stdout);
delete pEditFrame;
}
if(pButtons)
{
if (dbg) fprintf(stdout, "xIrcBanDialog::~xIrcBanDialog():Deleting pButtons\n");
if (dbg) fflush(stdout);
delete pButtons;
}
if (dbg) fprintf(stdout, "xIrcBanDialog::~xIrcBanDialog():Done!\n");
if (dbg) fflush(stdout);
// disconnect(this);
}
#include "xIrcBanDialog.moc"
|