1 #ifndef KSIRCTOPLEVEL_H
2 #define KSIRCTOPLEVEL_H
12 #include <Q3PopupMenu>
13 #include <kmainwindow.h>
15 #include "ahistlineedit.h"
16 #include "messageReceiver.h"
17 #include "chanButtons.h"
18 #include "KSTicker/ksticker.h"
19 #include "ksircchannel.h"
21 #define KST_CHANNEL_ID 2
27 class UserControlMenu
;
38 class KSircTopLevel
: public KMainWindow
,
39 public UnicodeMessageReceiver
42 friend class ChannelParser
;
45 * Constructor, needs the controlling ksircprocess passed to it, so
46 * we can make the ksircmessage receiver happy.
48 KSircTopLevel(KSircProcess
*_proc
, const KSircChannel
&channelInfo
, const char *
51 * Destructor, destroys itself.
56 * Reimplement show() to popup the menu bars and toolbar items
61 * Line recieved that should be printed on the screen. Unparsed, and
62 * ready processing. This is a single line, and it NOT \n
65 virtual void sirc_receive(QString str
, bool broadcast
= false);
68 * Reimplement the ksircmessagereceiver control messages. These
69 * are parsed and dealt with quickly.
71 virtual void control_message(int, QString
);
73 QWidget
*lineEdit() const { return linee
; }
75 void setTopic( const QString
&topic
);
76 QString
topic() const { return m_topic
; }
79 * This returns the current channel information for a toplevel
81 const KSircChannel
&channelInfo() const { return m_channelInfo
; }
85 * signals thats the toplevel widget wishes to
86 * output a new line. The line is correctly
87 * linefeed terminated, etc.
89 void outputLine(QByteArray
);
91 * open a new toplevel widget with for the
92 * channel/user QString.
94 void open_toplevel(const KSircChannel
&);
96 * emittedon shutdown, indicating that
97 * this window is closing. Refrence to outselves
100 void closing(KSircTopLevel
*, QString channel
);
102 * emitted when the user typed /quit, will disconnect from this
103 * server and close all toplevels belonging to it.
105 void requestQuit( const QByteArray
& command
);
107 * emitted when we change channel name
108 * on the fly. old is the old channel name, new
111 void changeChannel(const QString
&oldName
, const QString
&newName
);
113 * emitted to say that KSircTopLevel
114 * (this) is now the window with focus. Used by
115 * servercontroller to set the !default window.
117 void currentWindow(KSircTopLevel
*);
119 * Stop updating list item sizes, majour changes comming through
122 void freezeUpdates(bool);
124 * Emitted when a new message appeared in the irc window
126 void changed(bool, QString
);
130 * When enter is pressed, we read the SLE and output the results
131 * after processing via emitting outputLine.
133 virtual void sirc_line_return(const QString
&s
);
136 * Clears the message window
141 * If the focus shifts this should get called with
142 * the widget that just got focus. Used in MDI modes
143 * where the toplevel doesn't get focus in/out events.
145 void focusChange(QWidget
*w
);
149 * When the rightMouse button is pressed in the nick list, popup
150 * the User popup menu at his cursor location.
152 void UserSelected(int index
);
154 * Menu items was selected, now read the UserControlMenu and
155 * reupdate the required menus.
157 void UserParseMenu(int id
);
159 * Page down accel key. Tells the mainw to scroll down 1 page.
161 void AccelScrollDownPage();
163 * Page Up accell key. Tells the mainw to scroll down 1 page.
165 void AccelScrollUpPage();
167 * Slot to termiate (close) the window.
169 void terminate() { close( true /*alsoDelete*/ ); }
171 * Called when the user menu is finished and the popup menu needs
174 void UserUpdateMenu();
176 * Open the new channel/window selector.
180 * We've received focus, let's make us the default, and issue a
181 * /join such that we default to the right channel.
185 * We've lost focus, set ourselves as loosing focus.
189 * Create and popup the ticker. Make sure to restore it to the
190 * last position is was at.
192 // void showTicker();
194 * toggle the timestamp from the channel window menu (and with keyaccel)
196 void toggleTimestamp();
198 * toggle the filtering of join/part message
200 void toggleFilterJoinPart();
203 * toggle the beep from the channel window menu (and with keyaccel)
208 * show the dcc manager
213 * Delete the ticker and ppoup the main window
217 * On a TAB key press we call TabNickCompletion which
218 * reads the last thing in linee matches it with a nick and
219 * puts it back into the line.
221 void TabNickCompletionShift();
223 * On a TAB key press we call TabNickCompletion which
224 * reads the last thing in linee matches it with a nick and
225 * puts it back into the line.
227 void TabNickCompletionNormal();
230 * Signals a Line Change in linee
234 * Move the display to or from the root window
237 void toggleRootWindow();
239 * On a middle mouse button press we call pasteToWindow which
240 * reads the clip board and pastes into the main listbox.
242 void pasteToWindow();
244 * On a midle mouse button press to the nick list we open
245 * a query window and paste the text there
247 void pasteToNickList(int button
, Q3ListBoxItem
*item
, const QPoint
&pos
);
249 * dnd paste to nick list
251 void dndTextToNickList(const Q3ListBoxItem
*itom
, const QString
& text
);
253 * open a toplevel on double click
255 void openQueryFromNick(const QString
&);
258 * Some text was dropped on the listbox
260 void slotTextDropped(const QString
&);
263 * Calls slotDccURLs with the current nick we're talking to
265 void slotDropURLs(const QStringList
& urls
);
268 * Sends the list of urls to nick
270 void slotDccURLs(const QStringList
& urls
, const QString
& nick
);
273 * Re-apply color settings.
278 * Dumps current content of mainw into a logfile
283 * Makes a beep when a change happens (if the user has this on)
284 * the bool is TRUE if changed line contained user's nick
286 void doChange(bool, QString
);
289 * show the ticker window
294 * ksirc command menu clicked on
296 void cmd_process(int id
);
300 * On a TAB key press we call TabNickCompletion which
301 * reads the last thing in linee matches it with a nick and
302 * puts it back into the line.
304 void TabNickCompletion(int dir
);
307 * Make sure to update colors correctly.
309 virtual bool event( QEvent
*e
);
312 * Redfine closeEvent to emit closing and delete itself.
314 virtual void closeEvent(QCloseEvent
*);
316 * Searches through the nick list and finds the nick with the best match.
317 * which, arg2, selects nicks other than the first shouldarg1 match more
320 virtual QString
findNick(QString
, uint which
= 0);
322 * remove a nick from the prefered in nick completion list
324 virtual void removeCompleteNick(const QString
&);
326 * Adds a nick to the list of nicks to prefer in nick completion
327 * or moves it to the top of the list if it was already there
329 virtual void addCompleteNick(const QString
&);
331 * Changes a nick in the completion list if it has been listed,
332 * otherwise does nothing
334 virtual void changeCompleteNick(const QString
&, const QString
&);
336 virtual void setupCommandMenu();
339 * Returns true if this window is a private conversation (query or dcc chat)
340 *, instead of a public chat in a channel or a special window.
342 bool isPrivateChat() const;
345 * Returns true if this is a public channel window
347 bool isPublicChat() const;
350 * Returns true if this is a special window
352 bool isSpecialWindow() const;
355 void setTopicIntern( const QString
&topic
);
357 void setMode(QString
, int, QString currentNick
=0);
359 void returnPressed();
364 void outputUnicodeLine( const QString
&message
);
369 charSelector
*selector
;
370 chanButtons
*channelButtons
;
375 enum {PING
= 10, TOPIC
= 20};
377 aHistLineEdit
*linee
;
380 //QString m_currentNick;
382 //KSircProcess *proc;
388 BufferedLine() { wasBroadcast
= false; }
389 BufferedLine( const QString
&msg
, bool broadc
)
390 { message
= msg
; wasBroadcast
= broadc
; }
391 bool operator==( const BufferedLine
&other
)
392 { return message
== other
.message
&&
393 wasBroadcast
== other
.wasBroadcast
; }
400 QList
<BufferedLine
> LineBuffer
;
402 // QPopupMenu's used for the menubar
403 Q3PopupMenu
*file
, *edit
, *command
;
405 bool parse_input(const QString
&string
, QString
&plainText
);
406 void sirc_write(const QString
&str
);
408 Q3PopupMenu
*user_controls
;
409 static Q3PtrList
<UserControlMenu
> *user_menu
;
415 * The channel name that we belong too.
417 //QString channel_name;
420 * Caption at the top of the window.
424 * Current topic for the channel
429 * Does the window have focus? 1 when yes, 0 when no.
434 * Number of time tab has been pressed. Each time it's pressed
435 * roll through the list of matching nicks.
439 * When tabs pressed save the line for use at a latter date.
440 * tab_nick holds the last nick found so when a blank tab is pressed
441 * we pop the last niick and ": " up.
443 QString tab_saved
, tab_nick
;
444 int tab_start
, tab_end
;
446 // Ticker specific variables.
449 * Main pointer to ksticker. Caution, it doesn't always exist!
450 * Set to 0 ifwhen you delete it.
454 * Size and position of the main window. Main window is returns this
455 * this position when it reappears.
459 * Position of the main window
463 * Ticker's size and geometry
472 * Do we have a kick window open?
473 * Remember not to open 2
478 * Hold an internal parser object which does all our parsing for us.
479 * Since parsing an intergral part of TopLevel, it's also a friend
482 ChannelParser
*ChanParser
;
485 * QSize maintains size information in case it changes somehow
490 * ID of the timestamp menu item, to use in (un)checking it from slot
495 * ID of the filter join/part menu item, to use in (un)checking it from slot
500 * ID of the beep menu item, to use in (un)checking it from slot
505 * ID of the toggle topic menu item, to use in (un)checking it from slot
510 * ID of the show/hide ticker menu item
515 * List of nicks already used in nick completion to give them
518 QStringList completeNicks
;
521 * The time of the last beep to prevent your soundcard from detonating
522 * in high traffic channels
530 KSelectAction
*encodingAction
;
532 static QStringList cmd_menu
;
534 bool m_gotMsgWithoutFocus
;
536 KSircChannel m_channelInfo
;