void AnnotationOutput::readAnnotations()
{
  if (!Project::ref()->hasProject())
  {
    m_allAnnotations->clear();
    m_yourAnnotations->clear();
    m_yourAnnotationsNum = 0;
    setTabLabel(m_yourAnnotations, i18n("For You"));
    return;
  }

  KURL baseURL = Project::ref()->projectBaseURL();
  QStringList openedItems;
  QListViewItem *item = m_allAnnotations->firstChild();
  while (item)
  {
    if (item->isOpen())
        openedItems += item->text(0);
    item = item->nextSibling();
  }
  m_allAnnotations->clear();
  m_annotatedFileItems.clear();
  m_fileNames.clear();
  m_lines.clear();

  QStringList yourOpenedItems;
  item = m_yourAnnotations->firstChild();
  while (item)
  {
    if (item->isOpen())
        yourOpenedItems += item->text(0);
    item = item->nextSibling();
  }

  m_yourAnnotations->clear();
  m_yourFileItems.clear();
  m_yourFileNames.clear();
  m_yourLines.clear();
  m_yourAnnotationsNum = 0;

  QDomElement annotationElement = Project::ref()->dom()->firstChild().firstChild().namedItem("annotations").toElement();
  if (annotationElement.isNull())
    return;
  QString yourself = Project::ref()->yourself().lower();
  QStringList roles = Project::ref()->yourRoles();
  QDomNodeList nodes = annotationElement.childNodes();
  int count = nodes.count();
  for (int i = 0; i < count; i++)
  {
    QDomElement el = nodes.item(i).toElement();
    QString fileName = el.attribute("url");
    KURL u = baseURL;
    QuantaCommon::setUrl(u, fileName);
    u = QExtFileInfo::toAbsolute(u, baseURL);
    if (Project::ref()->contains(u))
    {
      bool ok;
      int line = el.attribute("line").toInt(&ok, 10);
      QString text = el.attribute("text");
      QString receiver = el.attribute("receiver");
      text.replace('\n',' ');
      QString lineText = QString("%1").arg(line);
      if (lineText.length() < 20)
      {
        QString s;
        s.fill('0', 20 - lineText.length());
        lineText.prepend(s);
      }
      KListViewItem *fileIt = m_annotatedFileItems[fileName];
      if (!fileIt)
      {
        fileIt = new KListViewItem(m_allAnnotations, fileName);
        m_annotatedFileItems.insert(fileName, fileIt);
        m_fileNames[fileIt] = u.url();
      }
      KListViewItem *it = new KListViewItem(fileIt, fileIt, text, lineText);
      if (openedItems.contains(fileName))
        fileIt->setOpen(true);
      m_fileNames[it] = u.url();
      m_lines[it] = line;
   
      if (!yourself.isEmpty() && (receiver == yourself || roles.contains(receiver)))
      {
        m_yourAnnotationsNum++;
        KListViewItem *fileIt = m_yourFileItems[fileName];
        if (!fileIt)
        {
          fileIt = new KListViewItem(m_yourAnnotations, fileName);
          m_yourFileItems.insert(fileName, fileIt);
          m_yourFileNames[fileIt] = u.url();
        }
        KListViewItem *it = new KListViewItem(fileIt, fileIt, text, lineText);
        if (yourOpenedItems.contains(fileName))
          fileIt->setOpen(true);
        m_yourFileNames[it] = u.url();
        m_yourLines[it] = line;
      }
    } else
    {
      annotationElement.removeChild(el);
    }
  }
  if (m_yourAnnotationsNum > 0)
  {
    setTabLabel(m_yourAnnotations, i18n("For You: %1").arg(m_yourAnnotationsNum));
  } else
  {
    setTabLabel(m_yourAnnotations, i18n("For You"));
  }
}
/**
 * Sets the tab title & tooltip from the filename
 * @param widget A pointer to the widget on the tab
 * @param filename The filename on the tab
 */
void MultiTabScriptInterpreter::setTabTitle(QWidget *widget, const QString & filename)
{
  setTabLabel(widget, createTabTitle(filename));
  setTabToolTip(widget, filename);
}