Re: how do I delete a row in a Gtk::ListViewText



On 27/05/13 17:20, Juan Angel Moreno wrote:
For the selected row, use get_selection(), get_selected() and with the iterator returned by get_selected(), use erase(iterator).
For an arbitrary row, iterate over the rows of your model with your_model->children().begin(), your_model->children().end(), etc. and use erase() on the iterator you want.

umm where does the erase function come from, I did this

    Gtk::ListViewText::SelectionList sellst = m_listviewtextAvailable->get_selected();
    if(sellst.empty()) return;
    Gtk::TreeModel::iterator sel_it = m_listviewtextAvailable->get_selection()->get_selected();
    int sel = sellst[0];
    Glib::ustring selrow = m_listviewtextAvailable->get_text(sel);
    erase(sel_it);

 and I get a compile error on erase the compiler cannot find it??


Greetings


2013/5/27 Francis (Grizzly) Smit <grizzly smit id au>
Yeah I have been trying to delete a row in a Gtk::ListViewText, but I
cannot find a member function to do this, I have tried the following

    guint num_cols = get_num_columns();
    guint num_rows = size();
    Glib::ustring result;
    if(num_cols == 1){
        std::vector<Glib::ustring> tmp;
        for(int r = 0; r < num_rows; r++){
            if(r == row){
                result = get_text(r);
            }else{
                tmp.insert(tmp.end(), get_text(r));
            }
        }
        remove_all_columns();
        guint n = tmp.size();
        for(int r = 0; r < n; r++){
            append(tmp[r]);
        }
    }else{
        std::vector<std::vector<Glib::ustring> > tmp;
        std::vector<Glib::ustring> t;
        for(int r = 0; r < num_rows; r++){
            if(r == row){
                result = get_text(r);
            }else{
                t.insert(t.end(), get_text(r));
                for(int c = 1; c < num_cols; c++){
                    t.insert(t.end(), get_text (r, c));
                }
                tmp.insert(tmp.end(), t);
            }
        }
        remove_all_columns();
        guint n = tmp.size();
        for(int r = 0; r < n; r++){
            guint _r = append(tmp[r][0]);
            guint m = tmp[r].size();
            for(int c = 1; c < num_cols && c < m; c++){
                set_text(_r, c, tmp[r][c]);
            }
        }
    }

but the remove_all_columns(); is too drastic I loose every thing and can
no longer put the rows I want to keep back as append stops working as I
have no columns any more I'd really appreciate some help on this thx



--


  .~.     In my life God comes first....
  /V\         but Linux is pretty high after that :-D
 /( )\    Francis (Grizzly) Smit
 ^^-^^    http://www.smit.id.au/

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list



--
Atentamente:
Juan Ángel Moreno Fernández
jamf gm gmail com
------------------------------
  Proyecto Gelide
  http://gelide.sf.net
------------------------------


--

  .~.     In my life God comes first.... 
  /V\         but Linux is pretty high after that :-D
 /( )\    Francis (Grizzly) Smit
 ^^-^^    http://www.smit.id.au/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]