diff options
Diffstat (limited to 'src/pluginlist.h')
| -rw-r--r-- | src/pluginlist.h | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/pluginlist.h b/src/pluginlist.h index f8c69e11..95f90e09 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -33,13 +33,46 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <BOSS-API.h> + +template <class C> +class ChangeBracket { +public: + ChangeBracket(C *model) + : m_Model(nullptr) + { + QVariant var = model->property("__aboutToChange"); + bool aboutToChange = var.isValid() && var.toBool(); + if (!aboutToChange) { + model->layoutAboutToBeChanged(); + model->setProperty("__aboutToChange", true); + m_Model = model; + } + } + ~ChangeBracket() { + finish(); + } + + void finish() { + if (m_Model != nullptr) { + m_Model->layoutChanged(); + m_Model->setProperty("__aboutToChange", false); + m_Model = nullptr; + } + } + +private: + C *m_Model; +}; + + + /** * @brief model representing the plugins (.esp/.esm) in the current virtual data folder **/ class PluginList : public QAbstractTableModel, public MOBase::IPluginList { Q_OBJECT - + friend class ChangeBracket<PluginList>; public: enum EColumn { @@ -225,7 +258,6 @@ private: friend bool ByDate(const ESPInfo& LHS, const ESPInfo& RHS); friend bool ByPriority(const ESPInfo& LHS, const ESPInfo& RHS); - class BossDLL : public PDLL { DECLARE_CLASS(BossDLL) @@ -353,4 +385,6 @@ private: }; + + #endif // PLUGINLIST_H |
