# HG changeset patch # User lbajardsilogic # Date 1204283289 0 # Node ID a6b881972a625d814c5ffaa02282af1e2823c373 # Parent 59d84a8bb76ce85b9246ae15080da4dcf51aec24 add FileProperty to browse file on local system for query by humming diff -r 59d84a8bb76c -r a6b881972a62 base/PropertyContainer.h --- 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 }; /** diff -r 59d84a8bb76c -r a6b881972a62 data/model/QueryModel.cpp --- 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; diff -r 59d84a8bb76c -r a6b881972a62 widgets/BrowseLineEdit.cpp --- /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 +#include +#include + +#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 diff -r 59d84a8bb76c -r a6b881972a62 widgets/BrowseLineEdit.h --- /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 +#include + +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 diff -r 59d84a8bb76c -r a6b881972a62 widgets/SearchWidget.cpp --- 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 #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); diff -r 59d84a8bb76c -r a6b881972a62 widgets/SearchWidget.h --- 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: diff -r 59d84a8bb76c -r a6b881972a62 widgets/svwidgets.vcproj --- 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 @@ > + + @@ -567,6 +571,42 @@ + + + + + + + + + + + @@ -1400,7 +1440,7 @@ @@ -2247,6 +2287,10 @@ > + + diff -r 59d84a8bb76c -r a6b881972a62 widgets/widgets.pro --- 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