Changeset View
Changeset View
Standalone View
Standalone View
resources/imap/subscriptiondialog.cpp
Show First 20 Lines • Show All 319 Lines • ▼ Show 20 Line(s) | 309 | if (item->checkState() != item->data(InitialStateRole).toInt()) { | |||
---|---|---|---|---|---|
320 | } | 320 | } | ||
321 | 321 | | |||
322 | m_subscriptionChanged = true; | 322 | m_subscriptionChanged = true; | ||
323 | } | 323 | } | ||
324 | } | 324 | } | ||
325 | } | 325 | } | ||
326 | 326 | | |||
327 | SubscriptionFilterProxyModel::SubscriptionFilterProxyModel(QObject *parent) | 327 | SubscriptionFilterProxyModel::SubscriptionFilterProxyModel(QObject *parent) | ||
328 | : KRecursiveFilterProxyModel(parent) | 328 | : QSortFilterProxyModel(parent) | ||
329 | { | 329 | { | ||
330 | setRecursiveFilteringEnabled(true); | ||||
330 | } | 331 | } | ||
331 | 332 | | |||
332 | void SubscriptionFilterProxyModel::setSearchPattern(const QString &pattern) | 333 | void SubscriptionFilterProxyModel::setSearchPattern(const QString &pattern) | ||
333 | { | 334 | { | ||
334 | if (m_pattern != pattern) { | 335 | if (m_pattern != pattern) { | ||
335 | m_pattern = pattern; | 336 | m_pattern = pattern; | ||
336 | invalidate(); | 337 | invalidate(); | ||
337 | } | 338 | } | ||
338 | } | 339 | } | ||
339 | 340 | | |||
340 | void SubscriptionFilterProxyModel::setIncludeCheckedOnly(bool checkedOnly) | 341 | void SubscriptionFilterProxyModel::setIncludeCheckedOnly(bool checkedOnly) | ||
341 | { | 342 | { | ||
342 | if (m_checkedOnly != checkedOnly) { | 343 | if (m_checkedOnly != checkedOnly) { | ||
343 | m_checkedOnly = checkedOnly; | 344 | m_checkedOnly = checkedOnly; | ||
344 | invalidate(); | 345 | invalidate(); | ||
345 | } | 346 | } | ||
346 | } | 347 | } | ||
347 | 348 | | |||
348 | void SubscriptionFilterProxyModel::setIncludeCheckedOnly(int checkedOnlyState) | 349 | void SubscriptionFilterProxyModel::setIncludeCheckedOnly(int checkedOnlyState) | ||
349 | { | 350 | { | ||
350 | m_checkedOnly = (checkedOnlyState == Qt::Checked); | 351 | m_checkedOnly = (checkedOnlyState == Qt::Checked); | ||
351 | invalidate(); | 352 | invalidate(); | ||
352 | } | 353 | } | ||
353 | 354 | | |||
354 | bool SubscriptionFilterProxyModel::acceptRow(int sourceRow, const QModelIndex &sourceParent) const | 355 | bool SubscriptionFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const | ||
355 | { | 356 | { | ||
356 | QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent); | 357 | QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent); | ||
357 | 358 | | |||
358 | const bool checked = sourceIndex.data(Qt::CheckStateRole).toInt() == Qt::Checked; | 359 | const bool checked = sourceIndex.data(Qt::CheckStateRole).toInt() == Qt::Checked; | ||
359 | 360 | | |||
360 | if (m_checkedOnly && !checked) { | 361 | if (m_checkedOnly && !checked) { | ||
361 | return false; | 362 | return false; | ||
362 | } else if (!m_pattern.isEmpty()) { | 363 | } else if (!m_pattern.isEmpty()) { | ||
363 | const QString text = sourceIndex.data(Qt::DisplayRole).toString(); | 364 | const QString text = sourceIndex.data(Qt::DisplayRole).toString(); | ||
364 | return text.contains(m_pattern, Qt::CaseInsensitive); | 365 | return text.contains(m_pattern, Qt::CaseInsensitive); | ||
365 | } else { | 366 | } else { | ||
366 | return true; | 367 | return true; | ||
367 | } | 368 | } | ||
368 | } | 369 | } |