Example #1
0
//Called from window with a timer (currently 200ms)
void SnifferModel::refresh()
{
    QMap<quint32, SnifferItem*>::iterator i;
    QVector<quint32> toRemove;
    SnifferItem* item;

    mTimeSequence++;

    /* update markers */


    for (i = mMap.begin(); i != mMap.end(); ++i)
    {
        i.value()->updateMarker();
        if(i.value()->elapsed()>5000 && !mNeverExpire)
            toRemove.append(i.key());
    }

    if(toRemove.size())
    {
        beginResetModel();
        foreach(quint32 id, toRemove)
        {
            /* remove element */
            item = mMap.take(id);
            mFilters.remove(id);
            delete item;
            /* send notification */
            emit idChange(id, false);
        }
void WidgetClients::creerTableau()
{
    clients = new Clients;
    tableau = new QTreeView;
    tableau->setModel(clients->model(this, baseDeDonnees));
    tableau->setRootIsDecorated(false);
    tableau->setAlternatingRowColors(true);
    tableau->setSortingEnabled(true);
    tableau->sortByColumn(0, Qt::AscendingOrder);
    tableau->setSelectionMode(QAbstractItemView::SingleSelection);
    tableau->setSelectionBehavior(QAbstractItemView::SelectRows);
    tableau->setEditTriggers(false);
    tableau->setColumnHidden(2, true);

    for(int i = 0; i < 13; i++)
    {
        tableau->resizeColumnToContents(i);
    }


    connect(tableau->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(idChange(QItemSelection, QItemSelection)));
}