Logo Search packages:      
Sourcecode: basket version File versions  Download package

QString Item::toHtml ( const QString &  imageName  ) 

FIXME: Since fullPath() doesn't exist yet, the icon rely on the extension. Bad if there isn't one or if it's a wrong one.

Definition at line 284 of file item.cpp.

References text(), Basket::textToHTMLWithoutP(), and LinkLabel::toHtml().

{
      switch (m_type) {
            case Text:
                  {
                        QString font;
                        switch (textFontType()) {
                              case 1:  font = " face=sans-serif"; break;
                              case 2:  font = " face=serif";      break;
                              case 3:  font = " face=monospace";  break;
                        }
                        return "<font color=" + textColor().name() + font + ">" +
                               m_parentBasket->textToHTMLWithoutP(text()) + "</font>";
                        //return m_parentBasket->textToHTMLWithoutP(text());
                  }
            case Html:
                  return Basket::htmlToParagraph(html());
            case Image:
            case Animation:
                  {
                        if ( (m_type == Image     && pixmap() == 0L) ||
                             (m_type == Animation && movie()  == 0L)    ) {
                              QMimeSourceFactory::defaultFactory()->setData(imageName, 0L);
                              return i18n("(Image)"); // Image or animation not yet loaded!!
                        }

                        QImage image;
                        if (m_type == Image)
                              image = pixmap()->convertToImage();
                        else
                              image = movie()->framePixmap().convertToImage();
                        image = image.smoothScale(200, 150, QImage::ScaleMin);
                        QPixmap pixmap = QPixmap(image);
                        QMimeSourceFactory::defaultFactory()->setPixmap(imageName, pixmap);
                        return "<img src=" + imageName + ">"; ///

/*                      // FIXME: movie isn't loaded yet: CRASH!
                        return i18n("(Image)");
                        // Not executed, because don't work:
                        QImage image;
                        if (m_type == Image)
                              image = pixmap()->convertToImage();
                        else
                              image = movie()->framePixmap().convertToImage();
                        image = image.smoothScale(200, 150, QImage::ScaleMin);
                        QPixmap pixmap = QPixmap(image);
                        QMimeSourceFactory::defaultFactory()->setPixmap(imageName, pixmap);
                        return "<img src=" + imageName + ">"; ///
      */                //TODO?: QMimeSourceFactory::defaultFactory()->setData(imageName, 0L);
                  }
            case Sound:
            case File:
                  {
                        /// FIXME: Since fullPath() doesn't exist yet, the icon rely on the extension.
                        ///        Bad if there isn't one or if it's a wrong one.
                        /*QPixmap icon = DesktopIcon(
                              ItemFactory::iconForURL(fullPath()),
                              (m_type == Sound ? LinkLook::soundLook : LinkLook::fileLook)->iconSize());
                        QMimeSourceFactory::defaultFactory()->setPixmap(imageName, icon);
                        return "<img src=" + imageName + "> " + fileName(); */ ///
                        return m_linkLabel->toHtml(imageName);
                  }
            case Link:
                  {
                        QString link = m_linkLabel->toHtml(imageName);
                        if (!autoTitle() && title() != ItemFactory::titleForURL(url().prettyURL()))
                              link += "<br><i>" + url().prettyURL() + "</i>"; ///
                        return link;
                  }
            case Launcher:
                  {
                        return m_linkLabel->toHtml(imageName);
                        //KService service(fullPath()); // service.icon()
                        //return service.name() + "<br><i>" + service.exec() + "</i>"; ///
                  }
            case Color:
                  return "<b><font color=" + color().name() + ">" + color().name() + "</font></b>";
            case Unknow:
                  return text();
      }
      return QString();
}


Generated by  Doxygen 1.6.0   Back to index