Ejemplo n.º 1
0
// Profiling note: About 30% of the time taken to initialize the
// listview is spent in this function. About 60% is spent in operator
// new and QListViewItem::QListViewItem.
void HeaderItem::irefresh()
{
  KMHeaders *headers = static_cast<KMHeaders*>(listView());
  NestingPolicy threadingPolicy = headers->getNestingPolicy();
  if ((threadingPolicy == AlwaysOpen) ||
      (threadingPolicy == DefaultOpen)) {
    //Avoid opening items as QListView is currently slow to do so.
    setOpen(true);
    return;

  }
  if (threadingPolicy == DefaultClosed)
    return; //default to closed

  // otherwise threadingPolicy == OpenUnread
  if (parent() && parent()->isOpen()) {
    setOpen(true);
    return;
  }

  KMMsgBase *mMsgBase = headers->folder()->getMsgBase( mMsgId );
  mSerNum = mMsgBase->getMsgSerNum();
  if (mMsgBase->isNew() || mMsgBase->isUnread()
      || mMsgBase->isImportant() || mMsgBase->isTodo() || mMsgBase->isWatched() ) {
    setOpen(true);
    HeaderItem * topOfThread = this;
    while(topOfThread->parent())
      topOfThread = (HeaderItem*)topOfThread->parent();
    topOfThread->setOpenRecursive(true);
  }
}
Ejemplo n.º 2
0
QModelIndex HtModelPrototype::parent(const QModelIndex &child) const
{
    if (!child.isValid())
        return QModelIndex();

    HeaderItem *childItem = static_cast<HeaderItem*>(child.internalPointer());
    HeaderItem *parentItem = childItem->parent();

    if (parentItem==0 ||
            parentItem == m_rootItem)
        return QModelIndex();

    HeaderItem * superParent=parentItem->parent();
    if(superParent)
    {
        return createIndex(superParent->childs().indexOf(parentItem),
                           0, parentItem);
    }
    return createIndex(0,
                       0, parentItem);
}