35 #include <QtCore/QDir>
36 #include <QtCore/QRegExp>
37 #include <QtCore/QTimer>
38 #include <QtCore/QAbstractItemModel>
39 #include <QtGui/QApplication>
40 #include <QtGui/QDialog>
41 #include <QtGui/QHeaderView>
42 #include <QtGui/QLabel>
43 #include <QtGui/QLayout>
44 #include <QtGui/QListView>
45 #include <QtGui/QMouseEvent>
46 #include <QtGui/QTreeView>
47 #include <QtGui/QPushButton>
48 #include <QtGui/QProgressBar>
49 #include <QtGui/QScrollBar>
50 #include <QtGui/QSplitter>
51 #include <QtGui/QWheelEvent>
82 #include <kdeversion.h>
85 template class QHash<QString, KFileItem>;
95 class KDirOperatorIconView :
public QListView
99 virtual ~KDirOperatorIconView();
102 virtual QStyleOptionViewItem viewOptions()
const;
103 virtual void dragEnterEvent(QDragEnterEvent* event);
104 virtual void mousePressEvent(QMouseEvent *event);
105 virtual void wheelEvent(QWheelEvent *event);
115 setViewMode(QListView::IconMode);
116 setFlow(QListView::TopToBottom);
117 setResizeMode(QListView::Adjust);
119 setMovement(QListView::Static);
120 setDragDropMode(QListView::DragOnly);
121 setVerticalScrollMode(QListView::ScrollPerPixel);
122 setHorizontalScrollMode(QListView::ScrollPerPixel);
123 setEditTriggers(QAbstractItemView::NoEditTriggers);
128 KDirOperatorIconView::~KDirOperatorIconView()
132 QStyleOptionViewItem KDirOperatorIconView::viewOptions()
const
134 QStyleOptionViewItem viewOptions = QListView::viewOptions();
135 viewOptions.showDecorationSelected =
true;
136 viewOptions.decorationPosition = ops->decorationPosition();
138 viewOptions.displayAlignment = Qt::AlignLeft | Qt::AlignVCenter;
140 viewOptions.displayAlignment = Qt::AlignCenter;
146 void KDirOperatorIconView::dragEnterEvent(QDragEnterEvent* event)
148 if (event->mimeData()->hasUrls()) {
149 event->acceptProposedAction();
153 void KDirOperatorIconView::mousePressEvent(QMouseEvent *event)
155 if (!indexAt(event->pos()).isValid()) {
156 const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
157 if (!(modifiers & Qt::ShiftModifier) && !(modifiers & Qt::ControlModifier)) {
162 QListView::mousePressEvent(event);
165 void KDirOperatorIconView::wheelEvent(QWheelEvent *event)
167 QListView::wheelEvent(event);
171 if (event->orientation() == Qt::Vertical) {
172 QWheelEvent horizEvent(event->pos(),
177 QApplication::sendEvent(horizontalScrollBar(), &horizEvent);
183 if (!(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )) {
188 class KDirOperator::Private
194 enum InlinePreviewState {
201 bool checkPreviewInternal()
const;
202 void checkPath(
const QString &txt,
bool takeFiles =
false);
204 int sortColumn()
const;
205 Qt::SortOrder sortOrder()
const;
206 void updateSorting(QDir::SortFlags sort);
208 static bool isReadable(
const KUrl &url);
213 void _k_slotDetailedView();
214 void _k_slotSimpleView();
215 void _k_slotTreeView();
216 void _k_slotDetailedTreeView();
217 void _k_slotToggleHidden(
bool);
218 void _k_togglePreview(
bool);
219 void _k_toggleInlinePreviews(
bool);
220 void _k_slotOpenFileManager();
221 void _k_slotSortByName();
222 void _k_slotSortBySize();
223 void _k_slotSortByDate();
224 void _k_slotSortByType();
225 void _k_slotSortReversed(
bool doReverse);
226 void _k_slotToggleDirsFirst();
227 void _k_slotToggleIgnoreCase();
228 void _k_slotStarted();
229 void _k_slotProgress(
int);
230 void _k_slotShowProgress();
231 void _k_slotIOFinished();
232 void _k_slotCanceled();
233 void _k_slotRedirected(
const KUrl&);
234 void _k_slotProperties();
235 void _k_slotActivated(
const QModelIndex&);
236 void _k_slotSelectionChanged();
237 void _k_openContextMenu(
const QPoint&);
238 void _k_triggerPreview(
const QModelIndex&);
239 void _k_showPreview();
240 void _k_slotSplitterMoved(
int,
int);
241 void _k_assureVisibleSelection();
242 void _k_synchronizeSortingState(
int, Qt::SortOrder);
243 void _k_slotChangeDecorationPosition();
244 void _k_slotExpandToUrl(
const QModelIndex&);
245 void _k_slotItemsChanged();
246 void _k_slotDirectoryCreated(
const KUrl&);
248 void updateListViewGrid();
249 int iconSizeForViewType(QAbstractItemView *itemView)
const;
253 QStack<KUrl*> backStack;
254 QStack<KUrl*> forwardStack;
256 QModelIndex lastHoveredIndex;
263 bool completeListDirty;
264 QDir::SortFlags sorting;
265 QStyleOptionViewItem::Position decorationPosition;
269 QAbstractItemView *itemView;
280 QProgressBar *progressBar;
286 bool dirHighlighting;
287 bool onlyDoubleClickSelectsFiles;
289 QTimer *progressDelayTimer;
309 bool shouldFetchForItems;
310 InlinePreviewState inlinePreviewState;
316 decorationPosition(QStyleOptionViewItem::
Left),
325 dirHighlighting(false),
327 progressDelayTimer(0),
339 shouldFetchForItems(false),
340 inlinePreviewState(NotForced)
344 KDirOperator::Private::~Private()
354 qDeleteAll(backStack);
355 qDeleteAll(forwardStack);
367 delete progressDelayTimer;
368 progressDelayTimer = 0;
375 d->splitter =
new QSplitter(
this);
376 d->splitter->setChildrenCollapsible(
false);
377 connect(d->splitter, SIGNAL(splitterMoved(
int,
int)),
378 this, SLOT(_k_slotSplitterMoved(
int,
int)));
385 if (_url.isEmpty()) {
386 QString strPath = QDir::currentPath();
387 strPath.append(QChar(
'/'));
388 d->currUrl = QUrl::fromLocalFile(strPath);
391 if (d->currUrl.protocol().isEmpty())
392 d->currUrl.setProtocol(QLatin1String(
"file"));
394 d->currUrl.addPath(
"/");
400 setLayoutDirection(Qt::LeftToRight);
403 connect(&d->completion, SIGNAL(match(
QString)),
406 d->progressBar =
new QProgressBar(
this);
407 d->progressBar->setObjectName(
"d->progressBar");
408 d->progressBar->adjustSize();
409 d->progressBar->move(2, height() - d->progressBar->height() - 2);
411 d->progressDelayTimer =
new QTimer(
this);
412 d->progressDelayTimer->setObjectName(QLatin1String(
"d->progressBar delay timer"));
413 connect(d->progressDelayTimer, SIGNAL(
timeout()),
414 SLOT(_k_slotShowProgress()));
416 d->completeListDirty =
false;
422 d->sorting = QDir::NoSort;
423 d->updateSorting(QDir::Name | QDir::DirsFirst);
425 setFocusPolicy(Qt::WheelFocus);
431 disconnect(d->dirLister, 0,
this, 0);
438 d->updateSorting(spec);
449 if (
url().isLocalFile()) {
451 if (path.length() == 3)
452 return (path[0].isLetter() && path[1] ==
':' && path[2] ==
'/');
467 QApplication::restoreOverrideCursor();
468 d->progressBar->hide();
473 d->updateSorting((d->sorting & ~
QDirSortMask) | QDir::Name);
478 d->updateSorting((d->sorting & ~
QDirSortMask) | QDir::Size);
483 d->updateSorting((d->sorting & ~
QDirSortMask) | QDir::Time);
488 d->updateSorting((d->sorting & ~
QDirSortMask) | QDir::Type);
494 d->_k_slotSortReversed(!(d->sorting & QDir::Reversed));
499 d->_k_slotToggleDirsFirst();
504 if (d->proxyModel != 0) {
505 Qt::CaseSensitivity cs = d->proxyModel->sortCaseSensitivity();
506 cs = (cs == Qt::CaseSensitive) ? Qt::CaseInsensitive : Qt::CaseSensitive;
507 d->proxyModel->setSortCaseSensitivity(cs);
513 const bool hasSelection = (d->itemView != 0) &&
514 d->itemView->selectionModel()->hasSelection();
515 d->actionCollection->action(
"trash")->setEnabled(hasSelection);
516 d->actionCollection->action(
"delete")->setEnabled(hasSelection);
517 d->actionCollection->action(
"properties")->setEnabled(hasSelection);
522 const bool showPreview = (w != 0);
526 d->viewKind = (d->viewKind & ~
KFile::PreviewContents);
533 d->splitter->addWidget(w);
537 previewAction->setEnabled(showPreview);
538 previewAction->setChecked(showPreview);
539 setView(static_cast<KFile::FileView>(d->viewKind));
545 if (d->itemView == 0) {
549 const QItemSelection selection = d->proxyModel->mapSelectionToSource(d->itemView->selectionModel()->selection());
551 const QModelIndexList indexList = selection.indexes();
552 foreach(
const QModelIndex &index, indexList) {
553 KFileItem item = d->dirModel->itemForIndex(index);
555 itemList.append(item);
564 if ((item.
isNull()) || (d->itemView == 0)) {
568 const QModelIndex dirIndex = d->dirModel->indexForItem(item);
569 const QModelIndex proxyIndex = d->proxyModel->mapFromSource(dirIndex);
570 return d->itemView->selectionModel()->isSelected(proxyIndex);
575 return (d->dirLister == 0) ? 0 : d->dirLister->directories().count();
580 return (d->dirLister == 0) ? 0 : d->dirLister->items().count() -
numDirs();
590 return const_cast<KCompletion *
>(&d->dirCompletion);
595 return d->actionCollection;
602 void KDirOperator::Private::_k_slotDetailedView()
605 parent->setView(view);
608 void KDirOperator::Private::_k_slotSimpleView()
611 parent->setView(view);
614 void KDirOperator::Private::_k_slotTreeView()
617 parent->setView(view);
620 void KDirOperator::Private::_k_slotDetailedTreeView()
623 parent->setView(view);
626 void KDirOperator::Private::_k_slotToggleHidden(
bool show)
628 dirLister->setShowingDotFiles(show);
630 _k_assureVisibleSelection();
633 void KDirOperator::Private::_k_togglePreview(
bool on)
639 actionCollection->action(
"preview")->setChecked(
true);
640 splitter->addWidget(preview);
645 QMetaObject::invokeMethod(parent,
"_k_assureVisibleSelection", Qt::QueuedConnection);
647 const QModelIndex index = itemView->selectionModel()->currentIndex();
648 if (index.isValid()) {
649 _k_triggerPreview(index);
652 }
else if (preview != 0) {
653 viewKind = viewKind & ~
KFile::PreviewContents;
658 void KDirOperator::Private::_k_toggleInlinePreviews(
bool show)
660 if (showPreviews == show) {
666 if (!previewGenerator) {
670 previewGenerator->setPreviewShown(show);
675 for (
int i = 0; i < model->rowCount(); ++i) {
676 QModelIndex index = model->index(i, 0);
677 const KFileItem item = dirModel->itemForIndex(index);
683 void KDirOperator::Private::_k_slotOpenFileManager()
685 new KRun(currUrl, parent);
688 void KDirOperator::Private::_k_slotSortByName()
690 parent->sortByName();
693 void KDirOperator::Private::_k_slotSortBySize()
695 parent->sortBySize();
698 void KDirOperator::Private::_k_slotSortByDate()
700 parent->sortByDate();
703 void KDirOperator::Private::_k_slotSortByType()
705 parent->sortByType();
708 void KDirOperator::Private::_k_slotSortReversed(
bool doReverse)
710 QDir::SortFlags s = sorting & ~QDir::Reversed;
717 void KDirOperator::Private::_k_slotToggleDirsFirst()
719 QDir::SortFlags s = (sorting ^ QDir::DirsFirst);
723 void KDirOperator::Private::_k_slotToggleIgnoreCase()
739 d->newFileMenu->setPopupFiles(
url());
741 d->newFileMenu->createDirectory();
750 bool writeOk =
false;
754 const QStringList dirs = directory.split(
'/', QString::SkipEmptyParts);
755 QStringList::ConstIterator it = dirs.begin();
757 for (; it != dirs.end(); ++it) {
765 }
else if (!writeOk) {
767 "create that folder."));
768 }
else if (enterDirectory) {
777 bool ask,
bool showProgress)
779 if (items.isEmpty()) {
781 i18n(
"You did not select a file to delete."),
782 i18n(
"Nothing to Delete"));
801 if (items.count() == 1) {
803 i18n(
"<qt>Do you really want to delete\n <b>'%1'</b>?</qt>" ,
810 i18np(
"Do you really want to delete this item?",
"Do you really want to delete these %1 items?", items.count()),
812 i18n(
"Delete Files"),
832 if (!list.isEmpty()) {
839 bool ask,
bool showProgress)
841 if (items.isEmpty()) {
843 i18n(
"You did not select a file to trash."),
844 i18n(
"Nothing to Trash"));
859 if (items.count() == 1) {
861 i18n(
"<qt>Do you really want to trash\n <b>'%1'</b>?</qt>" ,
868 i18np(
"translators: not called for n == 1",
"Do you really want to trash these %1 items?", items.count()),
889 return d->previewGenerator;
894 d->inlinePreviewState = show ? Private::ForcedToTrue : Private::ForcedToFalse;
899 return d->showPreviews;
919 if (d->itemView == 0) {
923 if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
929 if (!list.isEmpty()) {
936 if (d->iconsZoom == _value) {
941 value = qMin(100, value);
942 value = qMax(0, value);
944 d->iconsZoom = value;
946 if (d->configGroup && d->inlinePreviewState == Private::NotForced) {
947 if (qobject_cast<QListView*>(d->itemView)) {
948 d->configGroup->writeEntry(
"listViewIconSize", d->iconsZoom);
950 d->configGroup->writeEntry(
"detailedViewIconSize", d->iconsZoom);
954 if (!d->previewGenerator) {
959 const int val = (maxSize * value / 100) + KIconLoader::SizeSmall;
960 d->itemView->setIconSize(
QSize(val, val));
961 d->updateListViewGrid();
962 d->previewGenerator->updatePreviews();
970 d->pendingMimeTypes.clear();
971 d->completion.clear();
972 d->dirCompletion.clear();
973 d->completeListDirty =
true;
974 d->dirLister->stop();
977 void KDirOperator::Private::checkPath(
const QString &,
bool )
984 text = text.trimmed();
987 if (text.find(
':') < 0 && text[0] !=
'/')
988 text.insert(0, d->currUrl);
992 if (!selection.isNull()) {
993 int position = text.lastIndexOf(
'/');
994 ASSERT(position >= 0);
995 QString filename = text.mid(position + 1, text.length());
996 if (filename != selection)
1001 bool filenameEntered =
false;
1003 if (u.isLocalFile()) {
1010 if (acceptOnlyExisting && !i.isFile())
1011 warning(
"you entered an invalid URL");
1013 filenameEntered =
true;
1018 if (filenameEntered) {
1019 filename_ = u.url();
1020 emit fileSelected(filename_);
1022 QApplication::restoreOverrideCursor();
1027 kDebug(kfile_area) <<
"TODO KDirOperator::checkPath()";
1034 if (!_newurl.isValid())
1035 newurl = QUrl::fromLocalFile(QDir::homePath());
1045 if (!Private::isReadable(newurl)) {
1053 if ((!res || !Private::isReadable(newurl)) && i.
isDir()) {
1056 i18n(
"The specified folder does not exist "
1057 "or was not readable."));
1059 }
else if (!i.
isDir()) {
1066 d->backStack.push(
new KUrl(d->currUrl));
1067 qDeleteAll(d->forwardStack);
1068 d->forwardStack.clear();
1072 d->currUrl = newurl;
1078 QAction* forwardAction = d->actionCollection->action(
"forward");
1079 forwardAction->setEnabled(!d->forwardStack.isEmpty());
1081 QAction* backAction = d->actionCollection->action(
"back");
1082 backAction->setEnabled(!d->backStack.isEmpty());
1084 QAction* upAction = d->actionCollection->action(
"up");
1085 upAction->setEnabled(!
isRoot());
1092 QApplication::setOverrideCursor(Qt::WaitCursor);
1093 d->dirLister->emitChanges();
1094 QApplication::restoreOverrideCursor();
1104 bool KDirOperator::Private::openUrl(
const KUrl& url, KDirLister::OpenUrlFlags flags)
1113 int KDirOperator::Private::sortColumn()
const
1129 Qt::SortOrder KDirOperator::Private::sortOrder()
const
1131 return (sorting & QDir::Reversed) ? Qt::DescendingOrder :
1135 void KDirOperator::Private::updateSorting(QDir::SortFlags sort)
1137 kDebug(kfile_area) <<
"changing sort flags from" << sorting <<
"to" << sort;
1138 if (sort == sorting) {
1142 if ((sorting ^ sort) & QDir::DirsFirst) {
1148 Qt::SortOrder tmpSortOrder = (sortOrder() == Qt::AscendingOrder ? Qt::DescendingOrder : Qt::AscendingOrder);
1149 proxyModel->sort(sortOrder(), tmpSortOrder);
1150 proxyModel->setSortFoldersFirst(sort & QDir::DirsFirst);
1154 parent->updateSortActions();
1155 proxyModel->sort(sortColumn(), sortOrder());
1164 if (treeView != 0) {
1165 QHeaderView* headerView = treeView->header();
1166 headerView->blockSignals(
true);
1167 headerView->setSortIndicator(sortColumn(), sortOrder());
1168 headerView->blockSignals(
false);
1171 _k_assureVisibleSelection();
1177 if (d->itemView == 0)
1180 d->pendingMimeTypes.clear();
1182 d->completion.clear();
1183 d->dirCompletion.clear();
1186 QApplication::restoreOverrideCursor();
1189 QApplication::setOverrideCursor(Qt::WaitCursor);
1191 if (!Private::isReadable(d->currUrl)) {
1193 i18n(
"The specified folder does not exist "
1194 "or was not readable."));
1195 if (d->backStack.isEmpty())
1202 void KDirOperator::Private::_k_slotRedirected(
const KUrl& newURL)
1205 pendingMimeTypes.clear();
1207 dirCompletion.clear();
1208 completeListDirty =
true;
1209 emit parent->urlEntered(newURL);
1215 if (d->backStack.isEmpty())
1218 d->forwardStack.push(
new KUrl(d->currUrl));
1220 KUrl *s = d->backStack.pop();
1229 if (d->forwardStack.isEmpty())
1232 d->backStack.push(
new KUrl(d->currUrl));
1234 KUrl *s = d->forwardStack.pop();
1246 KUrl tmp(d->currUrl);
1247 tmp.
cd(QLatin1String(
".."));
1253 KUrl u = QUrl::fromLocalFile(QDir::homePath());
1259 d->dirLister->setNameFilter(
QString());
1260 d->dirLister->clearMimeFilter();
1266 d->dirLister->setNameFilter(filter);
1272 return d->dirLister->nameFilter();
1277 d->dirLister->setMimeFilter(mimetypes);
1283 return d->dirLister->mimeFilters();
1288 d->newFileMenu->setSupportedMimeTypes(mimeTypes);
1293 return d->newFileMenu->supportedMimeTypes();
1300 bool hasPreviewSupport =
false;
1302 if (cg.
readEntry(
"Show Default Preview",
true))
1303 hasPreviewSupport = d->checkPreviewInternal();
1305 previewAction->setEnabled(hasPreviewSupport);
1306 return hasPreviewSupport;
1314 d->newFileMenu->setPopupFiles(
url());
1316 d->newFileMenu->checkUpToDate();
1320 d->actionMenu->menu()->exec(pos);
1334 switch(event->type()) {
1335 case QEvent::MouseMove: {
1336 if (d->preview && !d->preview->isHidden()) {
1337 const QModelIndex hoveredIndex = d->itemView->indexAt(d->itemView->viewport()->mapFromGlobal(QCursor::pos()));
1339 if (d->lastHoveredIndex == hoveredIndex)
1342 d->lastHoveredIndex = hoveredIndex;
1344 const QModelIndex focusedIndex = d->itemView->selectionModel() ? d->itemView->selectionModel()->currentIndex()
1347 if (!hoveredIndex.isValid() && focusedIndex.isValid() &&
1348 d->itemView->selectionModel()->isSelected(focusedIndex) &&
1349 (d->lastHoveredIndex != focusedIndex)) {
1350 const QModelIndex sourceFocusedIndex = d->proxyModel->mapToSource(focusedIndex);
1351 const KFileItem item = d->dirModel->itemForIndex(sourceFocusedIndex);
1353 d->preview->showPreview(item.
url());
1359 case QEvent::MouseButtonRelease: {
1360 if (d->preview != 0 && !d->preview->isHidden()) {
1361 const QModelIndex hoveredIndex = d->itemView->indexAt(d->itemView->viewport()->mapFromGlobal(QCursor::pos()));
1362 const QModelIndex focusedIndex = d->itemView->selectionModel() ? d->itemView->selectionModel()->currentIndex()
1365 if (((!focusedIndex.isValid()) ||
1366 !d->itemView->selectionModel()->isSelected(focusedIndex)) &&
1367 (!hoveredIndex.isValid())) {
1368 d->preview->clearPreview();
1373 case QEvent::Wheel: {
1374 QWheelEvent *evt =
static_cast<QWheelEvent*
>(event);
1375 if (evt->modifiers() & Qt::ControlModifier) {
1376 if (evt->delta() > 0) {
1392 bool KDirOperator::Private::checkPreviewInternal()
const
1396 if (parent->dirOnlyMode() && supported.indexOf(
"inode/directory") == -1)
1400 const QStringList nameFilter = dirLister->nameFilter().split(
' ', QString::SkipEmptyParts);
1402 if (mimeTypes.isEmpty() && nameFilter.isEmpty() && !supported.isEmpty())
1406 r.setPatternSyntax(QRegExp::Wildcard);
1408 if (!mimeTypes.isEmpty()) {
1409 QStringList::ConstIterator it = supported.begin();
1411 for (; it != supported.end(); ++it) {
1415 if (!result.isEmpty()) {
1421 if (!nameFilter.isEmpty()) {
1423 QStringList::const_iterator it1 = nameFilter.begin();
1424 for (; it1 != nameFilter.end(); ++it1) {
1425 if ((*it1) ==
"*") {
1436 QStringList::ConstIterator it2 = supported.begin();
1437 for (; it2 != supported.end(); ++it2) {
1439 if (r.indexIn(mime) != -1) {
1452 QAbstractItemView *itemView = 0;
1456 itemView = detailView;
1458 itemView =
new KDirOperatorIconView(
this, parent);
1474 d->dropOptions = options;
1497 && d->actionCollection->action(
"preview")->isEnabled();
1500 d->viewKind =
static_cast<int>(viewKind);
1503 QAbstractItemView *newView =
createView(
this, viewKind);
1506 d->_k_togglePreview(preview);
1521 if (d->mode == mode)
1529 if (d->itemView != 0)
1530 setView(static_cast<KFile::FileView>(d->viewKind));
1535 if (view == d->itemView) {
1540 d->pendingMimeTypes.clear();
1541 const bool listDir = (d->itemView == 0);
1544 view->setSelectionMode(QAbstractItemView::ExtendedSelection);
1546 view->setSelectionMode(QAbstractItemView::SingleSelection);
1550 if ((d->itemView != 0) && d->itemView->selectionModel()->hasSelection()) {
1553 const QItemSelection selection = d->itemView->selectionModel()->selection();
1555 selectionModel->select(selection, QItemSelectionModel::Select);
1561 d->itemView->setModel(d->proxyModel);
1562 setFocusProxy(d->itemView);
1564 view->viewport()->installEventFilter(
this);
1567 d->itemView->setItemDelegate(delegate);
1568 d->itemView->viewport()->setAttribute(Qt::WA_Hover);
1569 d->itemView->setContextMenuPolicy(Qt::CustomContextMenu);
1570 d->itemView->setMouseTracking(
true);
1576 QHeaderView* headerView = treeView->header();
1577 headerView->setSortIndicator(d->sortColumn(), d->sortOrder());
1578 connect(headerView, SIGNAL(sortIndicatorChanged(
int,Qt::SortOrder)),
1579 this, SLOT(_k_synchronizeSortingState(
int,Qt::SortOrder)));
1582 connect(d->itemView, SIGNAL(activated(QModelIndex)),
1583 this, SLOT(_k_slotActivated(QModelIndex)));
1584 connect(d->itemView, SIGNAL(customContextMenuRequested(
QPoint)),
1585 this, SLOT(_k_openContextMenu(
QPoint)));
1586 connect(d->itemView, SIGNAL(entered(QModelIndex)),
1587 this, SLOT(_k_triggerPreview(QModelIndex)));
1590 d->splitter->insertWidget(0, d->itemView);
1592 d->splitter->resize(size());
1593 d->itemView->show();
1596 QApplication::setOverrideCursor(Qt::WaitCursor);
1597 d->openUrl(d->currUrl);
1600 if (selectionModel != 0) {
1601 d->itemView->setSelectionModel(selectionModel);
1602 QMetaObject::invokeMethod(
this,
"_k_assureVisibleSelection", Qt::QueuedConnection);
1605 connect(d->itemView->selectionModel(),
1606 SIGNAL(currentChanged(QModelIndex,QModelIndex)),
1607 this, SLOT(_k_triggerPreview(QModelIndex)));
1608 connect(d->itemView->selectionModel(),
1609 SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
1610 this, SLOT(_k_slotSelectionChanged()));
1614 d->decorationMenu->setEnabled(qobject_cast<QListView*>(d->itemView));
1617 if (d->shouldFetchForItems) {
1618 connect(d->dirModel, SIGNAL(expand(QModelIndex)),
this, SLOT(_k_slotExpandToUrl(QModelIndex)));
1620 d->itemsToBeSetAsCurrent.clear();
1623 const bool previewForcedToTrue = d->inlinePreviewState == Private::ForcedToTrue;
1624 const bool previewShown = d->inlinePreviewState == Private::NotForced ? d->showPreviews : previewForcedToTrue;
1627 const int val = (maxSize * d->iconsZoom / 100) + KIconLoader::SizeSmall;
1629 d->previewGenerator->setPreviewShown(previewShown);
1630 d->actionCollection->action(
"inline preview")->setChecked(previewShown);
1633 d->_k_slotChangeDecorationPosition();
1637 const int zoom = previewForcedToTrue ? (
KIconLoader::SizeHuge - KIconLoader::SizeSmall + 1) * 100 / maxSize : d->iconSizeForViewType(view);
1645 if (lister == d->dirLister)
1651 delete d->proxyModel;
1655 d->dirLister = lister;
1658 d->dirModel->setDirLister(d->dirLister);
1661 d->shouldFetchForItems = qobject_cast<
QTreeView*>(d->itemView);
1662 if (d->shouldFetchForItems) {
1663 connect(d->dirModel, SIGNAL(expand(QModelIndex)),
this, SLOT(_k_slotExpandToUrl(QModelIndex)));
1665 d->itemsToBeSetAsCurrent.clear();
1669 d->proxyModel->setSourceModel(d->dirModel);
1671 d->dirLister->setAutoUpdate(
true);
1672 d->dirLister->setDelayedMimeTypes(
true);
1674 QWidget* mainWidget = topLevelWidget();
1675 d->dirLister->setMainWindow(mainWidget);
1678 connect(d->dirLister, SIGNAL(percent(
int)),
1679 SLOT(_k_slotProgress(
int)));
1680 connect(d->dirLister, SIGNAL(started(
KUrl)), SLOT(_k_slotStarted()));
1681 connect(d->dirLister, SIGNAL(completed()), SLOT(_k_slotIOFinished()));
1682 connect(d->dirLister, SIGNAL(canceled()), SLOT(_k_slotCanceled()));
1683 connect(d->dirLister, SIGNAL(redirection(
KUrl)),
1684 SLOT(_k_slotRedirected(
KUrl)));
1685 connect(d->dirLister, SIGNAL(newItems(
KFileItemList)), SLOT(_k_slotItemsChanged()));
1686 connect(d->dirLister, SIGNAL(itemsDeleted(
KFileItemList)), SLOT(_k_slotItemsChanged()));
1687 connect(d->dirLister, SIGNAL(itemsFilteredByMime(
KFileItemList)), SLOT(_k_slotItemsChanged()));
1688 connect(d->dirLister, SIGNAL(
clear()), SLOT(_k_slotItemsChanged()));
1698 QApplication::restoreOverrideCursor();
1705 if ((d->preview != 0 && !d->preview->isHidden()) && !item.
isNull()) {
1706 d->preview->showPreview(item.
url());
1716 KFileItem item = d->dirLister->findByUrl(url);
1717 if (d->shouldFetchForItems && item.
isNull()) {
1718 d->itemsToBeSetAsCurrent <<
url;
1719 d->dirModel->expandToUrl(url);
1738 const QModelIndex dirIndex = d->dirModel->indexForItem(item);
1739 const QModelIndex proxyIndex = d->proxyModel->mapFromSource(dirIndex);
1740 selModel->setCurrentIndex(proxyIndex, QItemSelectionModel::Select);
1754 foreach (
const QString &url, urls) {
1755 KFileItem item = d->dirLister->findByUrl(url);
1756 if (d->shouldFetchForItems && item.
isNull()) {
1757 d->itemsToBeSetAsCurrent <<
url;
1758 d->dirModel->expandToUrl(url);
1771 if (d->itemView == 0) {
1778 QModelIndex proxyIndex;
1779 foreach (
const KFileItem &item, items) {
1781 const QModelIndex dirIndex = d->dirModel->indexForItem(item);
1782 proxyIndex = d->proxyModel->mapFromSource(dirIndex);
1783 selModel->select(proxyIndex, QItemSelectionModel::Select);
1786 if (proxyIndex.isValid()) {
1787 selModel->setCurrentIndex(proxyIndex, QItemSelectionModel::NoUpdate);
1794 if (
string.isEmpty()) {
1795 d->itemView->selectionModel()->clear();
1800 return d->completion.makeCompletion(
string);
1805 if (
string.isEmpty()) {
1806 d->itemView->selectionModel()->clear();
1811 return d->dirCompletion.makeCompletion(
string);
1816 if (d->itemView == 0) {
1820 if (d->completeListDirty) {
1822 foreach (
const KFileItem &item, itemList) {
1823 d->completion.addItem(item.
name());
1825 d->dirCompletion.addItem(item.
name());
1828 d->completeListDirty =
false;
1841 d->actionCollection->setObjectName(
"KDirOperator::actionCollection");
1844 d->actionCollection->addAction(
"popupMenu", d->actionMenu);
1847 upAction->setText(
i18n(
"Parent Folder"));
1854 homeAction->setText(
i18n(
"Home Folder"));
1857 reloadAction->setText(
i18n(
"Reload"));
1861 d->actionCollection->addAction(
"mkdir", mkdirAction);
1862 mkdirAction->setIcon(
KIcon(QLatin1String(
"folder-new")));
1863 connect(mkdirAction, SIGNAL(triggered(
bool)),
this, SLOT(
mkdir()));
1866 d->actionCollection->addAction(
"trash", trash);
1867 trash->setIcon(
KIcon(
"user-trash"));
1869 connect(trash, SIGNAL(triggered(
bool)), SLOT(
trashSelected()));
1872 d->actionCollection->addAction(
"delete", action);
1873 action->setIcon(
KIcon(
"edit-delete"));
1875 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(
deleteSelected()));
1879 d->actionCollection->addAction(
"sorting menu", sortMenu);
1882 d->actionCollection->addAction(
"by name", byNameAction);
1883 connect(byNameAction, SIGNAL(triggered(
bool)),
this, SLOT(_k_slotSortByName()));
1886 d->actionCollection->addAction(
"by size", bySizeAction);
1887 connect(bySizeAction, SIGNAL(triggered(
bool)),
this, SLOT(_k_slotSortBySize()));
1890 d->actionCollection->addAction(
"by date", byDateAction);
1891 connect(byDateAction, SIGNAL(triggered(
bool)),
this, SLOT(_k_slotSortByDate()));
1894 d->actionCollection->addAction(
"by type", byTypeAction);
1895 connect(byTypeAction, SIGNAL(triggered(
bool)),
this, SLOT(_k_slotSortByType()));
1898 d->actionCollection->addAction(
"descending", descendingAction);
1899 connect(descendingAction, SIGNAL(triggered(
bool)),
this, SLOT(_k_slotSortReversed(
bool)));
1902 d->actionCollection->addAction(
"dirs first", dirsFirstAction);
1903 connect(dirsFirstAction, SIGNAL(triggered(
bool)),
this, SLOT(_k_slotToggleDirsFirst()));
1905 QActionGroup* sortGroup =
new QActionGroup(
this);
1906 byNameAction->setActionGroup(sortGroup);
1907 bySizeAction->setActionGroup(sortGroup);
1908 byDateAction->setActionGroup(sortGroup);
1909 byTypeAction->setActionGroup(sortGroup);
1912 d->actionCollection->addAction(
"decoration menu", d->decorationMenu);
1915 d->actionCollection->addAction(
"decorationAtLeft", d->leftAction);
1916 connect(d->leftAction, SIGNAL(triggered(
bool)),
this, SLOT(_k_slotChangeDecorationPosition()));
1919 d->actionCollection->addAction(
"decorationAtTop", topAction);
1920 connect(topAction, SIGNAL(triggered(
bool)),
this, SLOT(_k_slotChangeDecorationPosition()));
1922 d->decorationMenu->addAction(d->leftAction);
1923 d->decorationMenu->addAction(topAction);
1925 QActionGroup* decorationGroup =
new QActionGroup(
this);
1926 d->leftAction->setActionGroup(decorationGroup);
1927 topAction->setActionGroup(decorationGroup);
1930 d->actionCollection->addAction(
"short view", shortAction);
1931 shortAction->setIcon(
KIcon(QLatin1String(
"view-list-icons")));
1932 connect(shortAction, SIGNAL(triggered()), SLOT(_k_slotSimpleView()));
1935 d->actionCollection->addAction(
"detailed view", detailedAction);
1936 detailedAction->setIcon(
KIcon(QLatin1String(
"view-list-details")));
1937 connect(detailedAction, SIGNAL(triggered()), SLOT(_k_slotDetailedView()));
1940 d->actionCollection->addAction(
"tree view", treeAction);
1941 treeAction->setIcon(
KIcon(QLatin1String(
"view-list-tree")));
1942 connect(treeAction, SIGNAL(triggered()), SLOT(_k_slotTreeView()));
1945 d->actionCollection->addAction(
"detailed tree view", detailedTreeAction);
1946 detailedTreeAction->setIcon(
KIcon(QLatin1String(
"view-list-tree")));
1947 connect(detailedTreeAction, SIGNAL(triggered()), SLOT(_k_slotDetailedTreeView()));
1949 QActionGroup* viewGroup =
new QActionGroup(
this);
1950 shortAction->setActionGroup(viewGroup);
1951 detailedAction->setActionGroup(viewGroup);
1952 treeAction->setActionGroup(viewGroup);
1953 detailedTreeAction->setActionGroup(viewGroup);
1956 d->actionCollection->addAction(
"show hidden", showHiddenAction);
1957 connect(showHiddenAction, SIGNAL(toggled(
bool)), SLOT(_k_slotToggleHidden(
bool)));
1960 d->actionCollection->addAction(
"preview", previewAction);
1961 connect(previewAction, SIGNAL(toggled(
bool)),
1962 SLOT(_k_togglePreview(
bool)));
1965 i18n(
"Show Preview"),
this);
1966 d->actionCollection->addAction(
"inline preview", inlinePreview);
1967 connect(inlinePreview, SIGNAL(toggled(
bool)), SLOT(_k_toggleInlinePreviews(
bool)));
1970 d->actionCollection->addAction(
"file manager", fileManager);
1971 fileManager->setIcon(
KIcon(QLatin1String(
"system-file-manager")));
1972 connect(fileManager, SIGNAL(triggered()), SLOT(_k_slotOpenFileManager()));
1975 d->actionCollection->addAction(
"properties", action);
1976 action->setIcon(
KIcon(
"document-properties"));
1978 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(_k_slotProperties()));
1982 d->actionCollection->addAction(
"view menu", viewMenu);
1987 viewMenu->
addAction(detailedTreeAction);
1991 d->newFileMenu =
new KNewFileMenu(d->actionCollection,
"new",
this);
1992 connect(d->newFileMenu, SIGNAL(directoryCreated(
KUrl)),
this, SLOT(_k_slotDirectoryCreated(
KUrl)));
1994 d->actionCollection->addAssociatedWidget(
this);
1995 foreach (
QAction* action, d->actionCollection->actions())
1996 action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
2008 sortMenu->
menu()->clear();
2009 sortMenu->
addAction(d->actionCollection->action(
"by name"));
2010 sortMenu->
addAction(d->actionCollection->action(
"by size"));
2011 sortMenu->
addAction(d->actionCollection->action(
"by date"));
2012 sortMenu->
addAction(d->actionCollection->action(
"by type"));
2014 sortMenu->
addAction(d->actionCollection->action(
"descending"));
2015 sortMenu->
addAction(d->actionCollection->action(
"dirs first"));
2018 d->actionMenu->menu()->clear();
2020 d->actionMenu->addAction(d->actionCollection->action(
"up"));
2021 d->actionMenu->addAction(d->actionCollection->action(
"back"));
2022 d->actionMenu->addAction(d->actionCollection->action(
"forward"));
2023 d->actionMenu->addAction(d->actionCollection->action(
"home"));
2024 d->actionMenu->addSeparator();
2028 d->actionMenu->addAction(d->actionCollection->action(
"new"));
2029 if (d->currUrl.isLocalFile() && !(QApplication::keyboardModifiers() & Qt::ShiftModifier)) {
2030 d->actionMenu->addAction(d->actionCollection->action(
"trash"));
2033 const bool del = !d->currUrl.isLocalFile() ||
2034 (QApplication::keyboardModifiers() & Qt::ShiftModifier) ||
2035 cg.
readEntry(
"ShowDeleteCommand",
false);
2037 d->actionMenu->addAction(d->actionCollection->action(
"delete"));
2039 d->actionMenu->addSeparator();
2043 d->actionMenu->addAction(sortMenu);
2045 d->actionMenu->addSeparator();
2050 d->actionMenu->addAction(d->actionCollection->action(
"view menu"));
2051 d->actionMenu->addSeparator();
2054 if (whichActions & FileActions) {
2055 d->actionMenu->addAction(d->actionCollection->action(
"file manager"));
2056 d->actionMenu->addAction(d->actionCollection->action(
"properties"));
2063 d->actionCollection->action(
"by name")->setChecked(
true);
2065 d->actionCollection->action(
"by date")->setChecked(
true);
2067 d->actionCollection->action(
"by size")->setChecked(
true);
2069 d->actionCollection->action(
"by type")->setChecked(
true);
2071 d->actionCollection->action(
"descending")->setChecked(d->sorting & QDir::Reversed);
2072 d->actionCollection->action(
"dirs first")->setChecked(d->sorting & QDir::DirsFirst);
2093 if (viewStyle == QLatin1String(
"Detail")) {
2095 }
else if (viewStyle == QLatin1String(
"Tree")) {
2097 }
else if (viewStyle == QLatin1String(
"DetailTree")) {
2106 if (configGroup.
readEntry(QLatin1String(
"Show Preview"),
false)) {
2110 d->previewWidth = configGroup.
readEntry(QLatin1String(
"Preview Width"), 100);
2112 if (configGroup.
readEntry(QLatin1String(
"Show hidden files"),
2114 d->actionCollection->action(
"show hidden")->setChecked(
true);
2115 d->dirLister->setShowingDotFiles(
true);
2118 QDir::SortFlags
sorting = QDir::Name;
2119 if (configGroup.
readEntry(QLatin1String(
"Sort directories first"),
2121 sorting |= QDir::DirsFirst;
2125 if (sortBy == name) {
2126 sorting |= QDir::Name;
2127 }
else if (sortBy == QLatin1String(
"Size")) {
2128 sorting |= QDir::Size;
2129 }
else if (sortBy == QLatin1String(
"Date")) {
2130 sorting |= QDir::Time;
2131 }
else if (sortBy == QLatin1String(
"Type")) {
2132 sorting |= QDir::Type;
2135 sorting |= QDir::Reversed;
2137 d->updateSorting(sorting);
2139 if (d->inlinePreviewState == Private::NotForced) {
2140 d->showPreviews = configGroup.
readEntry(QLatin1String(
"Previews"),
false);
2148 QString sortBy = QLatin1String(
"Name");
2150 sortBy = QLatin1String(
"Size");
2152 sortBy = QLatin1String(
"Date");
2154 sortBy = QLatin1String(
"Type");
2157 configGroup.
writeEntry(QLatin1String(
"Sort by"), sortBy);
2159 configGroup.
writeEntry(QLatin1String(
"Sort reversed"),
2160 d->actionCollection->action(
"descending")->isChecked());
2162 configGroup.
writeEntry(QLatin1String(
"Sort directories first"),
2163 d->actionCollection->action(
"dirs first")->isChecked());
2166 bool appSpecificPreview =
false;
2169 appSpecificPreview = (tmp == 0);
2172 if (!appSpecificPreview) {
2174 if (previewAction->isEnabled()) {
2175 bool hasPreview = previewAction->isChecked();
2176 configGroup.
writeEntry(QLatin1String(
"Show Preview"), hasPreview);
2181 Q_ASSERT(sizes.count() == 2);
2182 configGroup.
writeEntry(QLatin1String(
"Preview Width"), sizes[1]);
2187 configGroup.
writeEntry(QLatin1String(
"Show hidden files"),
2188 d->actionCollection->action(
"show hidden")->isChecked());
2193 style = QLatin1String(
"Detail");
2195 style = QLatin1String(
"Simple");
2197 style = QLatin1String(
"Tree");
2199 style = QLatin1String(
"DetailTree");
2200 configGroup.
writeEntry(QLatin1String(
"View Style"), style);
2202 if (d->inlinePreviewState == Private::NotForced) {
2203 configGroup.
writeEntry(QLatin1String(
"Previews"), d->showPreviews);
2206 configGroup.
writeEntry(QLatin1String(
"Decoration position"), (
int) d->decorationPosition);
2214 const bool hasPreview = (sizes.count() == 2);
2216 d->splitter->resize(size());
2217 sizes = d->splitter->sizes();
2219 const bool restorePreviewWidth = hasPreview && (d->previewWidth != sizes[1]);
2220 if (restorePreviewWidth) {
2221 const int availableWidth = sizes[0] + sizes[1];
2222 sizes[0] = availableWidth - d->previewWidth;
2223 sizes[1] = d->previewWidth;
2224 d->splitter->setSizes(sizes);
2227 d->previewWidth = sizes[1];
2230 if (d->progressBar->parent() ==
this) {
2232 d->progressBar->move(2, height() - d->progressBar->height() - 2);
2238 d->onlyDoubleClickSelectsFiles = enable;
2247 return d->onlyDoubleClickSelectsFiles;
2250 void KDirOperator::Private::_k_slotStarted()
2252 progressBar->setValue(0);
2254 progressDelayTimer->setSingleShot(
true);
2255 progressDelayTimer->start(1000);
2258 void KDirOperator::Private::_k_slotShowProgress()
2260 progressBar->raise();
2261 progressBar->show();
2262 QApplication::flush();
2265 void KDirOperator::Private::_k_slotProgress(
int percent)
2267 progressBar->setValue(percent);
2269 if (progressBar->isVisible())
2270 QApplication::flush();
2274 void KDirOperator::Private::_k_slotIOFinished()
2276 progressDelayTimer->stop();
2277 _k_slotProgress(100);
2278 progressBar->hide();
2279 emit parent->finishedLoading();
2280 parent->resetCursor();
2283 preview->clearPreview();
2287 void KDirOperator::Private::_k_slotCanceled()
2289 emit parent->finishedLoading();
2290 parent->resetCursor();
2295 return d->progressBar;
2300 qDeleteAll(d->backStack);
2301 d->backStack.clear();
2302 d->actionCollection->action(
"back")->setEnabled(
false);
2304 qDeleteAll(d->forwardStack);
2305 d->forwardStack.clear();
2306 d->actionCollection->action(
"forward")->setEnabled(
false);
2311 d->dirHighlighting = enable;
2316 return d->dirHighlighting;
2330 void KDirOperator::Private::_k_slotProperties()
2332 if (itemView == 0) {
2337 if (!list.isEmpty()) {
2343 void KDirOperator::Private::_k_slotActivated(
const QModelIndex& index)
2345 const QModelIndex dirIndex = proxyModel->mapToSource(index);
2346 KFileItem item = dirModel->itemForIndex(dirIndex);
2348 const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
2349 if (item.
isNull() || (modifiers & Qt::ShiftModifier) || (modifiers & Qt::ControlModifier))
2353 parent->selectDir(item);
2355 parent->selectFile(item);
2359 void KDirOperator::Private::_k_slotSelectionChanged()
2361 if (itemView == 0) {
2368 const bool multiSelectionMode = (itemView->selectionMode() == QAbstractItemView::ExtendedSelection);
2369 const bool hasSelection = itemView->selectionModel()->hasSelection();
2370 if (multiSelectionMode || !hasSelection) {
2372 parent->highlightFile(nullItem);
2375 KFileItem selectedItem = parent->selectedItems().first();
2376 parent->highlightFile(selectedItem);
2380 void KDirOperator::Private::_k_openContextMenu(
const QPoint& pos)
2382 const QModelIndex proxyIndex = itemView->indexAt(pos);
2383 const QModelIndex dirIndex = proxyModel->mapToSource(proxyIndex);
2384 KFileItem item = dirModel->itemForIndex(dirIndex);
2389 parent->activatedMenu(item, QCursor::pos());
2392 void KDirOperator::Private::_k_triggerPreview(
const QModelIndex& index)
2394 if ((preview != 0 && !preview->isHidden()) && index.isValid() && (index.column() ==
KDirModel::Name)) {
2395 const QModelIndex dirIndex = proxyModel->mapToSource(index);
2396 const KFileItem item = dirModel->itemForIndex(dirIndex);
2401 if (!item.
isDir()) {
2402 previewUrl = item.
url();
2405 preview->clearPreview();
2410 void KDirOperator::Private::_k_showPreview()
2413 preview->showPreview(previewUrl);
2417 void KDirOperator::Private::_k_slotSplitterMoved(
int,
int)
2420 if (sizes.count() == 2) {
2422 previewWidth = sizes[1];
2426 void KDirOperator::Private::_k_assureVisibleSelection()
2428 if (itemView == 0) {
2433 if (selModel->hasSelection()) {
2434 const QModelIndex index = selModel->currentIndex();
2435 itemView->scrollTo(index, QAbstractItemView::EnsureVisible);
2436 _k_triggerPreview(index);
2441 void KDirOperator::Private::_k_synchronizeSortingState(
int logicalIndex, Qt::SortOrder order)
2443 QDir::SortFlags newSort = sorting & ~(
QDirSortMask | QDir::Reversed);
2445 switch (logicalIndex) {
2447 newSort |= QDir::Name;
2450 newSort |= QDir::Size;
2453 newSort |= QDir::Time;
2456 newSort |= QDir::Type;
2462 if (order == Qt::DescendingOrder) {
2463 newSort |= QDir::Reversed;
2466 updateSorting(newSort);
2468 QMetaObject::invokeMethod(parent,
"_k_assureVisibleSelection", Qt::QueuedConnection);
2471 void KDirOperator::Private::_k_slotChangeDecorationPosition()
2483 const bool leftChecked = actionCollection->action(
"decorationAtLeft")->isChecked();
2487 view->setFlow(QListView::TopToBottom);
2490 view->setFlow(QListView::LeftToRight);
2493 updateListViewGrid();
2498 void KDirOperator::Private::_k_slotExpandToUrl(
const QModelIndex &index)
2506 const KFileItem item = dirModel->itemForIndex(index);
2512 if (!item.
isDir()) {
2513 const QModelIndex proxyIndex = proxyModel->mapFromSource(index);
2515 KUrl::List::Iterator it = itemsToBeSetAsCurrent.begin();
2516 while (it != itemsToBeSetAsCurrent.end()) {
2517 const KUrl url = *it;
2519 const KFileItem _item = dirLister->findByUrl(url);
2521 const QModelIndex _index = dirModel->indexForItem(_item);
2522 const QModelIndex _proxyIndex = proxyModel->mapFromSource(_index);
2523 treeView->expand(_proxyIndex);
2527 treeView->selectionModel()->select(proxyIndex, QItemSelectionModel::Select);
2530 it = itemsToBeSetAsCurrent.erase(it);
2535 }
else if (!itemsToBeSetAsCurrent.contains(item.
url())) {
2536 itemsToBeSetAsCurrent << item.
url();
2540 void KDirOperator::Private::_k_slotItemsChanged()
2542 completeListDirty =
true;
2545 void KDirOperator::Private::updateListViewGrid()
2557 const bool leftChecked = actionCollection->action(
"decorationAtLeft")->isChecked();
2560 view->setGridSize(
QSize());
2566 const QFontMetrics metrics(itemView->viewport()->font());
2567 int size = itemView->iconSize().height() + metrics.height() * 2;
2569 view->setGridSize(
QSize(size * (3.0 / 2.0), size + metrics.height()));
2577 int KDirOperator::Private::iconSizeForViewType(QAbstractItemView *itemView)
const
2579 if (!itemView || !configGroup) {
2583 if (qobject_cast<QListView*>(itemView)) {
2584 return configGroup->readEntry(
"listViewIconSize", 0);
2586 return configGroup->readEntry(
"detailedViewIconSize", 0);
2592 delete d->configGroup;
2598 return d->configGroup;
2603 d->actionCollection->action(
"show hidden")->setChecked(s);
2608 return d->actionCollection->action(
"show hidden")->isChecked();
2613 return d->decorationPosition;
2618 d->decorationPosition = position;
2620 d->actionCollection->action(
"decorationAtLeft")->setChecked(decorationAtLeft);
2621 d->actionCollection->action(
"decorationAtTop")->setChecked(!decorationAtLeft);
2626 bool KDirOperator::Private::isReadable(
const KUrl& url)
2631 KDE_struct_stat buf;
2637 bool readable = (
KDE::stat(ts, &buf) == 0);
2640 test = opendir(QFile::encodeName(ts));
2641 readable = (test != 0);
2648 void KDirOperator::Private::_k_slotDirectoryCreated(
const KUrl& url)
2650 parent->setUrl(url,
true);
2653 #include "kdiroperator.moc"