From: Mikko Keinänen Date: Sun, 12 Dec 2010 00:29:55 +0000 (+0200) Subject: Added a QList for editable column indexes. bool ok gets false in default X-Git-Url: http://vcs.maemo.org/git/?p=emufront;a=commitdiff_plain;h=6643f19481801ff05ae13768934d2093235886a7 Added a QList for editable column indexes. bool ok gets false in default section of switch...case. --- diff --git a/src/models/emufrontquerymodel.h b/src/models/emufrontquerymodel.h index 47f48ef..ca64d27 100644 --- a/src/models/emufrontquerymodel.h +++ b/src/models/emufrontquerymodel.h @@ -37,6 +37,7 @@ public slots: protected: QString tableName; + QList editableColumns; }; #endif // EMUFRONTQUERYMODEL_H diff --git a/src/models/externalexecutablemodel.cpp b/src/models/externalexecutablemodel.cpp index bea2327..2e151c0 100644 --- a/src/models/externalexecutablemodel.cpp +++ b/src/models/externalexecutablemodel.cpp @@ -24,6 +24,10 @@ ExternalExecutableModel::ExternalExecutableModel(QObject *parent) : EmuFrontQueryModel(parent) { + editableColumns << Executable_Name; + editableColumns << Executable_Options; + editableColumns << Executable_Executable; + editableColumns << Executable_SetupId; refresh(); } @@ -61,10 +65,7 @@ Qt::ItemFlags ExternalExecutableModel::flags(const QModelIndex &index) const { Qt::ItemFlags flags = QSqlQueryModel::flags(index); int col = index.column(); - if (col == Executable_Name || - col == Executable_Options || - col == Executable_Executable || - col == Executable_SetupId) { + if (editableColumns.contains(index.column())) { flags |= Qt::ItemIsEditable; } return flags; @@ -72,8 +73,14 @@ Qt::ItemFlags ExternalExecutableModel::flags(const QModelIndex &index) const bool ExternalExecutableModel::setData(const QModelIndex &index, const QVariant &value, int role) { - // TODO - return false; + if (!editableColumns.contains(index.column())) + return false; + + QModelIndex primaryKeyIndex = QSqlQueryModel::index(index.row(), Executable_Id); + int id = data(primaryKeyIndex).toInt(); + clear(); + bool ok; + return ok; } bool ExternalExecutableModel::insertRows(int row, int count, const QModelIndex &parent) diff --git a/src/models/filepathmodel.cpp b/src/models/filepathmodel.cpp index d792f69..6462527 100644 --- a/src/models/filepathmodel.cpp +++ b/src/models/filepathmodel.cpp @@ -90,6 +90,7 @@ bool FilePathModel::setData(const QModelIndex &index, const QVariant &value, int ok = setFilePath(id, value.toString()); break; default: + ok = false; qDebug() << "File path model, this shouldn't be happening!"; } refresh(); diff --git a/src/models/setupmodel.cpp b/src/models/setupmodel.cpp index e590ee3..1dfa16d 100644 --- a/src/models/setupmodel.cpp +++ b/src/models/setupmodel.cpp @@ -97,6 +97,7 @@ bool SetupModel::setData(const QModelIndex &index, const QVariant &value, int /* break; default: + ok = false; qDebug() << "Setup model, this shouldn't be happening!"; }; refresh();