Mercurial > hg > easaier-soundaccess
comparison widgets/RelatedMediaWidget.cpp @ 257:057856cf81a2
reformat the InfoWidget and integrate the related media query
author | lbajardsilogic |
---|---|
date | Wed, 18 Jun 2008 10:38:39 +0000 |
parents | 00ab90498dcc |
children | 14e8a46d506d |
comparison
equal
deleted
inserted
replaced
256:6eeb195adbb4 | 257:057856cf81a2 |
---|---|
15 | 15 |
16 #include <QLayoutItem> | 16 #include <QLayoutItem> |
17 #include <QLinearGradient> | 17 #include <QLinearGradient> |
18 #include <QScrollArea> | 18 #include <QScrollArea> |
19 #include <QVBoxLayout> | 19 #include <QVBoxLayout> |
20 #include <QTextEdit> | |
20 | 21 |
21 #include <iostream> | 22 #include <iostream> |
22 | 23 |
23 #include "sv/main/MainWindow.h" | 24 #include "sv/main/MainWindow.h" |
24 | 25 |
44 while ((child = m_relMediaLayout->takeAt(0)) != 0) { | 45 while ((child = m_relMediaLayout->takeAt(0)) != 0) { |
45 delete child->widget(); | 46 delete child->widget(); |
46 } | 47 } |
47 } | 48 } |
48 | 49 |
49 void RelatedMediaWidget::addRelatedMedia(const QString &filename) | 50 void RelatedMediaWidget::addRelatedMedia(const QString &filename, std::map<QString, QString> relMediaList) |
50 { | 51 { |
51 QString imageSource; | 52 QString imageSource; |
52 QString extension = filename.right(filename.length() - (filename.lastIndexOf('.') + 1)); | 53 QString extension = filename.right(filename.length() - (filename.lastIndexOf('.') + 1)); |
53 | 54 |
54 int width; | 55 int width; |
78 "\"><img src=\"" + imageSource + "\" width=\"" + QString::number(width) + "\" height=\"" + QString::number(height) + "\"> </a></body></html>"); | 79 "\"><img src=\"" + imageSource + "\" width=\"" + QString::number(width) + "\" height=\"" + QString::number(height) + "\"> </a></body></html>"); |
79 | 80 |
80 connect(mediaLabel, SIGNAL(linkActivated(QString)), MainWindow::instance(), SLOT(runExternProcess(QString))); | 81 connect(mediaLabel, SIGNAL(linkActivated(QString)), MainWindow::instance(), SLOT(runExternProcess(QString))); |
81 | 82 |
82 QLabel *textLabel = new QLabel(); | 83 QLabel *textLabel = new QLabel(); |
83 textLabel->setText("<html><a >Info may be added here</a><a href=\"" + filename + "\">...</a></html>"); | 84 QString uri = "file:" + filename.right(filename.length() - filename.lastIndexOf("/data")); |
85 std::map<QString, QString>::iterator iter = relMediaList.find(uri); | |
86 if (iter != relMediaList.end()) | |
87 { | |
88 //textLabel->setText(iter->second); | |
89 textLabel->setText("<html><a >" + (iter->second).left(50) + "</a><a href=\"" + iter->second + "\">...</a></html>"); | |
90 connect(textLabel, SIGNAL(linkActivated(QString)), this, SLOT(showLabel(QString))); | |
91 } else { | |
92 textLabel->setText("<html><a >Info may be added here</a><a href=\"" + filename + "\">...</a></html>"); | |
93 } | |
84 | 94 |
85 QVBoxLayout *mediaLayout = new QVBoxLayout; | 95 QVBoxLayout *mediaLayout = new QVBoxLayout; |
86 mediaLayout->addWidget(mediaLabel); | 96 mediaLayout->addWidget(mediaLabel); |
87 mediaLayout->addWidget(textLabel); | 97 mediaLayout->addWidget(textLabel); |
88 | 98 |
91 | 101 |
92 m_relMediaLayout->addWidget(mediaWidget); | 102 m_relMediaLayout->addWidget(mediaWidget); |
93 | 103 |
94 m_nbRelMedia++; | 104 m_nbRelMedia++; |
95 } | 105 } |
106 | |
107 void RelatedMediaWidget::showLabel(QString label) | |
108 { | |
109 QTextEdit *showLabel = new QTextEdit; | |
110 showLabel->setReadOnly(true); | |
111 showLabel->setHtml("<html><br><br>" + label + "</br></br></html>"); | |
112 //showLabel->setText("<html><br><br>" + label + "</br></br></html>"); | |
113 //showLabel->setText(label); | |
114 showLabel->show(); | |
115 } |