<commit_before>/*
    chatmessagepart.h - Chat Message KPart

    Copyright (c) 2004      by <NAME>         <<EMAIL>>
    Copyright (c) 2005      by <NAME>      <<EMAIL>>
    Copyright (c) 2009      by <NAME>      <<EMAIL>>

    Kopete    (c) 2002-2008 by the Kopete developers <<EMAIL>>

    *************************************************************************
    *                                                                       *
    * 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 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#ifndef CHATMESSAGEPART_H
#define CHATMESSAGEPART_H

#include <khtml_part.h>
#include <dom/html_element.h>
#include <dom/dom2_events.h>

#include <kmenu.h>
#include <kopetemessage.h>

#include <kopete_export.h>

namespace Kopete
{
	class Message;
	class ChatSession;
	class Contact;
}
class KMenu;
class ChatWindowStyle;

/**
 * @author <NAME>
 */
class KOPETECHATWINDOW_SHARED_EXPORT ChatMessagePart : public KHTMLPart
{
	Q_OBJECT
public:
	/**
	 * Create a new ChatMessage Part.
	 */
	ChatMessagePart( Kopete::ChatSession *manager, QWidget *parent);
	~ChatMessagePart();

	/**
	 * Clear the message window
	 */
	void clear();

	/**
	 * Immediately scroll the chat to the bottom, as long as it has not been intentionally scrolled away from the bottom
	 * use
	 */
	void keepScrolledDown();

	/**
	 * Format contact's nickname/displayname according to preferences.
	 *
	 * @param contact Contact to format.
	 * @param format text format, only PlainText and RichText are supported
	 * @return the formatted name.
	 */
	QString formatName( const Kopete::Contact* contact, Qt::TextFormat format ) const;

	/**
	 * Format a nickname/displayname according to preferences.
	 *
	 * @param sourceName Source name to format.
	 * @param format text format, only PlainText and RichText are supported
	 * @return the formatted name.
	 */
	QString formatName( const QString &sourceName, Qt::TextFormat format ) const;

public slots:
	/**
	 * Initiates a copy action
	 * If there is text selected in the HTML view, that text is copied
	 * Otherwise if @p justselection is false, the entire edit area is copied.
	 *
	 * @param justselection If this is true, then the text will be only copied to the selection buffer only.
	 *                      In this mode, if nothing is selected, then nothing is copied.
	 */
	void copy(bool justselection = false);

	/**
	 * Print out the contents of the chatwindow
	 */
	void print();

	/**
	 * Save the contents of the chat to a file
	 */
	void save();

	/**
	 * Scroll the view up a page
	 */
	void pageUp();

	/**
	 * Scroll the view down a page
	 */
	void pageDown();

	/**
	 * Appends a message to the messave view
	 * @param message The message to be appended
	 * @param restoring This flag is used to not re-append message when changing style. By default false.
	 */
	void appendMessage( Kopete::Message &message, bool restoring = false);

	/**
	 * Change the current style.
	 * This method override is used when preferences change.
	 * This method create a new ChatWindowStyle object.
	 *
	 * Need to rebuild all the XHTML content.
	 *
	 * @param styleName name of the style.
	 */
	void setStyle( const QString &styleName );

	/**
	 * Change the current style
	 * This method override is used on preview and unit tests.
	 * Use a already existing ChatWindowStyle object.
	 *
	 * Need to rebuild all the XHTML content.
	 *
	 * @param chatWindowStyle ChatWindowStyle object.
	 */
	void setStyle( ChatWindowStyle *style );

	/**
	 * Change the current variant for the current style
	 * @param variantPath relative path to the style variant.
	 */
	void setStyleVariant( const QString &variantPath );

	void messageStateChanged( uint messageId, Kopete::Message::MessageState state );

	/**
	 * does nothing
	 */
	void slotToggleGraphicOverride(bool enable);

signals:
	/**
	 * Emits before the context menu is about to show
	 */
	void contextMenuEvent(  const QString &textUnderMouse, KMenu *popupMenu );

	/**
	 * Emits before the tooltip is about to show
	 */
	void tooltipEvent(  const QString &textUnderMouse, QString &toolTip );

private slots:
	void slotOpenURLRequest( const KUrl &url, const KParts::OpenUrlArguments &, const KParts::BrowserArguments & );
	void slotFileTransferIncomingDone( unsigned int id );
	void slotScrollView();
	void slotRenderingFinished();
	void slotAppearanceChanged();

	void slotScrollingTo( int y );

	void slotRefreshView();

	void slotRightClick( const QString &, const QPoint &point );

	void slotCopyURL();

