mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-19 16:31:21 +00:00
Implement DolphinView::setItemSelectionEnabled()
This commit is contained in:
parent
7b911df33e
commit
769084221f
|
@ -297,13 +297,22 @@ void DolphinView::markUrlsAsSelected(const QList<KUrl>& urls)
|
|||
|
||||
void DolphinView::setItemSelectionEnabled(const QRegExp& pattern, bool enabled)
|
||||
{
|
||||
Q_UNUSED(pattern);
|
||||
Q_UNUSED(enabled);
|
||||
/*const QItemSelection matchingIndexes = childrenMatchingPattern(QModelIndex(), pattern);
|
||||
const QItemSelectionModel::SelectionFlags command = enabled
|
||||
? QItemSelectionModel::Select
|
||||
: QItemSelectionModel::Deselect;
|
||||
m_viewAccessor.itemView()->selectionModel()->select(matchingIndexes, command);*/
|
||||
const KItemListSelectionManager::SelectionMode mode = enabled
|
||||
? KItemListSelectionManager::Select
|
||||
: KItemListSelectionManager::Deselect;
|
||||
const KFileItemModel* model = fileItemModel();
|
||||
KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
|
||||
|
||||
for (int index = 0; index < model->count(); index++) {
|
||||
const KFileItem item = model->fileItem(index);
|
||||
if (pattern.exactMatch(item.name())) {
|
||||
// An alternative approach would be to store the matching items in a QSet<int> and
|
||||
// select them in one go after the loop, but we'd need a new function
|
||||
// KItemListSelectionManager::setSelected(QSet<int>, SelectionMode mode)
|
||||
// for that.
|
||||
selectionManager->setSelected(index, 1, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinView::setZoomLevel(int level)
|
||||
|
@ -1162,32 +1171,6 @@ void DolphinView::markPastedUrlsAsSelected(const QMimeData* mimeData)
|
|||
markUrlsAsSelected(urls);
|
||||
}
|
||||
|
||||
QItemSelection DolphinView::childrenMatchingPattern(const QModelIndex& parent, const QRegExp& pattern) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
Q_UNUSED(pattern);
|
||||
QItemSelection matchingIndexes;
|
||||
/*const DolphinSortFilterProxyModel* proxyModel = m_viewAccessor.proxyModel();
|
||||
const DolphinModel* dolphinModel = m_viewAccessor.dirModel();
|
||||
|
||||
const int rowCount = proxyModel->rowCount(parent);
|
||||
|
||||
for (int row = 0; row < rowCount; ++row) {
|
||||
QModelIndex index = proxyModel->index(row, 0, parent);
|
||||
QModelIndex sourceIndex = proxyModel->mapToSource(index);
|
||||
|
||||
if (sourceIndex.isValid() && pattern.exactMatch(dolphinModel->data(sourceIndex).toString())) {
|
||||
matchingIndexes += QItemSelectionRange(index);
|
||||
}
|
||||
|
||||
if (proxyModel->hasChildren(index)) {
|
||||
matchingIndexes += childrenMatchingPattern(index, pattern);
|
||||
}
|
||||
}*/
|
||||
|
||||
return matchingIndexes;
|
||||
}
|
||||
|
||||
void DolphinView::updateWritableState()
|
||||
{
|
||||
const bool wasFolderWritable = m_isFolderWritable;
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include <QBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QLinkedList>
|
||||
#include <QListView>
|
||||
#include <QSet>
|
||||
#include <QWidget>
|
||||
|
||||
|
@ -720,12 +719,6 @@ private:
|
|||
*/
|
||||
void markPastedUrlsAsSelected(const QMimeData* mimeData);
|
||||
|
||||
/**
|
||||
* Helper method for DolphinView::setItemSelectionEnabled(): Returns the selection for
|
||||
* all items of \p parent that match with the regular expression defined by \p pattern.
|
||||
*/
|
||||
QItemSelection childrenMatchingPattern(const QModelIndex& parent, const QRegExp& pattern) const;
|
||||
|
||||
/**
|
||||
* Updates m_isFolderWritable dependent on whether the folder represented by
|
||||
* the current URL is writable. If the state has changed, the signal
|
||||
|
|
Loading…
Reference in a new issue