on xenial help sign in
more fixes
commit55c9ca537479a1bb8de06ed98a152d0bb130366c authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 4 Nov 2016, 12:39 (10 years ago) parentcc1fa6a
2 files changed+37−6
plugins/Utils/appdrawerproxymodel.cpp+4−3 qml/Launcher/Drawer.qml+33−3
plugins/Utils/appdrawerproxymodel.cpp+4−3
@@ -7,6 +7,7 @@ AppDrawerProxyModel::AppDrawerProxyModel(QObject *parent):
77{
88 setSortRole(AppDrawerModelInterface::RoleName);
99 setSortLocaleAware(true);
10+ sort(0);
1011
1112 connect(this, &QAbstractListModel::rowsInserted, this, &AppDrawerProxyModel::countChanged);
1213 connect(this, &QAbstractListModel::rowsRemoved, this, &AppDrawerProxyModel::countChanged);
@@ -97,7 +98,7 @@ QVariant AppDrawerProxyModel::data(const QModelIndex &index, int role) const
9798 QModelIndex idx = mapToSource(index);
9899 if (role == Qt::UserRole) {
99100 QString name = m_source->data(idx, AppDrawerModelInterface::RoleName).toString();
100− return name.length() > 0 ? QString(name.at(0)) : QChar();
101+ return name.length() > 0 ? QString(name.at(0)).toUpper() : QChar();
101102 }
102103 return m_source->data(idx, role);
103104}
@@ -121,7 +122,7 @@ bool AppDrawerProxyModel::filterAcceptsRow(int source_row, const QModelIndex &so
121122 QChar currentLetter = currentName.length() > 0 ? currentName.at(0) : QChar();
122123 QString previousName = m_source->data(m_source->index(source_row - 1,0 ), AppDrawerModelInterface::RoleName).toString();
123124 QChar previousLetter = previousName.length() > 0 ? previousName.at(0) : QChar();
124− if (currentLetter == previousLetter) {
125+ if (currentLetter.toLower() == previousLetter.toLower()) {
125126 return false;
126127 }
127128 } else if(m_group == GroupByAll && source_row > 0) {
@@ -130,7 +131,7 @@ bool AppDrawerProxyModel::filterAcceptsRow(int source_row, const QModelIndex &so
130131 if (!m_filterLetter.isEmpty()) {
131132 QString currentName = m_source->data(m_source->index(source_row, 0), AppDrawerModelInterface::RoleName).toString();
132133 QString currentLetter = currentName.length() > 0 ? QString(currentName.at(0)) : QString();
133− if (currentLetter != m_filterLetter) {
134+ if (currentLetter.toLower() != m_filterLetter.toLower()) {
134135 return false;
135136 }
136137 }
qml/Launcher/Drawer.qml+33−3
@@ -27,6 +27,7 @@ FocusScope {
2727 id: sortProxyModel
2828 source: appDrawerModel
2929 filterString: searchField.text
30+ sortBy: AppDrawerProxyModel.SortByAToZ
3031 }
3132
3233 Item {
@@ -57,6 +58,9 @@ FocusScope {
5758 },
5859 Action {
5960 text: i18n.ctr("Most used apps", "Most used")
61+ },
62+ Action {
63+ text: "DBG"
6064 }
6165 ]
6266
@@ -72,7 +76,13 @@ FocusScope {
7276 Loader {
7377 id: listLoader
7478 anchors { left: parent.left; top: sectionsContainer.bottom; right: parent.right; bottom: parent.bottom; leftMargin: units.gu(1); rightMargin: units.gu(1) }
75− sourceComponent: sections.selectedIndex == 0 ? aToZComponent : mostUsedComponent
79+ sourceComponent: {
80+ switch (sections.selectedIndex) {
81+ case 0: return aToZComponent;
82+ case 1: return mostUsedComponent;
83+ default: return debugComponent;
84+ }
85+ }
7686 }
7787
7888 MouseArea {
@@ -108,6 +118,27 @@ FocusScope {
108118 }
109119 }
110120
121+ Component {
122+ id: debugComponent
123+ ListView {
124+ anchors.fill: parent
125+ topMargin: units.gu(1)
126+ bottomMargin: units.gu(1)
127+ spacing: units.gu(1)
128+ clip: true
129+
130+ model: sortProxyModel
131+// model: AppDrawerProxyModel {
132+// source: sortProxyModel
133+// group: AppDrawerProxyModel.GroupByAToZ
134+// sortBy: AppDrawerProxyModel.SortByAToZ
135+// }
136+ delegate: Label {
137+ text: model.letter + " - " + model.name
138+ }
139+ }
140+ }
141+
111142 Component {
112143 id: mostUsedComponent
113144 ListView {
@@ -135,7 +166,6 @@ FocusScope {
135166 // NOTE: Cannot use gridView.rows here as it would evaluate to 0 at first and only update later,
136167 // which messes up the ListView.
137168 height: (Math.ceil(mostUsedGridView.model.count / mostUsedGridView.columns) * mostUsedGridView.delegateHeight) + units.gu(2)
138− enabled: parent.interactive
139169
140170 DrawerGridView {
141171 id: mostUsedGridView
@@ -170,6 +200,7 @@ FocusScope {
170200
171201 model: AppDrawerProxyModel {
172202 source: sortProxyModel
203+ sortBy: AppDrawerProxyModel.SortByAToZ
173204 group: AppDrawerProxyModel.GroupByAToZ
174205 }
175206
@@ -177,7 +208,6 @@ FocusScope {
177208 width: parent.width
178209 color: "#20ffffff"
179210 aspect: UbuntuShape.Flat
180− enabled: parent.interactive
181211
182212 // NOTE: Cannot use gridView.rows here as it would evaluate to 0 at first and only update later,
183213 // which messes up the ListView.