<commit_before>/**
 *  For conditions of distribution and use, see copyright notice in license.txt
 *
 *  @file   ECEditorWindow.h
 *  @brief  Entity-component editor window.
 */

#pragma once

#include "ECEditorModuleApi.h"
#include "CoreTypes.h"
#include "SceneFwd.h"

#include <QMap>
#include <QSet>
#include <QListWidgetItem>
#include <QPointer>
#include <QWidget>

class QPushButton;
class QListWidget;
class QTreeWidget;
class QPoint;

struct EntityComponentSelection
{
    EntityPtr entity;
    std::vector<ComponentPtr> components;
};

class Framework;
class ECBrowser;
class TransformEditor;

/// List widget item representing entity. Holds a weak pointer to the represented entity.
/// \ingroup ECEditorModuleClient.
class EntityListWidgetItem: public QListWidgetItem
{
public:
    EntityListWidgetItem(const QString &name, QListWidget *list, Entity *entity);

    /// Returns shared pointer of the entity that this item is presenting.
    EntityPtr Entity() const { return entity.lock(); }

private:
    EntityWeakPtr entity; ///< Weak pointer to the represented entity.
};

/// Entity-component editor window.
/** \ingroup ECEditorModuleClient. */
class ECEDITOR_MODULE_API ECEditorWindow : public QWidget
{
    Q_OBJECT

public:
    /// Constructor
    /** @param fw Framework. */
    explicit ECEditorWindow(Framework* fw, QWidget *parent = 0);

    /// Destructor.
    ~ECEditorWindow();

    /// Adds new entity to the entity list.
    /** @param id Entity ID.
        @param updateUi Do we want to update UI.
        @return The created list item.
    */
    EntityListWidgetItem *AddEntity(entity_id_t id, bool updateUi = true);

    /// Sets new list of entities to be shown in the editor.
    /** Calling this method will clear previously selected entities from the editor.
        @param entities a new list of entities that we want to add into the editor.
        @param select_all Do we want to select all entities from the list. */
    void AddEntities(const QList<entity_id_t> &entities, bool select_all = false);

    /// Removes entity from the entity list.
    /** @param id Entity ID. */
    void RemoveEntity(entity_id_t id, bool udpate_ui = true); 

    /// Sets which entities are selected in the editor window.
    /** @param ids List of entity ID's. */
    void SetSelectedEntities(const QList<entity_id_t> &ids);

    /// Clears entity list.
    void ClearEntities();

    /// Returns components that are currently selected.
    /** @return If any components aren't selected return emtpy list. */
    QObjectList GetSelectedComponents() const;

    /// Returns list of selected entities.
    QList<EntityPtr> GetSelectedEntities() const;

    /// Sets item active in the entity list. Also adds/removes EC_Highlight for the entity, if applicable.
    /** @param item Item to be select or deselect
        @param select Do we want to select or deselect. */
    void SetEntitySelected(EntityListWidgetItem *item, bool select);

    /// Returns list item for specific entity.
    /** @param id Entity ID. */
    EntityListWidgetItem *FindItem(entity_id_t id) const;

    void ShowVisualEditingAids(bool show);

public slots:
    /// Deletes selected entity entries from the list (does not delete the entity itself).
    void DeleteEntitiesFromList();

    /// Remove coponent from entity and refresh property browser.
    void DeleteComponent(const QString &componentType, const QString &name);

    /// Opens a dialog that will handle new entity creation.
    /** After the dialog is done, ComponentDialogFinished method is called. */
    void CreateComponent();

