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 @@ ...@@ -14,6 +14,9 @@
<file>images/next_frame.png</file> <file>images/next_frame.png</file>
<file>images/previous_frame.png</file> <file>images/previous_frame.png</file>
<file>images/stop.png</file> <file>images/stop.png</file>
<file>images/clear.png</file>
<file>images/remove.png</file>
<file>images/add.png</file>
</qresource> </qresource>
<qresource prefix="/text" > <qresource prefix="/text" >
<file>AUTHORS</file> <file>AUTHORS</file>
......
...@@ -215,5 +215,14 @@ void Media::setMetaTags( const QStringList& tags ) ...@@ -215,5 +215,14 @@ void Media::setMetaTags( const QStringList& tags )
bool Media::matchMetaTag( const QString& tag ) const 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 ...@@ -42,6 +42,8 @@ LibraryWidget::LibraryWidget( QWidget *parent ) : QWidget( parent ), m_firstDire
if ( LibraryWidget::m_medias == NULL ) if ( LibraryWidget::m_medias == NULL )
LibraryWidget::m_medias = new QList<ListViewMediaItem*>(); 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() LibraryWidget::~LibraryWidget()
...@@ -225,3 +227,18 @@ const MediaListWidget* LibraryWidget::getAudioListWidget() const ...@@ -225,3 +227,18 @@ const MediaListWidget* LibraryWidget::getAudioListWidget() const
{ {
return m_ui.listWidgetAudio; 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: ...@@ -72,6 +72,7 @@ private:
public slots: public slots:
void newMediaLoaded( Media* ); void newMediaLoaded( Media* );
void mediaRemoved( const QUuid& ); void mediaRemoved( const QUuid& );
void updateFilter( const QString& );
private slots: private slots:
void on_pushButtonAddMedia_clicked(); void on_pushButtonAddMedia_clicked();
......
...@@ -120,4 +120,3 @@ void MediaListWidget::paintEvent( QPaintEvent* event ) ...@@ -120,4 +120,3 @@ void MediaListWidget::paintEvent( QPaintEvent* event )
} }
QListWidget::paintEvent( event ); QListWidget::paintEvent( event );
} }
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="4"> <item row="1" column="1" colspan="5">
<widget class="QTabWidget" name="LibraryTabs"> <widget class="QTabWidget" name="LibraryTabs">
<property name="acceptDrops"> <property name="acceptDrops">
<bool>true</bool> <bool>true</bool>
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<enum>QTabWidget::East</enum> <enum>QTabWidget::East</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<property name="elideMode"> <property name="elideMode">
<enum>Qt::ElideNone</enum> <enum>Qt::ElideNone</enum>
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="1">
<widget class="QPushButton" name="pushButtonAddMedia"> <widget class="QPushButton" name="pushButtonAddMedia">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="2">
<widget class="QPushButton" name="pushButtonRemoveMedia"> <widget class="QPushButton" name="pushButtonRemoveMedia">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="2" column="3">
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
...@@ -183,6 +183,27 @@ ...@@ -183,6 +183,27 @@
</property> </property>
</spacer> </spacer>
</item> </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> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
...@@ -192,6 +213,8 @@ ...@@ -192,6 +213,8 @@
<header>MediaListWidget.h</header> <header>MediaListWidget.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources>
<include location="../../../ressources.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>
...@@ -213,6 +213,10 @@ ...@@ -213,6 +213,10 @@
<property name="text"> <property name="text">
<string>...</string> <string>...</string>
</property> </property>
<property name="icon">
<iconset resource="../../../ressources.qrc">
<normaloff>:/images/images/add.png</normaloff>:/images/images/add.png</iconset>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
...@@ -220,11 +224,17 @@ ...@@ -220,11 +224,17 @@
<property name="text"> <property name="text">
<string>...</string> <string>...</string>
</property> </property>
<property name="icon">
<iconset resource="../../../ressources.qrc">
<normaloff>:/images/images/remove.png</normaloff>:/images/images/remove.png</iconset>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<resources/> <resources>
<include location="../../../ressources.qrc"/>
</resources>
<connections> <connections>
<connection> <connection>
<sender>buttonBox</sender> <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