]> granicus.if.org Git - transmission/commitdiff
(qt) #1220: 'change file and folder names': fix Qt renaming issue reported by taem...
authorJordan Lee <jordan@transmissionbt.com>
Wed, 23 Jan 2013 20:44:13 +0000 (20:44 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Wed, 23 Jan 2013 20:44:13 +0000 (20:44 +0000)
qt/file-tree.cc
qt/file-tree.h

index b48312e0e419d41d34a827bfd74053e6454f1b20..c3788c47f1bcf9b767eb66306faaddab5aafa4f1 100644 (file)
@@ -110,18 +110,38 @@ FileTreeItem :: row( ) const
 }
 
 QVariant
-FileTreeItem :: data( int column ) const
+FileTreeItem :: data (int column, int role) const
 {
-    QVariant value;
+  QVariant value;
 
-    switch( column ) {
-        case COL_NAME: value.setValue( fileSizeName( ) ); break;
-        case COL_PROGRESS: value.setValue( progress( ) ); break;
-        case COL_WANTED: value.setValue( isSubtreeWanted( ) ); break;
-        case COL_PRIORITY: value.setValue( priorityString( ) ); break;
+  if (role == Qt::EditRole)
+    {
+      if (column == 0)
+        value.setValue (name());
+    }
+  else if (role == Qt::DisplayRole)
+    {
+      switch( column )
+       {
+         case COL_NAME:
+           value.setValue (fileSizeName());
+           break;
+
+         case COL_PROGRESS:
+           value.setValue (progress());
+           break;
+
+         case COL_WANTED:
+           value.setValue (isSubtreeWanted());
+           break;
+
+         case COL_PRIORITY:
+           value.setValue (priorityString());
+           break;
+        }
     }
 
-    return value;
+  return value;
 }
 
 void
@@ -304,11 +324,11 @@ FileTreeModel :: data( const QModelIndex &index, int role ) const
 {
     QVariant value;
 
-    if( index.isValid() && role==Qt::DisplayRole )
-    {
-        FileTreeItem *item = static_cast<FileTreeItem*>(index.internalPointer());
-        value = item->data( index.column( ) );
-    }
+    if (index.isValid())
+      {
+        FileTreeItem * i = static_cast<FileTreeItem*>(index.internalPointer());
+        value = i->data (index.column(), role);
+      }
 
     return value;
 }
index 5f0f875011ddb46bf34dfd15ae94d0e6733c6ba3..b66adf2d9deaf66724e8ef6598a9f1d4f91e5377 100644 (file)
@@ -56,7 +56,7 @@ class FileTreeItem: public QObject
         const FileTreeItem * parent( ) const { return myParent; }
         int row( ) const;
         const QString& name( ) const { return myName; }
-        QVariant data( int column ) const;
+        QVariant data( int column, int role ) const;
         bool update( int index, bool want, int priority, uint64_t total, uint64_t have, bool torrentChanged );
         void twiddleWanted( QSet<int>& fileIds, bool& );
         void twiddlePriority( QSet<int>& fileIds, int& );