@@ -83,15 +83,16 @@ class TaskModel : public QAbstractListModel {
83
83
migrators_ = factory_->list (availableAddons);
84
84
migratorStatesCache_.resize (migrators_.size ());
85
85
int idx = 0 ;
86
- availMigrators_ = 0 ;
86
+ auto tmpAvailMigrators = 0 ;
87
87
for (const auto &migrator : migrators_) {
88
88
migratorStatesCache_[idx] = migrator->check ();
89
89
if (migratorStatesCache_[idx]) {
90
- availMigrators_ ++;
90
+ tmpAvailMigrators ++;
91
91
}
92
92
idx++;
93
93
}
94
94
selected_.clear ();
95
+ setAvailMigrators (tmpAvailMigrators);
95
96
endResetModel ();
96
97
Q_EMIT selectedChanged ();
97
98
}
@@ -116,7 +117,7 @@ class TaskModel : public QAbstractListModel {
116
117
}
117
118
118
119
bool allSelected () const {
119
- return static_cast <int >(availMigrators_) == selected_.size ();
120
+ return availMigrators_ != 0 && static_cast <int >(availMigrators_) == selected_.size ();
120
121
}
121
122
122
123
bool someSelected () const { return !selected_.isEmpty (); }
@@ -129,8 +130,16 @@ class TaskModel : public QAbstractListModel {
129
130
return result;
130
131
}
131
132
133
+ void setAvailMigrators (int availMigrators) {
134
+ if (availMigrators == static_cast <int >(availMigrators_))
135
+ return ;
136
+ availMigrators_ = availMigrators;
137
+ Q_EMIT availMigratorsChanged (availMigrators_);
138
+ }
139
+
132
140
Q_SIGNALS:
133
141
void selectedChanged ();
142
+ void availMigratorsChanged (int );
134
143
135
144
private:
136
145
const MigratorFactory *factory_;
@@ -148,7 +157,8 @@ TaskPage::TaskPage(MainWindow *parent)
148
157
taskView->setModel (model_);
149
158
fcitxNotRunningMessage->setVisible (!parent_->dbus ()->available ());
150
159
151
- descriptionLabel->setText (_ (" Click on an item for more details." ));
160
+ selectAllBox->hide ();
161
+ descriptionLabel->setText (_ (" No available migrators." ));
152
162
connect (taskView->selectionModel (), &QItemSelectionModel::currentChanged,
153
163
this , [this ](const QModelIndex ¤t) {
154
164
if (current.isValid ()) {
@@ -163,6 +173,15 @@ TaskPage::TaskPage(MainWindow *parent)
163
173
selectAllBox->setChecked (model_->allSelected ());
164
174
Q_EMIT completeChanged ();
165
175
});
176
+ connect (model_, &TaskModel::availMigratorsChanged, this , [this ](int availMigrators) {
177
+ if (!availMigrators) {
178
+ selectAllBox->hide ();
179
+ descriptionLabel->setText (_ (" No available migrators." ));
180
+ } else {
181
+ selectAllBox->show ();
182
+ descriptionLabel->setText (_ (" Click on an item for more details." ));
183
+ }
184
+ });
166
185
connect (selectAllBox, &QCheckBox::clicked, this , [this ](bool checked) {
167
186
if (checked) {
168
187
model_->selectAll ();
0 commit comments