Commit 30684a04 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Added filter functionanlity for the Media Library

Solved missing icons for MediaProperty dialog
parent 896bbc2b
images/add.png

907 Bytes

......@@ -14,6 +14,9 @@
<file>images/next_frame.png</file>
<file>images/previous_frame.png</file>
<file>images/stop.png</file>
<file>images/clear.png</file>
<file>images/remove.png</file>
<file>images/add.png</file>
</qresource>
<qresource prefix="/text" >
<file>AUTHORS</file>
......
......@@ -215,5 +215,14 @@ void Media::setMetaTags( const QStringList& tags )
bool Media::matchMetaTag( const QString& tag ) const
{
return m_metaTags.contains( tag, Qt::CaseInsensitive );
if ( tag.length() == 0 )
return true;
QString metaTag;
foreach ( metaTag, m_metaTags )
{
if ( metaTag.startsWith( tag, Qt::CaseInsensitive ) == true )
return true;
}
return false;
// m_metaTags.contains( tag, Qt::CaseInsensitive );
}
......@@ -42,6 +42,8 @@ LibraryWidget::LibraryWidget( QWidget *parent ) : QWidget( parent ), m_firstDire
if ( LibraryWidget::m_medias == NULL )
LibraryWidget::m_medias = new QList<ListViewMediaItem*>();
connect( m_ui.filterInput, SIGNAL( textChanged( QString ) ), this, SLOT( updateFilter( QString ) ) );
connect( m_ui.clearFilterButton, SIGNAL( clicked() ), m_ui.filterInput, SLOT( clear() ) );
}
LibraryWidget::~LibraryWidget()
......@@ -225,3 +227,18 @@ const MediaListWidget* LibraryWidget::getAudioListWidget() const
{
return m_ui.listWidgetAudio;
}
void LibraryWidget::updateFilter( const QString& filter )
{
qDebug() << "Updating filter with:"<<filter;
QListWidget* mediaList = ( QListWidget* )( m_ui.LibraryTabs->currentWidget()->children().back() );
unsigned int count = mediaList->count();
for ( unsigned int i = 0; i < count; ++i )
{
ListViewMediaItem* item = static_cast<ListViewMediaItem*>( mediaList->item( i ) );
if ( item != NULL )
{
item->setHidden( !(item->getMedia()->matchMetaTag( filter )) );
}
}
}
......@@ -72,6 +72,7 @@ private:
public slots:
void newMediaLoaded( Media* );
void mediaRemoved( const QUuid& );
void updateFilter( const QString& );
private slots:
void on_pushButtonAddMedia_clicked();
......
......@@ -120,4 +120,3 @@ void MediaListWidget::paintEvent( QPaintEvent* event )
}
QListWidget::paintEvent( event );
}
......@@ -14,7 +14,7 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="4">
<item row="1" column="1" colspan="5">
<widget class="QTabWidget" name="LibraryTabs">
<property name="acceptDrops">
<bool>true</bool>
......@@ -23,7 +23,7 @@
<enum>QTabWidget::East</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
......@@ -138,7 +138,7 @@
</widget>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="1">
<widget class="QPushButton" name="pushButtonAddMedia">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
......@@ -151,7 +151,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="2">
<widget class="QPushButton" name="pushButtonRemoveMedia">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
......@@ -170,7 +170,7 @@
</property>
</widget>
</item>
<item row="1" column="2">
<item row="2" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -183,6 +183,27 @@
</property>
</spacer>
</item>
<item row="0" column="2" colspan="2">
<widget class="QLineEdit" name="filterInput"/>
</item>
<item row="0" column="1">
<widget class="QLabel" name="filterLabel">
<property name="text">
<string>Filter:</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="clearFilterButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../ressources.qrc">
<normaloff>:/images/images/clear.png</normaloff>:/images/images/clear.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......@@ -192,6 +213,8 @@
<header>MediaListWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../../../ressources.qrc"/>
</resources>
<connections/>
</ui>
......@@ -213,6 +213,10 @@
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../ressources.qrc">
<normaloff>:/images/images/add.png</normaloff>:/images/images/add.png</iconset>
</property>
</widget>
</item>
<item row="1" column="2">
......@@ -220,11 +224,17 @@
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../ressources.qrc">
<normaloff>:/images/images/remove.png</normaloff>:/images/images/remove.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../../../ressources.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment