diff options
Diffstat (limited to 'src/kitemviews')
43 files changed, 529 insertions, 648 deletions
diff --git a/src/kitemviews/kfileitemlistview.cpp b/src/kitemviews/kfileitemlistview.cpp index fd01f2c4c..32d390331 100644 --- a/src/kitemviews/kfileitemlistview.cpp +++ b/src/kitemviews/kfileitemlistview.cpp @@ -22,16 +22,13 @@ #include "kfileitemmodelrolesupdater.h" #include "kfileitemlistwidget.h" #include "kfileitemmodel.h" -#include <KLocale> -#include <KStringHandler> #include "private/kpixmapmodifier.h" #include <KDebug> -#include <KIcon> -#include <KTextEdit> +#include <QIcon> +#include <KIconLoader> #include <QPainter> -#include <QTextLine> #include <QTimer> // #define KFILEITEMLISTVIEW_DEBUG @@ -62,12 +59,12 @@ KFileItemListView::KFileItemListView(QGraphicsWidget* parent) : m_updateVisibleIndexRangeTimer = new QTimer(this); m_updateVisibleIndexRangeTimer->setSingleShot(true); m_updateVisibleIndexRangeTimer->setInterval(ShortInterval); - connect(m_updateVisibleIndexRangeTimer, SIGNAL(timeout()), this, SLOT(updateVisibleIndexRange())); + connect(m_updateVisibleIndexRangeTimer, &QTimer::timeout, this, &KFileItemListView::updateVisibleIndexRange); m_updateIconSizeTimer = new QTimer(this); m_updateIconSizeTimer->setSingleShot(true); m_updateIconSizeTimer->setInterval(LongInterval); - connect(m_updateIconSizeTimer, SIGNAL(timeout()), this, SLOT(updateIconSize())); + connect(m_updateIconSizeTimer, &QTimer::timeout, this, &KFileItemListView::updateIconSize); setVisibleRoles(QList<QByteArray>() << "text"); } @@ -169,7 +166,7 @@ QPixmap KFileItemListView::createDragPixmap(const KItemSet& indexes) const foreach (int index, indexes) { QPixmap pixmap = model()->data(index).value("iconPixmap").value<QPixmap>(); if (pixmap.isNull()) { - KIcon icon(model()->data(index).value("iconName").toString()); + QIcon icon = QIcon::fromTheme(model()->data(index).value("iconName").toString()); pixmap = icon.pixmap(size, size); } else { KPixmapModifier::scale(pixmap, QSize(size, size)); @@ -421,4 +418,3 @@ QSize KFileItemListView::availableIconSize() const return QSize(iconSize, iconSize); } -#include "kfileitemlistview.moc" diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp index fe8c7e997..a304ea69c 100644 --- a/src/kitemviews/kfileitemlistwidget.cpp +++ b/src/kitemviews/kfileitemlistwidget.cpp @@ -23,10 +23,11 @@ #include <kmimetype.h> #include <KDebug> -#include <KGlobal> #include <KLocale> #include <KIO/MetaData> #include <QDateTime> +#include <KFormat> +#include <QMimeDatabase> KFileItemListWidgetInformant::KFileItemListWidgetInformant() : KStandardItemListWidgetInformant() @@ -78,11 +79,11 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray& role, } } else { const KIO::filesize_t size = roleValue.value<KIO::filesize_t>(); - text = KGlobal::locale()->formatByteSize(size); + text = KFormat().formatByteSize(size); } } else if (role == "date") { const QDateTime dateTime = roleValue.toDateTime(); - text = KGlobal::locale()->formatDateTime(dateTime); + text = KLocale::global()->formatDateTime(dateTime); } else { text = KStandardItemListWidgetInformant::roleText(role, values); } @@ -142,7 +143,8 @@ int KFileItemListWidget::selectionLength(const QString& text) const return selectionLength; } - const QString extension = KMimeType::extractKnownExtension(text); + QMimeDatabase db; + const QString extension = db.suffixForFileName(text); if (extension.isEmpty()) { // For an unknown extension just exclude the extension after // the last point. This does not work for multiple extensions like @@ -161,4 +163,3 @@ int KFileItemListWidget::selectionLength(const QString& text) const return selectionLength; } -#include "kfileitemlistwidget.moc" diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 72acf776a..711b0797b 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -22,14 +22,14 @@ #include "kfileitemmodel.h" #include <KGlobalSettings> -#include <KLocale> +#include <KLocalizedString> #include <KStringHandler> #include <KDebug> +#include <kstringhandler_deprecated.h> //TODO: port to QCollator #include "private/kfileitemmodelsortalgorithm.h" #include "private/kfileitemmodeldirlister.h" -#include <QApplication> #include <QMimeData> #include <QTimer> #include <QWidget> @@ -68,17 +68,17 @@ KFileItemModel::KFileItemModel(QObject* parent) : m_dirLister->setMainWindow(parentWidget->window()); } - connect(m_dirLister, SIGNAL(started(KUrl)), this, SIGNAL(directoryLoadingStarted())); - connect(m_dirLister, SIGNAL(canceled()), this, SLOT(slotCanceled())); - connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted())); - connect(m_dirLister, SIGNAL(itemsAdded(KUrl,KFileItemList)), this, SLOT(slotItemsAdded(KUrl,KFileItemList))); - connect(m_dirLister, SIGNAL(itemsDeleted(KFileItemList)), this, SLOT(slotItemsDeleted(KFileItemList))); - connect(m_dirLister, SIGNAL(refreshItems(QList<QPair<KFileItem,KFileItem> >)), this, SLOT(slotRefreshItems(QList<QPair<KFileItem,KFileItem> >))); - connect(m_dirLister, SIGNAL(clear()), this, SLOT(slotClear())); - connect(m_dirLister, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString))); - connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString))); - connect(m_dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SIGNAL(directoryRedirection(KUrl,KUrl))); - connect(m_dirLister, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl))); + connect(m_dirLister, &KFileItemModelDirLister::started, this, &KFileItemModel::directoryLoadingStarted); + connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)()>(&KFileItemModelDirLister::canceled), this, &KFileItemModel::slotCanceled); + connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)(const QUrl&)>(&KFileItemModelDirLister::completed), this, &KFileItemModel::slotCompleted); + connect(m_dirLister, &KFileItemModelDirLister::itemsAdded, this, &KFileItemModel::slotItemsAdded); + connect(m_dirLister, &KFileItemModelDirLister::itemsDeleted, this, &KFileItemModel::slotItemsDeleted); + connect(m_dirLister, &KFileItemModelDirLister::refreshItems, this, &KFileItemModel::slotRefreshItems); + connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)()>(&KFileItemModelDirLister::clear), this, &KFileItemModel::slotClear); + connect(m_dirLister, &KFileItemModelDirLister::infoMessage, this, &KFileItemModel::infoMessage); + connect(m_dirLister, &KFileItemModelDirLister::errorMessage, this, &KFileItemModel::errorMessage); + connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)(const QUrl&, const QUrl&)>(&KFileItemModelDirLister::redirection), this, &KFileItemModel::directoryRedirection); + connect(m_dirLister, &KFileItemModelDirLister::urlIsFileError, this, &KFileItemModel::urlIsFileError); // Apply default roles that should be determined resetRoles(); @@ -94,7 +94,7 @@ KFileItemModel::KFileItemModel(QObject* parent) : m_maximumUpdateIntervalTimer = new QTimer(this); m_maximumUpdateIntervalTimer->setInterval(2000); m_maximumUpdateIntervalTimer->setSingleShot(true); - connect(m_maximumUpdateIntervalTimer, SIGNAL(timeout()), this, SLOT(dispatchPendingItemsToInsert())); + connect(m_maximumUpdateIntervalTimer, &QTimer::timeout, this, &KFileItemModel::dispatchPendingItemsToInsert); // When changing the value of an item which represents the sort-role a resorting must be // triggered. Especially in combination with KFileItemModelRolesUpdater this might be done @@ -103,9 +103,10 @@ KFileItemModel::KFileItemModel(QObject* parent) : m_resortAllItemsTimer = new QTimer(this); m_resortAllItemsTimer->setInterval(500); m_resortAllItemsTimer->setSingleShot(true); - connect(m_resortAllItemsTimer, SIGNAL(timeout()), this, SLOT(resortAllItems())); + connect(m_resortAllItemsTimer, &QTimer::timeout, this, &KFileItemModel::resortAllItems); - connect(KGlobalSettings::self(), SIGNAL(naturalSortingChanged()), this, SLOT(slotNaturalSortingChanged())); + connect(KGlobalSettings::self(), &KGlobalSettings::naturalSortingChanged, + this, &KFileItemModel::slotNaturalSortingChanged); } KFileItemModel::~KFileItemModel() @@ -115,15 +116,15 @@ KFileItemModel::~KFileItemModel() qDeleteAll(m_pendingItemsToInsert); } -void KFileItemModel::loadDirectory(const KUrl& url) +void KFileItemModel::loadDirectory(const QUrl &url) { m_dirLister->openUrl(url); } -void KFileItemModel::refreshDirectory(const KUrl& url) +void KFileItemModel::refreshDirectory(const QUrl &url) { // Refresh all expanded directories first (Bug 295300) - QHashIterator<KUrl, KUrl> expandedDirs(m_expandedDirs); + QHashIterator<QUrl, QUrl> expandedDirs(m_expandedDirs); while (expandedDirs.hasNext()) { expandedDirs.next(); m_dirLister->openUrl(expandedDirs.value(), KDirLister::Reload); @@ -132,7 +133,7 @@ void KFileItemModel::refreshDirectory(const KUrl& url) m_dirLister->openUrl(url, KDirLister::Reload); } -KUrl KFileItemModel::directory() const +QUrl KFileItemModel::directory() const { return m_dirLister->url(); } @@ -188,8 +189,9 @@ bool KFileItemModel::setData(int index, const QHash<QByteArray, QVariant>& value m_itemData[index]->values = currentValues; if (changedRoles.contains("text")) { - KUrl url = m_itemData[index]->item.url(); - url.setFileName(currentValues["text"].toString()); + QUrl url = m_itemData[index]->item.url(); + url = url.adjusted(QUrl::RemoveFilename); + url.setPath(url.path() + currentValues["text"].toString()); m_itemData[index]->item.setUrl(url); } @@ -242,8 +244,8 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const // The following code has been taken from KDirModel::mimeData() // (kdelibs/kio/kio/kdirmodel.cpp) // Copyright (C) 2006 David Faure <[email protected]> - KUrl::List urls; - KUrl::List mostLocalUrls; + QList<QUrl> urls; + QList<QUrl> mostLocalUrls; bool canUseMostLocalUrls = true; const ItemData* lastAddedItem = 0; @@ -275,9 +277,9 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const const bool different = canUseMostLocalUrls && mostLocalUrls != urls; if (different) { - urls.populateMimeData(mostLocalUrls, data); + data->setUrls(mostLocalUrls); } else { - urls.populateMimeData(data); + data->setUrls(urls); } return data; @@ -352,7 +354,7 @@ KFileItem KFileItemModel::fileItem(int index) const return KFileItem(); } -KFileItem KFileItemModel::fileItem(const KUrl& url) const +KFileItem KFileItemModel::fileItem(const QUrl &url) const { const int indexForUrl = index(url); if (indexForUrl >= 0) { @@ -366,10 +368,9 @@ int KFileItemModel::index(const KFileItem& item) const return index(item.url()); } -int KFileItemModel::index(const KUrl& url) const +int KFileItemModel::index(const QUrl& url) const { - KUrl urlToFind = url; - urlToFind.adjustPath(KUrl::RemoveTrailingSlash); + const QUrl urlToFind = url.adjusted(QUrl::StripTrailingSlash); const int itemCount = m_itemData.count(); int itemsInHash = m_items.count(); @@ -387,7 +388,7 @@ int KFileItemModel::index(const KUrl& url) const const int blockSize = 1000; const int currentBlockEnd = qMin(itemsInHash + blockSize, itemCount); for (int i = itemsInHash; i < currentBlockEnd; ++i) { - const KUrl nextUrl = m_itemData.at(i)->item.url(); + const QUrl nextUrl = m_itemData.at(i)->item.url(); m_items.insert(nextUrl, i); } @@ -411,12 +412,12 @@ int KFileItemModel::index(const KUrl& url) const kWarning() << "m_itemData.count() ==" << m_itemData.count(); // Check if there are multiple items with the same URL. - QMultiHash<KUrl, int> indexesForUrl; + QMultiHash<QUrl, int> indexesForUrl; for (int i = 0; i < m_itemData.count(); ++i) { indexesForUrl.insert(m_itemData.at(i)->item.url(), i); } - foreach (const KUrl& url, indexesForUrl.uniqueKeys()) { + foreach (const QUrl& url, indexesForUrl.uniqueKeys()) { if (indexesForUrl.count(url) > 1) { kWarning() << "Multiple items found with the URL" << url; foreach (int index, indexesForUrl.values(url)) { @@ -510,15 +511,15 @@ bool KFileItemModel::setExpanded(int index, bool expanded) } const KFileItem item = m_itemData.at(index)->item; - const KUrl url = item.url(); - const KUrl targetUrl = item.targetUrl(); + const QUrl url = item.url(); + const QUrl targetUrl = item.targetUrl(); if (expanded) { m_expandedDirs.insert(targetUrl, url); m_dirLister->openUrl(url, KDirLister::Keep); - const KUrl::List previouslyExpandedChildren = m_itemData.at(index)->values.value("previouslyExpandedChildren").value<KUrl::List>(); - foreach (const KUrl& url, previouslyExpandedChildren) { - m_urlsToExpand.insert(url); + const QVariantList previouslyExpandedChildren = m_itemData.at(index)->values.value("previouslyExpandedChildren").value<QVariantList>(); + foreach (const QVariant& var, previouslyExpandedChildren) { + m_urlsToExpand.insert(var.toUrl()); } } else { // Note that there might be (indirect) children of the folder which is to be collapsed in @@ -540,14 +541,14 @@ bool KFileItemModel::setExpanded(int index, bool expanded) const int itemCount = m_itemData.count(); const int firstChildIndex = index + 1; - KUrl::List expandedChildren; + QVariantList expandedChildren; int childIndex = firstChildIndex; while (childIndex < itemCount && expandedParentsCount(childIndex) > parentLevel) { ItemData* itemData = m_itemData.at(childIndex); if (itemData->values.value("isExpanded").toBool()) { - const KUrl targetUrl = itemData->item.targetUrl(); - const KUrl url = itemData->item.url(); + const QUrl targetUrl = itemData->item.targetUrl(); + const QUrl url = itemData->item.url(); m_expandedDirs.remove(targetUrl); m_dirLister->stop(url); // TODO: try to unit-test this, see https://bugs.kde.org/show_bug.cgi?id=332102#c11 expandedChildren.append(targetUrl); @@ -591,17 +592,17 @@ int KFileItemModel::expandedParentsCount(int index) const return 0; } -QSet<KUrl> KFileItemModel::expandedDirectories() const +QSet<QUrl> KFileItemModel::expandedDirectories() const { return m_expandedDirs.values().toSet(); } -void KFileItemModel::restoreExpandedDirectories(const QSet<KUrl>& urls) +void KFileItemModel::restoreExpandedDirectories(const QSet<QUrl> &urls) { m_urlsToExpand = urls; } -void KFileItemModel::expandParentDirectories(const KUrl& url) +void KFileItemModel::expandParentDirectories(const QUrl &url) { const int pos = m_dirLister->url().path().length(); @@ -609,17 +610,17 @@ void KFileItemModel::expandParentDirectories(const KUrl& url) // expanded is added to m_urlsToExpand. KDirLister // does not care whether the parent-URL has already been // expanded. - KUrl urlToExpand = m_dirLister->url(); + QUrl urlToExpand = m_dirLister->url(); const QStringList subDirs = url.path().mid(pos).split(QDir::separator()); for (int i = 0; i < subDirs.count() - 1; ++i) { - urlToExpand.addPath(subDirs.at(i)); + urlToExpand.setPath(urlToExpand.path() + '/' + subDirs.at(i)); m_urlsToExpand.insert(urlToExpand); } // KDirLister::open() must called at least once to trigger an initial // loading. The pending URLs that must be restored are handled // in slotCompleted(). - QSetIterator<KUrl> it2(m_urlsToExpand); + QSetIterator<QUrl> it2(m_urlsToExpand); while (it2.hasNext()) { const int idx = index(it2.next()); if (idx >= 0 && !isExpanded(idx)) { @@ -800,7 +801,7 @@ void KFileItemModel::resortAllItems() // Remember the order of the current URLs so // that it can be determined which indexes have // been moved because of the resorting. - QList<KUrl> oldUrls; + QList<QUrl> oldUrls; oldUrls.reserve(itemCount); foreach (const ItemData* itemData, m_itemData) { oldUrls.append(itemData->item.url()); @@ -869,7 +870,7 @@ void KFileItemModel::slotCompleted() // Note that the parent folder must be expanded before any of its subfolders become visible. // Therefore, some URLs in m_restoredExpandedUrls might not be visible yet // -> we expand the first visible URL we find in m_restoredExpandedUrls. - foreach (const KUrl& url, m_urlsToExpand) { + foreach (const QUrl& url, m_urlsToExpand) { const int indexForUrl = index(url); if (indexForUrl >= 0) { m_urlsToExpand.remove(url); @@ -897,16 +898,15 @@ void KFileItemModel::slotCanceled() emit directoryLoadingCanceled(); } -void KFileItemModel::slotItemsAdded(const KUrl& directoryUrl, const KFileItemList& items) +void KFileItemModel::slotItemsAdded(const QUrl &directoryUrl, const KFileItemList& items) { Q_ASSERT(!items.isEmpty()); - KUrl parentUrl; + QUrl parentUrl; if (m_expandedDirs.contains(directoryUrl)) { parentUrl = m_expandedDirs.value(directoryUrl); } else { - parentUrl = directoryUrl; - parentUrl.adjustPath(KUrl::RemoveTrailingSlash); + parentUrl = directoryUrl.adjusted(QUrl::StripTrailingSlash); } if (m_requestRole[ExpandedParentsCountRole]) { @@ -1201,7 +1201,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems) } // The indexes in m_items are not correct anymore. Therefore, we clear m_items. - // It will be re-populated with the updated indices if index(const KUrl&) is called. + // It will be re-populated with the updated indices if index(const QUrl&) is called. m_items.clear(); emit itemsInserted(itemRanges); @@ -1254,13 +1254,13 @@ void KFileItemModel::removeItems(const KItemRangeList& itemRanges, RemoveItemsBe m_itemData.erase(m_itemData.end() - removedItemsCount, m_itemData.end()); // The indexes in m_items are not correct anymore. Therefore, we clear m_items. - // It will be re-populated with the updated indices if index(const KUrl&) is called. + // It will be re-populated with the updated indices if index(const QUrl&) is called. m_items.clear(); emit itemsRemoved(itemRanges); } -QList<KFileItemModel::ItemData*> KFileItemModel::createItemDataList(const KUrl& parentUrl, const KFileItemList& items) const +QList<KFileItemModel::ItemData*> KFileItemModel::createItemDataList(const QUrl& parentUrl, const KFileItemList& items) const { if (m_sortRole == TypeRole) { // Try to resolve the MIME-types synchronously to prevent a reordering of @@ -1510,8 +1510,8 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item, // Don't use KFileItem::timeString() as this is too expensive when // having several thousands of items. Instead the formatting of the // date-time will be done on-demand by the view when the date will be shown. - const KDateTime dateTime = item.time(KFileItem::ModificationTime); - data.insert(sharedValue("date"), dateTime.dateTime()); + const QDateTime dateTime = item.time(KFileItem::ModificationTime); + data.insert(sharedValue("date"), dateTime); } if (m_requestRole[PermissionsRole]) { @@ -1536,7 +1536,7 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item, if (m_requestRole[PathRole]) { QString path; - if (item.url().protocol() == QLatin1String("trash")) { + if (item.url().scheme() == QLatin1String("trash")) { path = item.entry().stringValue(KIO::UDSEntry::UDS_EXTRA); } else { // For performance reasons cache the home-path in a static QString @@ -1715,8 +1715,8 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const } case DateRole: { - const KDateTime dateTimeA = itemA.time(KFileItem::ModificationTime); - const KDateTime dateTimeB = itemB.time(KFileItem::ModificationTime); + const QDateTime dateTimeA = itemA.time(KFileItem::ModificationTime); + const QDateTime dateTimeB = itemB.time(KFileItem::ModificationTime); if (dateTimeA < dateTimeB) { result = -1; } else if (dateTimeA > dateTimeB) { @@ -1908,7 +1908,7 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const const int maxIndex = count() - 1; QList<QPair<int, QVariant> > groups; - const QDate currentDate = KDateTime::currentLocalDateTime().date(); + const QDate currentDate = QDate::currentDate(); QDate previousModifiedDate; QString groupValue; @@ -1917,7 +1917,7 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const continue; } - const KDateTime modifiedTime = m_itemData.at(i)->item.time(KFileItem::ModificationTime); + const QDateTime modifiedTime = m_itemData.at(i)->item.time(KFileItem::ModificationTime); const QDate modifiedDate = modifiedTime.date(); if (modifiedDate == previousModifiedDate) { // The current item is in the same group as the previous item @@ -2004,7 +2004,7 @@ QList<QPair<int, QVariant> > KFileItemModel::permissionRoleGroups() const } permissionsString = newPermissionsString; - const QFileInfo info(itemData->item.url().pathOrUrl()); + const QFileInfo info(itemData->item.url().toLocalFile()); // Set user string QString user; @@ -2199,7 +2199,7 @@ QByteArray KFileItemModel::sharedValue(const QByteArray& value) bool KFileItemModel::isConsistent() const { // m_items may contain less items than m_itemData because m_items - // is populated lazily, see KFileItemModel::index(const KUrl& url). + // is populated lazily, see KFileItemModel::index(const QUrl& url). if (m_items.count() > m_itemData.count()) { return false; } @@ -2245,4 +2245,3 @@ bool KFileItemModel::isConsistent() const return true; } -#include "kfileitemmodel.moc" diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index 62a283d33..1a4f6928e 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -22,7 +22,7 @@ #include <libdolphin_export.h> #include <KFileItemList> -#include <KUrl> +#include <QUrl> #include <kitemviews/kitemmodelbase.h> #include <kitemviews/private/kfileitemmodelfilter.h> @@ -56,13 +56,13 @@ public: * indicate the current state of the loading process. The items * of the directory are added after the loading has been completed. */ - void loadDirectory(const KUrl& url); + void loadDirectory(const QUrl& url); /** * Throws away all currently loaded items and refreshes the directory * by reloading all items again. */ - void refreshDirectory(const KUrl& url); + void refreshDirectory(const QUrl& url); /** * @return Parent directory of the items that are shown. In case @@ -70,7 +70,7 @@ public: * the root-parent of all items. * @see rootItem() */ - KUrl directory() const; + QUrl directory() const; /** * Cancels the loading of a directory which has been started by either @@ -126,7 +126,7 @@ public: * URL is found KFileItem::isNull() will be true for the returned * file-item. The runtime complexity of this call is O(1). */ - KFileItem fileItem(const KUrl& url) const; + KFileItem fileItem(const QUrl& url) const; /** * @return The index for the file-item \a item. -1 is returned if no file-item @@ -139,7 +139,7 @@ public: * @return The index for the URL \a url. -1 is returned if no file-item * is found. The amortized runtime complexity of this call is O(1). */ - int index(const KUrl& url) const; + int index(const QUrl &url) const; /** * @return Root item of all items representing the item @@ -163,19 +163,19 @@ public: virtual bool isExpandable(int index) const; virtual int expandedParentsCount(int index) const; - QSet<KUrl> expandedDirectories() const; + QSet<QUrl> expandedDirectories() const; /** * Marks the URLs in \a urls as sub-directories which were expanded previously. * After calling loadDirectory() or refreshDirectory() the marked sub-directories * will be expanded step-by-step. */ - void restoreExpandedDirectories(const QSet<KUrl>& urls); + void restoreExpandedDirectories(const QSet<QUrl>& urls); /** * Expands all parent-directories of the item \a url. */ - void expandParentDirectories(const KUrl& url); + void expandParentDirectories(const QUrl& url); void setNameFilter(const QString& nameFilter); QString nameFilter() const; @@ -251,13 +251,13 @@ signals: * Is emitted if a redirection from the current URL \a oldUrl * to the new URL \a newUrl has been done. */ - void directoryRedirection(const KUrl& oldUrl, const KUrl& newUrl); + void directoryRedirection(const QUrl& oldUrl, const QUrl& newUrl); /** * Is emitted when the URL passed by KFileItemModel::setUrl() represents a file. * In this case no signal errorMessage() will be emitted. */ - void urlIsFileError(const KUrl& url); + void urlIsFileError(const QUrl& url); protected: virtual void onGroupedSortingChanged(bool current); @@ -273,7 +273,7 @@ private slots: void slotCompleted(); void slotCanceled(); - void slotItemsAdded(const KUrl& directoryUrl, const KFileItemList& items); + void slotItemsAdded(const QUrl& directoryUrl, const KFileItemList& items); void slotItemsDeleted(const KFileItemList& items); void slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& items); void slotClear(); @@ -317,7 +317,7 @@ private: * Note that the ItemData instances are created dynamically and * must be deleted by the caller. */ - QList<ItemData*> createItemDataList(const KUrl& parentUrl, const KFileItemList& items) const; + QList<ItemData*> createItemDataList(const QUrl& parentUrl, const KFileItemList& items) const; /** * Prepares the items for sorting. Normally, the hash 'values' in ItemData is filled @@ -470,11 +470,11 @@ private: QList<ItemData*> m_itemData; - // m_items is a cache for the method index(const KUrl&). If it contains N + // m_items is a cache for the method index(const QUrl&). If it contains N // entries, it is guaranteed that these correspond to the first N items in // the model, i.e., that (for every i between 0 and N - 1) // m_items.value(fileItem(i).url()) == i - mutable QHash<KUrl, int> m_items; + mutable QHash<QUrl, int> m_items; KFileItemModelFilter m_filter; QHash<KFileItem, ItemData*> m_filteredItems; // Items that got hidden by KFileItemModel::setNameFilter() @@ -489,11 +489,11 @@ private: mutable QList<QPair<int, QVariant> > m_groups; // Stores the URLs (key: target url, value: url) of the expanded directories. - QHash<KUrl, KUrl> m_expandedDirs; + QHash<QUrl, QUrl> m_expandedDirs; // URLs that must be expanded. The expanding is initially triggered in setExpanded() // and done step after step in slotCompleted(). - QSet<KUrl> m_urlsToExpand; + QSet<QUrl> m_urlsToExpand; friend class KFileItemModelLessThan; // Accesses lessThan() method friend class KFileItemModelRolesUpdater; // Accesses emitSortProgress() method diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index 0865d40e7..2353f106f 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -25,7 +25,8 @@ #include <KConfigGroup> #include <KDebug> #include <KFileItem> -#include <KGlobal> +#include <KIconLoader> +#include <KJobWidgets> #include <KIO/JobUiDelegate> #include <KIO/PreviewJob> @@ -42,9 +43,8 @@ #ifdef HAVE_BALOO #include "private/kbaloorolesprovider.h" - #include <baloo/file.h> - #include <baloo/filefetchjob.h> - #include <baloo/filemonitor.h> + #include <Baloo/File> + #include <Baloo/FileMonitor> #endif // #define KFILEITEMMODELROLESUPDATER_DEBUG @@ -95,29 +95,29 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO { Q_ASSERT(model); - const KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings"); + const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings"); m_enabledPlugins = globalConfig.readEntry("Plugins", QStringList() << "directorythumbnail" << "imagethumbnail" << "jpegthumbnail"); - connect(m_model, SIGNAL(itemsInserted(KItemRangeList)), - this, SLOT(slotItemsInserted(KItemRangeList))); - connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)), - this, SLOT(slotItemsRemoved(KItemRangeList))); - connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); - connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), - this, SLOT(slotItemsMoved(KItemRange,QList<int>))); - connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)), - this, SLOT(slotSortRoleChanged(QByteArray,QByteArray))); + connect(m_model, &KFileItemModel::itemsInserted, + this, &KFileItemModelRolesUpdater::slotItemsInserted); + connect(m_model, &KFileItemModel::itemsRemoved, + this, &KFileItemModelRolesUpdater::slotItemsRemoved); + connect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); + connect(m_model, &KFileItemModel::itemsMoved, + this, &KFileItemModelRolesUpdater::slotItemsMoved); + connect(m_model, &KFileItemModel::sortRoleChanged, + this, &KFileItemModelRolesUpdater::slotSortRoleChanged); // Use a timer to prevent that each call of slotItemsChanged() results in a synchronous // resolving of the roles. Postpone the resolving until no update has been done for 1 second. m_recentlyChangedItemsTimer = new QTimer(this); m_recentlyChangedItemsTimer->setInterval(1000); m_recentlyChangedItemsTimer->setSingleShot(true); - connect(m_recentlyChangedItemsTimer, SIGNAL(timeout()), this, SLOT(resolveRecentlyChangedItems())); + connect(m_recentlyChangedItemsTimer, &QTimer::timeout, this, &KFileItemModelRolesUpdater::resolveRecentlyChangedItems); m_resolvableRoles.insert("size"); m_resolvableRoles.insert("type"); @@ -127,8 +127,8 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO #endif m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this); - connect(m_directoryContentsCounter, SIGNAL(result(QString,int)), - this, SLOT(slotDirectoryContentsCountReceived(QString,int))); + connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result, + this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived); } KFileItemModelRolesUpdater::~KFileItemModelRolesUpdater() @@ -280,8 +280,8 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles) if (hasBalooRole && !m_balooFileMonitor) { m_balooFileMonitor = new Baloo::FileMonitor(this); - connect(m_balooFileMonitor, SIGNAL(fileMetaDataChanged(QString)), - this, SLOT(applyChangedBalooRoles(QString))); + connect(m_balooFileMonitor, &Baloo::FileMonitor::fileMetaDataChanged, + this, &KFileItemModelRolesUpdater::applyChangedBalooRoles); } else if (!hasBalooRole && m_balooFileMonitor) { delete m_balooFileMonitor; m_balooFileMonitor = 0; @@ -543,11 +543,11 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi data.insert("iconPixmap", scaledPixmap); - disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + disconnect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); m_model->setData(index, data); - connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + connect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); m_finishedItems.insert(item); } @@ -565,11 +565,11 @@ void KFileItemModelRolesUpdater::slotPreviewFailed(const KFileItem& item) QHash<QByteArray, QVariant> data; data.insert("iconPixmap", QPixmap()); - disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + disconnect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); m_model->setData(index, data); - connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + connect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); applyResolvedRoles(index, ResolveAll); m_finishedItems.insert(item); @@ -625,11 +625,11 @@ void KFileItemModelRolesUpdater::resolveNextSortRole() m_state = Idle; // Prevent that we try to update the items twice. - disconnect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), - this, SLOT(slotItemsMoved(KItemRange,QList<int>))); + disconnect(m_model, &KFileItemModel::itemsMoved, + this, &KFileItemModelRolesUpdater::slotItemsMoved); applySortProgressToModel(); - connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), - this, SLOT(slotItemsMoved(KItemRange,QList<int>))); + connect(m_model, &KFileItemModel::itemsMoved, + this, &KFileItemModelRolesUpdater::slotItemsMoved); startUpdating(); } } @@ -665,15 +665,15 @@ void KFileItemModelRolesUpdater::resolveNextPendingRoles() QHash<QByteArray, QVariant> data; data.insert("iconPixmap", QPixmap()); - disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + disconnect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); for (int index = 0; index <= m_model->count(); ++index) { if (m_model->data(index).contains("iconPixmap")) { m_model->setData(index, data); } } - connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + connect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); } m_clearPreviews = false; @@ -703,21 +703,8 @@ void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& itemUrl) return; } - Baloo::FileFetchJob* job = new Baloo::FileFetchJob(item.localPath()); - connect(job, SIGNAL(finished(KJob*)), this, SLOT(applyChangedBalooRolesJobFinished(KJob*))); - job->setProperty("item", QVariant::fromValue(item)); - job->start(); -#else -#ifndef Q_CC_MSVC - Q_UNUSED(itemUrl); -#endif -#endif -} - -void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob) -{ -#ifdef HAVE_BALOO - const KFileItem item = kjob->property("item").value<KFileItem>(); + Baloo::File file(item.localPath()); + file.load(); const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance(); QHash<QByteArray, QVariant> data; @@ -729,19 +716,22 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob) data.insert(role, QVariant()); } - Baloo::FileFetchJob* job = static_cast<Baloo::FileFetchJob*>(kjob); - QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(job->file(), m_roles)); + QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(file, m_roles)); while (it.hasNext()) { it.next(); data.insert(it.key(), it.value()); } - disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + disconnect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); const int index = m_model->index(item); m_model->setData(index, data); - connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + connect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); +#else +#ifndef Q_CC_MSVC + Q_UNUSED(itemUrl); +#endif #endif } @@ -751,7 +741,7 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin const bool getIsExpandableRole = m_roles.contains("isExpandable"); if (getSizeRole || getIsExpandableRole) { - const int index = m_model->index(KUrl(path)); + const int index = m_model->index(QUrl::fromLocalFile(path)); if (index >= 0) { QHash<QByteArray, QVariant> data; @@ -762,11 +752,11 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin data.insert("isExpandable", count > 0); } - disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + disconnect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); m_model->setData(index, data); - connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + connect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); } } } @@ -897,15 +887,15 @@ void KFileItemModelRolesUpdater::startPreviewJob() job->setIgnoreMaximumSize(itemSubSet.first().isLocalFile()); if (job->ui()) { - job->ui()->setWindow(qApp->activeWindow()); + KJobWidgets::setWindow(job, qApp->activeWindow()); } - connect(job, SIGNAL(gotPreview(KFileItem,QPixmap)), - this, SLOT(slotGotPreview(KFileItem,QPixmap))); - connect(job, SIGNAL(failed(KFileItem)), - this, SLOT(slotPreviewFailed(KFileItem))); - connect(job, SIGNAL(finished(KJob*)), - this, SLOT(slotPreviewJobFinished())); + connect(job, &KIO::PreviewJob::gotPreview, + this, &KFileItemModelRolesUpdater::slotGotPreview); + connect(job, &KIO::PreviewJob::failed, + this, &KFileItemModelRolesUpdater::slotPreviewFailed); + connect(job, &KIO::PreviewJob::finished, + this, &KFileItemModelRolesUpdater::slotPreviewJobFinished); m_previewJob = job; } @@ -998,11 +988,11 @@ void KFileItemModelRolesUpdater::applySortRole(int index) data = rolesData(item); } - disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + disconnect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); m_model->setData(index, data); - connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + connect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); } void KFileItemModelRolesUpdater::applySortProgressToModel() @@ -1042,11 +1032,11 @@ bool KFileItemModelRolesUpdater::applyResolvedRoles(int index, ResolveHint hint) data.insert("iconPixmap", QPixmap()); } - disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + disconnect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); m_model->setData(index, data); - connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); + connect(m_model, &KFileItemModel::itemsChanged, + this, &KFileItemModelRolesUpdater::slotItemsChanged); return true; } @@ -1099,12 +1089,12 @@ void KFileItemModelRolesUpdater::updateAllPreviews() void KFileItemModelRolesUpdater::killPreviewJob() { if (m_previewJob) { - disconnect(m_previewJob, SIGNAL(gotPreview(KFileItem,QPixmap)), - this, SLOT(slotGotPreview(KFileItem,QPixmap))); - disconnect(m_previewJob, SIGNAL(failed(KFileItem)), - this, SLOT(slotPreviewFailed(KFileItem))); - disconnect(m_previewJob, SIGNAL(finished(KJob*)), - this, SLOT(slotPreviewJobFinished())); + disconnect(m_previewJob, &KIO::PreviewJob::gotPreview, + this, &KFileItemModelRolesUpdater::slotGotPreview); + disconnect(m_previewJob, &KIO::PreviewJob::failed, + this, &KFileItemModelRolesUpdater::slotPreviewFailed); + disconnect(m_previewJob, &KIO::PreviewJob::finished, + this, &KFileItemModelRolesUpdater::slotPreviewJobFinished); m_previewJob->kill(); m_previewJob = 0; m_pendingPreviewItems.clear(); @@ -1168,4 +1158,3 @@ QList<int> KFileItemModelRolesUpdater::indexesToResolve() const return result; } -#include "kfileitemmodelrolesupdater.moc" diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h index a9e979ae1..e8b186a96 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/src/kitemviews/kfileitemmodelrolesupdater.h @@ -34,10 +34,13 @@ class KDirectoryContentsCounter; class KFileItemModel; -class KJob; class QPixmap; class QTimer; +namespace KIO { + class PreviewJob; +} + #ifdef HAVE_BALOO namespace Baloo { @@ -201,7 +204,6 @@ private slots: void resolveRecentlyChangedItems(); void applyChangedBalooRoles(const QString& file); - void applyChangedBalooRolesJobFinished(KJob* job); void slotDirectoryContentsCountReceived(const QString& path, int count); @@ -316,7 +318,7 @@ private: // A new preview job will be started from them once the first one finishes. KFileItemList m_pendingPreviewItems; - KJob* m_previewJob; + KIO::PreviewJob* m_previewJob; // When downloading or copying large files, the slot slotItemsChanged() // will be called periodically within a quite short delay. To prevent diff --git a/src/kitemviews/kitemlistcontainer.cpp b/src/kitemviews/kitemlistcontainer.cpp index 8498286c9..46ac4745e 100644 --- a/src/kitemviews/kitemlistcontainer.cpp +++ b/src/kitemviews/kitemlistcontainer.cpp @@ -31,7 +31,6 @@ #include <QApplication> #include <QGraphicsScene> #include <QGraphicsView> -#include <QPropertyAnimation> #include <QScrollBar> #include <QStyle> #include <QStyleOption> @@ -89,10 +88,10 @@ KItemListContainer::KItemListContainer(KItemListController* controller, QWidget* slotViewChanged(controller->view(), 0); } - connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), - this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*))); - connect(controller, SIGNAL(viewChanged(KItemListView*,KItemListView*)), - this, SLOT(slotViewChanged(KItemListView*,KItemListView*))); + connect(controller, &KItemListController::modelChanged, + this, &KItemListContainer::slotModelChanged); + connect(controller, &KItemListController::viewChanged, + this, &KItemListContainer::slotViewChanged); } KItemListContainer::~KItemListContainer() @@ -185,11 +184,15 @@ void KItemListContainer::wheelEvent(QWheelEvent* event) KItemListSmoothScroller* smoothScroller = scrollHorizontally ? m_horizontalSmoothScroller : m_verticalSmoothScroller; - const int numDegrees = event->delta() / 8; - const int numSteps = numDegrees / 15; - const QScrollBar* scrollBar = smoothScroller->scrollBar(); - smoothScroller->scrollTo(scrollBar->value() - numSteps * scrollBar->pageStep() / 4); + if (!event->pixelDelta().isNull()) { + const int numPixels = event->pixelDelta().y(); + smoothScroller->scrollTo(scrollBar->value() - numPixels); + } else { + const int numDegrees = event->angleDelta().y() / 8; + const int numSteps = numDegrees / 15; + smoothScroller->scrollTo(scrollBar->value() - numSteps * scrollBar->pageStep() / 4); + } event->accept(); } @@ -211,23 +214,33 @@ void KItemListContainer::slotViewChanged(KItemListView* current, KItemListView* QGraphicsScene* scene = static_cast<QGraphicsView*>(viewport())->scene(); if (previous) { scene->removeItem(previous); - disconnect(previous, SIGNAL(scrollOrientationChanged(Qt::Orientation,Qt::Orientation)), this, SLOT(slotScrollOrientationChanged(Qt::Orientation,Qt::Orientation))); - disconnect(previous, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar())); - disconnect(previous, SIGNAL(maximumScrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar())); - disconnect(previous, SIGNAL(itemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar())); - disconnect(previous, SIGNAL(maximumItemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar())); - disconnect(previous, SIGNAL(scrollTo(qreal)), this, SLOT(scrollTo(qreal))); + disconnect(previous, &KItemListView::scrollOrientationChanged, + this, &KItemListContainer::slotScrollOrientationChanged); + disconnect(previous, &KItemListView::scrollOffsetChanged, + this, &KItemListContainer::updateScrollOffsetScrollBar); + disconnect(previous, &KItemListView::maximumScrollOffsetChanged, + this, &KItemListContainer::updateScrollOffsetScrollBar); + disconnect(previous, &KItemListView::itemOffsetChanged, + this, &KItemListContainer::updateItemOffsetScrollBar); + disconnect(previous, &KItemListView::maximumItemOffsetChanged, + this, &KItemListContainer::updateItemOffsetScrollBar); + disconnect(previous, &KItemListView::scrollTo, this, &KItemListContainer::scrollTo); m_horizontalSmoothScroller->setTargetObject(0); m_verticalSmoothScroller->setTargetObject(0); } if (current) { scene->addItem(current); - connect(current, SIGNAL(scrollOrientationChanged(Qt::Orientation,Qt::Orientation)), this, SLOT(slotScrollOrientationChanged(Qt::Orientation,Qt::Orientation))); - connect(current, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar())); - connect(current, SIGNAL(maximumScrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar())); - connect(current, SIGNAL(itemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar())); - connect(current, SIGNAL(maximumItemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar())); - connect(current, SIGNAL(scrollTo(qreal)), this, SLOT(scrollTo(qreal))); + connect(current, &KItemListView::scrollOrientationChanged, + this, &KItemListContainer::slotScrollOrientationChanged); + connect(current, &KItemListView::scrollOffsetChanged, + this, &KItemListContainer::updateScrollOffsetScrollBar); + connect(current, &KItemListView::maximumScrollOffsetChanged, + this, &KItemListContainer::updateScrollOffsetScrollBar); + connect(current, &KItemListView::itemOffsetChanged, + this, &KItemListContainer::updateItemOffsetScrollBar); + connect(current, &KItemListView::maximumItemOffsetChanged, + this, &KItemListContainer::updateItemOffsetScrollBar); + connect(current, &KItemListView::scrollTo, this, &KItemListContainer::scrollTo); m_horizontalSmoothScroller->setTargetObject(current); m_verticalSmoothScroller->setTargetObject(current); updateSmoothScrollers(current->scrollOrientation()); @@ -403,4 +416,3 @@ void KItemListContainer::updateScrollOffsetScrollBarPolicy() } } -#include "kitemlistcontainer.moc" diff --git a/src/kitemviews/kitemlistcontainer.h b/src/kitemviews/kitemlistcontainer.h index 474a9ecc0..3373059d1 100644 --- a/src/kitemviews/kitemlistcontainer.h +++ b/src/kitemviews/kitemlistcontainer.h @@ -25,14 +25,12 @@ #include <libdolphin_export.h> -#include <QAbstractAnimation> #include <QAbstractScrollArea> class KItemListController; class KItemListSmoothScroller; class KItemListView; class KItemModelBase; -class QPropertyAnimation; /** * @brief Provides a QWidget based scrolling view for a KItemListController. diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 8e2ef5ef3..1cd06c7e1 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -61,15 +61,15 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v m_keyboardAnchorIndex(-1), m_keyboardAnchorPos(0) { - connect(m_keyboardManager, SIGNAL(changeCurrentItem(QString,bool)), - this, SLOT(slotChangeCurrentItem(QString,bool))); - connect(m_selectionManager, SIGNAL(currentChanged(int,int)), - m_keyboardManager, SLOT(slotCurrentChanged(int,int))); + connect(m_keyboardManager, &KItemListKeyboardSearchManager::changeCurrentItem, + this, &KItemListController::slotChangeCurrentItem); + connect(m_selectionManager, &KItemListSelectionManager::currentChanged, + m_keyboardManager, &KItemListKeyboardSearchManager::slotCurrentChanged); m_autoActivationTimer = new QTimer(this); m_autoActivationTimer->setSingleShot(true); m_autoActivationTimer->setInterval(-1); - connect(m_autoActivationTimer, SIGNAL(timeout()), this, SLOT(slotAutoActivationTimeout())); + connect(m_autoActivationTimer, &QTimer::timeout, this, &KItemListController::slotAutoActivationTimeout); setModel(model); setView(view); @@ -127,7 +127,7 @@ void KItemListController::setView(KItemListView* view) KItemListView* oldView = m_view; if (oldView) { - disconnect(oldView, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(slotViewScrollOffsetChanged(qreal,qreal))); + disconnect(oldView, &KItemListView::scrollOffsetChanged, this, &KItemListController::slotViewScrollOffsetChanged); oldView->deleteLater(); } @@ -137,7 +137,7 @@ void KItemListController::setView(KItemListView* view) m_view->setParent(this); m_view->setController(this); m_view->setModel(m_model); - connect(m_view, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(slotViewScrollOffsetChanged(qreal,qreal))); + connect(m_view, &KItemListView::scrollOffsetChanged, this, &KItemListController::slotViewScrollOffsetChanged); updateExtendedSelectionRegion(); } @@ -538,8 +538,7 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const m_pressedIndex = m_view->itemAt(m_pressedMousePos); emit mouseButtonPressed(m_pressedIndex, event->buttons()); - // TODO: Qt5: Replace Qt::XButton1 by Qt::BackButton and Qt::XButton2 by Qt::ForwardButton - if (event->buttons() & (Qt::XButton1 | Qt::XButton2)) { + if (event->buttons() & (Qt::BackButton | Qt::ForwardButton)) { // Do not select items when clicking the back/forward buttons, see // https://bugs.kde.org/show_bug.cgi?id=327412. return true; @@ -655,7 +654,7 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const rubberBand->setStartPosition(startPos); rubberBand->setEndPosition(startPos); rubberBand->setActive(true); - connect(rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandChanged())); + connect(rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListController::slotRubberBandChanged); m_view->setAutoScroll(true); } @@ -743,7 +742,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con KItemListRubberBand* rubberBand = m_view->rubberBand(); if (rubberBand->isActive()) { - disconnect(rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandChanged())); + disconnect(rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListController::slotRubberBandChanged); rubberBand->setActive(false); m_oldSelection.clear(); m_view->setAutoScroll(false); @@ -1310,4 +1309,3 @@ void KItemListController::updateExtendedSelectionRegion() } } -#include "kitemlistcontroller.moc" diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h index e9b70cdda..99df53104 100644 --- a/src/kitemviews/kitemlistcontroller.h +++ b/src/kitemviews/kitemlistcontroller.h @@ -28,9 +28,8 @@ #include "kitemset.h" #include <QObject> -#include <QPixmap> #include <QPointF> - +class QTimer; class KItemModelBase; class KItemListKeyboardSearchManager; class KItemListSelectionManager; @@ -44,7 +43,6 @@ class QGraphicsSceneWheelEvent; class QHideEvent; class QInputMethodEvent; class QKeyEvent; -class QMimeData; class QShowEvent; class QTransform; diff --git a/src/kitemviews/kitemlistgroupheader.cpp b/src/kitemviews/kitemlistgroupheader.cpp index 17c95a97c..accaf9ecf 100644 --- a/src/kitemviews/kitemlistgroupheader.cpp +++ b/src/kitemviews/kitemlistgroupheader.cpp @@ -233,4 +233,3 @@ QColor KItemListGroupHeader::baseColor() const return styleOption().palette.color(group, normalBaseColorRole()); } -#include "kitemlistgroupheader.moc" diff --git a/src/kitemviews/kitemlistheader.cpp b/src/kitemviews/kitemlistheader.cpp index e89ece0a1..a3fa14d35 100644 --- a/src/kitemviews/kitemlistheader.cpp +++ b/src/kitemviews/kitemlistheader.cpp @@ -81,8 +81,7 @@ KItemListHeader::KItemListHeader(KItemListView* listView) : m_headerWidget = m_view->m_headerWidget; Q_ASSERT(m_headerWidget); - connect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)), - this, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal))); + connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged, + this, &KItemListHeader::columnWidthChanged); } -#include "kitemlistheader.moc" diff --git a/src/kitemviews/kitemlistselectionmanager.cpp b/src/kitemviews/kitemlistselectionmanager.cpp index 1f0a89d06..ba524a6bf 100644 --- a/src/kitemviews/kitemlistselectionmanager.cpp +++ b/src/kitemviews/kitemlistselectionmanager.cpp @@ -396,4 +396,4 @@ int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRa } return qBound(-1, index - dec, m_model->count() - 1); } -#include "kitemlistselectionmanager.moc" + diff --git a/src/kitemviews/kitemliststyleoption.cpp b/src/kitemviews/kitemliststyleoption.cpp index edd6363c8..1ebcad141 100644 --- a/src/kitemviews/kitemliststyleoption.cpp +++ b/src/kitemviews/kitemliststyleoption.cpp @@ -19,7 +19,6 @@ #include "kitemliststyleoption.h" -#include <KIconLoader> KItemListStyleOption::KItemListStyleOption() : rect(), diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index 756f9e39a..ea1ec3f3a 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -35,11 +35,9 @@ #include "private/kitemlistviewlayouter.h" #include "private/kitemlistviewanimation.h" -#include <QCursor> #include <QGraphicsSceneMouseEvent> #include <QGraphicsView> #include <QPainter> -#include <QPropertyAnimation> #include <QStyle> #include <QStyleOptionRubberBand> #include <QTimer> @@ -58,7 +56,7 @@ namespace { } #ifndef QT_NO_ACCESSIBILITY -QAccessibleInterface* accessibleInterfaceFactory(const QString &key, QObject *object) +QAccessibleInterface* accessibleInterfaceFactory(const QString& key, QObject* object) { Q_UNUSED(key) @@ -114,16 +112,16 @@ KItemListView::KItemListView(QGraphicsWidget* parent) : m_layouter = new KItemListViewLayouter(m_sizeHintResolver, this); m_animation = new KItemListViewAnimation(this); - connect(m_animation, SIGNAL(finished(QGraphicsWidget*,KItemListViewAnimation::AnimationType)), - this, SLOT(slotAnimationFinished(QGraphicsWidget*,KItemListViewAnimation::AnimationType))); + connect(m_animation, &KItemListViewAnimation::finished, + this, &KItemListView::slotAnimationFinished); m_layoutTimer = new QTimer(this); m_layoutTimer->setInterval(300); m_layoutTimer->setSingleShot(true); - connect(m_layoutTimer, SIGNAL(timeout()), this, SLOT(slotLayoutTimerFinished())); + connect(m_layoutTimer, &QTimer::timeout, this, &KItemListView::slotLayoutTimerFinished); m_rubberBand = new KItemListRubberBand(this); - connect(m_rubberBand, SIGNAL(activationChanged(bool)), this, SLOT(slotRubberBandActivationChanged(bool))); + connect(m_rubberBand, &KItemListRubberBand::activationChanged, this, &KItemListView::slotRubberBandActivationChanged); m_headerWidget = new KItemListHeaderWidget(this); m_headerWidget->setVisible(false); @@ -267,7 +265,7 @@ void KItemListView::setAutoScroll(bool enabled) if (enabled && !m_autoScrollTimer) { m_autoScrollTimer = new QTimer(this); m_autoScrollTimer->setSingleShot(true); - connect(m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(triggerAutoScrolling())); + connect(m_autoScrollTimer, &QTimer::timeout, this, &KItemListView::triggerAutoScrolling); m_autoScrollTimer->start(InitialAutoScrollDelay); } else if (!enabled && m_autoScrollTimer) { delete m_autoScrollTimer; @@ -572,26 +570,26 @@ void KItemListView::setHeaderVisible(bool visible) m_headerWidget->setColumns(m_visibleRoles); m_headerWidget->setZValue(1); - connect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)), - this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal))); - connect(m_headerWidget, SIGNAL(columnMoved(QByteArray,int,int)), - this, SLOT(slotHeaderColumnMoved(QByteArray,int,int))); - connect(m_headerWidget, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), - this, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder))); - connect(m_headerWidget, SIGNAL(sortRoleChanged(QByteArray,QByteArray)), - this, SIGNAL(sortRoleChanged(QByteArray,QByteArray))); + connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged, + this, &KItemListView::slotHeaderColumnWidthChanged); + connect(m_headerWidget, &KItemListHeaderWidget::columnMoved, + this, &KItemListView::slotHeaderColumnMoved); + connect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged, + this, &KItemListView::sortOrderChanged); + connect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged, + this, &KItemListView::sortRoleChanged); m_layouter->setHeaderHeight(headerSize.height()); m_headerWidget->setVisible(true); } else if (!visible && m_headerWidget->isVisible()) { - disconnect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)), - this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal))); - disconnect(m_headerWidget, SIGNAL(columnMoved(QByteArray,int,int)), - this, SLOT(slotHeaderColumnMoved(QByteArray,int,int))); - disconnect(m_headerWidget, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), - this, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder))); - disconnect(m_headerWidget, SIGNAL(sortRoleChanged(QByteArray,QByteArray)), - this, SIGNAL(sortRoleChanged(QByteArray,QByteArray))); + disconnect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged, + this, &KItemListView::slotHeaderColumnWidthChanged); + disconnect(m_headerWidget, &KItemListHeaderWidget::columnMoved, + this, &KItemListView::slotHeaderColumnMoved); + disconnect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged, + this, &KItemListView::sortOrderChanged); + disconnect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged, + this, &KItemListView::sortRoleChanged); m_layouter->setHeaderHeight(0); m_headerWidget->setVisible(false); @@ -637,10 +635,10 @@ void KItemListView::editRole(int index, const QByteArray& role) m_editingRole = true; widget->setEditedRole(role); - connect(widget, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)), - this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant))); - connect(widget, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), - this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant))); + connect(widget, &KItemListWidget::roleEditingCanceled, + this, &KItemListView::slotRoleEditingCanceled); + connect(widget, &KItemListWidget::roleEditingFinished, + this, &KItemListView::slotRoleEditingFinished); } void KItemListView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) @@ -936,7 +934,7 @@ void KItemListView::dragEnterEvent(QGraphicsSceneDragDropEvent* event) setAutoScroll(true); } -void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent *event) +void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent* event) { QGraphicsWidget::dragMoveEvent(event); @@ -946,7 +944,7 @@ void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent *event) } } -void KItemListView::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) +void KItemListView::dragLeaveEvent(QGraphicsSceneDragDropEvent* event) { QGraphicsWidget::dragLeaveEvent(event); setAutoScroll(false); @@ -1268,8 +1266,12 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges, updateVisibleGroupHeaders(); doLayout(NoAnimation); } + + QAccessibleTableModelChangeEvent ev(this, QAccessibleTableModelChangeEvent::DataChanged); + ev.setFirstRow(itemRange.index); + ev.setLastRow(itemRange.index + itemRange.count); + QAccessible::updateAccessibility(&ev); } - QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged); } void KItemListView::slotGroupsChanged() @@ -1345,7 +1347,10 @@ void KItemListView::slotCurrentChanged(int current, int previous) currentWidget->setCurrent(true); } } - QAccessible::updateAccessibility(this, current+1, QAccessible::Focus); + + QAccessibleEvent ev(this, QAccessible::Focus); + ev.setChild(current); + QAccessible::updateAccessibility(&ev); } void KItemListView::slotSelectionChanged(const KItemSet& current, const KItemSet& previous) @@ -1412,12 +1417,12 @@ void KItemListView::slotRubberBandPosChanged() void KItemListView::slotRubberBandActivationChanged(bool active) { if (active) { - connect(m_rubberBand, SIGNAL(startPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged())); - connect(m_rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged())); + connect(m_rubberBand, &KItemListRubberBand::startPositionChanged, this, &KItemListView::slotRubberBandPosChanged); + connect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged); m_skipAutoScrollForRubberBand = true; } else { - disconnect(m_rubberBand, SIGNAL(startPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged())); - disconnect(m_rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged())); + disconnect(m_rubberBand, &KItemListRubberBand::startPositionChanged, this, &KItemListView::slotRubberBandPosChanged); + disconnect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged); m_skipAutoScrollForRubberBand = false; } @@ -1544,16 +1549,16 @@ void KItemListView::setController(KItemListController* controller) KItemListController* previous = m_controller; if (previous) { KItemListSelectionManager* selectionManager = previous->selectionManager(); - disconnect(selectionManager, SIGNAL(currentChanged(int,int)), this, SLOT(slotCurrentChanged(int,int))); - disconnect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), this, SLOT(slotSelectionChanged(KItemSet,KItemSet))); + disconnect(selectionManager, &KItemListSelectionManager::currentChanged, this, &KItemListView::slotCurrentChanged); + disconnect(selectionManager, &KItemListSelectionManager::selectionChanged, this, &KItemListView::slotSelectionChanged); } m_controller = controller; if (controller) { KItemListSelectionManager* selectionManager = controller->selectionManager(); - connect(selectionManager, SIGNAL(currentChanged(int,int)), this, SLOT(slotCurrentChanged(int,int))); - connect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), this, SLOT(slotSelectionChanged(KItemSet,KItemSet))); + connect(selectionManager, &KItemListSelectionManager::currentChanged, this, &KItemListView::slotCurrentChanged); + connect(selectionManager, &KItemListSelectionManager::selectionChanged, this, &KItemListView::slotSelectionChanged); } onControllerChanged(controller, previous); @@ -1569,22 +1574,22 @@ void KItemListView::setModel(KItemModelBase* model) KItemModelBase* previous = m_model; if (m_model) { - disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); - disconnect(m_model, SIGNAL(itemsInserted(KItemRangeList)), - this, SLOT(slotItemsInserted(KItemRangeList))); - disconnect(m_model, SIGNAL(itemsRemoved(KItemRangeList)), - this, SLOT(slotItemsRemoved(KItemRangeList))); - disconnect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), - this, SLOT(slotItemsMoved(KItemRange,QList<int>))); - disconnect(m_model, SIGNAL(groupsChanged()), - this, SLOT(slotGroupsChanged())); - disconnect(m_model, SIGNAL(groupedSortingChanged(bool)), - this, SLOT(slotGroupedSortingChanged(bool))); - disconnect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), - this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder))); - disconnect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)), - this, SLOT(slotSortRoleChanged(QByteArray,QByteArray))); + disconnect(m_model, &KItemModelBase::itemsChanged, + this, &KItemListView::slotItemsChanged); + disconnect(m_model, &KItemModelBase::itemsInserted, + this, &KItemListView::slotItemsInserted); + disconnect(m_model, &KItemModelBase::itemsRemoved, + this, &KItemListView::slotItemsRemoved); + disconnect(m_model, &KItemModelBase::itemsMoved, + this, &KItemListView::slotItemsMoved); + disconnect(m_model, &KItemModelBase::groupsChanged, + this, &KItemListView::slotGroupsChanged); + disconnect(m_model, &KItemModelBase::groupedSortingChanged, + this, &KItemListView::slotGroupedSortingChanged); + disconnect(m_model, &KItemModelBase::sortOrderChanged, + this, &KItemListView::slotSortOrderChanged); + disconnect(m_model, &KItemModelBase::sortRoleChanged, + this, &KItemListView::slotSortRoleChanged); m_sizeHintResolver->itemsRemoved(KItemRangeList() << KItemRange(0, m_model->count())); } @@ -1594,22 +1599,22 @@ void KItemListView::setModel(KItemModelBase* model) m_grouped = model->groupedSorting(); if (m_model) { - connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); - connect(m_model, SIGNAL(itemsInserted(KItemRangeList)), - this, SLOT(slotItemsInserted(KItemRangeList))); - connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)), - this, SLOT(slotItemsRemoved(KItemRangeList))); - connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), - this, SLOT(slotItemsMoved(KItemRange,QList<int>))); - connect(m_model, SIGNAL(groupsChanged()), - this, SLOT(slotGroupsChanged())); - connect(m_model, SIGNAL(groupedSortingChanged(bool)), - this, SLOT(slotGroupedSortingChanged(bool))); - connect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), - this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder))); - connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)), - this, SLOT(slotSortRoleChanged(QByteArray,QByteArray))); + connect(m_model, &KItemModelBase::itemsChanged, + this, &KItemListView::slotItemsChanged); + connect(m_model, &KItemModelBase::itemsInserted, + this, &KItemListView::slotItemsInserted); + connect(m_model, &KItemModelBase::itemsRemoved, + this, &KItemListView::slotItemsRemoved); + connect(m_model, &KItemModelBase::itemsMoved, + this, &KItemListView::slotItemsMoved); + connect(m_model, &KItemModelBase::groupsChanged, + this, &KItemListView::slotGroupsChanged); + connect(m_model, &KItemModelBase::groupedSortingChanged, + this, &KItemListView::slotGroupedSortingChanged); + connect(m_model, &KItemModelBase::sortOrderChanged, + this, &KItemListView::slotSortOrderChanged); + connect(m_model, &KItemModelBase::sortRoleChanged, + this, &KItemListView::slotSortRoleChanged); const int itemCount = m_model->count(); if (itemCount > 0) { @@ -2023,7 +2028,7 @@ void KItemListView::updateGroupHeaderForWidget(KItemListWidget* widget) groupHeader = groupHeaderCreator()->create(this); groupHeader->setParentItem(widget); m_visibleGroups.insert(widget, groupHeader); - connect(widget, SIGNAL(geometryChanged()), this, SLOT(slotGeometryOfGroupHeaderParentChanged())); + connect(widget, &KItemListWidget::geometryChanged, this, &KItemListView::slotGeometryOfGroupHeaderParentChanged); } Q_ASSERT(groupHeader->parentItem() == widget); @@ -2070,7 +2075,7 @@ void KItemListView::recycleGroupHeaderForWidget(KItemListWidget* widget) header->setParentItem(0); groupHeaderCreator()->recycle(header); m_visibleGroups.remove(widget); - disconnect(widget, SIGNAL(geometryChanged()), this, SLOT(slotGeometryOfGroupHeaderParentChanged())); + disconnect(widget, &KItemListWidget::geometryChanged, this, &KItemListView::slotGeometryOfGroupHeaderParentChanged); } } @@ -2624,8 +2629,8 @@ void KItemListView::disconnectRoleEditingSignals(int index) return; } - widget->disconnect(SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)), this); - widget->disconnect(SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), this); + disconnect(widget, &KItemListWidget::roleEditingCanceled, this, nullptr); + disconnect(widget, &KItemListWidget::roleEditingFinished, this, nullptr); } int KItemListView::calculateAutoScrollingIncrement(int pos, int range, int oldInc) @@ -2719,4 +2724,3 @@ void KItemListGroupHeaderCreatorBase::recycle(KItemListGroupHeader* header) pushRecycleableWidget(header); } -#include "kitemlistview.moc" diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index cf6f27c03..c8054a691 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -44,7 +44,6 @@ class KItemListViewLayouter; class KItemListWidget; class KItemListWidgetInformant; class KItemListWidgetCreatorBase; -class KItemListViewCreatorBase; class QTimer; /** diff --git a/src/kitemviews/kitemlistviewaccessible.cpp b/src/kitemviews/kitemlistviewaccessible.cpp index d9ddd58f8..8efa60fff 100644 --- a/src/kitemviews/kitemlistviewaccessible.cpp +++ b/src/kitemviews/kitemlistviewaccessible.cpp @@ -27,7 +27,7 @@ #include "kitemlistview.h" #include "private/kitemlistviewlayouter.h" -#include <QtGui/qaccessible2.h> +#include <QtGui/qaccessible.h> #include <qgraphicsscene.h> #include <qgraphicsview.h> @@ -40,35 +40,52 @@ KItemListView* KItemListViewAccessible::view() const } KItemListViewAccessible::KItemListViewAccessible(KItemListView* view_) : - QAccessibleObjectEx(view_) + QAccessibleObject(view_) { Q_ASSERT(view()); + m_cells.resize(childCount()); } -void KItemListViewAccessible::modelReset() +KItemListViewAccessible::~KItemListViewAccessible() { + foreach (QAccessibleInterface* child, m_cells) { + if (child) { + QAccessible::Id childId = QAccessible::uniqueId(child); + QAccessible::deleteAccessibleInterface(childId); + } + } } -QAccessible::Role KItemListViewAccessible::cellRole() const +void* KItemListViewAccessible::interface_cast(QAccessible::InterfaceType type) { - return QAccessible::Cell; + if (type == QAccessible::TableInterface) { + return static_cast<QAccessibleTableInterface*>(this); + } + return Q_NULLPTR; } -QAccessibleTable2CellInterface* KItemListViewAccessible::cell(int index) const +void KItemListViewAccessible::modelReset() +{ +} + +QAccessibleInterface* KItemListViewAccessible::cell(int index) const { if (index < 0 || index >= view()->model()->count()) { return 0; - } else { - return new KItemListAccessibleCell(view(), index); } -} -QVariant KItemListViewAccessible::invokeMethodEx(Method, int, const QVariantList&) -{ - return QVariant(); + if (m_cells.size() < index - 1) + m_cells.resize(childCount()); + + QAccessibleInterface* child = m_cells.at(index); + if (!child) { + child = new KItemListAccessibleCell(view(), index); + QAccessible::registerAccessibleInterface(child); + } + return child; } -QAccessibleTable2CellInterface* KItemListViewAccessible::cellAt(int row, int column) const +QAccessibleInterface* KItemListViewAccessible::cellAt(int row, int column) const { return cell(columnCount() * row + column); } @@ -127,9 +144,9 @@ QString KItemListViewAccessible::rowDescription(int) const return QString(); } -QList<QAccessibleTable2CellInterface*> KItemListViewAccessible::selectedCells() const +QList<QAccessibleInterface*> KItemListViewAccessible::selectedCells() const { - QList<QAccessibleTable2CellInterface*> cells; + QList<QAccessibleInterface*> cells; Q_FOREACH (int index, view()->controller()->selectionManager()->selectedItems()) { cells.append(cell(index)); } @@ -181,42 +198,31 @@ bool KItemListViewAccessible::unselectColumn(int) return true; } -QAccessible2::TableModelChange KItemListViewAccessible::modelChange() const +void KItemListViewAccessible::modelChange(QAccessibleTableModelChangeEvent* /*event*/) +{} + +QAccessible::Role KItemListViewAccessible::role() const { - QAccessible2::TableModelChange change; - change.lastRow = rowCount(); - change.lastColumn = columnCount(); - return change; + return QAccessible::Table; } -QAccessible::Role KItemListViewAccessible::role(int child) const +QAccessible::State KItemListViewAccessible::state() const { - Q_ASSERT(child >= 0); - - if (child > 0) { - return QAccessible::Cell; - } else { - return QAccessible::Table; - } + QAccessible::State s; + return s; } -QAccessible::State KItemListViewAccessible::state(int child) const +QAccessibleInterface* KItemListViewAccessible::childAt(int x, int y) const { - if (child) { - QAccessibleInterface* interface = 0; - navigate(Child, child, &interface); - if (interface) { - return interface->state(0); - } - } - - return QAccessible::Normal | QAccessible::HasInvokeExtension; + const QPointF point = QPointF(x, y); + int itemIndex = view()->itemAt(view()->mapFromScene(point)); + return child(itemIndex); } -int KItemListViewAccessible::childAt(int x, int y) const +QAccessibleInterface* KItemListViewAccessible::parent() const { - const QPointF point = QPointF(x,y); - return view()->itemAt(view()->mapFromScene(point)); + // FIXME: return KItemListContainerAccessible here + return Q_NULLPTR; } int KItemListViewAccessible::childCount() const @@ -227,18 +233,16 @@ int KItemListViewAccessible::childCount() const int KItemListViewAccessible::indexOfChild(const QAccessibleInterface* interface) const { const KItemListAccessibleCell* widget = static_cast<const KItemListAccessibleCell*>(interface); - return widget->index() + 1; + return widget->index(); } -QString KItemListViewAccessible::text(Text, int child) const +QString KItemListViewAccessible::text(QAccessible::Text) const { - Q_ASSERT(child == 0); return QString(); } -QRect KItemListViewAccessible::rect(int child) const +QRect KItemListViewAccessible::rect() const { - Q_UNUSED(child) if (!view()->isVisible()) { return QRect(); } @@ -253,50 +257,14 @@ QRect KItemListViewAccessible::rect(int child) const } } -int KItemListViewAccessible::navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const +QAccessibleInterface* KItemListViewAccessible::child(int index) const { - *interface = 0; - - switch (relation) { - case QAccessible::Child: - Q_ASSERT(index > 0); - *interface = cell(index - 1); - if (*interface) { - return 0; - } - break; - - default: - break; + if (index >= 0 && index < childCount()) { + return cell(index); } - - return -1; + return Q_NULLPTR; } -QAccessible::Relation KItemListViewAccessible::relationTo(int, const QAccessibleInterface*, int) const -{ - return QAccessible::Unrelated; -} - -#ifndef QT_NO_ACTION - -int KItemListViewAccessible::userActionCount(int) const -{ - return 0; -} - -QString KItemListViewAccessible::actionText(int, Text, int) const -{ - return QString(); -} - -bool KItemListViewAccessible::doAction(int, int, const QVariantList&) -{ - return false; -} - -#endif - // Table Cell KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index) : @@ -306,6 +274,14 @@ KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index) Q_ASSERT(index >= 0 && index < view->model()->count()); } +void* KItemListAccessibleCell::interface_cast(QAccessible::InterfaceType type) +{ + if (type == QAccessible::TableCellInterface) { + return static_cast<QAccessibleTableCellInterface*>(this); + } + return Q_NULLPTR; +} + int KItemListAccessibleCell::columnExtent() const { return 1; @@ -341,52 +317,39 @@ bool KItemListAccessibleCell::isSelected() const return m_view->controller()->selectionManager()->isSelected(m_index); } -void KItemListAccessibleCell::rowColumnExtents(int* row, int* column, int* rowExtents, int* columnExtents, bool* selected) const +QAccessibleInterface* KItemListAccessibleCell::table() const { - const KItemListViewLayouter* layouter = m_view->m_layouter; - *row = layouter->itemRow(m_index); - *column = layouter->itemColumn(m_index); - *rowExtents = 1; - *columnExtents = 1; - *selected = isSelected(); + return QAccessible::queryAccessibleInterface(m_view); } -QAccessibleTable2Interface* KItemListAccessibleCell::table() const +QAccessible::Role KItemListAccessibleCell::role() const { - return QAccessible::queryAccessibleInterface(m_view)->table2Interface(); -} - -QAccessible::Role KItemListAccessibleCell::role(int child) const -{ - Q_ASSERT(child == 0); return QAccessible::Cell; } -QAccessible::State KItemListAccessibleCell::state(int child) const +QAccessible::State KItemListAccessibleCell::state() const { - Q_ASSERT(child == 0); - QAccessible::State state = Normal; + QAccessible::State state; + state.selectable = true; if (isSelected()) { - state |= Selected; + state.selected = true; } + state.focusable = true; if (m_view->controller()->selectionManager()->currentItem() == m_index) { - state |= Focused; + state.focused = true; } - state |= Selectable; - state |= Focusable; - if (m_view->controller()->selectionBehavior() == KItemListController::MultiSelection) { - state |= MultiSelectable; + state.multiSelectable = true; } if (m_view->model()->isExpandable(m_index)) { if (m_view->model()->isExpanded(m_index)) { - state |= Expanded; + state.expanded = true; } else { - state |= Collapsed; + state.collapsed = true; } } @@ -398,7 +361,7 @@ bool KItemListAccessibleCell::isExpandable() const return m_view->model()->isExpandable(m_index); } -QRect KItemListAccessibleCell::rect(int) const +QRect KItemListAccessibleCell::rect() const { QRect rect = m_view->itemRect(m_index).toRect(); @@ -411,13 +374,9 @@ QRect KItemListAccessibleCell::rect(int) const return rect; } -QString KItemListAccessibleCell::text(QAccessible::Text t, int child) const +QString KItemListAccessibleCell::text(QAccessible::Text t) const { - Q_ASSERT(child == 0); - Q_UNUSED(child) - switch (t) { - case QAccessible::Value: case QAccessible::Name: { const QHash<QByteArray, QVariant> data = m_view->model()->data(m_index); return data["text"].toString(); @@ -430,9 +389,13 @@ QString KItemListAccessibleCell::text(QAccessible::Text t, int child) const return QString(); } -void KItemListAccessibleCell::setText(QAccessible::Text, int child, const QString&) +void KItemListAccessibleCell::setText(QAccessible::Text, const QString&) { - Q_ASSERT(child == 0); +} + +QAccessibleInterface* KItemListAccessibleCell::child(int) const +{ + return Q_NULLPTR; } bool KItemListAccessibleCell::isValid() const @@ -440,9 +403,9 @@ bool KItemListAccessibleCell::isValid() const return m_view && (m_index >= 0) && (m_index < m_view->model()->count()); } -int KItemListAccessibleCell::childAt(int, int) const +QAccessibleInterface* KItemListAccessibleCell::childAt(int, int) const { - return 0; + return Q_NULLPTR; } int KItemListAccessibleCell::childCount() const @@ -456,43 +419,11 @@ int KItemListAccessibleCell::indexOfChild(const QAccessibleInterface* child) con return -1; } -int KItemListAccessibleCell::navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const -{ - if (relation == Ancestor && index == 1) { - *interface = new KItemListViewAccessible(m_view); - return 0; - } - - *interface = 0; - return -1; -} - -QAccessible::Relation KItemListAccessibleCell::relationTo(int child, const QAccessibleInterface* , int otherChild) const -{ - Q_ASSERT(child == 0); - Q_ASSERT(otherChild == 0); - return QAccessible::Unrelated; -} - -#ifndef QT_NO_ACTION - -int KItemListAccessibleCell::userActionCount(int) const +QAccessibleInterface* KItemListAccessibleCell::parent() const { - return 0; -} - -QString KItemListAccessibleCell::actionText(int, Text, int) const -{ - return QString(); + return QAccessible::queryAccessibleInterface(m_view); } -bool KItemListAccessibleCell::doAction(int, int, const QVariantList&) -{ - return false; -} - -#endif - int KItemListAccessibleCell::index() const { return m_index; @@ -505,7 +436,7 @@ QObject* KItemListAccessibleCell::object() const // Container Interface KItemListContainerAccessible::KItemListContainerAccessible(KItemListContainer* container) : - QAccessibleWidgetEx(container) + QAccessibleWidget(container) { } @@ -521,20 +452,17 @@ int KItemListContainerAccessible::childCount() const int KItemListContainerAccessible::indexOfChild(const QAccessibleInterface* child) const { if (child->object() == container()->controller()->view()) { - return 1; - } else { - return -1; + return 0; } + return -1; } -int KItemListContainerAccessible::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface** target) const +QAccessibleInterface* KItemListContainerAccessible::child(int index) const { - if (relation == QAccessible::Child) { - *target = new KItemListViewAccessible(container()->controller()->view()); - return 0; - } else { - return QAccessibleWidgetEx::navigate(relation, index, target); + if (index == 0) { + return QAccessible::queryAccessibleInterface(container()->controller()->view()); } + return Q_NULLPTR; } const KItemListContainer* KItemListContainerAccessible::container() const diff --git a/src/kitemviews/kitemlistviewaccessible.h b/src/kitemviews/kitemlistviewaccessible.h index c2213cd67..674f1d1af 100644 --- a/src/kitemviews/kitemlistviewaccessible.h +++ b/src/kitemviews/kitemlistviewaccessible.h @@ -22,118 +22,104 @@ #ifndef QT_NO_ACCESSIBILITY +#include <libdolphin_export.h> + #include <QtCore/qpointer.h> #include <QtGui/qaccessible.h> -#include <QtGui/qaccessible2.h> -#include <QtGui/qaccessiblewidget.h> #include <QtGui/qaccessibleobject.h> +#include <QtWidgets/qaccessiblewidget.h> class KItemListView; class KItemListContainer; -class KItemListViewAccessible: public QAccessibleTable2Interface, public QAccessibleObjectEx +class LIBDOLPHINPRIVATE_EXPORT KItemListViewAccessible: public QAccessibleObject, public QAccessibleTableInterface { - Q_ACCESSIBLE_OBJECT - public: explicit KItemListViewAccessible(KItemListView* view); + ~KItemListViewAccessible(); - Role role(int child) const; - State state(int child) const; - QString text(Text t, int child) const; - QRect rect(int child) const; - - int childAt(int x, int y) const; - int childCount() const; - int indexOfChild(const QAccessibleInterface*) const; + void* interface_cast(QAccessible::InterfaceType type) Q_DECL_OVERRIDE; - int navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const; - Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const; + QAccessible::Role role() const Q_DECL_OVERRIDE; + QAccessible::State state() const Q_DECL_OVERRIDE; + QString text(QAccessible::Text t) const Q_DECL_OVERRIDE; + QRect rect() const Q_DECL_OVERRIDE; -#ifndef QT_NO_ACTION - int userActionCount(int child) const; - QString actionText(int action, Text t, int child) const; - bool doAction(int action, int child, const QVariantList& params); -#endif - QVariant invokeMethodEx(Method, int, const QVariantList&); + QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE; + int childCount() const Q_DECL_OVERRIDE; + int indexOfChild(const QAccessibleInterface*) const Q_DECL_OVERRIDE; + QAccessibleInterface* childAt(int x, int y) const Q_DECL_OVERRIDE; + QAccessibleInterface* parent() const Q_DECL_OVERRIDE; - // Table2 interface - virtual QAccessibleTable2CellInterface* cellAt(int row, int column) const; - virtual QAccessibleInterface* caption() const; - virtual QAccessibleInterface* summary() const; - virtual QString columnDescription(int column) const; - virtual QString rowDescription(int row) const; - virtual int columnCount() const; - virtual int rowCount() const; - virtual QAccessible2::TableModelChange modelChange() const; - virtual void rowsInserted(const QModelIndex&, int, int) {} - virtual void rowsRemoved(const QModelIndex&, int, int) {} - virtual void columnsInserted(const QModelIndex&, int, int) {} - virtual void columnsRemoved(const QModelIndex&, int, int) {} - virtual void rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int) {} - virtual void columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int) {} + // Table interface + virtual QAccessibleInterface* cellAt(int row, int column) const Q_DECL_OVERRIDE; + virtual QAccessibleInterface* caption() const Q_DECL_OVERRIDE; + virtual QAccessibleInterface* summary() const Q_DECL_OVERRIDE; + virtual QString columnDescription(int column) const Q_DECL_OVERRIDE; + virtual QString rowDescription(int row) const Q_DECL_OVERRIDE; + virtual int columnCount() const Q_DECL_OVERRIDE; + virtual int rowCount() const Q_DECL_OVERRIDE; // Selection - virtual int selectedCellCount() const; - virtual int selectedColumnCount() const; - virtual int selectedRowCount() const; - virtual QList<QAccessibleTable2CellInterface*> selectedCells() const; - virtual QList<int> selectedColumns() const; - virtual QList<int> selectedRows() const; - virtual bool isColumnSelected(int column) const; - virtual bool isRowSelected(int row) const; - virtual bool selectRow(int row); - virtual bool selectColumn(int column); - virtual bool unselectRow(int row); - virtual bool unselectColumn(int column); + virtual int selectedCellCount() const Q_DECL_OVERRIDE; + virtual int selectedColumnCount() const Q_DECL_OVERRIDE; + virtual int selectedRowCount() const Q_DECL_OVERRIDE; + virtual QList<QAccessibleInterface*> selectedCells() const Q_DECL_OVERRIDE; + virtual QList<int> selectedColumns() const Q_DECL_OVERRIDE; + virtual QList<int> selectedRows() const Q_DECL_OVERRIDE; + virtual bool isColumnSelected(int column) const Q_DECL_OVERRIDE; + virtual bool isRowSelected(int row) const Q_DECL_OVERRIDE; + virtual bool selectRow(int row) Q_DECL_OVERRIDE; + virtual bool selectColumn(int column) Q_DECL_OVERRIDE; + virtual bool unselectRow(int row) Q_DECL_OVERRIDE; + virtual bool unselectColumn(int column) Q_DECL_OVERRIDE; + virtual void modelChange(QAccessibleTableModelChangeEvent*) Q_DECL_OVERRIDE; KItemListView* view() const; protected: virtual void modelReset(); /** - * Create an QAccessibleTable2CellInterface representing the table + * Create an QAccessibleTableCellInterface representing the table * cell at the @index. Index is 0-based. */ - inline QAccessibleTable2CellInterface* cell(int index) const; - inline QAccessible::Role cellRole() const; + inline QAccessibleInterface* cell(int index) const; + +private: + mutable QVector<QAccessibleInterface*> m_cells; }; -class KItemListAccessibleCell: public QAccessibleTable2CellInterface +class LIBDOLPHINPRIVATE_EXPORT KItemListAccessibleCell: public QAccessibleInterface, public QAccessibleTableCellInterface { public: KItemListAccessibleCell(KItemListView* view, int m_index); - QObject* object() const; - Role role(int) const; - State state(int) const; - QRect rect(int) const; - bool isValid() const; - int childAt(int, int) const; - int childCount() const; - int indexOfChild(const QAccessibleInterface*) const; - QString text(Text t, int child) const; - void setText(Text t, int child, const QString& text); - int navigate(RelationFlag relation, int m_index, QAccessibleInterface** interface) const; - Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const; - bool isExpandable() const; + void* interface_cast(QAccessible::InterfaceType type) Q_DECL_OVERRIDE; + QObject* object() const Q_DECL_OVERRIDE; + bool isValid() const Q_DECL_OVERRIDE; + QAccessible::Role role() const Q_DECL_OVERRIDE; + QAccessible::State state() const Q_DECL_OVERRIDE; + QRect rect() const Q_DECL_OVERRIDE; + QString text(QAccessible::Text t) const Q_DECL_OVERRIDE; + void setText(QAccessible::Text t, const QString& text) Q_DECL_OVERRIDE; -#ifndef QT_NO_ACTION - int userActionCount(int child) const; - QString actionText(int action, Text t, int child) const; - bool doAction(int action, int child, const QVariantList& params); -#endif + QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE; + int childCount() const Q_DECL_OVERRIDE; + QAccessibleInterface* childAt(int x, int y) const Q_DECL_OVERRIDE; + int indexOfChild(const QAccessibleInterface*) const Q_DECL_OVERRIDE; + + QAccessibleInterface* parent() const Q_DECL_OVERRIDE; + bool isExpandable() const; // Cell Interface - virtual int columnExtent() const; - virtual QList<QAccessibleInterface*> columnHeaderCells() const; - virtual int columnIndex() const; - virtual int rowExtent() const; - virtual QList<QAccessibleInterface*> rowHeaderCells() const; - virtual int rowIndex() const; - virtual bool isSelected() const; - virtual void rowColumnExtents(int* row, int* column, int* rowExtents, int* columnExtents, bool* selected) const; - virtual QAccessibleTable2Interface* table() const; + virtual int columnExtent() const Q_DECL_OVERRIDE; + virtual QList<QAccessibleInterface*> columnHeaderCells() const Q_DECL_OVERRIDE; + virtual int columnIndex() const Q_DECL_OVERRIDE; + virtual int rowExtent() const Q_DECL_OVERRIDE; + virtual QList<QAccessibleInterface*> rowHeaderCells() const Q_DECL_OVERRIDE; + virtual int rowIndex() const Q_DECL_OVERRIDE; + virtual bool isSelected() const Q_DECL_OVERRIDE; + virtual QAccessibleInterface* table() const Q_DECL_OVERRIDE; inline int index() const; @@ -142,17 +128,15 @@ private: int m_index; }; -class KItemListContainerAccessible : public QAccessibleWidgetEx +class LIBDOLPHINPRIVATE_EXPORT KItemListContainerAccessible : public QAccessibleWidget { - Q_ACCESSIBLE_OBJECT - public: explicit KItemListContainerAccessible(KItemListContainer* container); virtual ~KItemListContainerAccessible(); - int childCount() const; - int indexOfChild(const QAccessibleInterface* child) const; - int navigate(RelationFlag relation, int entry, QAccessibleInterface** target) const; + QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE; + int childCount() const Q_DECL_OVERRIDE; + int indexOfChild(const QAccessibleInterface* child) const Q_DECL_OVERRIDE; private: const KItemListContainer* container() const; diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp index e7d2951b9..df19d49b1 100644 --- a/src/kitemviews/kitemlistwidget.cpp +++ b/src/kitemviews/kitemlistwidget.cpp @@ -252,7 +252,7 @@ void KItemListWidget::setHovered(bool hovered) m_hoverAnimation = new QPropertyAnimation(this, "hoverOpacity", this); const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 200; m_hoverAnimation->setDuration(duration); - connect(m_hoverAnimation, SIGNAL(finished()), this, SLOT(slotHoverAnimationFinished())); + connect(m_hoverAnimation, &QPropertyAnimation::finished, this, &KItemListWidget::slotHoverAnimationFinished); } m_hoverAnimation->stop(); @@ -526,4 +526,3 @@ void KItemListWidget::drawItemStyleOption(QPainter* painter, QWidget* widget, QS widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget); } -#include "kitemlistwidget.moc" diff --git a/src/kitemviews/kitemmodelbase.cpp b/src/kitemviews/kitemmodelbase.cpp index 4312640e4..bf41b1c84 100644 --- a/src/kitemviews/kitemmodelbase.cpp +++ b/src/kitemviews/kitemmodelbase.cpp @@ -159,4 +159,3 @@ void KItemModelBase::onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder pre Q_UNUSED(previous); } -#include "kitemmodelbase.moc" diff --git a/src/kitemviews/kstandarditem.h b/src/kitemviews/kstandarditem.h index 689db4251..59190bfd5 100644 --- a/src/kitemviews/kstandarditem.h +++ b/src/kitemviews/kstandarditem.h @@ -24,7 +24,6 @@ #include <QByteArray> #include <QHash> -#include <QIcon> #include <QList> #include <QVariant> diff --git a/src/kitemviews/kstandarditemlistgroupheader.cpp b/src/kitemviews/kstandarditemlistgroupheader.cpp index 1e23c0a56..99457c9b8 100644 --- a/src/kitemviews/kstandarditemlistgroupheader.cpp +++ b/src/kitemviews/kstandarditemlistgroupheader.cpp @@ -122,4 +122,3 @@ void KStandardItemListGroupHeader::updateCache() } } -#include "kstandarditemlistgroupheader.moc" diff --git a/src/kitemviews/kstandarditemlistview.cpp b/src/kitemviews/kstandarditemlistview.cpp index 135cd0b7d..1c07d5327 100644 --- a/src/kitemviews/kstandarditemlistview.cpp +++ b/src/kitemviews/kstandarditemlistview.cpp @@ -179,4 +179,3 @@ void KStandardItemListView::updateLayoutOfVisibleItems() } } -#include "kstandarditemlistview.moc" diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index 6407efc22..ec48f19db 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -22,10 +22,9 @@ #include "kfileitemlistview.h" #include "kfileitemmodel.h" -#include <KIcon> +#include <QIcon> #include <KIconEffect> #include <KIconLoader> -#include <KLocale> #include <kratingpainter.h> #include <KStringHandler> #include <KDebug> @@ -34,7 +33,6 @@ #include "private/kitemlistroleeditor.h" #include "private/kpixmapmodifier.h" -#include <QFontMetricsF> #include <QGraphicsScene> #include <QGraphicsSceneResizeEvent> #include <QGraphicsView> @@ -682,7 +680,7 @@ void KStandardItemListWidget::dataChanged(const QHash<QByteArray, QVariant>& cur // The URL might have changed (i.e., if the sort order of the items has // been changed). Therefore, the "is cut" state must be updated. KFileItemClipboard* clipboard = KFileItemClipboard::instance(); - const KUrl itemUrl = data().value("url").value<KUrl>(); + const QUrl itemUrl = data().value("url").value<QUrl>(); m_isCut = clipboard->isCut(itemUrl); // The icon-state might depend from other roles and hence is @@ -758,10 +756,10 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const if (m_roleEditor) { emit roleEditingCanceled(index(), current, data().value(current)); - disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)), - this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant))); - disconnect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)), - this, SLOT(slotRoleEditingFinished(QByteArray,QVariant))); + disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, + this, &KStandardItemListWidget::slotRoleEditingCanceled); + disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, + this, &KStandardItemListWidget::slotRoleEditingFinished); if (m_oldRoleEditor) { m_oldRoleEditor->deleteLater(); @@ -796,10 +794,10 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const m_roleEditor->setTextCursor(cursor); } - connect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)), - this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant))); - connect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)), - this, SLOT(slotRoleEditingFinished(QByteArray,QVariant))); + connect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, + this, &KStandardItemListWidget::slotRoleEditingCanceled); + connect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, + this, &KStandardItemListWidget::slotRoleEditingFinished); // Adjust the geometry of the editor QRectF rect = roleEditingRect(current); @@ -833,24 +831,24 @@ void KStandardItemListWidget::showEvent(QShowEvent* event) // Listen to changes of the clipboard to mark the item as cut/uncut KFileItemClipboard* clipboard = KFileItemClipboard::instance(); - const KUrl itemUrl = data().value("url").value<KUrl>(); + const QUrl itemUrl = data().value("url").value<QUrl>(); m_isCut = clipboard->isCut(itemUrl); - connect(clipboard, SIGNAL(cutItemsChanged()), - this, SLOT(slotCutItemsChanged())); + connect(clipboard, &KFileItemClipboard::cutItemsChanged, + this, &KStandardItemListWidget::slotCutItemsChanged); } void KStandardItemListWidget::hideEvent(QHideEvent* event) { - disconnect(KFileItemClipboard::instance(), SIGNAL(cutItemsChanged()), - this, SLOT(slotCutItemsChanged())); + disconnect(KFileItemClipboard::instance(), &KFileItemClipboard::cutItemsChanged, + this, &KStandardItemListWidget::slotCutItemsChanged); KItemListWidget::hideEvent(event); } void KStandardItemListWidget::slotCutItemsChanged() { - const KUrl itemUrl = data().value("url").value<KUrl>(); + const QUrl itemUrl = data().value("url").value<QUrl>(); const bool isCut = KFileItemClipboard::instance()->isCut(itemUrl); if (m_isCut != isCut) { m_isCut = isCut; @@ -1415,10 +1413,10 @@ QRectF KStandardItemListWidget::roleEditingRect(const QByteArray& role) const void KStandardItemListWidget::closeRoleEditor() { - disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)), - this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant))); - disconnect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)), - this, SLOT(slotRoleEditingFinished(QByteArray,QVariant))); + disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, + this, &KStandardItemListWidget::slotRoleEditingCanceled); + disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, + this, &KStandardItemListWidget::slotRoleEditingFinished); if (m_roleEditor->hasFocus()) { // If the editing was not ended by a FocusOut event, we have @@ -1440,7 +1438,7 @@ QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStrin QPixmap pixmap; if (!QPixmapCache::find(key, pixmap)) { - const KIcon icon(name); + const QIcon icon = QIcon::fromTheme(name); int requestedSize; if (size <= KIconLoader::SizeSmall) { @@ -1497,4 +1495,3 @@ qreal KStandardItemListWidget::columnPadding(const KItemListStyleOption& option) return option.padding * 6; } -#include "kstandarditemlistwidget.moc" diff --git a/src/kitemviews/kstandarditemmodel.cpp b/src/kitemviews/kstandarditemmodel.cpp index e8c1b6204..060440aec 100644 --- a/src/kitemviews/kstandarditemmodel.cpp +++ b/src/kitemviews/kstandarditemmodel.cpp @@ -237,5 +237,3 @@ void KStandardItemModel::onItemRemoved(int index, KStandardItem* removedItem) Q_UNUSED(removedItem); } - -#include "kstandarditemmodel.moc" diff --git a/src/kitemviews/private/kbaloorolesprovider.cpp b/src/kitemviews/private/kbaloorolesprovider.cpp index c0ae0c544..5ca56c58b 100644 --- a/src/kitemviews/private/kbaloorolesprovider.cpp +++ b/src/kitemviews/private/kbaloorolesprovider.cpp @@ -22,10 +22,11 @@ #include <KDebug> #include <KGlobal> -#include <KLocale> +#include <KLocalizedString> -#include <baloo/file.h> -#include <kfilemetadata/propertyinfo.h> +#include <Baloo/File> +#include <KFileMetaData/PropertyInfo> +#include <KFileMetaData/UserMetaData> #include <QTime> #include <QMap> @@ -99,14 +100,15 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f } } + KFileMetaData::UserMetaData md(file.path()); if (roles.contains("tags")) { - values.insert("tags", tagsFromValues(file.tags())); + values.insert("tags", tagsFromValues(md.tags())); } if (roles.contains("rating")) { - values.insert("rating", QString::number(file.rating())); + values.insert("rating", QString::number(md.rating())); } if (roles.contains("comment")) { - values.insert("comment", file.userComment()); + values.insert("comment", md.userComment()); } return values; diff --git a/src/kitemviews/private/kdirectorycontentscounter.cpp b/src/kitemviews/private/kdirectorycontentscounter.cpp index 7d1e76999..af7312ad2 100644 --- a/src/kitemviews/private/kdirectorycontentscounter.cpp +++ b/src/kitemviews/private/kdirectorycontentscounter.cpp @@ -35,8 +35,8 @@ KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObj m_dirWatcher(0), m_watchedDirs() { - connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)), - this, SLOT(slotItemsRemoved())); + connect(m_model, &KFileItemModel::itemsRemoved, + this, &KDirectoryContentsCounter::slotItemsRemoved); if (!m_workerThread) { m_workerThread = new QThread(); @@ -47,13 +47,13 @@ KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObj m_worker->moveToThread(m_workerThread); ++m_workersCount; - connect(this, SIGNAL(requestDirectoryContentsCount(QString,KDirectoryContentsCounterWorker::Options)), - m_worker, SLOT(countDirectoryContents(QString,KDirectoryContentsCounterWorker::Options))); - connect(m_worker, SIGNAL(result(QString,int)), - this, SLOT(slotResult(QString,int))); + connect(this, &KDirectoryContentsCounter::requestDirectoryContentsCount, + m_worker, &KDirectoryContentsCounterWorker::countDirectoryContents); + connect(m_worker, &KDirectoryContentsCounterWorker::result, + this, &KDirectoryContentsCounter::slotResult); m_dirWatcher = new KDirWatch(this); - connect(m_dirWatcher, SIGNAL(dirty(QString)), this, SLOT(slotDirWatchDirty(QString))); + connect(m_dirWatcher, &KDirWatch::dirty, this, &KDirectoryContentsCounter::slotDirWatchDirty); } KDirectoryContentsCounter::~KDirectoryContentsCounter() @@ -122,7 +122,7 @@ void KDirectoryContentsCounter::slotResult(const QString& path, int count) void KDirectoryContentsCounter::slotDirWatchDirty(const QString& path) { - const int index = m_model->index(KUrl(path)); + const int index = m_model->index(QUrl::fromLocalFile(path)); if (index >= 0) { if (!m_model->fileItem(index).isDir()) { // If INotify is used, KDirWatch issues the dirty() signal @@ -151,7 +151,7 @@ void KDirectoryContentsCounter::slotItemsRemoved() QMutableSetIterator<QString> it(m_watchedDirs); while (it.hasNext()) { const QString& path = it.next(); - if (m_model->index(KUrl(path)) < 0) { + if (m_model->index(QUrl::fromLocalFile(path)) < 0) { m_dirWatcher->removeDir(path); it.remove(); } @@ -181,4 +181,4 @@ void KDirectoryContentsCounter::startWorker(const QString& path) } QThread* KDirectoryContentsCounter::m_workerThread = 0; -int KDirectoryContentsCounter::m_workersCount = 0;
\ No newline at end of file +int KDirectoryContentsCounter::m_workersCount = 0; diff --git a/src/kitemviews/private/kdirectorycontentscounterworker.h b/src/kitemviews/private/kdirectorycontentscounterworker.h index 96831ef81..b2e31ef0f 100644 --- a/src/kitemviews/private/kdirectorycontentscounterworker.h +++ b/src/kitemviews/private/kdirectorycontentscounterworker.h @@ -20,7 +20,6 @@ #ifndef KDIRECTORYCONTENTENTSCOUNTERWORKER_H #define KDIRECTORYCONTENTENTSCOUNTERWORKER_H -#include <QFlags> #include <QMetaType> #include <QObject> diff --git a/src/kitemviews/private/kfileitemclipboard.cpp b/src/kitemviews/private/kfileitemclipboard.cpp index 0dcc81f4f..e12767853 100644 --- a/src/kitemviews/private/kfileitemclipboard.cpp +++ b/src/kitemviews/private/kfileitemclipboard.cpp @@ -19,17 +19,17 @@ #include "kfileitemclipboard.h" -#include <KGlobal> #include <QApplication> #include <QClipboard> #include <QMimeData> +#include <KUrlMimeData> class KFileItemClipboardSingleton { public: KFileItemClipboard instance; }; -K_GLOBAL_STATIC(KFileItemClipboardSingleton, s_KFileItemClipboard) +Q_GLOBAL_STATIC(KFileItemClipboardSingleton, s_KFileItemClipboard) @@ -38,12 +38,12 @@ KFileItemClipboard* KFileItemClipboard::instance() return &s_KFileItemClipboard->instance; } -bool KFileItemClipboard::isCut(const KUrl& url) const +bool KFileItemClipboard::isCut(const QUrl& url) const { return m_cutItems.contains(url); } -QList<KUrl> KFileItemClipboard::cutItems() const +QList<QUrl> KFileItemClipboard::cutItems() const { return m_cutItems.toList(); } @@ -66,7 +66,7 @@ void KFileItemClipboard::updateCutItems() const QByteArray data = mimeData->data("application/x-kde-cutselection"); const bool isCutSelection = (!data.isEmpty() && data.at(0) == QLatin1Char('1')); if (isCutSelection) { - m_cutItems = KUrl::List::fromMimeData(mimeData).toSet(); + m_cutItems = KUrlMimeData::urlsFromMimeData(mimeData).toSet(); } else { m_cutItems.clear(); } @@ -79,8 +79,6 @@ KFileItemClipboard::KFileItemClipboard() : { updateCutItems(); - connect(QApplication::clipboard(), SIGNAL(dataChanged()), - this, SLOT(updateCutItems())); + connect(QApplication::clipboard(), &QClipboard::dataChanged, + this, &KFileItemClipboard::updateCutItems); } - -#include "kfileitemclipboard.moc" diff --git a/src/kitemviews/private/kfileitemclipboard.h b/src/kitemviews/private/kfileitemclipboard.h index 86eb8e9fc..d02fc0d47 100644 --- a/src/kitemviews/private/kfileitemclipboard.h +++ b/src/kitemviews/private/kfileitemclipboard.h @@ -20,7 +20,7 @@ #ifndef KFILEITEMCLIPBOARD_H #define KFILEITEMCLIPBOARD_H -#include <KUrl> +#include <QUrl> #include <QList> #include <QSet> #include <QObject> @@ -38,9 +38,9 @@ class LIBDOLPHINPRIVATE_EXPORT KFileItemClipboard : public QObject public: static KFileItemClipboard* instance(); - bool isCut(const KUrl& url) const; + bool isCut(const QUrl& url) const; - QList<KUrl> cutItems() const; + QList<QUrl> cutItems() const; signals: void cutItemsChanged(); @@ -54,7 +54,7 @@ private slots: private: KFileItemClipboard(); - QSet<KUrl> m_cutItems; + QSet<QUrl> m_cutItems; friend class KFileItemClipboardSingleton; }; diff --git a/src/kitemviews/private/kfileitemmodeldirlister.cpp b/src/kitemviews/private/kfileitemmodeldirlister.cpp index 3d36386a9..d5c8bbb18 100644 --- a/src/kitemviews/private/kfileitemmodeldirlister.cpp +++ b/src/kitemviews/private/kfileitemmodeldirlister.cpp @@ -18,7 +18,7 @@ ***************************************************************************/ #include "kfileitemmodeldirlister.h" -#include <KLocale> +#include <KLocalizedString> #include <KIO/JobClasses> KFileItemModelDirLister::KFileItemModelDirLister(QObject* parent) : @@ -45,4 +45,3 @@ void KFileItemModelDirLister::handleError(KIO::Job* job) } } -#include "kfileitemmodeldirlister.moc" diff --git a/src/kitemviews/private/kfileitemmodeldirlister.h b/src/kitemviews/private/kfileitemmodeldirlister.h index 688ee9c5b..94a0e39fd 100644 --- a/src/kitemviews/private/kfileitemmodeldirlister.h +++ b/src/kitemviews/private/kfileitemmodeldirlister.h @@ -22,6 +22,7 @@ #include <libdolphin_export.h> #include <KDirLister> +#include <QUrl> /** * @brief Extends the class KDirLister by emitting a signal when an @@ -44,7 +45,7 @@ signals: * Is emitted when the URL of the directory lister represents a file. * In this case no signal errorMessage() will be emitted. */ - void urlIsFileError(const KUrl& url); + void urlIsFileError(const QUrl& url); protected: virtual void handleError(KIO::Job* job); diff --git a/src/kitemviews/private/kfileitemmodelsortalgorithm.h b/src/kitemviews/private/kfileitemmodelsortalgorithm.h index 1d5689432..3c875ce5a 100644 --- a/src/kitemviews/private/kfileitemmodelsortalgorithm.h +++ b/src/kitemviews/private/kfileitemmodelsortalgorithm.h @@ -23,6 +23,7 @@ #define KFILEITEMMODELSORTALGORITHM_H #include <QtCore> +#include <QtConcurrent/QtConcurrent> #include <algorithm> diff --git a/src/kitemviews/private/kitemlistheaderwidget.cpp b/src/kitemviews/private/kitemlistheaderwidget.cpp index 1f210ab5a..e820bd789 100644 --- a/src/kitemviews/private/kitemlistheaderwidget.cpp +++ b/src/kitemviews/private/kitemlistheaderwidget.cpp @@ -19,8 +19,6 @@ #include "kitemlistheaderwidget.h" -#include <KAction> -#include <KMenu> #include <kitemviews/kitemmodelbase.h> #include <QApplication> @@ -62,19 +60,19 @@ void KItemListHeaderWidget::setModel(KItemModelBase* model) } if (m_model) { - disconnect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)), - this, SLOT(slotSortRoleChanged(QByteArray,QByteArray))); - disconnect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), - this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder))); + disconnect(m_model, &KItemModelBase::sortRoleChanged, + this, &KItemListHeaderWidget::slotSortRoleChanged); + disconnect(m_model, &KItemModelBase::sortOrderChanged, + this, &KItemListHeaderWidget::slotSortOrderChanged); } m_model = model; if (m_model) { - connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)), - this, SLOT(slotSortRoleChanged(QByteArray,QByteArray))); - connect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), - this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder))); + connect(m_model, &KItemModelBase::sortRoleChanged, + this, &KItemListHeaderWidget::slotSortRoleChanged); + connect(m_model, &KItemModelBase::sortOrderChanged, + this, &KItemListHeaderWidget::slotSortOrderChanged); } } @@ -569,4 +567,3 @@ qreal KItemListHeaderWidget::roleXPosition(const QByteArray& role) const return -1; } -#include "kitemlistheaderwidget.moc" diff --git a/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp b/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp index 3bd1b01f3..ffa92a1cf 100644 --- a/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp +++ b/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp @@ -22,8 +22,6 @@ #include "kitemlistkeyboardsearchmanager.h" -#include <QApplication> -#include <QElapsedTimer> KItemListKeyboardSearchManager::KItemListKeyboardSearchManager(QObject* parent) : QObject(parent), diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp index 0a48f1ba0..6e7e89c17 100644 --- a/src/kitemviews/private/kitemlistroleeditor.cpp +++ b/src/kitemviews/private/kitemlistroleeditor.cpp @@ -38,7 +38,7 @@ KItemListRoleEditor::KItemListRoleEditor(QWidget *parent) : parent->installEventFilter(this); } - connect(this, SIGNAL(textChanged()), this, SLOT(autoAdjustSize())); + connect(this, &KItemListRoleEditor::textChanged, this, &KItemListRoleEditor::autoAdjustSize); } KItemListRoleEditor::~KItemListRoleEditor() @@ -148,4 +148,3 @@ void KItemListRoleEditor::emitRoleEditingFinished() } } -#include "kitemlistroleeditor.moc" diff --git a/src/kitemviews/private/kitemlistrubberband.cpp b/src/kitemviews/private/kitemlistrubberband.cpp index 58567c460..702873126 100644 --- a/src/kitemviews/private/kitemlistrubberband.cpp +++ b/src/kitemviews/private/kitemlistrubberband.cpp @@ -88,4 +88,3 @@ bool KItemListRubberBand::isActive() const return m_active; } -#include "kitemlistrubberband.moc" diff --git a/src/kitemviews/private/kitemlistselectiontoggle.cpp b/src/kitemviews/private/kitemlistselectiontoggle.cpp index accbe5181..4daa55f9a 100644 --- a/src/kitemviews/private/kitemlistselectiontoggle.cpp +++ b/src/kitemviews/private/kitemlistselectiontoggle.cpp @@ -19,7 +19,6 @@ #include "kitemlistselectiontoggle.h" -#include <KIconEffect> #include <KIconLoader> #include <QPainter> @@ -115,4 +114,3 @@ int KItemListSelectionToggle::iconSize() const return iconSize; } -#include "kitemlistselectiontoggle.moc" diff --git a/src/kitemviews/private/kitemlistselectiontoggle.h b/src/kitemviews/private/kitemlistselectiontoggle.h index 758dc63bb..8a1a857f6 100644 --- a/src/kitemviews/private/kitemlistselectiontoggle.h +++ b/src/kitemviews/private/kitemlistselectiontoggle.h @@ -25,7 +25,6 @@ #include <QGraphicsWidget> #include <QPixmap> -class QPropertyAnimation; /** * @brief Allows to toggle between the selected and unselected state of an item. diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp index 491461b80..24eea0cef 100644 --- a/src/kitemviews/private/kitemlistsmoothscroller.cpp +++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp @@ -38,8 +38,8 @@ KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar, m_animation = new QPropertyAnimation(this); const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 100; m_animation->setDuration(duration); - connect(m_animation, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)), - this, SLOT(slotAnimationStateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + connect(m_animation, &QPropertyAnimation::stateChanged, + this, &KItemListSmoothScroller::slotAnimationStateChanged); m_scrollBar->installEventFilter(this); } @@ -209,4 +209,3 @@ void KItemListSmoothScroller::handleWheelEvent(QWheelEvent* event) event->accept(); } -#include "kitemlistsmoothscroller.moc" diff --git a/src/kitemviews/private/kitemlistviewanimation.cpp b/src/kitemviews/private/kitemlistviewanimation.cpp index 5a00c8c3a..336ba38ad 100644 --- a/src/kitemviews/private/kitemlistviewanimation.cpp +++ b/src/kitemviews/private/kitemlistviewanimation.cpp @@ -172,7 +172,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type, } Q_ASSERT(propertyAnim); - connect(propertyAnim, SIGNAL(finished()), this, SLOT(slotFinished())); + connect(propertyAnim, &QPropertyAnimation::finished, this, &KItemListViewAnimation::slotFinished); m_animation[type].insert(widget, propertyAnim); propertyAnim->start(); @@ -242,4 +242,3 @@ void KItemListViewAnimation::slotFinished() Q_ASSERT(false); } -#include "kitemlistviewanimation.moc" diff --git a/src/kitemviews/private/kitemlistviewanimation.h b/src/kitemviews/private/kitemlistviewanimation.h index a3aceb0f5..e2e533850 100644 --- a/src/kitemviews/private/kitemlistviewanimation.h +++ b/src/kitemviews/private/kitemlistviewanimation.h @@ -28,7 +28,6 @@ class KItemListView; class QGraphicsWidget; -class QPointF; class QPropertyAnimation; /** diff --git a/src/kitemviews/private/kitemlistviewlayouter.cpp b/src/kitemviews/private/kitemlistviewlayouter.cpp index 04325c7d0..e2dcc62e7 100644 --- a/src/kitemviews/private/kitemlistviewlayouter.cpp +++ b/src/kitemviews/private/kitemlistviewlayouter.cpp @@ -621,4 +621,3 @@ qreal KItemListViewLayouter::minimumGroupHeaderWidth() const return 100; } -#include "kitemlistviewlayouter.moc" |
