changeset 228:a6b881972a62

add FileProperty to browse file on local system for query by humming
author lbajardsilogic
date Fri, 29 Feb 2008 11:08:09 +0000
parents 59d84a8bb76c
children 7d5d51145b81
files base/PropertyContainer.h data/model/QueryModel.cpp widgets/BrowseLineEdit.cpp widgets/BrowseLineEdit.h widgets/SearchWidget.cpp widgets/SearchWidget.h widgets/svwidgets.vcproj widgets/widgets.pro
diffstat 8 files changed, 178 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/base/PropertyContainer.h	Wed Feb 27 16:00:02 2008 +0000
+++ b/base/PropertyContainer.h	Fri Feb 29 11:08:09 2008 +0000
@@ -43,7 +43,8 @@
         UnitsProperty, // unit from UnitDatabase, get/set unit id
 		InvalidProperty, // property not found!
 		StringProperty,	//string value that can be set to any value
-		PlotProperty,	//string value that can be set to any value
+		PlotProperty,	//2D function 
+		FileProperty,	//2D function 
     };
 
     /**
--- a/data/model/QueryModel.cpp	Wed Feb 27 16:00:02 2008 +0000
+++ b/data/model/QueryModel.cpp	Fri Feb 29 11:08:09 2008 +0000
@@ -288,6 +288,10 @@
 				m_max = m_range.size();
 			}
 		}
+	} else if (type == "file")
+	{
+		m_type = FileProperty;
+
 	} else if (type == "gYear")
 	{
 		m_type = RangeProperty;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/widgets/BrowseLineEdit.cpp	Fri Feb 29 11:08:09 2008 +0000
@@ -0,0 +1,63 @@
+/* -*- 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 <QFileDialog>
+#include <QMessageBox>
+#include <QHBoxLayout>
+
+#include "BrowseLineEdit.h"
+
+BrowseLineEdit::BrowseLineEdit(void) : QWidget()
+{
+	QHBoxLayout *mainLayout = new QHBoxLayout;
+	mainLayout->setSpacing(0);
+	mainLayout->setMargin(0);
+
+	m_lineEdit = new QLineEdit();
+	m_browseButton = new QPushButton(tr("&Browse..."));
+
+	connect(m_lineEdit, SIGNAL(textChanged(const QString &)), this, SIGNAL(textChanged(const QString &)));
+
+	connect(m_browseButton, SIGNAL(clicked()), this, SLOT(browse()));
+
+	mainLayout->addWidget(m_lineEdit);
+	mainLayout->addSpacing(10);
+	mainLayout->addWidget(m_browseButton);
+	
+	setLayout(mainLayout);
+
+}
+
+BrowseLineEdit::~BrowseLineEdit(void)
+{
+}
+
+void BrowseLineEdit::browse()
+{
+	QString curPath = m_lineEdit->text();
+
+	QString path = QFileDialog::getOpenFileName(this, tr("Select file"), curPath);
+
+	if (path.isEmpty()) return;
+
+    if (!(QFileInfo(path).exists() &&
+				QFileInfo(path).isFile() &&
+				QFileInfo(path).isReadable())) 
+	{
+		QMessageBox::critical(this, tr("Failed to open file"), tr("File \"%1\" does not exist or is not a readable file").arg(path));
+		return;
+	}
+
+	m_lineEdit->setText(path);
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/widgets/BrowseLineEdit.h	Fri Feb 29 11:08:09 2008 +0000
@@ -0,0 +1,42 @@
+/* -*- 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 _BROWSE_LINE_EDIT_H_
+#define _BROWSE_LINE_EDIT_H_
+
+
+#include <QLineEdit>
+#include <QPushButton>
+
+class BrowseLineEdit : public QWidget 
+{
+	Q_OBJECT
+
+public:
+	BrowseLineEdit(void);
+	~BrowseLineEdit(void);
+
+public slots:
+	void browse();
+
+signals:
+	void textChanged(const QString &);
+
+protected:
+
+	QLineEdit * m_lineEdit;
+	QPushButton *m_browseButton;
+
+};
+
+#endif
\ No newline at end of file
--- a/widgets/SearchWidget.cpp	Wed Feb 27 16:00:02 2008 +0000
+++ b/widgets/SearchWidget.cpp	Fri Feb 29 11:08:09 2008 +0000
@@ -26,6 +26,7 @@
 #include <iostream>
 
 #include "sv/main/MainWindow.h"
+#include "BrowseLineEdit.h"
 
 SearchWidget::SearchWidget() : QWidget(),
 	m_curThemeWidget(0),
@@ -175,6 +176,8 @@
 
 	PropertyContainer::PropertyType type = curTheme->getPropertyType(name);
 
+	QString unit = curTheme->getPropertyUnit(name);
+
 	switch (type)  //draw a different widget according to the datatype
 	{
 	case PropertyContainer::StringProperty:
@@ -224,6 +227,18 @@
 		
 		break;
 	}
+	case PropertyContainer::FileProperty:
+	{
+		BrowseLineEdit * browseLineEdit = new BrowseLineEdit();
+		
+		connect(browseLineEdit, SIGNAL(textChanged(const QString &)), curTheme, SLOT(setProperty(QString)));
+
+		m_curBoxLayout->addWidget(browseLineEdit, m_curBoxRow, 2);
+		
+		field = browseLineEdit;
+
+		break;
+	}
 
 	default: break;
 
@@ -234,9 +249,7 @@
 		field->setObjectName(name);
 		m_curBoxLayout->addWidget(field, m_curBoxRow, 1);
 	}
-
-	QString unit = curTheme->getPropertyUnit(name);
-
+	
 	if (unit != "")
 	{
 		m_curBoxLayout->addWidget(new QLabel(unit), m_curBoxRow, 2);
--- a/widgets/SearchWidget.h	Wed Feb 27 16:00:02 2008 +0000
+++ b/widgets/SearchWidget.h	Fri Feb 29 11:08:09 2008 +0000
@@ -57,6 +57,9 @@
 
 public slots:
 	void activeTheme();
+	
+signals:
+	void fileSelected(const QString &);
 
 protected:
 
--- a/widgets/svwidgets.vcproj	Wed Feb 27 16:00:02 2008 +0000
+++ b/widgets/svwidgets.vcproj	Fri Feb 29 11:08:09 2008 +0000
@@ -264,6 +264,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\BrowseLineEdit.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\ConnectionSettings.cpp"
 				>
 			</File>
@@ -567,6 +571,42 @@
 					</FileConfiguration>
 				</File>
 				<File
+					RelativePath=".\BrowseLineEdit.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 &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtXml&quot; -I &quot;$(QTDIR)\include\QtXml&quot; -I &quot;$(QTDIR)\include&quot; -I &quot;.&quot; -I &quot;..&quot; -I &quot;$(QTDIR)\include\ActiveQt&quot; -I &quot;tmp_moc&quot; -I &quot;.&quot; -I&quot;$(QTDIR)\mkspecs\win32-msvc2005&quot; $(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 &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtXml&quot; -I &quot;$(QTDIR)\include\QtXml&quot; -I &quot;$(QTDIR)\include&quot; -I &quot;.&quot; -I &quot;..&quot; -I &quot;$(QTDIR)\include\ActiveQt&quot; -I &quot;tmp_moc&quot; -I &quot;.&quot; -I&quot;$(QTDIR)\mkspecs\win32-msvc2005&quot; $(InputPath) -o tmp_moc\moc_$(InputName).cpp"
+							AdditionalDependencies="$(QTDIR)\bin\moc.exe"
+							Outputs="tmp_moc\moc_$(InputName).cpp"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Static_Release|Win32"
+						>
+						<Tool
+							Name="VCCustomBuildTool"
+							Description="MOC $(InputFileName)"
+							AdditionalDependencies="$(QTDIR)\bin\moc.exe"
+							Outputs="tmp_moc\moc_$(InputName).cpp"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
 					RelativePath=".\ConnectionSettings.h"
 					>
 					<FileConfiguration
@@ -1389,7 +1429,7 @@
 						<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 &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtXml&quot; -I &quot;$(QTDIR)\include\QtXml&quot; -I &quot;$(QTDIR)\include&quot; -I &quot;.&quot; -I &quot;..&quot; -I &quot;$(QTDIR)\include\ActiveQt&quot; -I &quot;tmp_moc&quot; -I &quot;.&quot; -I&quot;$(QTDIR)\mkspecs\win32-msvc2005&quot; $(InputPath) -o tmp_moc\moc_$(InputName).cpp"
+							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 &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtXml&quot; -I &quot;$(QTDIR)\include\QtXml&quot; -I &quot;$(QTDIR)\include&quot; -I &quot;.&quot; -I &quot;..&quot; -I &quot;$(QTDIR)\include\ActiveQt&quot; -I &quot;tmp_moc&quot; -I &quot;.&quot; -I&quot;$(QTDIR)\mkspecs\win32-msvc2005&quot; $(InputPath) -o tmp_moc\moc_$(InputName).cpp&#x0D;&#x0A;"
 							AdditionalDependencies="$(QTDIR)\bin\moc.exe"
 							Outputs="tmp_moc\moc_$(InputName).cpp"
 						/>
@@ -1400,7 +1440,7 @@
 						<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 &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtXml&quot; -I &quot;$(QTDIR)\include\QtXml&quot; -I &quot;$(QTDIR)\include&quot; -I &quot;.&quot; -I &quot;..&quot; -I &quot;$(QTDIR)\include\ActiveQt&quot; -I &quot;tmp_moc&quot; -I &quot;.&quot; -I&quot;$(QTDIR)\mkspecs\win32-msvc2005&quot; $(InputPath) -o tmp_moc\moc_$(InputName).cpp"
+							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 &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtXml&quot; -I &quot;$(QTDIR)\include\QtXml&quot; -I &quot;$(QTDIR)\include&quot; -I &quot;.&quot; -I &quot;..&quot; -I &quot;$(QTDIR)\include\ActiveQt&quot; -I &quot;tmp_moc&quot; -I &quot;.&quot; -I&quot;$(QTDIR)\mkspecs\win32-msvc2005&quot; $(InputPath) -o tmp_moc\moc_$(InputName).cpp&#x0D;&#x0A;"
 							AdditionalDependencies="$(QTDIR)\bin\moc.exe"
 							Outputs="tmp_moc\moc_$(InputName).cpp"
 						/>
@@ -2247,6 +2287,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\tmp_moc\moc_BrowseLineEdit.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\tmp_moc\moc_ConfidenceListWidget.cpp"
 				>
 			</File>
--- a/widgets/widgets.pro	Wed Feb 27 16:00:02 2008 +0000
+++ b/widgets/widgets.pro	Fri Feb 29 11:08:09 2008 +0000
@@ -60,6 +60,7 @@
            Slider.h \
            RelatedMediaWidget.h \
            RadialLNFButton.h \
+           BrowseLineEdit.h \
            FlowLayout.h 
 SOURCES += AudioDial.cpp \
            Fader.cpp \
@@ -107,5 +108,6 @@
            Slider.cpp \
            RelatedMediaWidget.cpp \
            RadialLNFButton.cpp \
+           BrowseLineEdit.cpp \
            FlowLayout.cpp