Changeset 13930


Ignore:
Timestamp:
Feb 1, 2013, 10:40:08 PM (8 years ago)
Author:
jordan
Message:

(qt) #5252 'file-renaming issues in Qt client': fix renaming flicker error reported by rb07

Location:
trunk/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/file-tree.cc

    r13929 r13930  
    1111 */
    1212
     13#include <algorithm>
    1314#include <cassert>
    1415
     
    188189#include <iostream>
    189190
    190 bool
     191std::pair<int,int>
    191192FileTreeItem :: update (const QString& name,
    192193                        bool           wanted,
     
    195196                        bool           updateFields)
    196197{
    197   bool changed = false;
     198  int changed_count = 0;
     199  int changed_fields[3];
    198200
    199201  if (myName != name)
     
    203205
    204206      myName = name;
    205       changed = true;
     207      changed_fields[changed_count++] = COL_NAME;
    206208    }
    207209
     
    209211    {
    210212      if (myHaveSize != haveSize)
    211         {
    212           myHaveSize = haveSize;
    213           changed = true;
    214         }
     213        myHaveSize = haveSize;
    215214
    216215      if (updateFields)
     
    219218            {
    220219              myIsWanted = wanted;
    221               changed = true;
     220              changed_fields[changed_count++] = COL_WANTED;
    222221            }
    223222
     
    225224            {
    226225              myPriority = priority;
    227               changed = true;
     226              changed_fields[changed_count++] = COL_PRIORITY;
    228227            }
    229228        }
    230229    }
    231230
     231  std::pair<int,int> changed (-1, -1);
     232  if (changed_count > 0)
     233    {
     234      std::sort (changed_fields, changed_fields+changed_count);
     235      changed.first = changed_fields[0];
     236      changed.second = changed_fields [changed_count-1];
     237      std::cerr << "changed.first " << changed.first << " changed.second " << changed.second << std::endl;
     238    }
    232239  return changed;
    233240}
     
    567574
    568575  return ret;
    569 }
    570 
    571 void
    572 FileTreeModel :: itemChanged (FileTreeItem * item)
    573 {
    574   dataChanged (indexOf(item, FIRST_VISIBLE_COLUMN), indexOf(item, LAST_VISIBLE_COLUMN));
    575576}
    576577
     
    596597        {
    597598          const QString token = tokens.takeLast();
    598           if (item->update (token, wanted, priority, have, updateFields))
    599             itemChanged (item);
     599          const std::pair<int,int> changed = item->update (token, wanted, priority, have, updateFields);
     600          if (changed.first >= 0)
     601            dataChanged (indexOf (item, changed.first), indexOf (item, changed.second));
    600602          item = item->parent();
    601603        }
     
    633635          assert (item->totalSize() == totalSize);
    634636
    635           if (item->update (item->name(), wanted, priority, have, added || updateFields))
    636             itemChanged (item);
     637          const std::pair<int,int> changed = item->update (item->name(), wanted, priority, have, added || updateFields);
     638          if (changed.first >= 0)
     639            dataChanged (indexOf (item, changed.first), indexOf (item, changed.second));
    637640        }
    638641    }
  • trunk/qt/file-tree.h

    r13894 r13930  
    6464    const QString& name () const { return myName; }
    6565    QVariant data (int column, int role) const;
    66     bool update (const QString& name, bool want, int priority, uint64_t have, bool updateFields);
     66    std::pair<int,int> update (const QString& name, bool want, int priority, uint64_t have, bool updateFields);
    6767    void twiddleWanted (QSet<int>& fileIds, bool&);
    6868    void twiddlePriority (QSet<int>& fileIds, int&);
     
    126126
    127127  private:
    128     void itemChanged (FileTreeItem *);
    129128    void clearSubtree (const QModelIndex &);
    130129    QModelIndex indexOf (FileTreeItem *, int column) const;
Note: See TracChangeset for help on using the changeset viewer.