[kde-doc-english] [kde-runtime] kurifilter-plugins/ikws: - Moved the checkbox used to select preferred shortcuts into its own column to

Dawit Alemayehu adawit at kde.org
Wed May 9 22:36:44 UTC 2012


Git commit 0707b07d3afb14870d5c31149238e0f32e0d1187 by Dawit Alemayehu.
Committed on 07/05/2012 at 09:36.
Pushed by adawit into branch 'master'.

- Moved the checkbox used to select preferred shortcuts into its own column to
  prevent user confusion.

- Allow the shortcut list to be filtered using the shortcut texts.

BUG: 218164
BUG: 168223
FIXED-IN: 4.9.0
REVIEW: 104900
GUI: New translatable text

M  +37   -21   kurifilter-plugins/ikws/ikwsopts.cpp
M  +5    -5    kurifilter-plugins/ikws/ikwsopts_p.h
M  +1    -1    kurifilter-plugins/ikws/ikwsopts_ui.ui

http://commits.kde.org/kde-runtime/0707b07d3afb14870d5c31149238e0f32e0d1187

diff --git a/kurifilter-plugins/ikws/ikwsopts.cpp b/kurifilter-plugins/ikws/ikwsopts.cpp
index f1cc481..aa10b7d 100644
--- a/kurifilter-plugins/ikws/ikwsopts.cpp
+++ b/kurifilter-plugins/ikws/ikwsopts.cpp
@@ -48,10 +48,17 @@ QVariant ProvidersModel::headerData(int section, Qt::Orientation orientation, in
   Q_UNUSED(orientation);
   if (role == Qt::DisplayRole)
   {
-    if (section==Name)
+    switch (section) {
+    case Name:
       return i18n("Name");
-    return i18n("Shortcuts");
-  }   
+    case Shortcuts:
+      return i18n("Shortcuts");
+    case Preferred:
+      return i18n("Preferred");
+    default:
+      break;
+    }
+  }
   return QVariant();
 }
 
@@ -59,7 +66,7 @@ Qt::ItemFlags ProvidersModel::flags(const QModelIndex& index) const
 {
   if (!index.isValid())
     return Qt::ItemIsEnabled;
-  if (index.column()==Name)
+  if (index.column()==Preferred)
     return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
   return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
 }
@@ -80,22 +87,31 @@ bool ProvidersModel::setData (const QModelIndex& index, const QVariant& value, i
 
 QVariant ProvidersModel::data(const QModelIndex& index, int role) const
 {
-  if (!index.isValid())
-    return QVariant();
-  
-  if (role == Qt::CheckStateRole && index.column()==Name)
-    return (m_favoriteEngines.contains(m_providers.at(index.row())->desktopEntryName()) ? Qt::Checked : Qt::Unchecked);
-
-  if (role == Qt::DisplayRole)
+  if (index.isValid())
   {
-    if (index.column()==Name)
-      return m_providers.at(index.row())->name();
-    if (index.column()==Shortcuts)
-      return m_providers.at(index.row())->keys().join(",");
-  }
+    if (role == Qt::CheckStateRole && index.column()==Preferred)
+      return (m_favoriteEngines.contains(m_providers.at(index.row())->desktopEntryName()) ? Qt::Checked : Qt::Unchecked);
+
+    if (role == Qt::DisplayRole)
+    {
+      if (index.column()==Name)
+        return m_providers.at(index.row())->name();
+      if (index.column()==Shortcuts)
+        return m_providers.at(index.row())->keys().join(",");
+    }
 
-  if (role == Qt::UserRole)
-    return index.row();//a nice way to bypass proxymodel
+    if (role == Qt::ToolTipRole || role == Qt::WhatsThisRole)
+    {
+      if (index.column() == Preferred)
+        return i18n("<qt>Check this box to select the highlighted web shortcut "
+                    "as preferred.<p/><br/>Preferred web shortcuts are used in "
+                    "places where only a few select shortcuts can be shown "
+                    "at one time.</qt>");
+    }
+
+    if (role == Qt::UserRole)
+      return index.row();//a nice way to bypass proxymodel
+  }
 
   return QVariant();
 }
