OSDN Git Service

ProjectModel: Only claim editable if editable
authordt_ <qtc-committer@nokia.com>
Wed, 20 Apr 2011 13:31:20 +0000 (15:31 +0200)
committerdt_ <qtc-committer@nokia.com>
Wed, 20 Apr 2011 13:31:20 +0000 (15:31 +0200)
Task-Nr: QTCREATORBUG-4545

src/plugins/projectexplorer/projectmodels.cpp

index 1ce7ce1..0cbd4e8 100644 (file)
@@ -289,7 +289,15 @@ Qt::ItemFlags FlatModel::flags(const QModelIndex &index) const
     // We claim that everything is editable
     // That's slightly wrong
     // We control the only view, and that one does the checks
-    return Qt::ItemIsSelectable|Qt::ItemIsEnabled | Qt::ItemIsEditable;
+    Qt::ItemFlags f = Qt::ItemIsSelectable|Qt::ItemIsEnabled;
+    if (Node *node = nodeForIndex(index)) {
+        if (!qobject_cast<ProjectNode *>(node)) {
+            // either folder or file node
+            if (node->projectNode()->supportedActions(node).contains(ProjectNode::Rename))
+                f = f | Qt::ItemIsEditable;
+        }
+    }
+    return f;
 }
 
 bool FlatModel::setData(const QModelIndex &index, const QVariant &value, int role)