	void slotCloseView( bool force = false );
<commit_msg>Method ChatMessagePart::slotToggleGraphicOverride does nothing so mark it as deprecated<commit_after>/*
    chatmessagepart.h - Chat Message KPart

    Copyright (c) 2004      by <NAME>         <<EMAIL>>
    Copyright (c) 2005      by <NAME>      <<EMAIL>>
    Copyright (c) 2009      by <NAME>      <<EMAIL>>

    Kopete    (c) 2002-2008 by the Kopete developers <<EMAIL>>

    *************************************************************************
    *                                                                       *
    * 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 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#ifndef CHATMESSAGEPART_H
#define CHATMESSAGEPART_H

#include <khtml_part.h>
#include <dom/html_element.h>
#include <dom/dom2_events.h>

#include <kmenu.h>
#include <kopetemessage.h>

#include <kopete_export.h>

namespace Kopete
{
	class Message;
	class ChatSession;
	class Contact;
}
class KMenu;
class ChatWindowStyle;

/**
 * @author <NAME>
 */
class KOPETECHATWINDOW_SHARED_EXPORT ChatMessagePart : public KHTMLPart
{
	Q_OBJECT
public:
	/**
	 * Create a new ChatMessage Part.
	 */
	ChatMessagePart( Kopete::ChatSession *manager, QWidget *parent);
	~ChatMessagePart();

	/**
	 * Clear the message window
	 */
	void clear();

	/**
	 * Immediately scroll the chat to the bottom, as long as it has not been intentionally scrolled away from the bottom
	 * use
	 */
	void keepScrolledDown();

	/**
	 * Format contact's nickname/displayname according to preferences.
	 *
	 * @param contact Contact to format.
	 * @param format text format, only PlainText and RichText are supported
	 * @return the formatted name.
	 */
	QString formatName( const Kopete::Contact* contact, Qt::TextFormat format ) const;

	/**
	 * Format a nickname/displayname according to preferences.
	 *
	 * @param sourceName Source name to format.
	 * @param format text format, only PlainText and RichText are supported
	 * @return the formatted name.
	 */
	QString formatName( const QString &sourceName, Qt::TextFormat format ) const;

public slots:
	/**
	 * Initiates a copy action
	 * If there is text selected in the HTML view, that text is copied
	 * Otherwise if @p justselection is false, the entire edit area is copied.
	 *
	 * @param justselection If this is true, then the text will be only copied to the selection buffer only.
	 *                      In this mode, if nothing is selected, then nothing is copied.
	 */
	void copy(bool justselection = false);

	/**
	 * Print out the contents of the chatwindow
	 */
	void print();

	/**
	 * Save the contents of the chat to a file
	 */
	void save();

	/**
	 * Scroll the view up a page
	 */
	void pageUp();

	/**
	 * Scroll the view down a page
	 */
	void pageDown();

	/**
	 * Appends a message to the messave view
	 * @param message The message to be appended
	 * @param restoring This flag is used to not re-append message when changing style. By default false.
	 */
	void appendMessage( Kopete::Message &message, bool restoring = false);

	/**
	 * Change the current style.
	 * This method override is used when preferences change.
	 * This method create a new ChatWindowStyle object.
	 *
	 * Need to rebuild all the XHTML content.
	 *
	 * @param styleName name of the style.
	 */
	void setStyle( const QString &styleName );

	/**
	 * Change the current style
	 * This method override is used on preview and unit tests.
	 * Use a already existing ChatWindowStyle object.
	 *
	 * Need to rebuild all the XHTML content.
	 *
	 * @param chatWindowStyle ChatWindowStyle object.
	 */
	void setStyle( ChatWindowStyle *style );

	/**
	 * Change the current variant for the current style
	 * @param variantPath relative path to the style variant.
	 */
	void setStyleVariant( const QString &variantPath );

	void messageStateChanged( uint messageId, Kopete::Message::MessageState state );

	/**
	 * @deprecated
	 * does nothing
	 */
	KDE_DEPRECATED void slotToggleGraphicOverride(bool enable);

signals:
	/**
	 * Emits before the context menu is about to show
	 */
	void contextMenuEvent(  const QString &textUnderMouse, KMenu *popupMenu );

	/**
	 * Emits before the tooltip is about to show
	 */
	void tooltipEvent(  const QString &textUnderMouse, QString &toolTip );

private slots:
	void slotOpenURLRequest( const KUrl &url, const KParts::OpenUrlArguments &, const KParts::BrowserArguments & );
	void slotFileTransferIncomingDone( unsigned int id );
	void slotScrollView();
	void slotRenderingFinished();
	void slotAppearanceChanged();

	void slotScrollingTo( int y );

	void slotRefreshView();

	void slotRightClick( const QString &, const QPoint &point );

	void slotCopyURL();

	void slotCloseView( bool force = false );

{'fraction_non_alphanumeric': 0.1141885811418858, 'fraction_numerical': 0.004399560043995601, 'mean_word_length': 3.0428455941794663, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1767854', 'n_tokens_mistral': 2888, 'n_tokens_neox': 2620, 'n_words': 1072}