    /// Shows dialog for invoking entity actions for currently selected entities.
    void OpenEntityActionDialog();<commit_msg>Add documentation for function.<commit_after>/**
 *  For conditions of distribution and use, see copyright notice in license.txt
 *
 *  @file   ECEditorWindow.h
 *  @brief  Entity-component editor window.
 */

#pragma once

#include "ECEditorModuleApi.h"
#include "CoreTypes.h"
#include "SceneFwd.h"

#include <QMap>
#include <QSet>
#include <QListWidgetItem>
#include <QPointer>
#include <QWidget>

class QPushButton;
class QListWidget;
class QTreeWidget;
class QPoint;

struct EntityComponentSelection
{
    EntityPtr entity;
    std::vector<ComponentPtr> components;
};

class Framework;
class ECBrowser;
class TransformEditor;

/// List widget item representing entity. Holds a weak pointer to the represented entity.
/// \ingroup ECEditorModuleClient.
class EntityListWidgetItem: public QListWidgetItem
{
public:
    EntityListWidgetItem(const QString &name, QListWidget *list, Entity *entity);

    /// Returns shared pointer of the entity that this item is presenting.
    EntityPtr Entity() const { return entity.lock(); }

private:
    EntityWeakPtr entity; ///< Weak pointer to the represented entity.
};

/// Entity-component editor window.
/** \ingroup ECEditorModuleClient. */
class ECEDITOR_MODULE_API ECEditorWindow : public QWidget
{
    Q_OBJECT

public:
    /// Constructor
    /** @param fw Framework. */
    explicit ECEditorWindow(Framework* fw, QWidget *parent = 0);

    /// Destructor.
    ~ECEditorWindow();

    /// Adds new entity to the entity list.
    /** @param id Entity ID.
        @param updateUi Do we want to update UI.
        @return The created list item.
    */
    EntityListWidgetItem *AddEntity(entity_id_t id, bool updateUi = true);

    /// Sets new list of entities to be shown in the editor.
    /** Calling this method will clear previously selected entities from the editor.
        @param entities a new list of entities that we want to add into the editor.
        @param select_all Do we want to select all entities from the list. */
    void AddEntities(const QList<entity_id_t> &entities, bool select_all = false);

    /// Removes entity from the entity list.
    /** @param id Entity ID. */
    void RemoveEntity(entity_id_t id, bool udpate_ui = true); 

    /// Sets which entities are selected in the editor window.
    /** @param ids List of entity ID's. */
    void SetSelectedEntities(const QList<entity_id_t> &ids);

    /// Clears entity list.
    void ClearEntities();

    /// Returns components that are currently selected.
    /** @return If any components aren't selected return emtpy list. */
    QObjectList GetSelectedComponents() const;

    /// Returns list of selected entities.
    QList<EntityPtr> GetSelectedEntities() const;

    /// Sets item active in the entity list. Also adds/removes EC_Highlight for the entity, if applicable.
    /** @param item Item to be select or deselect
        @param select Do we want to select or deselect. */
    void SetEntitySelected(EntityListWidgetItem *item, bool select);

    /// Returns list item for specific entity.
    /** @param id Entity ID. */
    EntityListWidgetItem *FindItem(entity_id_t id) const;

    /// Sets visibility of visual editing aids for this editor window (if applicable).
    /** @note The state visibility state is not stored within this class. ECEditorModule is authorative for this state.
        @param show Do we want to show or hide the visual editing aids. */
    void ShowVisualEditingAids(bool show);

public slots:
    /// Deletes selected entity entries from the list (does not delete the entity itself).
    void DeleteEntitiesFromList();

    /// Remove coponent from entity and refresh property browser.
    void DeleteComponent(const QString &componentType, const QString &name);

    /// Opens a dialog that will handle new entity creation.
    /** After the dialog is done, ComponentDialogFinished method is called. */
    void CreateComponent();

    /// Shows dialog for invoking entity actions for currently selected entities.
    void OpenEntityActionDialog();
{'fraction_non_alphanumeric': 0.08789364997418689, 'fraction_numerical': 0.0002581311306143521, 'mean_word_length': 3.331470095025154, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1054613', 'n_tokens_mistral': 2119, 'n_tokens_neox': 2040, 'n_words': 848}