[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/systemsettings
From:       Ben Cooksley <sourtooth () gmail ! com>
Date:       2009-07-19 10:33:39
Message-ID: 1247999619.800602.32314.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 999142 by bcooksley:

Fix MenuItem so that it does what the API docs say it does
Add search dialog autocompletion for keywords and module names
Fix potential crash when accessing MenuItem with invalid service

 M  +5 -2      app/SettingsBase.cpp  
 M  +2 -2      classic/CategoryList.cpp  
 M  +9 -2      core/MenuItem.cpp  
 M  +7 -0      core/MenuItem.h  
 M  +4 -4      core/MenuModel.cpp  
 M  +2 -2      core/ToolTipManager.cpp  
 M  +1 -1      icons/IconMode.cpp  


--- trunk/KDE/kdebase/workspace/systemsettings/app/SettingsBase.cpp #999141:999142
@@ -55,6 +55,7 @@
     searchText = new KLineEdit( this );
     searchText->setClearButtonShown( true );
     searchText->setClickMessage( i18nc( "Search through a list of control modules", \
"Search" ) ); +    searchText->setCompletionMode( KGlobalSettings::CompletionPopup );
 
     spacerWidget = new QWidget( this );
     spacerWidget->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Maximum \
); @@ -168,7 +169,7 @@
     for (int i = 0; i < categories.size(); ++i) {
         const KService::Ptr entry = categories.at(i);
         const QString parentCategory = \
                entry->property("X-KDE-System-Settings-Parent-Category").toString();
-        if ( parentCategory == parent->name() ) {
+        if ( parentCategory == parent->category() ) {
             MenuItem * menuItem = new MenuItem(true, parent);
             menuItem->setService( entry );
             initMenuList( menuItem );
@@ -179,7 +180,7 @@
     for (int i = 0; i < modules.size(); ++i) {
         const KService::Ptr entry = modules.at(i);
         const QString category = \
                entry->property("X-KDE-System-Settings-Parent-Category").toString();
-        if(!parent->name().isEmpty() && category == parent->name() ) {
+        if( !parent->category().isEmpty() && category == parent->category() ) {
             // Add the module info to the menu
             MenuItem * infoItem = new MenuItem(false, parent);
             infoItem->setService( entry );
@@ -282,6 +283,8 @@
     changeAboutMenu( activeView->aboutData(), aboutViewAction, i18n("About Active \
View") );  viewChange(false);
     activeView->setEnhancedTooltipEnabled( showTooltips );
+    searchText->completionObject()->setIgnoreCase( true );
+    searchText->completionObject()->setItems( \
BaseData::instance()->menuItem()->keywords() );  \
stackedWidget->setCurrentWidget(activeView->mainWidget());  updateViewActions();
 
--- trunk/KDE/kdebase/workspace/systemsettings/classic/CategoryList.cpp \
#999141:999142 @@ -93,7 +93,7 @@
     templateString = templateString.arg( i18n( title_infotext ) );
     templateString = templateString.arg( i18n( intro_infotext ) );
     if ( d->categoryMenu.isValid() ) {
-        moduleName = d->itemModel->data( d->categoryMenu, Qt::UserRole \
).value<MenuItem*>()->service()->name(); +        moduleName = d->itemModel->data( \
d->categoryMenu, Qt::DisplayRole ).toString();  }
     content += "<div id=\"tableTitle\">" + moduleName + "</div>";
     content += "<table class=\"kc_table\">\n";
@@ -101,7 +101,7 @@
         QModelIndex childIndex = d->itemModel->index( done, 0, d->categoryMenu );
         MenuItem *childItem = d->itemModel->data( childIndex, Qt::UserRole \
                ).value<MenuItem*>();
         content += "<tr><td class=\"kc_leftcol\"><img src=\"%1\" width=\"24\" \
                height=\"24\"></td><td class=\"kc_middlecol\">";
-        const QString szName = childItem->service()->name();
+        const QString szName = childItem->name();
         const QString szComment = childItem->service()->comment();
         content += "<a href=\"%2\">" + szName + "</a></td><td \
class=\"kc_rightcol\">" + szComment;  const QString linkURL( "kcm://" + \
                childItem->item().fileName() );
--- trunk/KDE/kdebase/workspace/systemsettings/core/MenuItem.cpp #999141:999142
@@ -39,6 +39,7 @@
     QList<MenuItem*> children;
     bool menu;
     QString name;
+    QString category;
     int weight;
     KService::Ptr service;
     KCModuleInfo item;
@@ -75,7 +76,7 @@
 {
     QStringList listOfKeywords;
 
-    listOfKeywords << d->item.keywords() << d->service->name();
+    listOfKeywords << d->item.keywords() << d->name;
     foreach ( MenuItem * child, d->children ) {
         listOfKeywords += child->keywords();
     }
@@ -107,6 +108,11 @@
     return d->name;
 }
 
+QString& MenuItem::category() const
+{
+    return d->category;
+}
+
 int MenuItem::weight()
 {
     return d->weight;
@@ -120,7 +126,8 @@
 void MenuItem::setService( const KService::Ptr& service )
 {
     d->service = service;
-    d->name = service->property("X-KDE-System-Settings-Category").toString();
+    d->category = service->property("X-KDE-System-Settings-Category").toString();
+    d->name = service->name();
     d->item = KCModuleInfo( service->entryPath() );
     const QVariant itemWeight = d->service->property( "X-KDE-Weight", QVariant::Int \
);  if( itemWeight.isValid() ) {
--- trunk/KDE/kdebase/workspace/systemsettings/core/MenuItem.h #999141:999142
@@ -125,6 +125,13 @@
     QString& name() const;
 
     /**
+     * Convienence function which provides the System Settings category of the \
current item. +     *
+     * @returns The category of the item, if the service object has been set.
+     */
+    QString& category() const;
+
+    /**
      * Provides the weight of the current item, as determined by its service.
      * If the service does not specify a weight, it is 100
      *
--- trunk/KDE/kdebase/workspace/systemsettings/core/MenuModel.cpp #999141:999142
@@ -77,7 +77,7 @@
     mi = static_cast<MenuItem*>( index.internalPointer() );
     switch ( role ) {
         case Qt::DisplayRole:
-            theData.setValue( mi->service()->name() );
+            theData.setValue( mi->name() );
             break;
         case Qt::ToolTipRole:
             theData.setValue( mi->service()->comment() );
@@ -87,12 +87,12 @@
             break;
         case KCategorizedSortFilterProxyModel::CategorySortRole:
             if ( mi->parent() ) {
-                theData.setValue( QString("%1%2").arg( \
QString::number(mi->parent()->weight()), 5, '0' ).arg( \
mi->parent()->service()->name() ) ); +                theData.setValue( \
QString("%1%2").arg( QString::number(mi->parent()->weight()), 5, '0' ).arg( \
mi->parent()->name() ) );  }
             break;
         case KCategorizedSortFilterProxyModel::CategoryDisplayRole:
             if ( mi->parent() ) {
-                theData.setValue( mi->parent()->service()->name() );
+                theData.setValue( mi->parent()->name() );
             }
             break;
         case Qt::UserRole:
@@ -102,7 +102,7 @@
             theData.setValue( mi->keywords().join( QString() ) );
             break;
         case MenuModel::UserSortRole:
-            theData.setValue( QString("%1%2").arg( QString::number(mi->weight()), 5, \
'0' ).arg( mi->service()->name() ) ); +            theData.setValue( \
QString("%1%2").arg( QString::number(mi->weight()), 5, '0' ).arg( mi->name() ) );  \
break;  default:
             break;
--- trunk/KDE/kdebase/workspace/systemsettings/core/ToolTipManager.cpp #999141:999142
@@ -121,7 +121,7 @@
     for ( int done = 0; itemModel->rowCount( d->item ) > done; done = 1 + done ) {
         QModelIndex childIndex = itemModel->index( done, 0, d->item );
         MenuItem * child = itemModel->data( childIndex, Qt::UserRole \
                ).value<MenuItem*>();
-        const QString text = QString( "%1<br />" ).arg( child->service()->name() );
+        const QString text = QString( "%1<br />" ).arg( child->name() );
         toolTip->addLine( KIcon( child->service()->icon() ), text );
     }
 
@@ -130,7 +130,7 @@
 
 QString ToolTipManager::generateToolTipContent( QModelIndex index, MenuItem * item )
 {
-    QString text = QString( "<b>%1</b><br />%2" ).arg( item->service()->name() );
+    QString text = QString( "<b>%1</b><br />%2" ).arg( item->name() );
     if ( !item->service()->comment().isEmpty() ) {
         text = text.arg( item->service()->comment() );
     } else {
--- trunk/KDE/kdebase/workspace/systemsettings/icons/IconMode.cpp #999141:999142
@@ -113,7 +113,7 @@
         proxyModel->setCategorizedModel( true );
         proxyModel->setSourceModel( model );
         proxyModel->sort( 0 );
-        d->proxyMap.insert( proxyModel, childItem->service()->name() );
+        d->proxyMap.insert( proxyModel, childItem->name() );
         d->proxyList << proxyModel;
     }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic