rem: if (folder == kernel->outboxFolder() || folder == kernel->sentFolder() || folder == kernel->draftsFolder())
add: if (kernel->folderIsDraftOrOutbox(folder))
context:   static QString generate_key( int id, KMHeaders *headers, KMMsgBase *msg, const KMPaintInfo *paintInfo, int sortOrder)  {    int column = sortOrder & ((1 << 5) - 1);    QString ret = QString("%1") .arg( (char)sortOrder );    QString sortArrival = QString( "%1" ).arg( id, 8, 36 );    if (column == paintInfo->dateCol) {      if (paintInfo->orderOfArrival)        return ret + sortArrival;      else {        static const int dateLength = 30;        char cDate[dateLength + 1];        const time_t date = msg->date();        strftime( cDate, dateLength, "%Y:%j:%H:%M:%S", gmtime( &date ));        return ret + cDate + sortArrival;      }    } else if (column == paintInfo->senderCol) {      QString tmp;      KMFolder *folder = msg->parent();      if (folder == kernel->outboxFolder() || folder == kernel->sentFolder()          || folder == kernel->draftsFolder())        tmp = msg->toStrip();      else        tmp = msg->fromStrip();      return ret + tmp.lower() + " " + sortArrival;    } else if (column == paintInfo->subCol) {      if (paintInfo->status)        return ret + QString( QChar( (uint)msg->status() ));      return ret + KMMsgBase::skipKeyword( msg->subject().lower() ) + " " + sortArrival;    }    else if (column == paintInfo->sizeCol) {      if (headers->folder()->protocol() == "imap")      {        QCString cstr;        headers->folder()->getMsgString(id, cstr);        int a = cstr.find("\nX-Length: ");        int b = cstr.find("\n", a+1);        return ret + QString( "%1" ).arg( cstr.mid(a+11, b-a-11), 9 );      }      return ret + QString( "%1" ).arg( msg->msgSize(), 9 );    }    return ret + "missing key"; //you forgot something!!  }