@@ -169,7 +185,7 @@ QStringList ProvidersModel::favoriteEngines() const
 //BEGIN ProvidersListModel
 ProvidersListModel::ProvidersListModel(QList<SearchProvider*>& providers,  QObject* parent)
     : QAbstractListModel(parent)
-    , m_providers(providers)        
+    , m_providers(providers)
 {}
 
 QVariant ProvidersListModel::data(const QModelIndex& index, int role) const
@@ -190,7 +206,6 @@ QVariant ProvidersListModel::data(const QModelIndex& index, int role) const
       return m_providers.at(index.row())->desktopEntryName();
     }
   }
-    
   return QVariant();
 }
 
@@ -209,6 +224,7 @@ static QSortFilterProxyModel* wrapInProxyModel(QAbstractItemModel* model)
   proxyModel->setDynamicSortFilter(true);
   proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
   proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
+  proxyModel->setFilterKeyColumn(-1);
   return proxyModel;
 }
 
@@ -333,7 +349,7 @@ void FilterOptions::save()
     changedProviderCount++;
 
     KConfig _service(path + provider->desktopEntryName() + ".desktop", KConfig::SimpleConfig );
-    KConfigGroup service(&_service, "Desktop Entry");                                                                                                      
+    KConfigGroup service(&_service, "Desktop Entry");
     service.writeEntry("Type", "Service");
     service.writeEntry("ServiceTypes", "SearchProvider");
     service.writeEntry("Name", provider->name());
diff --git a/kurifilter-plugins/ikws/ikwsopts_p.h b/kurifilter-plugins/ikws/ikwsopts_p.h
index 9cfc12c..d048f08 100644
--- a/kurifilter-plugins/ikws/ikwsopts_p.h
+++ b/kurifilter-plugins/ikws/ikwsopts_p.h
@@ -27,17 +27,17 @@ class ProvidersModel: public QAbstractTableModel
 {
     Q_OBJECT
 public:
-    enum {Name,Shortcuts,ColumnCount};
+    enum {Name,Shortcuts,Preferred,ColumnCount};
     ProvidersModel(QObject* parent = 0): QAbstractTableModel(parent){}
     ~ProvidersModel();
-    
+
     Qt::ItemFlags flags(const QModelIndex& index) const;
     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
     bool setData (const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
     QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
     int rowCount(const QModelIndex& parent = QModelIndex()) const;
     int columnCount(const QModelIndex& parent = QModelIndex()) const{Q_UNUSED(parent); return ColumnCount;}
-    
+
     void setProviders(const QList<SearchProvider*>&, const QStringList&);
     void setFavoriteProviders(const QStringList&);
     void addProvider(SearchProvider* p);
@@ -45,12 +45,12 @@ public:
     void changeProvider(SearchProvider* p);
     QStringList favoriteEngines() const;
     QList<SearchProvider*> providers() const{ return m_providers;}
-    
+
     ///Creates new ProvidersListModel which directly uses data of this model.
     QAbstractListModel* createListModel();
 
 Q_SIGNALS:
-    void dataModified();   
+    void dataModified();
 
 private:
     QSet<QString> m_favoriteEngines;
diff --git a/kurifilter-plugins/ikws/ikwsopts_ui.ui b/kurifilter-plugins/ikws/ikwsopts_ui.ui
index 440c201..fcf4aca 100644
--- a/kurifilter-plugins/ikws/ikwsopts_ui.ui
+++ b/kurifilter-plugins/ikws/ikwsopts_ui.ui
@@ -29,7 +29,7 @@ Enable shortcuts that allow you to quickly search for information on the web. Fo
       <bool>false</bool>
      </property>
      <property name="text">
-      <string>&Use selected shortcuts only</string>
+      <string>&Use preferred shortcuts only</string>
      </property>
     </widget>
    </item>


More information about the kde-doc-english mailing list