Mercurial > hg > easaier-soundaccess
view widgets/InfoWidget.cpp @ 156:c3296b15c43e
add the RelatedMediaWidget in the InfoWidget
author | lbajardsilogic |
---|---|
date | Thu, 15 Nov 2007 11:07:01 +0000 |
parents | 708c00883180 |
children | ec2ca3fbd957 |
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 "InfoWidget.h" #include <QScrollArea> #include <QLayoutItem> #include <iostream> #include "sv/main/MainWindow.h" #include "RelatedMediaWidget.h" #include "AdvancedToolBox.h" InfoWidget::InfoWidget(RelatedMediaWidget * relMediaWidget) : QWidget() { m_infoLayout = new QGridLayout; QWidget *infoWidget = new QWidget; infoWidget->setLayout(m_infoLayout); AdvancedToolBox * toolBox= new AdvancedToolBox; toolBox->addItem("File Information", infoWidget); toolBox->addItem("Related Media", relMediaWidget); QScrollArea * scrollArea = new QScrollArea; scrollArea->setWidget(toolBox); scrollArea->setWidgetResizable(true); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(scrollArea); setLayout(mainLayout); } InfoWidget::~InfoWidget() {} void InfoWidget::reset() { QLayoutItem *child; while ((child = m_infoLayout->takeAt(0)) != 0) { delete child->widget(); } } void InfoWidget::displayAudioSourceInfo(AudioSourceInfoModel* model) { reset(); std::map<QString, QString> info = model->getInfo(); std::map<QString, QString>::iterator iterInfo; QLabel* proper; QLabel* icon; QLabel* value; int row = 0; m_infoLayout->setColumnMinimumWidth(1,20); m_infoLayout->setColumnMinimumWidth(3,20); //display author and title at first iterInfo = info.find("title"); if (iterInfo!= info.end()) { proper = new QLabel(iterInfo->first.toUpper()); value = new QLabel(iterInfo->second); m_infoLayout->addWidget(proper, row, 0,1,3); m_infoLayout->addWidget(value, row, 4,1,1); row++; } iterInfo = info.find("author"); if (iterInfo!= info.end()) { proper = new QLabel(iterInfo->first.toUpper()); value = new QLabel(iterInfo->second); m_infoLayout->addWidget(proper, row, 0,1,3); m_infoLayout->addWidget(value, row, 4,1,1); row++; } m_infoLayout->setRowMinimumHeight(row,25); row++; //display other info for (iterInfo = info.begin(); iterInfo != info.end(); iterInfo++) { if ((iterInfo->first != "title") && (iterInfo->first != "author") && (iterInfo->first.contains("http://purl.org/ontology/mo"))) { QString properName; properName = iterInfo->first.split("#").last(); proper = new QLabel(properName); icon = new QLabel(); if(properName == "beats"){ icon->setPixmap(QPixmap(":icons/instants.png")); }else if(properName == "chromagram"){ icon->setPixmap(QPixmap(":icons/colour3d.png")); }else if(properName == "instruments"){ icon->setPixmap(QPixmap(":icons/notes.png")); }else if(properName == "key"){ icon->setPixmap(QPixmap(":icons/values.png")); }else if(properName == "tempo"){ icon->setPixmap(QPixmap(":icons/values.png")); }else{ //nothing } QString valueText(iterInfo->second); if (valueText.right(4) == ".xml") { value = new QLabel(); //value->setIcon(QIcon(":icons/redo.png")); value->setText("<html><header><style type=\"text/css\">a {text-decoration: none;}</style></header><body><a href=\"" + iterInfo->second + "\"><img src=\":icons/addToLayer.png\"> </a></body></html>"); value->setToolTip(tr("Add this layer to the layer list")); //connect the main window to the linkActivated signal connect(value, SIGNAL(linkActivated(QString)), MainWindow::instance(), SLOT(importEasaierLayer(QString))); m_infoLayout->addWidget(icon,row,0,1,1); m_infoLayout->addWidget(proper, row, 2,1,1); m_infoLayout->addWidget(value, row, 4,1,1); row++; } } } m_infoLayout->setColumnStretch( 4, 1); m_infoLayout->setRowStretch( row, 1); }