Mercurial > hg > easaier-soundaccess
view widgets/RelatedMediaWidget.cpp @ 168:00ab90498dcc
cleaning
author | lbajardsilogic |
---|---|
date | Fri, 16 Nov 2007 16:47:00 +0000 |
parents | 77f4ef621c54 |
children | 057856cf81a2 |
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ /* Sound Access EASAIER client application. Silogic 2007. Laure Bajard. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING included with this distribution for more information . */ #include "RelatedMediaWidget.h" #include <QLayoutItem> #include <QLinearGradient> #include <QScrollArea> #include <QVBoxLayout> #include <iostream> #include "sv/main/MainWindow.h" RelatedMediaWidget::RelatedMediaWidget() : QWidget() , m_nbRelMedia(0), m_painter(0), m_relMediaMaxHeight(150) { m_relMediaLayout = new FlowLayout; //m_relMediaLayout->setSizeConstraint(QLayout::SetMinimumSize); setLayout(m_relMediaLayout); } RelatedMediaWidget::~RelatedMediaWidget() {} void RelatedMediaWidget::reset() { m_nbRelMedia = 0; QLayoutItem *child; while ((child = m_relMediaLayout->takeAt(0)) != 0) { delete child->widget(); } } void RelatedMediaWidget::addRelatedMedia(const QString &filename) { QString imageSource; QString extension = filename.right(filename.length() - (filename.lastIndexOf('.') + 1)); int width; int height; if (extension == "pdf") { imageSource = ":icons/icon_pdf.png"; } else { imageSource = filename; } QPixmap image(imageSource); if (image.height() > m_relMediaMaxHeight) { height = m_relMediaMaxHeight; width = image.width() * m_relMediaMaxHeight / image.height(); } else { height = image.height(); width = image.width(); } QLabel *mediaLabel = new QLabel(); mediaLabel->setText("<html><header><style type=\"text/css\">a {text-decoration: none;}</style></header><body><a href=\"" + filename + "\"><img src=\"" + imageSource + "\" width=\"" + QString::number(width) + "\" height=\"" + QString::number(height) + "\"> </a></body></html>"); connect(mediaLabel, SIGNAL(linkActivated(QString)), MainWindow::instance(), SLOT(runExternProcess(QString))); QLabel *textLabel = new QLabel(); textLabel->setText("<html><a >Info may be added here</a><a href=\"" + filename + "\">...</a></html>"); QVBoxLayout *mediaLayout = new QVBoxLayout; mediaLayout->addWidget(mediaLabel); mediaLayout->addWidget(textLabel); QWidget *mediaWidget = new QWidget; mediaWidget->setLayout(mediaLayout); m_relMediaLayout->addWidget(mediaWidget); m_nbRelMedia++; }