17 #include <QtAlgorithms>
19 #include "../../util/btassert.h"
20 #include "../../util/btconnect.h"
21 #include "../../util/macros.h"
22 #include "../drivers/cswordmoduleinfo.h"
23 #include "../drivers/btconstmoduleset.h"
46 case Qt::DecorationRole:
50 return QVariant::fromValue(
static_cast<void *
>(
module));
66 return QStringLiteral(
"<b>%1:</b><br/>%2")
75 if (!index.isValid() || index.column() != 0 || index.parent().isValid())
78 int row = index.row();
86 Qt::Orientation orientation,
89 if (role == Qt::DisplayRole
90 && orientation == Qt::Horizontal
100 const QVariant & value,
103 int row = index.row();
107 && index.column() == 0)
115 return m_data.at(row)->setHidden(value.toBool());
124 beginRemoveRows(QModelIndex(), 0,
m_data.size() - 1);
137 const int index(
m_data.size());
138 beginInsertRows(QModelIndex(), index, index);
155 beginRemoveRows(QModelIndex(), index, index);
172 for (
auto module: modules)
179 for (
auto const *
const module : modules)
191 BT_ASSERT(qobject_cast<CSwordModuleInfo *>(sender()));
197 BT_ASSERT(qobject_cast<CSwordModuleInfo *>(sender()));
203 BT_ASSERT(qobject_cast<CSwordModuleInfo *>(sender()));
212 Q_EMIT dataChanged(i, i);
static std::shared_ptr< BtBookshelfModel > newInstance()
void removeModule(CSwordModuleInfo *const module, bool destroy=false)
void addModule(CSwordModuleInfo *const module)
void moduleIndexed(bool indexed)
CSwordModuleInfo * module(QModelIndex const &index) const
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
bool setData(const QModelIndex &index, const QVariant &value, int role=ModuleHiddenRole) override
~BtBookshelfModel() noexcept override
QList< CSwordModuleInfo * > m_data
QVariant data(CSwordModuleInfo *module, int role) const
void moduleHidden(bool hidden)
CSwordModuleInfo * getModule(const QString &name) const
void moduleUnlocked(bool unlocked)
void moduleDataChanged(CSwordModuleInfo *module)
BtBookshelfModel(BtBookshelfModel &&)=delete
void removeModules(BtConstModuleSet const &modules, bool destroy=false)
void clear(bool destroy=false)
QString config(const CSwordModuleInfo::ConfigEntry entry) const
void hasIndexChanged(bool hasIndex)
QString const & name() const
void hiddenChanged(bool hidden)
void unlockedChanged(bool unlocked)
::qint64 indexSize() const
CSwordModuleInfo::Category category() const
#define UNLIKELY(c)
Gives the compiler a hint that the given conditional is likely to evaluate to false.
Used to restrict construction to newInstance() only.