Changeset 1894

Show
Ignore:
Timestamp:
Wed Feb 1 18:04:51 2006
Author:
fgerlits
Message:

made the rows in the Live Mode window drag'n'drop reorderable

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/livesupport/src/products/gLiveSupport/src/LiveModeWindow.h

    r1869 r1894  
    193 193  
    194 194         /**  
    195            *  Signal handler for the "rows reordered" event.  
    196            */  
    197           void  
    198           onRowsReordered(const Gtk::TreeModel::Path &      path,  
    199                           const Gtk::TreeModel::iterator&   iter,  
    200                           int*                              newToOldMapping)  
    201                                                                   throw ()  
    202           {  
    203   //            std::cerr << "rows changed: " << path.to_string() << "; "  
    204   //                      << "iter: " << (iter ? "true" : "false") << "\n";  
    205           }  
    206    
    207           /**  
    208            *  Signal handler for the "row deleted" event.  
    209            */  
    210           void  
    211           onRowDeleted(const Gtk::TreeModel::Path &   path)       throw ()  
    212           {  
    213   //            std::cerr << "rows deleted: " << path.to_string() << ";\n";  
    214               treeView->columns_autosize();  
    215           }  
    216    
    217           /**  
    218 195          *  Function to catch the event of the close button being pressed.  
    219 196          */  
  • trunk/livesupport/src/products/gLiveSupport/src/LiveModeWindow.cxx

    r1869 r1894  
    89 89     // Create the tree model:  
    90 90     treeModel = Gtk::ListStore::create(modelColumns);  
    91       treeModel->signal_rows_reordered().connect(sigc::mem_fun(*this,  
    92                                               &LiveModeWindow::onRowsReordered));  
    93       treeModel->signal_row_deleted().connect(sigc::mem_fun(*this,  
    94                                               &LiveModeWindow::onRowDeleted));  
    95 91      
    96 92     // ... and the tree view:  
    97 93     treeView = Gtk::manage(wf->createTreeView(treeModel));  
      94     treeView->set_reorderable(true);  
    98 95     treeView->set_headers_visible(false);  
    99 96     treeView->set_enable_search(false);  
    263 260     }  
    264 261  
    265       for (iter = treeModel->children().begin();  
    266                               iter != treeModel->children().end(); ++iter) {  
    267           Gtk::TreeRow    row = *iter;  
    268           int     rowNumber = row[modelColumns.rowNumberColumn];  
    269           row[modelColumns.rowNumberColumn] = --rowNumber;  
    270       }  
    271        
    272 262     return playable;  
    273 263 }  
  • trunk/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h

    r1601 r1894  
    144 144         }  
    145 145  
      146         /**  
      147          *  Renumber the rows after they have changed.  
      148          *  
      149          *  This is called from the onRowInserted(), onRowDeleted() and  
      150          *  onRowsReordered() signal handlers.  
      151          */  
      152         void  
      153         renumberRows(void)                                      throw ();  
      154  
    146 155  
    147 156     protected:  
    155 164                      const Glib::ustring &>     signalCellEditedObject;  
    156 165  
      166         /**  
      167          *  Event handler for the row_inserted signal.  
      168          *  
      169          *  @param  path    a path pointing to the inserted row.  
      170          *  @param  iter    an iterator pointing to the inserted row.  
      171          */  
      172         void  
      173         onRowInserted(const Gtk::TreeModel::Path &      path,  
      174                       const Gtk::TreeModel::iterator &  iter)  
      175                                                                 throw ();  
      176  
      177         /**  
      178          *  Event handler for the row_deleted signal.  
      179          *  
      180          *  @param  path    points to the previous location of the deleted row.  
      181          */  
      182         void  
      183         onRowDeleted(const Gtk::TreeModel::Path &   path)       throw ();  
      184  
      185         /**  
      186          *  Event handler for the rows_reordered signal.  
      187          *  
      188          *  @param  path    points to the tree node whose children have been  
      189          *                  reordered.  
      190          *  @param  iter    points to the node whose children have been  
      191          *                  reordered, or 0 if the depth of path is 0.  
      192          *  @param  mapping an array of integers mapping the current position  
      193          *                  of each child to its old position before the  
      194          *                  re-ordering, i.e. mapping[newpos] = oldpos.  
      195          */  
      196         void  
      197         onRowsReordered(const Gtk::TreeModel::Path &      path,  
      198                         const Gtk::TreeModel::iterator&   iter,  
      199                         int*                              mapping)  
      200                                                                 throw ();  
      201  
    157 202  
    158 203     public:  
  • trunk/livesupport/src/modules/widgets/src/ZebraTreeView.cxx

    r1601 r1894  
    63 63                 : Gtk::TreeView(treeModel)  
    64 64 {  
      65     treeModel->signal_row_inserted().connect(sigc::mem_fun(*this,  
      66                                             &ZebraTreeView::onRowInserted));  
      67     treeModel->signal_row_deleted().connect(sigc::mem_fun(*this,  
      68                                             &ZebraTreeView::onRowDeleted));  
      69     treeModel->signal_rows_reordered().connect(sigc::mem_fun(*this,  
      70                                             &ZebraTreeView::onRowsReordered));  
    65 71 }  
    66 72  
    435 441     treeModel->erase(iter);  
    436 442 }  
      443  
      444  
      445 /*------------------------------------------------------------------------------  
      446  *  Event handler for the row_inserted signal.  
      447  *----------------------------------------------------------------------------*/  
      448 void  
      449 ZebraTreeView :: onRowInserted(const Gtk::TreeModel::Path &      path,  
      450                                const Gtk::TreeModel::iterator &  iter)  
      451                                                                     throw ()  
      452 {  
      453     renumberRows();  
      454     columns_autosize();  
      455 }  
      456  
      457  
      458 /*------------------------------------------------------------------------------  
      459  *  Event handler for the row_deleted signal.  
      460  *----------------------------------------------------------------------------*/  
      461 void  
      462 ZebraTreeView :: onRowDeleted(const Gtk::TreeModel::Path &      path)  
      463                                                                     throw ()  
      464 {  
      465     renumberRows();  
      466     columns_autosize();  
      467 }  
      468  
      469  
      470 /*------------------------------------------------------------------------------  
      471  *  Event handler for the rows_reordered signal.  
      472  *----------------------------------------------------------------------------*/  
      473 void  
      474 ZebraTreeView :: onRowsReordered(const Gtk::TreeModel::Path &      path,  
      475                                  const Gtk::TreeModel::iterator &  iter,  
      476                                  int*                              mapping)  
      477                                                                     throw ()  
      478 {  
      479     renumberRows();  
      480 }  
      481  
      482  
      483 /*------------------------------------------------------------------------------  
      484  *  Renumber the rows after they have changed.  
      485  *----------------------------------------------------------------------------*/  
      486 void  
      487 ZebraTreeView :: renumberRows(void)                                 throw ()  
      488 {  
      489     Glib::RefPtr<Gtk::TreeModel>    treeModel = get_model();  
      490     ZebraTreeModelColumnRecord      modelColumns;  
      491     int                             rowNumber = 0;  
      492     Gtk::TreeModel::iterator        iter;  
      493  
      494     for (iter = treeModel->children().begin();  
      495                             iter != treeModel->children().end(); ++iter) {  
      496         Gtk::TreeRow    row = *iter;  
      497         row[modelColumns.rowNumberColumn] = rowNumber;  
      498         ++rowNumber;  
      499     }  
      500 }  
      501