From ea6292168a6acd4c263913f0ccd7dd64daf4f5cf Mon Sep 17 00:00:00 2001 From: Sandro Jäckel Date: Fri, 23 Feb 2018 01:45:58 +0100 Subject: Revert "Applied clang-format on source" This reverts commit 5e5c9c07291f6b09623d31c92b1fb61c4ede576e. --- src/modlist.h | 432 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 222 insertions(+), 210 deletions(-) (limited to 'src/modlist.h') diff --git a/src/modlist.h b/src/modlist.h index 4cdfe294..bd715107 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -20,24 +20,26 @@ along with Mod Organizer. If not, see . #ifndef MODLIST_H #define MODLIST_H + #include "categories.h" -#include "modinfo.h" #include "nexusinterface.h" +#include "modinfo.h" #include "profile.h" -#include #include +#include #include #include -#include #include +#include #ifndef Q_MOC_RUN #include #endif -#include #include #include +#include + class QSortFilterProxyModel; @@ -46,278 +48,288 @@ class QSortFilterProxyModel; * This is used in a view in the main window of MO. It combines general information about * the mods from ModInfo with status information from the Profile **/ -class ModList : public QAbstractItemModel, public MOBase::IModList { - Q_OBJECT +class ModList : public QAbstractItemModel, public MOBase::IModList +{ + Q_OBJECT public: - enum EColumn { - COL_NAME, - COL_FLAGS, - COL_CONTENT, - COL_CATEGORY, - COL_MODID, - COL_VERSION, - COL_INSTALLTIME, - COL_PRIORITY, - - COL_LASTCOLUMN = COL_PRIORITY - }; - - typedef boost::signals2::signal SignalModStateChanged; - typedef boost::signals2::signal SignalModMoved; + + enum EColumn { + COL_NAME, + COL_FLAGS, + COL_CONTENT, + COL_CATEGORY, + COL_MODID, + COL_VERSION, + COL_INSTALLTIME, + COL_PRIORITY, + + COL_LASTCOLUMN = COL_PRIORITY + }; + + typedef boost::signals2::signal SignalModStateChanged; + typedef boost::signals2::signal SignalModMoved; public: - /** - * @brief constructor - * @todo ensure this view works without a profile set, otherwise there are intransparent dependencies on the - *initialisation order - **/ - ModList(QObject* parent = nullptr); - ~ModList(); + /** + * @brief constructor + * @todo ensure this view works without a profile set, otherwise there are intransparent dependencies on the initialisation order + **/ + ModList(QObject *parent = nullptr); + + ~ModList(); - /** - * @brief set the profile used for status information - * - * @param profile the profile to use - **/ - void setProfile(Profile* profile); + /** + * @brief set the profile used for status information + * + * @param profile the profile to use + **/ + void setProfile(Profile *profile); - /** - * @brief retrieve the current sorting mode - * @note this is used to store the sorting mode between sessions - * @return current sorting mode, encoded to be compatible to previous versions - **/ - int getCurrentSortingMode() const; + /** + * @brief retrieve the current sorting mode + * @note this is used to store the sorting mode between sessions + * @return current sorting mode, encoded to be compatible to previous versions + **/ + int getCurrentSortingMode() const; - /** - * @brief remove the specified mod without asking for confirmation - * @param row the row to remove - */ - void removeRowForce(int row, const QModelIndex& parent); + /** + * @brief remove the specified mod without asking for confirmation + * @param row the row to remove + */ + void removeRowForce(int row, const QModelIndex &parent); - void notifyChange(int rowStart, int rowEnd = -1); - static QString getColumnName(int column); + void notifyChange(int rowStart, int rowEnd = -1); + static QString getColumnName(int column); - void changeModPriority(int sourceIndex, int newPriority); + void changeModPriority(int sourceIndex, int newPriority); - void setOverwriteMarkers(const std::set& overwrite, const std::set& overwritten); + void setOverwriteMarkers(const std::set &overwrite, const std::set &overwritten); - bool modInfoAboutToChange(ModInfo::Ptr info); - void modInfoChanged(ModInfo::Ptr info); + bool modInfoAboutToChange(ModInfo::Ptr info); + void modInfoChanged(ModInfo::Ptr info); - void disconnectSlots(); + void disconnectSlots(); - int timeElapsedSinceLastChecked() const; + int timeElapsedSinceLastChecked() const; - void highlightMods(const QItemSelection& selected, const MOShared::DirectoryEntry& directoryEntry); + void highlightMods(const QItemSelection &selected, const MOShared::DirectoryEntry &directoryEntry); public: - /// \copydoc MOBase::IModList::displayName - virtual QString displayName(const QString& internalName) const override; - /// \copydoc MOBase::IModList::allMods - virtual QStringList allMods() const override; + /// \copydoc MOBase::IModList::displayName + virtual QString displayName(const QString &internalName) const override; - /// \copydoc MOBase::IModList::state - virtual ModStates state(const QString& name) const override; + /// \copydoc MOBase::IModList::allMods + virtual QStringList allMods() const override; - /// \copydoc MOBase::IModList::setActive - virtual bool setActive(const QString& name, bool active) override; + /// \copydoc MOBase::IModList::state + virtual ModStates state(const QString &name) const override; - /// \copydoc MOBase::IModList::priority - virtual int priority(const QString& name) const override; + /// \copydoc MOBase::IModList::setActive + virtual bool setActive(const QString &name, bool active) override; - /// \copydoc MOBase::IModList::setPriority - virtual bool setPriority(const QString& name, int newPriority) override; + /// \copydoc MOBase::IModList::priority + virtual int priority(const QString &name) const override; - /// \copydoc MOBase::IModList::onModStateChanged - virtual bool onModStateChanged(const std::function& func) override; + /// \copydoc MOBase::IModList::setPriority + virtual bool setPriority(const QString &name, int newPriority) override; - /// \copydoc MOBase::IModList::onModMoved - virtual bool onModMoved(const std::function& func) override; + /// \copydoc MOBase::IModList::onModStateChanged + virtual bool onModStateChanged(const std::function &func) override; + + /// \copydoc MOBase::IModList::onModMoved + virtual bool onModMoved(const std::function &func) override; public: // implementation of virtual functions of QAbstractItemModel - virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; - virtual bool hasChildren(const QModelIndex& parent = QModelIndex()) const; - virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; - virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; - virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); - virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - virtual Qt::ItemFlags flags(const QModelIndex& modelIndex) const; - virtual Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; } - virtual QStringList mimeTypes() const; - virtual QMimeData* mimeData(const QModelIndexList& indexes) const; - virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, - const QModelIndex& parent); - virtual bool removeRows(int row, int count, const QModelIndex& parent); - - virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const; - virtual QModelIndex parent(const QModelIndex& child) const; - - virtual QMap itemData(const QModelIndex& index) const; + + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; + virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const; + virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + virtual Qt::ItemFlags flags(const QModelIndex &modelIndex) const; + virtual Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; } + virtual QStringList mimeTypes() const; + virtual QMimeData *mimeData(const QModelIndexList &indexes) const; + virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); + virtual bool removeRows(int row, int count, const QModelIndex &parent); + + virtual QModelIndex index(int row, int column, + const QModelIndex &parent = QModelIndex()) const; + virtual QModelIndex parent(const QModelIndex &child) const; + + virtual QMap itemData(const QModelIndex &index) const; public slots: - void dropModeUpdate(bool dropOnItems); + void dropModeUpdate(bool dropOnItems); signals: - /** - * @brief emitted whenever the sorting in the list was changed by the user - * - * the sorting of the list can only be manually changed if the list is sorted by priority - * in which case the move is intended to change the priority of a mod - **/ - void modorder_changed(); - - /** - * @brief emitted when the model wants a text to be displayed by the UI - * - * @param message the message to display - **/ - void showMessage(const QString& message); - - /** - * @brief signals change to the count of headers - */ - void resizeHeaders(); - - /** - * @brief requestColumnSelect is emitted whenever the user requested a menu to select visible columns - * @param pos the position to display the menu at - */ - void requestColumnSelect(QPoint pos); - - /** - * @brief emitted to remove a file origin - * @param name name of the orign to remove - */ - void removeOrigin(const QString& name); - - /** - * @brief emitted after a mod has been renamed - * This signal MUST be used to fix the mod names in profiles (except the active one) and to invalidate/refresh other - * structures that may have become invalid with the rename - * - * @param oldName the old name of the mod - * @param newName new name of the mod - */ - void modRenamed(const QString& oldName, const QString& newName); - - /** - * @brief emitted after a mod has been uninstalled - * @param fileName filename of the mod being uninstalled - */ - void modUninstalled(const QString& fileName); - - /** - * @brief emitted whenever a row in the list has changed - * - * @param index the index of the changed field - * @param role role of the field that changed - * @note this signal must only be emitted if the row really did change. - * Slots handling this signal therefore do not have to verify that a change has happened - * @note this signal is currently only used in tutorials - **/ - void modlist_changed(const QModelIndex& index, int role); - - /** - * @brief emitted to have all selected mods deleted - */ - void removeSelectedMods(); - - /** - * @brief fileMoved emitted when a file is moved from one mod to another - * @param relativePath relative path of the file moved - * @param oldOriginName name of the origin that previously contained the file - * @param newOriginName name of the origin that now contains the file - */ - void fileMoved(const QString& relativePath, const QString& oldOriginName, const QString& newOriginName); - - void aboutToChangeData(); - - void postDataChanged(); + /** + * @brief emitted whenever the sorting in the list was changed by the user + * + * the sorting of the list can only be manually changed if the list is sorted by priority + * in which case the move is intended to change the priority of a mod + **/ + void modorder_changed(); + + /** + * @brief emitted when the model wants a text to be displayed by the UI + * + * @param message the message to display + **/ + void showMessage(const QString &message); + + /** + * @brief signals change to the count of headers + */ + void resizeHeaders(); + + /** + * @brief requestColumnSelect is emitted whenever the user requested a menu to select visible columns + * @param pos the position to display the menu at + */ + void requestColumnSelect(QPoint pos); + + /** + * @brief emitted to remove a file origin + * @param name name of the orign to remove + */ + void removeOrigin(const QString &name); + + /** + * @brief emitted after a mod has been renamed + * This signal MUST be used to fix the mod names in profiles (except the active one) and to invalidate/refresh other + * structures that may have become invalid with the rename + * + * @param oldName the old name of the mod + * @param newName new name of the mod + */ + void modRenamed(const QString &oldName, const QString &newName); + + /** + * @brief emitted after a mod has been uninstalled + * @param fileName filename of the mod being uninstalled + */ + void modUninstalled(const QString &fileName); + + /** + * @brief emitted whenever a row in the list has changed + * + * @param index the index of the changed field + * @param role role of the field that changed + * @note this signal must only be emitted if the row really did change. + * Slots handling this signal therefore do not have to verify that a change has happened + * @note this signal is currently only used in tutorials + **/ + void modlist_changed(const QModelIndex &index, int role); + + /** + * @brief emitted to have all selected mods deleted + */ + void removeSelectedMods(); + + /** + * @brief fileMoved emitted when a file is moved from one mod to another + * @param relativePath relative path of the file moved + * @param oldOriginName name of the origin that previously contained the file + * @param newOriginName name of the origin that now contains the file + */ + void fileMoved(const QString &relativePath, const QString &oldOriginName, const QString &newOriginName); + + void aboutToChangeData(); + + void postDataChanged(); protected: - // event filter, handles event from the header and the tree view itself - bool eventFilter(QObject* obj, QEvent* event); + + // event filter, handles event from the header and the tree view itself + bool eventFilter(QObject *obj, QEvent *event); private: - bool testValid(const QString& modDir); - void changeModPriority(std::vector sourceIndices, int newPriority); + bool testValid(const QString &modDir); - QVariant getOverwriteData(int column, int role) const; + void changeModPriority(std::vector sourceIndices, int newPriority); - QString getFlagText(ModInfo::EFlag flag, ModInfo::Ptr modInfo) const; + QVariant getOverwriteData(int column, int role) const; - static QString getColumnToolTip(int column); + QString getFlagText(ModInfo::EFlag flag, ModInfo::Ptr modInfo) const; - QVariantList contentsToIcons(const std::vector& content) const; + static QString getColumnToolTip(int column); - QString contentsToToolTip(const std::vector& contents) const; + QVariantList contentsToIcons(const std::vector &content) const; - ModList::EColumn getEnabledColumn(int index) const; + QString contentsToToolTip(const std::vector &contents) const; - QVariant categoryData(int categoryID, int column, int role) const; - QVariant modData(int modID, int modelColumn, int role) const; + ModList::EColumn getEnabledColumn(int index) const; - bool renameMod(int index, const QString& newName); + QVariant categoryData(int categoryID, int column, int role) const; + QVariant modData(int modID, int modelColumn, int role) const; - bool dropURLs(const QMimeData* mimeData, int row, const QModelIndex& parent); + bool renameMod(int index, const QString &newName); - bool dropMod(const QMimeData* mimeData, int row, const QModelIndex& parent); + bool dropURLs(const QMimeData *mimeData, int row, const QModelIndex &parent); - ModStates state(unsigned int modIndex) const; + bool dropMod(const QMimeData *mimeData, int row, const QModelIndex &parent); - bool moveSelection(QAbstractItemView* itemView, int direction); + ModStates state(unsigned int modIndex) const; - bool deleteSelection(QAbstractItemView* itemView); + bool moveSelection(QAbstractItemView *itemView, int direction); - bool toggleSelection(QAbstractItemView* itemView); + bool deleteSelection(QAbstractItemView *itemView); + + bool toggleSelection(QAbstractItemView *itemView); private slots: private: - struct TModInfo { - TModInfo(unsigned int index, ModInfo::Ptr modInfo) - : modInfo(modInfo), nameOrder(index), priorityOrder(0), modIDOrder(0), categoryOrder(0) {} - ModInfo::Ptr modInfo; - unsigned int nameOrder; - unsigned int priorityOrder; - unsigned int modIDOrder; - unsigned int categoryOrder; - }; - - struct TModInfoChange { - QString name; - QFlags state; - }; + + struct TModInfo { + TModInfo(unsigned int index, ModInfo::Ptr modInfo) + : modInfo(modInfo), nameOrder(index), priorityOrder(0), modIDOrder(0), categoryOrder(0) {} + ModInfo::Ptr modInfo; + unsigned int nameOrder; + unsigned int priorityOrder; + unsigned int modIDOrder; + unsigned int categoryOrder; + }; + + struct TModInfoChange { + QString name; + QFlags state; + }; private: - Profile* m_Profile; - NexusInterface* m_NexusInterface; - std::set m_RequestIDs; + Profile *m_Profile; + + NexusInterface *m_NexusInterface; + std::set m_RequestIDs; - mutable bool m_Modified; + mutable bool m_Modified; - QFontMetrics m_FontMetrics; + QFontMetrics m_FontMetrics; - bool m_DropOnItems; + bool m_DropOnItems; - std::set m_Overwrite; - std::set m_Overwritten; + std::set m_Overwrite; + std::set m_Overwritten; - TModInfoChange m_ChangeInfo; + TModInfoChange m_ChangeInfo; - SignalModStateChanged m_ModStateChanged; - SignalModMoved m_ModMoved; + SignalModStateChanged m_ModStateChanged; + SignalModMoved m_ModMoved; - std::map> m_ContentIcons; + std::map > m_ContentIcons; + + QTime m_LastCheck; - QTime m_LastCheck; }; #endif // MODLIST_H + -- cgit v1.3.1