X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/5f57256a2f293622c7a10844adae29190907b9eb..3e95a6cccc76d61473a2815457beefaaae62ec7c:/src/kitemviews/kitemlistviewaccessible.cpp diff --git a/src/kitemviews/kitemlistviewaccessible.cpp b/src/kitemviews/kitemlistviewaccessible.cpp index c593dad82..ffc088bdb 100644 --- a/src/kitemviews/kitemlistviewaccessible.cpp +++ b/src/kitemviews/kitemlistviewaccessible.cpp @@ -1,21 +1,8 @@ -/*************************************************************************** - * Copyright (C) 2012 by Amandeep Singh * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ +/* + * SPDX-FileCopyrightText: 2012 Amandeep Singh + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #ifndef QT_NO_ACCESSIBILITY @@ -27,11 +14,8 @@ #include "kitemlistview.h" #include "private/kitemlistviewlayouter.h" -#include -#include -#include - -#include +#include +#include KItemListView* KItemListViewAccessible::view() const { @@ -47,10 +31,9 @@ KItemListViewAccessible::KItemListViewAccessible(KItemListView* view_) : KItemListViewAccessible::~KItemListViewAccessible() { - foreach (QAccessibleInterface* child, m_cells) { - if (child) { - QAccessible::Id childId = QAccessible::uniqueId(child); - QAccessible::deleteAccessibleInterface(childId); + for (AccessibleIdWrapper idWrapper : qAsConst(m_cells)) { + if (idWrapper.isValid) { + QAccessible::deleteAccessibleInterface(idWrapper.id); } } } @@ -78,12 +61,13 @@ QAccessibleInterface* KItemListViewAccessible::cell(int index) const } Q_ASSERT(index < m_cells.size()); - QAccessibleInterface* child = m_cells.at(index); - if (!child) { - child = new KItemListAccessibleCell(view(), index); - QAccessible::registerAccessibleInterface(child); + AccessibleIdWrapper idWrapper = m_cells.at(index); + if (!idWrapper.isValid) { + idWrapper.id = QAccessible::registerAccessibleInterface(new KItemListAccessibleCell(view(), index)); + idWrapper.isValid = true; + m_cells.insert(index, idWrapper); } - return child; + return QAccessible::accessibleInterface(idWrapper.id); } QAccessibleInterface* KItemListViewAccessible::cellAt(int row, int column) const @@ -268,6 +252,12 @@ QAccessibleInterface* KItemListViewAccessible::child(int index) const return nullptr; } +KItemListViewAccessible::AccessibleIdWrapper::AccessibleIdWrapper() : + isValid(false), + id(0) +{ +} + // Table Cell KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index) : @@ -418,7 +408,7 @@ int KItemListAccessibleCell::childCount() const int KItemListAccessibleCell::indexOfChild(const QAccessibleInterface* child) const { - Q_UNUSED(child); + Q_UNUSED(child) return -1; }