[vlc-commits] Qt: PrefsItemData search
Yuval Tze
git at videolan.org
Fri Jul 29 13:06:16 CEST 2011
vlc | branch: master | Yuval Tze <yuvaltze at gmail.com> | Tue Jul 26 21:44:49 2011 +0300| [a27faa4c9474b66883cfef0cbf9453b895525b87] | committer: Francois Cartegnie
Qt: PrefsItemData search
add contains function to search text in item's name, help and in the config items' text
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a27faa4c9474b66883cfef0cbf9453b895525b87
---
.../gui/qt4/components/complete_preferences.cpp | 90 ++++++++++++++++++++
.../gui/qt4/components/complete_preferences.hpp | 1 +
2 files changed, 91 insertions(+), 0 deletions(-)
diff --git a/modules/gui/qt4/components/complete_preferences.cpp b/modules/gui/qt4/components/complete_preferences.cpp
index 4f267b8..94866d2 100644
--- a/modules/gui/qt4/components/complete_preferences.cpp
+++ b/modules/gui/qt4/components/complete_preferences.cpp
@@ -343,6 +343,96 @@ void PrefsTree::doAll( bool doclean )
}
}
+/* go over the module config items and search text in psz_text
+ * also search the module name and head */
+bool PrefsItemData::contains( const QString &text, Qt::CaseSensitivity cs )
+{
+ /* Find our module */
+ module_t *p_module = NULL;
+ if( this->i_type == TYPE_CATEGORY )
+ return false;
+ else if( this->i_type == TYPE_MODULE )
+ p_module = module_find( this->psz_name );
+ else
+ {
+ p_module = module_get_main();
+ assert( p_module );
+ }
+
+ unsigned confsize;
+ module_config_t *const p_config = module_config_get (p_module, &confsize),
+ *p_item = p_config,
+ *p_end = p_config + confsize;
+
+ if( this->i_type == TYPE_SUBCATEGORY || this->i_type == TYPE_CATSUBCAT )
+ {
+ while ( p_item < p_end )
+ {
+ if( p_item->i_type == CONFIG_SUBCATEGORY &&
+ (
+ ( this->i_type == TYPE_SUBCATEGORY &&
+ p_item->value.i == this->i_object_id )
+ ||
+ ( this->i_type == TYPE_CATSUBCAT &&
+ p_item->value.i == this->i_subcat_id )
+ )
+ )
+ break;
+ p_item++;
+ }
+ }
+
+ QString head;
+
+ if( this->i_type == TYPE_SUBCATEGORY || this->i_type == TYPE_CATSUBCAT )
+ {
+ head.clear();
+ p_item++; // Why that ? +1
+ }
+ else
+ {
+ head = QString( qtr( module_GetLongName( p_module ) ) );
+ }
+
+ if (name.contains( text, cs ) || head.contains( text, cs ) || help.contains( text, cs ))
+ {
+ module_release( p_module );
+ return true;
+ }
+
+ if( p_item ) do
+ {
+ if (
+ (
+ ( this->i_type == TYPE_SUBCATEGORY && p_item->value.i != this->i_object_id )
+ ||
+ ( this->i_type == TYPE_CATSUBCAT && p_item->value.i != this->i_subcat_id )
+ ) &&
+ ( p_item->i_type == CONFIG_CATEGORY || p_item->i_type == CONFIG_SUBCATEGORY )
+ ) break;
+
+ if( p_item->b_internal ) continue;
+
+ if ( p_item->psz_text && qtr( p_item->psz_text ).contains( text, cs ) )
+ {
+ module_release( p_module );
+ return true;
+ }
+ }
+ while (
+ !(
+ ( this->i_type == TYPE_SUBCATEGORY || this->i_type == TYPE_CATSUBCAT )
+ &&
+ ( p_item->i_type == CONFIG_CATEGORY || p_item->i_type == CONFIG_SUBCATEGORY )
+ )
+ && ( ++p_item < p_end )
+ );
+
+
+ module_release( p_module );
+ return false;
+}
+
/*********************************************************************
* The Panel
*********************************************************************/
diff --git a/modules/gui/qt4/components/complete_preferences.hpp b/modules/gui/qt4/components/complete_preferences.hpp
index 32ad189..f58b50f 100644
--- a/modules/gui/qt4/components/complete_preferences.hpp
+++ b/modules/gui/qt4/components/complete_preferences.hpp
@@ -51,6 +51,7 @@ public:
PrefsItemData()
{ panel = NULL; i_object_id = 0; i_subcat_id = -1; psz_name = NULL; };
virtual ~PrefsItemData() { free( psz_name ); };
+ bool contains( const QString &text, Qt::CaseSensitivity cs );
AdvPrefsPanel *panel;
int i_object_id;
int i_subcat_id;
More information about the vlc-commits
mailing list