Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManangement - Script Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-15
|
||||
*/
|
||||
|
||||
#include "pre_mobile_model.h"
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
PreMobileDialogModel::PreMobileDialogModel(QObject *parent)
|
||||
: PresentationManagementDialogModel(parent)
|
||||
, m_logger(getLogger("PreMobileDialogModel"))
|
||||
{
|
||||
//m_vecColumns.append(tr("Download"));
|
||||
m_checkboxColumn = 1;
|
||||
}
|
||||
|
||||
|
||||
PreMobileDialogModel::~PreMobileDialogModel()
|
||||
{}
|
||||
|
||||
QVariant PreMobileDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::CheckStateRole &&
|
||||
index.column() == m_checkboxColumn &&
|
||||
indexIsValid(index))
|
||||
{
|
||||
if (m_vecDownload.size() <= index.row())
|
||||
return Qt::Unchecked;
|
||||
return m_vecDownload.at(index.row()) ? Qt::Checked : Qt::Unchecked;
|
||||
}
|
||||
|
||||
return PresentationManagementDialogModel::data(index, role);
|
||||
}
|
||||
|
||||
bool PreMobileDialogModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
Q_UNUSED(value);
|
||||
if (role == Qt::CheckStateRole)
|
||||
{
|
||||
switchCheckbox(index);
|
||||
emit checkboxClicked();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PreMobileDialogModel::switchCheckbox(const QModelIndex &index)
|
||||
{
|
||||
if (m_vecDownload.size() <= index.row())
|
||||
m_vecDownload.resize(index.row() + 1);
|
||||
|
||||
m_vecDownload[index.row()] = !m_vecDownload.at(index.row());
|
||||
emit dataChanged(index, index, {Qt::CheckStateRole});
|
||||
}
|
||||
|
||||
Qt::ItemFlags PreMobileDialogModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
Qt::ItemFlags flags(PresentationManagementDialogModel::flags(index) & ~Qt::ItemIsSelectable);
|
||||
if (index.column() == m_checkboxColumn)
|
||||
flags.setFlag(Qt::ItemIsUserCheckable);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
QVector<int> PreMobileDialogModel::getDownloadedScriptIds() const
|
||||
{
|
||||
QVector<int> ret;
|
||||
|
||||
for (int i = 0; i < m_vecData.size(); ++i)
|
||||
{
|
||||
const Presentation &p = m_vecData.at(i);
|
||||
|
||||
if (m_vecDownload.size() <= i) // lazy init in switchCheckBox
|
||||
break;
|
||||
if (m_vecDownload.at(i))
|
||||
ret.push_back(p.id());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace PresentationManagement
|
||||
Reference in new issue
Block a user