diff options
| author | Tannin <devnull@localhost> | 2014-02-02 00:09:03 +0100 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2014-02-02 00:09:03 +0100 |
| commit | 48704877ca1dc44b9215ec834e93f34fd953b2fb (patch) | |
| tree | db680a70dceb6ac3317eaa32dc6f2a312d8a8665 /src/pluginlist.h | |
| parent | 48c944c737a0e277c3ac85c10008031f39cbc04c (diff) | |
- bugfix: upon moving files between mods, an attempt was made to access origins
for both, even if one (or both) mods weren't active
- bugfix: plugin-list should now deal with nested "layoutAboutToBeChanged" calls
gracefully. May be the reason of a bug.
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 |
