File: xIrcConnectDialog.cpp

package info (click to toggle)
xirc 2.0-3
  • links: PTS
  • area: contrib
  • in suites: hamm, slink
  • size: 2,624 kB
  • ctags: 2,093
  • sloc: cpp: 21,094; makefile: 1,033
file content (206 lines) | stat: -rw-r--r-- 7,052 bytes parent folder | download
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
/***************************************************************************
**    xIrcConnectDialog.cpp  $Revision: 1.1 $ - $Name: V2-0 $ 
**    Dialog Box to Complete Connection Parameter Entry
**
** 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 <qstrlist.h>
#include "xIrcConnectDialog.h"

static int dbg = 0;

xIrcConnectDialog::xIrcConnectDialog(xWidgetResInfo *pPRes, QWidget *pParent = NULL,
                                     const char *pName,
                                     xIrcServerEntry *entry = NULL) :
                   xDialog(wdtRes = new xWidgetResInfo(pPRes, QString("connectdialog"),
                                                              QString("ConnectDialog")),
                           pParent, pName, TRUE)
{
   QStrList ports(TRUE);
   const char *cp;

   if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): Enter\n");
   if (dbg) fflush(stdout);

   setDefPallet(this, wdtRes);
   setDefFont(this, wdtRes);
   setMargins(0, 0);
   setWidgetSpacing(0);
   
   mainFrame->setAutoDelete(TRUE);
   setAlignment(xALIGN_Vert);
   ports.setAutoDelete(TRUE);

   if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): Creating Frame\n");
   if (dbg) fflush(stdout);
   pFrame = new xFrame(wdtRes, this);
   pFrame->setAutoDelete(TRUE);
   pFrame->setFrameStyle(QFrame::Panel | QFrame::Raised);
   pFrame->setAlignment(xALIGN_Vert);
   pFrame->setMargins(5, 5);
   pFrame->setWidgetSpacing(0);

   if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): Creating Group Edit\n");
   if (dbg) fflush(stdout);
   pGroup = new xLineEdit(wdtRes, pFrame, "Group:");
   pGroup->setAlignment(xALIGN_Horz);
   pGroup->setEditWidth(15);
   pGroup->setMargins(0, 2);
   pGroup->setWidgetSpacing(0);
   pGroup->setText(entry->group());
   pGroup->setEnabled(FALSE);
   pFrame->addWidget(pGroup);

   if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): Creating Country Edit\n");
   if (dbg) fflush(stdout);
   pCountry = new xLineEdit(wdtRes, pFrame, "Country:");
   pCountry->setAlignment(xALIGN_Horz);
   pCountry->setEditWidth(10);
   pCountry->setMargins(0, 2);
   pCountry->setWidgetSpacing(0);
   pCountry->setText(entry->country());
   pCountry->setEnabled(FALSE);
   pFrame->addWidget(pCountry);

   if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): Creating State Edit\n");
   if (dbg) fflush(stdout);
   pState = new xLineEdit(wdtRes, pFrame, "State:");
   pState->setAlignment(xALIGN_Horz);
   pState->setEditWidth(10);
   pState->setMargins(0, 2);
   pState->setWidgetSpacing(0);
   pState->setText(entry->state());
   pState->setEnabled(FALSE);
   pFrame->addWidget(pState);

   if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): Creating City Edit\n");
   if (dbg) fflush(stdout);
   pCity = new xLineEdit(wdtRes, pFrame, "City:");
   pCity->setAlignment(xALIGN_Horz);
   pCity->setEditWidth(25);
   pCity->setMargins(0, 2);
   pCity->setWidgetSpacing(0);
   pCity->setText(entry->city());
   pCity->setEnabled(FALSE);
   pFrame->addWidget(pCity);

   if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): Creating Server Edit\n");
   if (dbg) fflush(stdout);
   pServer = new xLineEdit(wdtRes, pFrame, "Server:");
   pServer->setAlignment(xALIGN_Horz);
   pServer->setEditWidth(25);
   pServer->setMargins(0, 2);
   pServer->setWidgetSpacing(0);
   pServer->setText(entry->server());
   pFrame->addWidget(pServer);

   if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): Creating Port Combo and Frame\n");
   if (dbg) fflush(stdout);
   pPortFrame = new xFrame(wdtRes, pFrame);
   pPortFrame->setAutoDelete(TRUE);
   pPortFrame->setResizeMode(xSPACE_Resize);
   pPortFrame->setMargins(0, 2);
//   pPortFrame->setFrameStyle(QFrame::Panel | QFrame::Raised);
   pPortFrame->setAlignment(xALIGN_Horz);
//   pPortFrame->setMargins(0, 0);
   pPortFrame->setWidgetSpacing(0);

//   pPort->setAutoResize(TRUE);
   pPort = new xComboBox(wdtRes, TRUE, pPortFrame, "ports");
   setDefPallet(pPort, wdtRes);
   setDefFont(pPort, wdtRes);

   if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): Parsing Ports...\n");
   if (dbg) fflush(stdout);
   for (cp = entry->ports(); *cp;)
   {
      QString s;
      if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): cp = |%s|\n", cp);
      if (dbg) fflush(stdout);
      while (*cp != ',' && *cp != '\0')
         s += *(cp++);
      ports.inSort(s);
      if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): cp remaining length = %d\n", 
                              strlen(cp));
      if (dbg) fflush(stdout);
      if (*cp != '\0')
         cp++;
   }

   if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): Adding Ports...\n");
   if (dbg) fflush(stdout);
   pPort->insertStrList(&ports);
   pPort->setCurrentItem(0);
   pPort->setCurrentItem(1);
   pPort->setCurrentItem(0);

   pPortLabel = new xLabel(wdtRes, "Port:", pPortFrame);
   pPortFrame->addWidget(pPortLabel);

   pPortFrame->addWidget(pPort);
   pPortFrame->fitFrame();
   pFrame->addWidget(pPortFrame);

   pFrame->fitFrame();

   if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): Adding buttons\n");
   if (dbg) fflush(stdout);
   pButtons = new xPshBtnFrame(wdtRes, this);
   pButtons->setFrameStyle(QFrame::Panel | QFrame::Raised);
   pButtons->setAlignment(xALIGN_Horz);
   pButtons->addButton("Connect", Accepted);
   pButtons->addButton("Cancel", Rejected);
   connect(pButtons, SIGNAL(clicked(int)), this, SLOT(gotButton(int)));

   addWidget(pFrame);
   addWidget(pButtons);
   initFrame();
   if (dbg) fprintf(stdout, "xIrcConnectDialog::xIrcConnectDialog(): Enter\n");
   if (dbg) fflush(stdout);
}

xIrcConnectDialog::~xIrcConnectDialog()
{
}

QString xIrcConnectDialog::port()
{
   QString rv;

   if (strlen(pPort->currentText()) > 0)
      rv = pPort->currentText();
   else
      rv = pPort->text(pPort->currentItem());
   return(rv);
}

void xIrcConnectDialog::gotButton(int btn)
{
   switch (btn)
   {
      case Rejected:
         emit completed(0);
         done(Rejected);
         break;
      case Accepted:
         emit completed(1);
         done(Accepted);
         break;
   }
}
#include "xIrcConnectDialog.moc"