Some model shit.

This commit is contained in:
Martin Rotter 2015-11-19 19:23:22 +01:00
parent dec5f18ad6
commit a8316e2c2a

View file

@ -162,7 +162,12 @@ void MessagesModel::setupHeaderData() {
Qt::ItemFlags MessagesModel::flags(const QModelIndex &index) const { Qt::ItemFlags MessagesModel::flags(const QModelIndex &index) const {
Q_UNUSED(index) Q_UNUSED(index)
#if QT_VERSION >= 0x050000
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemNeverHasChildren; return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemNeverHasChildren;
#else
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;
#endif
} }
QVariant MessagesModel::data(int row, int column, int role) const { QVariant MessagesModel::data(int row, int column, int role) const {
@ -305,9 +310,7 @@ bool MessagesModel::switchMessageImportance(int row_index) {
int current_importance = data(target_index, Qt::EditRole).toInt(); int current_importance = data(target_index, Qt::EditRole).toInt();
// Rewrite "visible" data in the model. // Rewrite "visible" data in the model.
bool working_change = current_importance == 1 ? bool working_change = current_importance == 1 ? setData(target_index, 0) : setData(target_index, 1);
setData(target_index, 0) :
setData(target_index, 1);
if (!working_change) { if (!working_change) {
// If rewriting in the model failed, then cancel all actions. // If rewriting in the model failed, then cancel all actions.