Show
Ignore:
Timestamp:
04/05/08 21:55:21 (8 months ago)
Author:
eugene
Message:

Updated the spanning algorithm to make newly added rows be spanned too if needed.

Location:
trunk/qt4-gui/src/views
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/views/userview.cpp

    r6129 r6130  
    127127    header()->hide(); 
    128128 
    129   setGroupSpanning(); 
     129  spanRowRange(rootIndex(), 0, model()->rowCount(rootIndex()) - 1); 
    130130} 
    131131 
     
    141141} 
    142142 
    143 void UserView::setGroupSpanning() 
    144 { 
    145   QModelIndex root = rootIndex(); 
    146   int rows = model()->rowCount(root); 
    147  
    148   if (root.isValid()) 
    149   { 
    150     // Single group (non-threaded) view - bars are sorted with contacts 
    151     for (int i = 0; i < rows; ++i) 
    152       if (model()->data(model()->index(i, 0, root), ContactListModel::ItemTypeRole).toUInt() == 
    153           ContactListModel::BarItem) 
    154         setFirstColumnSpanned(i, root, true); 
    155   } 
    156   else 
    157   { 
    158     // Full tree (threaded) view - all top level items are groups 
    159     for (int i = 0; i < rows; ++i) 
    160       setFirstColumnSpanned(i, root, true); 
     143void UserView::spanRowRange(const QModelIndex& parent, int start, int end) 
     144{ 
     145  for (int i = start; i <= end; i++) 
     146  { 
     147    // get the real model index 
     148    QModelIndex index = model()->index(i, 0, parent); 
     149    unsigned itemType = model()->data(index, ContactListModel::ItemTypeRole).toUInt(); 
     150 
     151    if (itemType == ContactListModel::GroupItem || 
     152        itemType == ContactListModel::BarItem) 
     153      setFirstColumnSpanned(i, parent, true); 
    161154  } 
    162155} 
     
    179172  setFrameStyle(Config::Skin::active()->frame.frameStyle); 
    180173  UserViewBase::applySkin(); 
     174} 
     175 
     176void UserView::rowsInserted(const QModelIndex& parent, int start, int end) 
     177{ 
     178  spanRowRange(parent, start, end); 
     179  UserViewBase::rowsInserted(parent, start, end); 
    181180} 
    182181 
  • trunk/qt4-gui/src/views/userview.h

    r5916 r6130  
    8585  virtual void applySkin(); 
    8686 
     87  /** 
     88   * Overload the base class so we can analyze the rows 
     89   * which were inserted and act accordingly 
     90   * 
     91   * @param parent The view index which was populated 
     92   * @param start The number of the first inserted row 
     93   * @param end The number of the last inserted row 
     94   */ 
     95  virtual void rowsInserted(const QModelIndex& parent, int start, int end); 
     96 
    8797private: 
    8898  /** 
     
    108118 
    109119  /** 
    110    * Set group spanning for header rows 
     120   * Sets row spanning for particular rows in the given group 
     121   * 
     122   * @param parent The view index to analyze 
     123   * @param start The count of the first row 
     124   * @param end The count of the last row 
    111125   */ 
    112   void setGroupSpanning(); 
     126  void spanRowRange(const QModelIndex& parent, int start, int end); 
    113127 
    114128private slots: