Mercurial > hg > easaier-soundaccess
changeset 143:97fd6148fb8e
support related media display and loading
author | lbajardsilogic |
---|---|
date | Tue, 13 Nov 2007 10:07:49 +0000 |
parents | c1ea7af931e7 |
children | f3dce7a985cf |
files | data/data.pro data/fileio/SparqlRelatedMediaReader.cpp data/fileio/SparqlRelatedMediaReader.h data/svdata.vcproj sv/main/EasaierSessionManager.cpp sv/main/EasaierSessionManager.h sv/main/MainWindow.cpp sv/main/MainWindow.h widgets/RelatedMediaWidget.cpp widgets/RelatedMediaWidget.h widgets/svwidgets.vcproj widgets/widgets.pro |
diffstat | 12 files changed, 444 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/data/data.pro Mon Nov 12 14:50:15 2007 +0000 +++ b/data/data.pro Tue Nov 13 10:07:49 2007 +0000 @@ -41,6 +41,7 @@ fileio/ModelReader.h \ fileio/QueryConfigReader.h \ fileio/SparqlResultsReader.h \ + fileio/SparqlRelatedMediaReader.h \ model/DenseThreeDimensionalModel.h \ model/DenseTimeValueModel.h \ model/EditableDenseThreeDimensionalModel.h \ @@ -86,6 +87,7 @@ fileio/ModelReader.cpp \ fileio/QueryConfigReader.cpp \ fileio/SparqlResultsReader.cpp \ + fileio/SparqlRelatedMediaReader.cpp \ model/DenseTimeValueModel.cpp \ model/EditableDenseThreeDimensionalModel.cpp \ model/FFTModel.cpp \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/fileio/SparqlRelatedMediaReader.cpp Tue Nov 13 10:07:49 2007 +0000 @@ -0,0 +1,153 @@ +/* -*- 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 "SparqlRelatedMediaReader.h" + +#include <iostream> + +SparqlRelatedMediaReader::SparqlRelatedMediaReader(std::list<QString> *relMediaList) : + m_relMediaList(relMediaList) +{} + +bool SparqlRelatedMediaReader::parse(const QString & filename) +{ + SparqlRelatedMediaHandler handler(m_relMediaList); + QXmlSimpleReader reader; + reader.setContentHandler(&handler); + reader.setErrorHandler(&handler); + + QFile file(filename); + + if (!file.open(QFile::ReadOnly | QFile::Text)) { + return false; + } + + QXmlInputSource xmlInputSource(&file); + if (reader.parse(xmlInputSource)) + { + return true; + } + + return false; +} + +SparqlRelatedMediaHandler::SparqlRelatedMediaHandler(std::list<QString> *relMediaList) : QXmlDefaultHandler(), + m_relMediaList(relMediaList), + m_inBinding(false), + m_curBindingName("") +{} + +bool SparqlRelatedMediaHandler::startElement(const QString &namespaceURI, const QString &localName, + const QString &qName, const QXmlAttributes &attributes) +{ + + QString name = qName.toLower(); + + bool ok = false; + + // Valid element names: + // + // sparql + // head + // variable + // results + // result + // binding + + if (name == "sparql") { + + // nothing needed + ok = true; + + } else if (name == "head") { + + // nothing needed + ok = true; + + } else if (name == "variable") { + + // nothing needed + ok = true; + + } else if (name == "results") { + + // nothing needed + ok = true; + + } else if (name == "result") { + + // nothing needed + ok = true; + + } else if (name == "binding") { + + // nothing needed + ok = true; + + } else if ( (name == "uri") || (name == "literal") ) { + m_inBinding = true; + ok = true; + } + + if (!ok) { + std::cerr << "WARNING: SparqlResultsHandler-XML: Failed to completely process element \"" + << name.toLocal8Bit().data() << "\"" << std::endl; + } + + return true; +} + +bool SparqlRelatedMediaHandler::endElement(const QString &namespaceURI, const QString &localName, + const QString &qName) +{ + QString name = qName.toLower(); + + if ( (name == "uri") || (name == "literal") ) + { + m_inBinding = false; + } + + return true; +} + +bool SparqlRelatedMediaHandler::characters(const QString &str) +{ + if (m_inBinding) + { + m_relMediaList->push_back(str); + } + + return true; +} + +bool SparqlRelatedMediaHandler::error(const QXmlParseException &exception) +{ + QString errorString; + errorString += QString("ERROR: SparqlRelatedMediaHandler-XML: %1 at line %2, column %3") + .arg(exception.message()) + .arg(exception.lineNumber()) + .arg(exception.columnNumber()); + std::cerr << errorString.toLocal8Bit().data() << std::endl; + return QXmlDefaultHandler::error(exception); +} + +bool SparqlRelatedMediaHandler::fatalError(const QXmlParseException &exception) +{ + QString errorString; + errorString += QString("FATAL ERROR: SparqlRelatedMediaHandler-XML: %1 at line %2, column %3") + .arg(exception.message()) + .arg(exception.lineNumber()) + .arg(exception.columnNumber()); + std::cerr << errorString.toLocal8Bit().data() << std::endl; + return QXmlDefaultHandler::fatalError(exception); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/fileio/SparqlRelatedMediaReader.h Tue Nov 13 10:07:49 2007 +0000 @@ -0,0 +1,54 @@ +/* -*- 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. +*/ + +#ifndef _SPARQL_RELATED_MEDIA_READER_H_ +#define _SPARQL_RELATED_MEDIA_READER_H_ + +#include <QXmlDefaultHandler> + +class SparqlRelatedMediaReader +{ +public: + SparqlRelatedMediaReader(std::list<QString> *relMediaList); + virtual ~SparqlRelatedMediaReader(){} + + bool parse(const QString & filename); + +private: + + std::list<QString> *m_relMediaList; +}; + +class SparqlRelatedMediaHandler : public QXmlDefaultHandler +{ +public: + SparqlRelatedMediaHandler(std::list<QString> *relMediaList); + + bool startElement(const QString &namespaceURI, const QString &localName, + const QString &qName, const QXmlAttributes &attributes); + bool endElement(const QString &namespaceURI, const QString &localName, + const QString &qName); + bool characters(const QString &str); + bool error(const QXmlParseException &exception); + bool fatalError(const QXmlParseException &exception); + + +private: + + bool m_inBinding; + QString m_curBindingName; + + std::list<QString> *m_relMediaList; +}; + +#endif
--- a/data/svdata.vcproj Mon Nov 12 14:50:15 2007 +0000 +++ b/data/svdata.vcproj Tue Nov 13 10:07:49 2007 +0000 @@ -310,6 +310,10 @@ > </File> <File + RelativePath=".\fileio\SparqlRelatedMediaReader.cpp" + > + </File> + <File RelativePath=".\fileio\SparqlResultsReader.cpp" > </File> @@ -415,6 +419,10 @@ > </File> <File + RelativePath=".\fileio\SparqlRelatedMediaReader.h" + > + </File> + <File RelativePath=".\fileio\SparqlResultsReader.h" > </File>
--- a/sv/main/EasaierSessionManager.cpp Mon Nov 12 14:50:15 2007 +0000 +++ b/sv/main/EasaierSessionManager.cpp Tue Nov 13 10:07:49 2007 +0000 @@ -30,9 +30,11 @@ #include "data/fileio/ModelReader.h" #include "data/fileio/QueryConfigReader.h" #include "data/fileio/SparqlResultsReader.h" +#include "data/fileio/SparqlRelatedMediaReader.h" #include "data/model/WaveFileModel.h" #include "main/MainWindow.h" #include "widgets/QueryResultsWidget.h" +#include "widgets/RelatedMediaWidget.h" #include "base/PropertyContainer.h" #include "data/fileio/AudioFileReaderFactory.h" @@ -91,12 +93,19 @@ QString params = "&identification=" + m_fileName; - QString query = m_httpClient->getServletName() + "?theme=infoFile"+params; + //get infofile + QString query = m_httpClient->getServletName() + "?theme=infoFile" + params; QString filename = "/easaier/servlet/infoFile"; loadFile(query, filename, LoadedFile::AUDIO_SOURCE_INFO); + //get related media + + query = m_httpClient->getServletName() + "?theme=relatedMedia" + params; + filename = "/easaier/servlet/relatedMedia"; + loadFile(query, filename, LoadedFile::RELATED_MEDIA_LIST); + return true; } @@ -264,6 +273,21 @@ } break; } + case LoadedFile::RELATED_MEDIA_LIST : + { + std::list<QString> relMediaList; + SparqlRelatedMediaReader reader(&relMediaList); + read = reader.parse(filename); + importRelatedMedia(&relMediaList); + break; + } + case LoadedFile::RELATED_MEDIA : + { + read = true; + RelatedMediaWidget* relMediaWidget = MainWindow::instance()->getRelatedMediaWidget(); + relMediaWidget->addRelatedMedia(filename); + break; + } default: break; } @@ -385,6 +409,22 @@ m_currentPane = pane; } +void EasaierSessionManager::importRelatedMedia(std::list<QString> *relMediaList) +{ + QString filename; + QString query; + + std::list<QString>::iterator iter; + for (iter = relMediaList->begin(); iter != relMediaList->end(); iter++) + { + filename = *iter; + + query = m_httpClient->getServletName() + "?theme=getFile&fileName=" + filename; + + loadFile( query, filename, LoadedFile::RELATED_MEDIA); + } +} + void EasaierSessionManager::queryDatabase(const QString& themeName) {
--- a/sv/main/EasaierSessionManager.h Mon Nov 12 14:50:15 2007 +0000 +++ b/sv/main/EasaierSessionManager.h Tue Nov 13 10:07:49 2007 +0000 @@ -45,7 +45,9 @@ MODEL = 2, // load a model in a existing layer METADATA = 3, // load the model and create an associated layer QUERY_CONFIG = 4, // config of the queries - QUERY_RESULTS = 5 // query results + QUERY_RESULTS = 5, // query results + RELATED_MEDIA_LIST = 6, // related media list + RELATED_MEDIA = 7 // related media }; inline FileType getFileType() const {return m_type;} @@ -84,6 +86,9 @@ /*import metadata info in a new layer*/ void importMetadata(const QString& filename, Pane* pane); + /*load all the related media from the list*/ + void importRelatedMedia(std::list<QString> *relMediaList); + /* load the appropriate metadata (needed by opened layers) of an audio file */
--- a/sv/main/MainWindow.cpp Mon Nov 12 14:50:15 2007 +0000 +++ b/sv/main/MainWindow.cpp Tue Nov 13 10:07:49 2007 +0000 @@ -44,6 +44,7 @@ #include "widgets/InfoWidget.h" #include "widgets/SearchWidget.h" #include "widgets/QueryResultsWidget.h" +#include "widgets/RelatedMediaWidget.h" #include "widgets/ExpandWidget.h" #include "widgets/AdvancedToolBox.h" #include "widgets/ConnectionStatus.h" @@ -271,12 +272,13 @@ m_infoWidget = new InfoWidget(); m_searchWidget = new SearchWidget(); m_resultsWidget = new QueryResultsWidget(); + m_relMediaWidget = new RelatedMediaWidget(); m_qtabwidget = new QTabWidget(); m_qtabwidget->addTab(m_searchWidget, tr("Search")); m_qtabwidget->addTab(m_resultsWidget, tr("Result")); m_qtabwidget->addTab(m_infoWidget, tr("Info")); - m_qtabwidget->addTab(new QWidget, tr("Related media")); + m_qtabwidget->addTab(m_relMediaWidget, tr("Related media")); QGridLayout *auxlayout = new QGridLayout; auxlayout->addWidget(m_paneStack, 0, 0, 1, 2); @@ -2889,6 +2891,7 @@ m_infoWidget->reset(); m_searchWidget->reset(); m_resultsWidget->reset(); + m_relMediaWidget->reset(); delete m_document; m_document = 0; @@ -5149,6 +5152,11 @@ return m_resultsWidget; } +RelatedMediaWidget *MainWindow::getRelatedMediaWidget() +{ + return m_relMediaWidget; +} + void MainWindow::newEasaierSession() { if (!checkSaveModified()) return; @@ -5369,6 +5377,18 @@ m_EasaierManager->importMetadata(filename, pane); } +void MainWindow::runExternProcess(const QString& filename) +{ + int pos = filename.lastIndexOf('/'); + QString dir = filename.left(pos); + QString name = filename.right(filename.length() - (pos + 1)); + QString program = "cmd /c start " + name; + + QProcess *openFile = new QProcess(this); + openFile->setWorkingDirectory(dir); + openFile->start(program); +} + void MainWindow::importEasaierFile(const QString& filename) { int i = m_paneStack->getPaneCount(); @@ -5411,7 +5431,10 @@ void MainWindow::audioSourceInfoAdded(AudioSourceInfoModel * info) { if (m_infoWidget) + { m_infoWidget->displayAudioSourceInfo(info); + m_relMediaWidget->reset(); + } m_qtabwidget->setCurrentIndex(Info); }
--- a/sv/main/MainWindow.h Mon Nov 12 14:50:15 2007 +0000 +++ b/sv/main/MainWindow.h Tue Nov 13 10:07:49 2007 +0000 @@ -23,6 +23,7 @@ #include <QPointer> #include <QTabWidget> #include <QStatusBar> +#include <QProcess> #include <time.h> #include "base/Command.h" #include "view/ViewManager.h" @@ -65,6 +66,7 @@ class InfoWidget; class SearchWidget; class QueryResultsWidget; +class RelatedMediaWidget; class AdvancedToolBox; class EasaierSessionManager; class QueryModel; @@ -118,6 +120,7 @@ static MainWindow *instance(); QueryResultsWidget *getQueryResultsWidget(); + RelatedMediaWidget *getRelatedMediaWidget(); bool openEasaierSessionFile(QString path); bool saveEasaierSessionFile(QString path); @@ -295,6 +298,8 @@ void importEasaierLayer(const QString& filename); void importEasaierFile(const QString& filename); + void runExternProcess(const QString& filename); + void connectionSettings(); void styleSetting(); @@ -495,6 +500,7 @@ InfoWidget *m_infoWidget; SearchWidget *m_searchWidget; QueryResultsWidget *m_resultsWidget; + RelatedMediaWidget *m_relMediaWidget; QTabWidget *m_qtabwidget;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/RelatedMediaWidget.cpp Tue Nov 13 10:07:49 2007 +0000 @@ -0,0 +1,65 @@ +/* -*- 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 <QScrollArea> +#include <QLayoutItem> +#include <QLinearGradient> + +#include <iostream> + +#include "sv/main/MainWindow.h" + +RelatedMediaWidget::RelatedMediaWidget() : QWidget() , + m_nbRelMedia(0), + m_painter(0) +{ + m_relMediaLayout = new QGridLayout; + + QWidget *mediaWidget = new QWidget; + mediaWidget->setLayout(m_relMediaLayout); + + QScrollArea * scrollArea = new QScrollArea; + scrollArea->setWidget(mediaWidget); + scrollArea->setWidgetResizable(true); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(scrollArea); + + setLayout(mainLayout); +} + +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) +{ + QLabel *mediaLabel = new QLabel(); + mediaLabel->setText("<html><header><style type=\"text/css\">a {text-decoration: none;}</style></header><body><a href=\"" + filename + "\"><img src=\"" + filename + "\"> </a></body></html>"); + + connect(mediaLabel, SIGNAL(linkActivated(QString)), MainWindow::instance(), SLOT(runExternProcess(QString))); + + m_relMediaLayout->addWidget(mediaLabel, 0, m_nbRelMedia); + m_nbRelMedia++; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/RelatedMediaWidget.h Tue Nov 13 10:07:49 2007 +0000 @@ -0,0 +1,47 @@ +/* -*- 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. +*/ + +#ifndef _RELATED_MEDIA_WIDGET_H_ +#define _RELATED_MEDIA_WIDGET_H_ + +#include <QWidget> +#include <QPainter> +#include <QGridLayout> + +//#include "data/model/AudioSourceInfoModel.h" + +class RelatedMediaWidget : public QWidget { + + Q_OBJECT +public: + RelatedMediaWidget(); + virtual ~RelatedMediaWidget(); + + void reset(); + + void addRelatedMedia(const QString &filename); + +protected: + + QGridLayout *m_relMediaLayout; + + QWidget *m_mediaWidget; + + QPainter * m_painter; + + int m_nbRelMedia; + +}; + + +#endif \ No newline at end of file
--- a/widgets/svwidgets.vcproj Mon Nov 12 14:50:15 2007 +0000 +++ b/widgets/svwidgets.vcproj Tue Nov 13 10:07:49 2007 +0000 @@ -298,6 +298,10 @@ > </File> <File + RelativePath=".\RelatedMediaWidget.cpp" + > + </File> + <File RelativePath=".\SearchWidget.cpp" > </File> @@ -1168,6 +1172,32 @@ </FileConfiguration> </File> <File + RelativePath=".\RelatedMediaWidget.h" + > + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCustomBuildTool" + Description="MOC $(InputFileName)" + CommandLine="$(QTDIR)\bin\moc.exe -DNDEBUG -DBUILD_RELEASE -DUSE_VC -D_WINDOWS -DUNICODE -DQT_LARGEFILE_SUPPORT -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DHAVE_BZ2 -DHAVE_PORTAUDIO -DHAVE_PORTAUDIO_V18 -DHAVE_OGGZ -DHAVE_FISHSOUND -DHAVE_FFTW3F -DHAVE_VAMP -DHAVE_VAMP_HOSTSDK -DHAVE_SNDFILE -DHAVE_SAMPLERATE -DQT_THREAD_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I "$(QTDIR)\include\QtCore" -I "$(QTDIR)\include\QtCore" -I "$(QTDIR)\include\QtGui" -I "$(QTDIR)\include\QtGui" -I "$(QTDIR)\include\QtXml" -I "$(QTDIR)\include\QtXml" -I "$(QTDIR)\include" -I "." -I ".." -I "$(QTDIR)\include\ActiveQt" -I "tmp_moc" -I "." -I"$(QTDIR)\mkspecs\win32-msvc2005" $(InputPath) -o tmp_moc\moc_$(InputName).cpp
" + AdditionalDependencies="$(QTDIR)\bin\moc.exe" + Outputs="tmp_moc\moc_$(InputName).cpp" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCustomBuildTool" + Description="MOC $(InputFileName)" + CommandLine="$(QTDIR)\bin\moc.exe -DBUILD_DEBUG -DUSE_VC -D_WINDOWS -DUNICODE -DQT_LARGEFILE_SUPPORT -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DHAVE_BZ2 -DHAVE_PORTAUDIO -DHAVE_PORTAUDIO_V18 -DHAVE_OGGZ -DHAVE_FISHSOUND -DHAVE_FFTW3F -DHAVE_VAMP -DHAVE_VAMP_HOSTSDK -DHAVE_SNDFILE -DHAVE_SAMPLERATE -DQT_THREAD_SUPPORT -DQT_DLL -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I "$(QTDIR)\include\QtCore" -I "$(QTDIR)\include\QtCore" -I "$(QTDIR)\include\QtGui" -I "$(QTDIR)\include\QtGui" -I "$(QTDIR)\include\QtXml" -I "$(QTDIR)\include\QtXml" -I "$(QTDIR)\include" -I "." -I ".." -I "$(QTDIR)\include\ActiveQt" -I "tmp_moc" -I "." -I"$(QTDIR)\mkspecs\win32-msvc2005" $(InputPath) -o tmp_moc\moc_$(InputName).cpp
" + AdditionalDependencies="$(QTDIR)\bin\moc.exe" + Outputs="tmp_moc\moc_$(InputName).cpp" + /> + </FileConfiguration> + </File> + <File RelativePath=".\SearchWidget.h" > <FileConfiguration @@ -1660,6 +1690,10 @@ > </File> <File + RelativePath=".\tmp_moc\moc_RelatedMediaWidget.cpp" + > + </File> + <File RelativePath=".\tmp_moc\moc_SearchWidget.cpp" > </File>
--- a/widgets/widgets.pro Mon Nov 12 14:50:15 2007 +0000 +++ b/widgets/widgets.pro Tue Nov 13 10:07:49 2007 +0000 @@ -57,7 +57,8 @@ ConfidenceListWidget.h \ WaitingWidget.h \ CriteriaDialog.h \ - Slider.h + Slider.h \ + RelatedMediaWidget.h SOURCES += AudioDial.cpp \ Fader.cpp \ ItemEditDialog.cpp \ @@ -100,5 +101,6 @@ ConfidenceListWidget.cpp \ WaitingWidget.cpp \ CriteriaDialog.cpp \ - Slider.hcpp + Slider.cpp \ + RelatedMediaWidget.cpp