39 return createIndex(row, column);
60 if (
myQuest == NULL || !index.isValid())
63 if (role != Qt::DisplayRole && role != Qt::EditRole && (role != Qt::CheckStateRole || index.column() != 2))
69 switch(index.column())
75 return step->description();
78 if (role == Qt::DisplayRole)
80 return step->isCompletion() ? Qt::Checked : Qt::Unchecked;
85 return step->setWhen().join(
"\n");
93 if (orientation != Qt::Horizontal || role != Qt::DisplayRole)
101 return tr(
"description");
105 return tr(
"set when");
113 if (!index.isValid())
116 if (index.column() == 2)
117 return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
119 return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
129 if (role != Qt::EditRole && index.column() != 2)
132 if (index.column() == 0)
134 else if (index.column() == 1)
136 else if (index.column() == 2)
138 else if (index.column() == 3)
139 step->
setWhen() = value.toString().split(
"\n");
141 emit dataChanged(index, index);
162 if (
myQuest == NULL || parent.isValid() || count != 1)
168 beginRemoveRows(parent, row, row);
180 beginMoveRows(QModelIndex(), step, step, QModelIndex(), step - 1);
193 beginMoveRows(QModelIndex(), step + 1, step + 1, QModelIndex(), step);
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
virtual ~CREQuestItemModel()
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const
CREQuestItemModel(QObject *parent)
virtual QVariant data(const QModelIndex &index, int role) const
const QStringList & setWhen() const
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
QList< const QuestStep * > steps() const
void setCompletion(bool completion)
virtual int columnCount(const QModelIndex &parent) const
virtual int rowCount(const QModelIndex &parent) const
virtual Qt::ItemFlags flags(const QModelIndex &index) const
virtual QModelIndex parent(const QModelIndex &index) const
void setDescription(const QString &description)
void setQuest(Quest *quest)
void setModified(bool modified)