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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
|
#ifndef KSIRCTOPLEVEL_H
#define KSIRCTOPLEVEL_H
#include <qdatetime.h>
#include <kmainwindow.h>
#include "ahistlineedit.h"
#include "messageReceiver.h"
#include "chanButtons.h"
#include "KSTicker/ksticker.h"
#include "ksircchannel.h"
#define KST_CHANNEL_ID 2
class KSircTopic;
class QSplitter;
class KSircView;
class aListBox;
class UserControlMenu;
class ChannelParser;
class charSelector;
class LogFile;
class KSelectAction;
class QLabel;
class QVBox;
class QListBoxItem;
class QPopupMenu;
class KSircTopLevel : public KMainWindow,
public UnicodeMessageReceiver
{
Q_OBJECT
friend class ChannelParser;
public:
/**
* Constructor, needs the controlling ksircprocess passed to it, so
* we can make the ksircmessage receiver happy.
*/
KSircTopLevel(KSircProcess *_proc, const KSircChannel &channelInfo, const char *
name=0);
/**
* Destructor, destroys itself.
*/
~KSircTopLevel();
/**
* Reimplement show() to popup the menu bars and toolbar items
*/
virtual void show();
/**
* Line recieved that should be printed on the screen. Unparsed, and
* ready processing. This is a single line, and it NOT \n
* terminated.
*/
virtual void sirc_receive(QString str, bool broadcast = false);
/**
* Reimplement the ksircmessagereceiver control messages. These
* are parsed and dealt with quickly.
*/
virtual void control_message(int, QString);
QWidget *lineEdit() const { return linee; }
void setTopic( const QString &topic );
QString topic() const { return m_topic; }
/**
* This returns the current channel information for a toplevel
*/
const KSircChannel &channelInfo() const { return m_channelInfo; }
signals:
/**
* signals thats the toplevel widget wishes to
* output a new line. The line is correctly
* linefeed terminated, etc.
*/
void outputLine(QCString);
/**
* open a new toplevel widget with for the
* channel/user QString.
*/
void open_toplevel(const KSircChannel &);
/**
* emittedon shutdown, indicating that
* this window is closing. Refrence to outselves
* is include.
*/
void closing(KSircTopLevel *, QString channel);
/**
* emitted when the user typed /quit, will disconnect from this
* server and close all toplevels belonging to it.
*/
void requestQuit( const QCString& command );
/**
* emitted when we change channel name
* on the fly. old is the old channel name, new
* is the new one.
*/
void changeChannel(const QString &oldName, const QString &newName);
/**
* emitted to say that KSircTopLevel
* (this) is now the window with focus. Used by
* servercontroller to set the !default window.
*/
void currentWindow(KSircTopLevel *);
/**
* Stop updating list item sizes, majour changes comming through
*
*/
void freezeUpdates(bool);
/**
* Emitted when a new message appeared in the irc window
*/
void changed(bool, QString);
public slots:
/**
* When enter is pressed, we read the SLE and output the results
* after processing via emitting outputLine.
*/
virtual void sirc_line_return(const QString &s);
/**
* Clears the message window
*/
void clearWindow();
/**
* If the focus shifts this should get called with
* the widget that just got focus. Used in MDI modes
* where the toplevel doesn't get focus in/out events.
*/
void focusChange(QWidget *w);
protected slots:
/**
* When the rightMouse button is pressed in the nick list, popup
* the User popup menu at his cursor location.
*/
void UserSelected(int index);
/**
* Menu items was selected, now read the UserControlMenu and
* reupdate the required menus.
*/
void UserParseMenu(int id);
/**
* Page down accel key. Tells the mainw to scroll down 1 page.
*/
void AccelScrollDownPage();
/**
* Page Up accell key. Tells the mainw to scroll down 1 page.
*/
void AccelScrollUpPage();
/**
* Slot to termiate (close) the window.
*/
void terminate() { close( true /*alsoDelete*/ ); }
/**
* Called when the user menu is finished and the popup menu needs
* to be updated.
*/
void UserUpdateMenu();
/**
* Open the new channel/window selector.
*/
void newWindow();
/**
* We've received focus, let's make us the default, and issue a
* /join such that we default to the right channel.
*/
void gotFocus();
/**
* We've lost focus, set ourselves as loosing focus.
*/
void lostFocus();
/**
* Create and popup the ticker. Make sure to restore it to the
* last position is was at.
*/
// void showTicker();
/**
* toggle the timestamp from the channel window menu (and with keyaccel)
*/
void toggleTimestamp();
/**
* toggle the filtering of join/part message
*/
void toggleFilterJoinPart();
/**
* toggle the beep from the channel window menu (and with keyaccel)
*/
void toggleBeep();
/**
* show the dcc manager
*/
void showDCCMgr();
/**
* Delete the ticker and ppoup the main window
*/
// void unHide();
/**
* On a TAB key press we call TabNickCompletion which
* reads the last thing in linee matches it with a nick and
* puts it back into the line.
*/
void TabNickCompletionShift();
/**
* On a TAB key press we call TabNickCompletion which
* reads the last thing in linee matches it with a nick and
* puts it back into the line.
*/
void TabNickCompletionNormal();
/**
* Signals a Line Change in linee
*/
void lineeNotTab();
/**
* Move the display to or from the root window
*
*/
void toggleRootWindow();
/**
* On a middle mouse button press we call pasteToWindow which
* reads the clip board and pastes into the main listbox.
*/
void pasteToWindow();
/**
* On a midle mouse button press to the nick list we open
* a query window and paste the text there
*/
void pasteToNickList(int button, QListBoxItem *item, const QPoint &pos);
/**
* dnd paste to nick list
*/
void dndTextToNickList(const QListBoxItem *itom, const QString& text);
/**
* open a toplevel on double click
*/
void openQueryFromNick(const QString &);
/**
* Some text was dropped on the listbox
*/
void slotTextDropped(const QString&);
/**
* Calls slotDccURLs with the current nick we're talking to
*/
void slotDropURLs(const QStringList& urls);
/**
* Sends the list of urls to nick
*/
void slotDccURLs(const QStringList& urls, const QString& nick );
/**
* Re-apply color settings.
*/
void initColors();
/**
* Dumps current content of mainw into a logfile
*/
void saveCurrLog();
/**
* Makes a beep when a change happens (if the user has this on)
* the bool is TRUE if changed line contained user's nick
*/
void doChange(bool, QString);
/**
* show the ticker window
*/
void toggleTicker();
/**
* ksirc command menu clicked on
*/
void cmd_process(int id);
protected:
/**
* On a TAB key press we call TabNickCompletion which
* reads the last thing in linee matches it with a nick and
* puts it back into the line.
*/
void TabNickCompletion(int dir);
/**
* Make sure to update colors correctly.
*/
virtual bool event( QEvent *e);
/**
* Redfine closeEvent to emit closing and delete itself.
*/
virtual void closeEvent(QCloseEvent *);
/**
* Searches through the nick list and finds the nick with the best match.
* which, arg2, selects nicks other than the first shouldarg1 match more
* than 1 nick.
*/
virtual QString findNick(QString, uint which = 0);
/**
* remove a nick from the prefered in nick completion list
*/
virtual void removeCompleteNick(const QString &);
/**
* Adds a nick to the list of nicks to prefer in nick completion
* or moves it to the top of the list if it was already there
*/
virtual void addCompleteNick(const QString &);
/**
* Changes a nick in the completion list if it has been listed,
* otherwise does nothing
*/
virtual void changeCompleteNick(const QString &, const QString &);
virtual void setupCommandMenu();
/**
* Returns true if this window is a private conversation (query or dcc chat)
*, instead of a public chat in a channel or a special window.
*/
bool isPrivateChat() const;
/**
* Returns true if this is a public channel window
*/
bool isPublicChat() const;
/**
* Returns true if this is a special window
*/
bool isSpecialWindow() const;
private slots:
void setTopicIntern( const QString &topic );
void insertText();
void setMode(QString, int, QString currentNick=0);
void setEncoding();
void returnPressed();
void toggleTopic();
private:
void outputUnicodeLine( const QString &message );
bool atBottom();
bool continued_line;
charSelector *selector;
chanButtons *channelButtons;
QSplitter *pan;
QVBox *nicks_box;
QVBox *top;
KMenuBar *kmenu;
QLabel *lag;
enum {PING = 10, TOPIC = 20};
KSircView *mainw;
aHistLineEdit *linee;
aListBox *nicks;
//QString m_currentNick;
//KSircProcess *proc;
int lines;
struct BufferedLine
{
BufferedLine() { wasBroadcast = false; }
BufferedLine( const QString &msg, bool broadc )
{ message = msg; wasBroadcast = broadc; }
bool operator==( const BufferedLine &other )
{ return message == other.message &&
wasBroadcast == other.wasBroadcast; }
QString message;
bool wasBroadcast;
};
bool Buffer;
QValueList<BufferedLine> LineBuffer;
// QPopupMenu's used for the menubar
QPopupMenu *file, *edit, *command;
bool parse_input(const QString &string, QString &plainText);
void sirc_write(const QString &str);
QPopupMenu *user_controls;
static QPtrList<UserControlMenu> *user_menu;
int opami;
QAccel *accel;
/**
* The channel name that we belong too.
*/
//QString channel_name;
/**
* Caption at the top of the window.
*/
QString caption;
/**
* Current topic for the channel
*/
QString m_topic;
/**
* Does the window have focus? 1 when yes, 0 when no.
*/
int have_focus;
/**
* Number of time tab has been pressed. Each time it's pressed
* roll through the list of matching nicks.
*/
int tab_pressed;
/**
* When tabs pressed save the line for use at a latter date.
* tab_nick holds the last nick found so when a blank tab is pressed
* we pop the last niick and ": " up.
*/
QString tab_saved, tab_nick;
int tab_start, tab_end;
// Ticker specific variables.
/**
* Main pointer to ksticker. Caution, it doesn't always exist!
* Set to 0 ifwhen you delete it.
*/
KSTicker *ticker;
/**
* Size and position of the main window. Main window is returns this
* this position when it reappears.
*/
QRect myrect;
/**
* Position of the main window
*/
QPoint mypoint;
/**
* Ticker's size and geometry
*/
QRect tickerrect;
/**
* Tickers position
*/
QPoint tickerpoint;
QSize tickersize;
/**
* Do we have a kick window open?
* Remember not to open 2
*/
bool KickWinOpen;
/**
* Hold an internal parser object which does all our parsing for us.
* Since parsing an intergral part of TopLevel, it's also a friend
* of ours
*/
ChannelParser *ChanParser;
/**
* QSize maintains size information in case it changes somehow
*/
QSize current_size;
/**
* ID of the timestamp menu item, to use in (un)checking it from slot
*/
int tsitem;
/**
* ID of the filter join/part menu item, to use in (un)checking it from slot
*/
int fjpitem;
/**
* ID of the beep menu item, to use in (un)checking it from slot
*/
int beepitem;
/**
* ID of the toggle topic menu item, to use in (un)checking it from slot
*/
int topicitem;
/**
* ID of the show/hide ticker menu item
*/
int tickeritem;
/**
* List of nicks already used in nick completion to give them
* higher priority
*/
QStringList completeNicks;
/**
* The time of the last beep to prevent your soundcard from detonating
* in high traffic channels
*/
QTime lastBeep;
KSircTopic *ksTopic;
LogFile *logFile;
KSelectAction *encodingAction;
static QStringList cmd_menu;
bool m_gotMsgWithoutFocus;
KSircChannel m_channelInfo;
};
#endif
// vim: ts=2 sw=2 et
|