KDE

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • rejigging a listview in place

    3 answers - 1781 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Can someone tell me if I'm on a hiding to nothing here?
    I have a listview that is non-hierarchical. At the instance of the user I want
    to reorganize this view and group items together with a common characteristic
    in a two-deep hierarchy.
    I don't want to clear and reload the view from the data source - though will
    do if below is known to be fruitless.
    So I thought I could just copy the listview, iterate through each item and
    takeItem() insertItem() my way down the list, then replace the listview with
    the new one.
    However it seems:
    - I can't make a copy of qlistview - the compiler tells me the operator is
    private. And I can't use a qvaluelist, because it will only accept the
    pointer to the listviewitems rather than a copy of the items themselves.
    - So I have to reorganizse the listview in place. I am trying:
    QListViewItem *;
    QListViewItem *tm;
    for (QListViewItem *child = m_view->serverList->firstChild(); child; child
    = ) {
    = child->nextSibling();
    QRegExp rx("^[0-9]{1,3}\\.[0-9]{1,3}\\.");
    rx.search(child->text(5));
    QString tmp = rx.cap(0);
    if (tmp.isEmpty()){
    break;
    }
    if (!( tm = m_view->serverList->findItem((tmp),0))){
    tm = new QListViewItem(m_view->serverList, tmp);
    }
    m_view->serverList->takeItem(child);
    tm->insertItem(child);
    }
    Apart from taking ages to finish, the above also does not insert the existing
    items as children of their new parents - the above takes place on a
    completely flat listview.
    Can anyone point me in the direction of how rejig a list like this in place?
    I'm assuming I must be going about it completely the wrong way.
  • No.1 | | 2182 bytes | |

    Thursday 01 March 2007 11:06, Robert Hogan wrote:
    Can someone tell me if I'm on a hiding to nothing here?

    I have a listview that is non-hierarchical. At the instance of the user I
    want to reorganize this view and group items together with a common
    characteristic in a two-deep hierarchy.

    I don't want to clear and reload the view from the data source - though
    will do if below is known to be fruitless.

    So I thought I could just copy the listview, iterate through each item and
    takeItem() insertItem() my way down the list, then replace the listview
    with the new one.

    However it seems:

    - I can't make a copy of qlistview - the compiler tells me the operator is
    private. And I can't use a qvaluelist, because it will only accept the
    pointer to the listviewitems rather than a copy of the items themselves.

    - So I have to reorganizse the listview in place. I am trying:

    QListViewItem *;
    QListViewItem *tm;

    for (QListViewItem *child = m_view->serverList->firstChild(); child;
    child = ) {
    = child->nextSibling();

    QRegExp rx("^[0-9]{1,3}\\.[0-9]{1,3}\\.");
    rx.search(child->text(5));
    QString tmp = rx.cap(0);
    if (tmp.isEmpty()){
    break;
    }

    if (!( tm = m_view->serverList->findItem((tmp),0))){
    tm = new QListViewItem(m_view->serverList, tmp);
    }

    m_view->serverList->takeItem(child);
    tm->insertItem(child);
    }
    --
    Apart from taking ages to finish, the above also does not insert the
    existing items as children of their new parents - the above takes place on
    a completely flat listview.

    Can anyone point me in the direction of how rejig a list like this in
    place? I'm assuming I must be going about it completely the wrong way.

    Qt3 or Qt4?

    In Qt4, you can use the model-view architecture, and just change the model (I
    think). That's just the sort of thing that the model-view architecture is
    there for. I don't know how you could do it in Qt3, though.

    Branan

    >Visit #unsub to unsubscribe <<
  • No.2 | | 330 bytes | |

    Thursday 01 March 2007 19:16, Branan Riley wrote:

    Qt3 or Qt4?

    In Qt4, you can use the model-view architecture, and just change the model
    (I think). That's just the sort of thing that the model-view architecture
    is there for. I don't know how you could do it in Qt3, though.

    Qt3 unfortunately.
  • No.3 | | 330 bytes | |

    Thursday 01 March 2007 19:16, Branan Riley wrote:

    Qt3 or Qt4?

    In Qt4, you can use the model-view architecture, and just change the model
    (I think). That's just the sort of thing that the model-view architecture
    is there for. I don't know how you could do it in Qt3, though.

    Qt3 unfortunately.

Re: rejigging a listview in place


max 4000 letters.
Your nickname that display:
In order to stop the spam: 0 + 0 =
QUESTION ON "KDE"

EMSDN.COM