kopete/kopete
chatmessagepart.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CHATMESSAGEPART_H
00020 #define CHATMESSAGEPART_H
00021
00022 #include <khtml_part.h>
00023 #include <dom/html_element.h>
00024 #include <dom/dom2_events.h>
00025
00026 #include <kmenu.h>
00027 #include <kopetemessage.h>
00028
00029 #include <kopete_export.h>
00030
00031 namespace Kopete
00032 {
00033 class Message;
00034 class ChatSession;
00035 class Contact;
00036 }
00037 class KMenu;
00038 class ChatWindowStyle;
00039
00043 class KOPETECHATWINDOW_SHARED_EXPORT ChatMessagePart : public KHTMLPart
00044 {
00045 Q_OBJECT
00046 public:
00050 ChatMessagePart( Kopete::ChatSession *manager, QWidget *parent);
00051 ~ChatMessagePart();
00052
00056 void clear();
00057
00062 void keepScrolledDown();
00063
00071 QString formatName( const Kopete::Contact* contact, Qt::TextFormat format ) const;
00072
00080 QString formatName( const QString &sourceName, Qt::TextFormat format ) const;
00081
00082 public slots:
00091 void copy(bool justselection = false);
00092
00096 void print();
00097
00101 void save();
00102
00106 void pageUp();
00107
00111 void pageDown();
00112
00118 void appendMessage( Kopete::Message &message, bool restoring = false);
00119
00129 void setStyle( const QString &styleName );
00130
00140 void setStyle( ChatWindowStyle *style );
00141
00146 void setStyleVariant( const QString &variantPath );
00147
00148 void messageStateChanged( uint messageId, Kopete::Message::MessageState state );
00149
00150 signals:
00154 void contextMenuEvent( const QString &textUnderMouse, KMenu *popupMenu );
00155
00159 void tooltipEvent( const QString &textUnderMouse, QString &toolTip );
00160
00161 private slots:
00162 void slotOpenURLRequest( const KUrl &url, const KParts::OpenUrlArguments &, const KParts::BrowserArguments & );
00163 void slotFileTransferIncomingDone( unsigned int id );
00164 void slotScrollView();
00165 void slotAppearanceChanged();
00166
00167 void slotScrollingTo( int y );
00168
00169 void slotRefreshView();
00170
00171 void slotRightClick( const QString &, const QPoint &point );
00172
00173 void slotCopyURL();
00174
00175 void slotCloseView( bool force = false );
00176
00180 void changeStyle();
00181
00185 void slotUpdateHeaderDisplayName();
00189 void slotUpdateHeaderPhoto();
00190
00191 void resendMessage( uint messageId );
00192
00193 protected:
00194 virtual void khtmlDrawContentsEvent( khtml::DrawContentsEvent * );
00195
00196 private:
00197 void readOverrides();
00198
00199 const QString styleHTML() const;
00200
00201 Kopete::Contact *contactFromNode( const DOM::Node &n ) const;
00202
00206 void emitTooltipEvent( const QString &textUnderMouse, QString &toolTipString );
00207
00211 QString textUnderMouse();
00212
00213
00214
00215
00225 QString formatStyleKeywords( const QString &sourceHTML, const Kopete::Message &message );
00234 QString formatStyleKeywords( const QString &sourceHTML );
00235
00244 QString formatTime(const QString &timeFormat, const QDateTime &dateTime);
00245
00253 QString formatMessageBody( const Kopete::Message &message );
00254
00258 void writeTemplate();
00259
00266 QString adjustStyleVariantForChatSession( const QString & styleVariant ) const;
00267
00272 QString photoForContact( const Kopete::Contact *contact ) const;
00273
00274 void addFileTransferButtonsEventListener( unsigned int id );
00275
00276 void disableFileTransferButtons( unsigned int id );
00277
00278 void changeMessageStateElement( uint id, Kopete::Message::MessageState state );
00279
00280 void registerClickEventListener( DOM::HTMLElement element );
00281
00282 class Private;
00283 Private *d;
00284 };
00285
00286 class HTMLEventListener: public QObject, public DOM::EventListener
00287 {
00288 Q_OBJECT
00289 public:
00290 virtual void handleEvent( DOM::Event &event );
00291 Q_SIGNALS:
00292 void resendMessage( uint messageId );
00293 };
00294
00295 #endif
00296
00297
00298