diff 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
line wrap: on
line diff
--- a/widgets/RelatedMediaWidget.cpp	Tue Jun 17 11:59:02 2008 +0000
+++ b/widgets/RelatedMediaWidget.cpp	Wed Jun 18 10:38:39 2008 +0000
@@ -17,6 +17,7 @@
 #include <QLinearGradient>
 #include <QScrollArea>
 #include <QVBoxLayout>
+#include <QTextEdit>
 
 #include <iostream>
 
@@ -46,7 +47,7 @@
 	}
 }
 
-void RelatedMediaWidget::addRelatedMedia(const QString &filename)
+void RelatedMediaWidget::addRelatedMedia(const QString &filename, std::map<QString, QString> relMediaList)
 {
 	QString imageSource;
 	QString extension = filename.right(filename.length() - (filename.lastIndexOf('.') + 1));
@@ -80,7 +81,16 @@
 	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>");
+	QString uri = "file:" + filename.right(filename.length() - filename.lastIndexOf("/data"));
+	std::map<QString, QString>::iterator iter = relMediaList.find(uri);
+	if (iter != relMediaList.end())
+	{
+		//textLabel->setText(iter->second);
+		textLabel->setText("<html><a >" + (iter->second).left(50) + "</a><a href=\"" + iter->second + "\">...</a></html>");
+		connect(textLabel, SIGNAL(linkActivated(QString)), this, SLOT(showLabel(QString)));
+	} else {
+		textLabel->setText("<html><a >Info may be added here</a><a href=\"" + filename + "\">...</a></html>");
+	}
 
 	QVBoxLayout *mediaLayout = new QVBoxLayout;
 	mediaLayout->addWidget(mediaLabel);
@@ -93,3 +103,13 @@
 
 	m_nbRelMedia++;
 }
+
+void RelatedMediaWidget::showLabel(QString label)
+{
+	QTextEdit *showLabel = new QTextEdit;
+	showLabel->setReadOnly(true);
+	showLabel->setHtml("<html><br><br>" + label + "</br></br></html>");
+	//showLabel->setText("<html><br><br>" + label + "</br></br></html>");
+	//showLabel->setText(label);
+	showLabel->show();
+}