VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp@ 102493

Last change on this file since 102493 was 102485, checked in by vboxsync, 9 months ago

FE/Qt: bugref:10561. Some refactoring.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 44.0 KB
Line 
1/* $Id: UIFileManagerTable.cpp 102485 2023-12-05 17:37:02Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIFileManagerTable class implementation.
4 */
5
6/*
7 * Copyright (C) 2016-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QAction>
30#include <QCheckBox>
31#include <QHBoxLayout>
32#include <QHeaderView>
33#include <QItemDelegate>
34#include <QGridLayout>
35#include <QTextEdit>
36
37/* GUI includes: */
38#include "QIDialog.h"
39#include "QIDialogButtonBox.h"
40#include "QILabel.h"
41#include "QILineEdit.h"
42#include "QIToolBar.h"
43#include "UIActionPool.h"
44#include "UICommon.h"
45#include "UIFileSystemModel.h"
46#include "UIErrorString.h"
47#include "UIFileManager.h"
48#include "UIFileManagerTable.h"
49#include "UIFileTableNavigationWidget.h"
50#include "UIIconPool.h"
51#include "UIPathOperations.h"
52#include "UITranslator.h"
53
54/* COM includes: */
55#include "CFsObjInfo.h"
56#include "CGuestFsObjInfo.h"
57#include "CGuestDirectory.h"
58#include "CProgress.h"
59
60
61/*********************************************************************************************************************************
62* UIGuestControlFileView definition. *
63*********************************************************************************************************************************/
64
65/** Using QITableView causes the following problem when I click on the table items
66 Qt WARNING: Cannot creat accessible child interface for object: UIGuestControlFileView.....
67 so for now subclass QTableView */
68class UIGuestControlFileView : public QTableView
69{
70
71 Q_OBJECT;
72
73signals:
74
75 void sigSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
76
77public:
78
79 UIGuestControlFileView(QWidget * parent = 0);
80 bool hasSelection() const;
81 bool isInEditState() const;
82
83protected:
84
85 virtual void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected) /*override */;
86
87private:
88
89 void configure();
90 QWidget *m_pParent;
91};
92
93
94/*********************************************************************************************************************************
95* UIFileDelegate definition. *
96*********************************************************************************************************************************/
97/** A QItemDelegate child class to disable dashed lines drawn around selected cells in QTableViews */
98class UIFileDelegate : public QItemDelegate
99{
100
101 Q_OBJECT;
102
103public:
104
105 UIFileDelegate(QObject *pParent)
106 : QItemDelegate(pParent){}
107
108protected:
109
110 virtual void drawFocus ( QPainter * /*painter*/, const QStyleOptionViewItem & /*option*/, const QRect & /*rect*/ ) const {}
111};
112
113
114/*********************************************************************************************************************************
115* UStringInputDialog definition. *
116*********************************************************************************************************************************/
117
118/** A QIDialog child including a line edit whose text exposed when the dialog is accepted */
119class UIStringInputDialog : public QIDialog
120{
121
122 Q_OBJECT;
123
124public:
125
126 UIStringInputDialog(QWidget *pParent = 0, Qt::WindowFlags enmFlags = Qt::WindowFlags());
127 QString getString() const;
128
129private:
130
131 QILineEdit *m_pLineEdit;
132};
133
134
135/*********************************************************************************************************************************
136* UIFileDeleteConfirmationDialog definition. *
137*********************************************************************************************************************************/
138
139/** A QIDialog child including a line edit whose text exposed when the dialog is accepted */
140class UIFileDeleteConfirmationDialog : public QIDialog
141{
142
143 Q_OBJECT;
144
145public:
146
147 UIFileDeleteConfirmationDialog(QWidget *pParent = 0, Qt::WindowFlags enmFlags = Qt::WindowFlags());
148 /** Returns whether m_pAskNextTimeCheckBox is checked or not. */
149 bool askDeleteConfirmationNextTime() const;
150
151private:
152
153 QCheckBox *m_pAskNextTimeCheckBox;
154 QILabel *m_pQuestionLabel;
155};
156
157
158/*********************************************************************************************************************************
159* UIHostDirectoryDiskUsageComputer implementation. *
160*********************************************************************************************************************************/
161
162UIDirectoryDiskUsageComputer::UIDirectoryDiskUsageComputer(QObject *parent, QStringList pathList)
163 :QThread(parent)
164 , m_pathList(pathList)
165 , m_fOkToContinue(true)
166{
167}
168
169void UIDirectoryDiskUsageComputer::run()
170{
171 for (int i = 0; i < m_pathList.size(); ++i)
172 directoryStatisticsRecursive(m_pathList[i], m_resultStatistics);
173}
174
175void UIDirectoryDiskUsageComputer::stopRecursion()
176{
177 m_mutex.lock();
178 m_fOkToContinue = false;
179 m_mutex.unlock();
180}
181
182bool UIDirectoryDiskUsageComputer::isOkToContinue() const
183{
184 return m_fOkToContinue;
185}
186
187
188/*********************************************************************************************************************************
189* UIGuestControlFileView implementation. *
190*********************************************************************************************************************************/
191
192UIGuestControlFileView::UIGuestControlFileView(QWidget *parent)
193 :QTableView(parent)
194 , m_pParent(parent)
195{
196 configure();
197}
198
199void UIGuestControlFileView::configure()
200{
201 setContextMenuPolicy(Qt::CustomContextMenu);
202 setShowGrid(false);
203 setSelectionBehavior(QAbstractItemView::SelectRows);
204 verticalHeader()->setVisible(false);
205 setEditTriggers(QAbstractItemView::NoEditTriggers);
206 /* Minimize the row height: */
207 verticalHeader()->setDefaultSectionSize(verticalHeader()->minimumSectionSize());
208 setAlternatingRowColors(true);
209 installEventFilter(m_pParent);
210}
211
212bool UIGuestControlFileView::hasSelection() const
213{
214 QItemSelectionModel *pSelectionModel = selectionModel();
215 if (!pSelectionModel)
216 return false;
217 return pSelectionModel->hasSelection();
218}
219
220bool UIGuestControlFileView::isInEditState() const
221{
222 return state() == QAbstractItemView::EditingState;
223}
224
225void UIGuestControlFileView::selectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
226{
227 emit sigSelectionChanged(selected, deselected);
228 QTableView::selectionChanged(selected, deselected);
229}
230
231
232/*********************************************************************************************************************************
233* UIFileStringInputDialog implementation. *
234*********************************************************************************************************************************/
235
236UIStringInputDialog::UIStringInputDialog(QWidget *pParent /* = 0 */, Qt::WindowFlags enmFlags /* = Qt::WindowFlags() */)
237 :QIDialog(pParent, enmFlags)
238{
239 QVBoxLayout *layout = new QVBoxLayout(this);
240 m_pLineEdit = new QILineEdit(this);
241 layout->addWidget(m_pLineEdit);
242
243 QIDialogButtonBox *pButtonBox =
244 new QIDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
245 layout->addWidget(pButtonBox);
246 connect(pButtonBox, &QIDialogButtonBox::accepted, this, &UIStringInputDialog::accept);
247 connect(pButtonBox, &QIDialogButtonBox::rejected, this, &UIStringInputDialog::reject);
248}
249
250QString UIStringInputDialog::getString() const
251{
252 if (!m_pLineEdit)
253 return QString();
254 return m_pLineEdit->text();
255}
256
257
258/*********************************************************************************************************************************
259* UIPropertiesDialog implementation. *
260*********************************************************************************************************************************/
261
262UIPropertiesDialog::UIPropertiesDialog(QWidget *pParent, Qt::WindowFlags enmFlags)
263 :QIDialog(pParent, enmFlags)
264 , m_pMainLayout(new QVBoxLayout)
265 , m_pInfoEdit(new QTextEdit)
266{
267 setLayout(m_pMainLayout);
268
269 if (m_pMainLayout)
270 m_pMainLayout->addWidget(m_pInfoEdit);
271 if (m_pInfoEdit)
272 {
273 m_pInfoEdit->setReadOnly(true);
274 m_pInfoEdit->setFrameStyle(QFrame::NoFrame);
275 }
276 QIDialogButtonBox *pButtonBox =
277 new QIDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, this);
278 m_pMainLayout->addWidget(pButtonBox);
279 connect(pButtonBox, &QIDialogButtonBox::accepted, this, &UIStringInputDialog::accept);
280}
281
282void UIPropertiesDialog::setPropertyText(const QString &strProperty)
283{
284 if (!m_pInfoEdit)
285 return;
286 m_strProperty = strProperty;
287 m_pInfoEdit->setHtml(strProperty);
288}
289
290void UIPropertiesDialog::addDirectoryStatistics(UIDirectoryStatistics directoryStatistics)
291{
292 if (!m_pInfoEdit)
293 return;
294 // QString propertyString = m_pInfoEdit->toHtml();
295 // propertyString += "<b>Total Size:</b> " + QString::number(directoryStatistics.m_totalSize) + QString(" bytes");
296 // if (directoryStatistics.m_totalSize >= UIFileManagerTable::m_iKiloByte)
297 // propertyString += " (" + UIFileManagerTable::humanReadableSize(directoryStatistics.m_totalSize) + ")";
298 // propertyString += "<br/>";
299 // propertyString += "<b>File Count:</b> " + QString::number(directoryStatistics.m_uFileCount);
300
301 // m_pInfoEdit->setHtml(propertyString);
302
303 QString detailsString(m_strProperty);
304 detailsString += "<br/>";
305 detailsString += "<b>" + UIFileManager::tr("Total Size") + "</b> " +
306 QString::number(directoryStatistics.m_totalSize) + UIFileManager::tr(" bytes");
307 if (directoryStatistics.m_totalSize >= UIFileManagerTable::m_iKiloByte)
308 detailsString += " (" + UIFileManagerTable::humanReadableSize(directoryStatistics.m_totalSize) + ")";
309 detailsString += "<br/>";
310
311 detailsString += "<b>" + UIFileManager::tr("File Count") + ":</b> " +
312 QString::number(directoryStatistics.m_uFileCount);
313
314 m_pInfoEdit->setHtml(detailsString);
315}
316
317
318/*********************************************************************************************************************************
319* UIDirectoryStatistics implementation. *
320*********************************************************************************************************************************/
321
322UIDirectoryStatistics::UIDirectoryStatistics()
323 : m_totalSize(0)
324 , m_uFileCount(0)
325 , m_uDirectoryCount(0)
326 , m_uSymlinkCount(0)
327{
328}
329
330/*********************************************************************************************************************************
331+* UIFileDeleteConfirmationDialog implementation. *
332+*********************************************************************************************************************************/
333
334UIFileDeleteConfirmationDialog::UIFileDeleteConfirmationDialog(QWidget *pParent /* = 0 */, Qt::WindowFlags enmFlags /* = Qt::WindowFlags() */)
335 :QIDialog(pParent, enmFlags)
336 , m_pAskNextTimeCheckBox(0)
337 , m_pQuestionLabel(0)
338{
339 QVBoxLayout *pLayout = new QVBoxLayout(this);
340
341 m_pQuestionLabel = new QILabel;
342 if (m_pQuestionLabel)
343 {
344 pLayout->addWidget(m_pQuestionLabel);
345 m_pQuestionLabel->setText(UIFileManager::tr("Delete the selected file(s) and/or folder(s)"));
346 }
347
348 QIDialogButtonBox *pButtonBox =
349 new QIDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
350 if (pButtonBox)
351 {
352 pLayout->addWidget(pButtonBox, 0, Qt::AlignCenter);
353 connect(pButtonBox, &QIDialogButtonBox::accepted, this, &UIStringInputDialog::accept);
354 connect(pButtonBox, &QIDialogButtonBox::rejected, this, &UIStringInputDialog::reject);
355 }
356
357 m_pAskNextTimeCheckBox = new QCheckBox;
358
359 if (m_pAskNextTimeCheckBox)
360 {
361 UIFileManagerOptions *pFileManagerOptions = UIFileManagerOptions::instance();
362 if (pFileManagerOptions)
363 m_pAskNextTimeCheckBox->setChecked(pFileManagerOptions->fAskDeleteConfirmation);
364
365 pLayout->addWidget(m_pAskNextTimeCheckBox);
366 m_pAskNextTimeCheckBox->setText(UIFileManager::tr("Ask for this confirmation next time"));
367 m_pAskNextTimeCheckBox->setToolTip(UIFileManager::tr("Delete confirmation can be "
368 "disabled/enabled also from the Options panel."));
369 }
370}
371
372bool UIFileDeleteConfirmationDialog::askDeleteConfirmationNextTime() const
373{
374 if (!m_pAskNextTimeCheckBox)
375 return true;
376 return m_pAskNextTimeCheckBox->isChecked();
377}
378
379
380/*********************************************************************************************************************************
381* UIFileManagerTable implementation. *
382*********************************************************************************************************************************/
383const unsigned UIFileManagerTable::m_iKiloByte = 1024; /**< Our kilo bytes are a power of two! (bird) */
384
385UIFileManagerTable::UIFileManagerTable(UIActionPool *pActionPool, QWidget *pParent /* = 0 */)
386 :QIWithRetranslateUI<QWidget>(pParent)
387 , m_eFileOperationType(FileOperationType_None)
388 , m_pLocationLabel(0)
389 , m_pPropertiesDialog(0)
390 , m_pActionPool(pActionPool)
391 , m_pToolBar(0)
392 , m_pMainLayout(0)
393 , m_pNavigationWidget(0)
394 , m_pModel(0)
395 , m_pView(0)
396 , m_pProxyModel(0)
397 , m_pathSeparator('/')
398 , m_pToolBarLayout(0)
399{
400 prepareObjects();
401}
402
403UIFileManagerTable::~UIFileManagerTable()
404{
405}
406
407void UIFileManagerTable::reset()
408{
409 if (m_pModel)
410 m_pModel->reset();
411
412 if (m_pNavigationWidget)
413 m_pNavigationWidget->reset();
414}
415
416void UIFileManagerTable::prepareObjects()
417{
418 m_pMainLayout = new QGridLayout();
419 if (!m_pMainLayout)
420 return;
421 m_pMainLayout->setSpacing(0);
422 m_pMainLayout->setContentsMargins(0, 0, 0, 0);
423 setLayout(m_pMainLayout);
424
425 m_pToolBarLayout = new QHBoxLayout;
426 if (m_pToolBarLayout)
427 {
428 m_pToolBarLayout->setSpacing(0);
429 m_pToolBarLayout->setContentsMargins(0, 0, 0, 0);
430
431 m_pToolBar = new QIToolBar;
432 if (m_pToolBar)
433 {
434 m_pToolBarLayout->addWidget(m_pToolBar);
435 m_sessionWidgets << m_pToolBar;
436 }
437
438 m_pMainLayout->addLayout(m_pToolBarLayout, 0, 0, 1, 7);
439 }
440
441 m_pLocationLabel = new QILabel;
442 if (m_pLocationLabel)
443 {
444 m_pMainLayout->addWidget(m_pLocationLabel, 1, 0, 1, 1);
445 m_sessionWidgets << m_pLocationLabel;
446 }
447
448 m_pNavigationWidget = new UIFileTableNavigationWidget;
449 if (m_pNavigationWidget)
450 {
451 m_pNavigationWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
452 connect(m_pNavigationWidget, &UIFileTableNavigationWidget::sigPathChanged,
453 this, &UIFileManagerTable::sltHandleNavigationWidgetPathChange);
454 connect(m_pNavigationWidget, &UIFileTableNavigationWidget::sigHistoryListChanged,
455 this, &UIFileManagerTable::sltHandleNavigationWidgetHistoryListChanged);
456 m_pMainLayout->addWidget(m_pNavigationWidget, 1, 1, 1, 6);
457 m_sessionWidgets << m_pNavigationWidget;
458 }
459
460 m_pModel = new UIFileSystemModel(this);
461 if (!m_pModel)
462 return;
463
464 connect(m_pModel, &UIFileSystemModel::sigItemRenamed,
465 this, &UIFileManagerTable::sltHandleItemRenameAttempt);
466
467 m_pProxyModel = new UIFileSystemProxyModel(this);
468 if (!m_pProxyModel)
469 return;
470 m_pProxyModel->setSourceModel(m_pModel);
471
472 m_pView = new UIGuestControlFileView(this);
473 if (m_pView)
474 {
475 m_pView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
476 m_pMainLayout->addWidget(m_pView, 2, 0, 5, 7);
477
478 QHeaderView *pHorizontalHeader = m_pView->horizontalHeader();
479 if (pHorizontalHeader)
480 {
481 pHorizontalHeader->setHighlightSections(false);
482 pHorizontalHeader->setSectionResizeMode(QHeaderView::ResizeToContents);
483 pHorizontalHeader->setStretchLastSection(true);
484 }
485
486 m_pView->setModel(m_pProxyModel);
487 m_pView->setItemDelegate(new UIFileDelegate(this));
488 m_pView->setSortingEnabled(true);
489 m_pView->sortByColumn(0, Qt::AscendingOrder);
490
491 connect(m_pView, &UIGuestControlFileView::doubleClicked,
492 this, &UIFileManagerTable::sltItemDoubleClicked);
493 connect(m_pView, &UIGuestControlFileView::clicked,
494 this, &UIFileManagerTable::sltItemClicked);
495 connect(m_pView, &UIGuestControlFileView::sigSelectionChanged,
496 this, &UIFileManagerTable::sltSelectionChanged);
497 connect(m_pView, &UIGuestControlFileView::customContextMenuRequested,
498 this, &UIFileManagerTable::sltCreateFileViewContextMenu);
499 m_pView->hideColumn(UIFileSystemModelData_LocalPath);
500 m_pView->hideColumn(UIFileSystemModelData_ISOFilePath);
501 m_pView->hideColumn(UIFileSystemModelData_RemovedFromVISO);
502 m_pView->hideColumn(UIFileSystemModelData_DescendantRemovedFromVISO);
503
504 m_sessionWidgets << m_pView;
505 }
506
507 m_pSearchLineEdit = new QILineEdit;
508 if (m_pSearchLineEdit)
509 {
510 m_pMainLayout->addWidget(m_pSearchLineEdit, 8, 0, 1, 7);
511 m_pSearchLineEdit->hide();
512 m_pSearchLineEdit->setClearButtonEnabled(true);
513 m_searchLineUnmarkColor = m_pSearchLineEdit->palette().color(QPalette::Base);
514 m_searchLineMarkColor = QColor(m_searchLineUnmarkColor.green(),
515 0.5 * m_searchLineUnmarkColor.green(),
516 0.5 * m_searchLineUnmarkColor.blue());
517 connect(m_pSearchLineEdit, &QLineEdit::textChanged,
518 this, &UIFileManagerTable::sltSearchTextChanged);
519 }
520 optionsUpdated();
521}
522
523void UIFileManagerTable::updateCurrentLocationEdit(const QString& strLocation)
524{
525 if (m_pNavigationWidget)
526 m_pNavigationWidget->setPath(strLocation);
527}
528
529void UIFileManagerTable::changeLocation(const QModelIndex &index)
530{
531 if (!index.isValid() || !m_pView)
532 return;
533 m_pView->setRootIndex(m_pProxyModel->mapFromSource(index));
534
535 if (m_pView->selectionModel())
536 m_pView->selectionModel()->reset();
537
538 UIFileSystemItem *item = static_cast<UIFileSystemItem*>(index.internalPointer());
539 if (item)
540 {
541 updateCurrentLocationEdit(item->path());
542 }
543 setSelectionDependentActionsEnabled(false);
544
545 m_pView->scrollToTop();
546}
547
548void UIFileManagerTable::initializeFileTree()
549{
550 if (m_pModel)
551 m_pModel->reset();
552 if (!rootItem())
553 return;
554
555 QString startPath("/");
556 /* On Unix-like systems startItem represents the root directory. On Windows it is like "my computer" under which
557 * drives are listed: */
558 UIFileSystemItem* startItem = new UIFileSystemItem(startPath, rootItem(), KFsObjType_Directory);
559
560 startItem->setIsOpened(false);
561 populateStartDirectory(startItem);
562
563 m_pModel->signalUpdate();
564 m_pView->setRootIndex(m_pProxyModel->mapFromSource(m_pModel->rootIndex()));
565 updateCurrentLocationEdit(currentDirectoryPath());
566}
567
568void UIFileManagerTable::populateStartDirectory(UIFileSystemItem *startItem)
569{
570 determineDriveLetters();
571 if (m_driveLetterList.isEmpty())
572 {
573 /* Read the root directory and get the list: */
574 readDirectory(startItem->path(), startItem, true);
575 }
576 else
577 {
578 for (int i = 0; i < m_driveLetterList.size(); ++i)
579 {
580 UIFileSystemItem* driveItem = new UIFileSystemItem(UIPathOperations::removeTrailingDelimiters(m_driveLetterList[i]),
581 startItem, KFsObjType_Directory);
582 driveItem->setIsOpened(false);
583 driveItem->setIsDriveItem(true);
584 startItem->setIsOpened(true);
585 }
586 }
587}
588
589void UIFileManagerTable::checkDotDot(QMap<QString,UIFileSystemItem*> &map,
590 UIFileSystemItem *parent, bool isStartDir)
591{
592 if (!parent)
593 return;
594 /* Make sure we have an item representing up directory, and make sure it is not there for the start dir: */
595 if (!map.contains(UIFileSystemModel::strUpDirectoryString) && !isStartDir)
596 {
597 UIFileSystemItem *item = new UIFileSystemItem(UIFileSystemModel::strUpDirectoryString,
598 parent, KFsObjType_Directory);
599 item->setIsOpened(false);
600 map.insert(UIFileSystemModel::strUpDirectoryString, item);
601 }
602 else if (map.contains(UIFileSystemModel::strUpDirectoryString) && isStartDir)
603 {
604 map.remove(UIFileSystemModel::strUpDirectoryString);
605 }
606}
607
608void UIFileManagerTable::sltItemDoubleClicked(const QModelIndex &index)
609{
610 if (!index.isValid() || !m_pModel || !m_pView)
611 return;
612 QModelIndex nIndex = m_pProxyModel ? m_pProxyModel->mapToSource(index) : index;
613 goIntoDirectory(nIndex);
614}
615
616void UIFileManagerTable::sltItemClicked(const QModelIndex &index)
617{
618 Q_UNUSED(index);
619 disableSelectionSearch();
620}
621
622void UIFileManagerTable::sltGoUp()
623{
624 if (!m_pView || !m_pModel)
625 return;
626 QModelIndex currentRoot = currentRootIndex();
627
628 if (!currentRoot.isValid())
629 return;
630 if (currentRoot != m_pModel->rootIndex())
631 {
632 QModelIndex parentIndex = currentRoot.parent();
633 if (parentIndex.isValid())
634 {
635 changeLocation(currentRoot.parent());
636 m_pView->selectRow(currentRoot.row());
637 }
638 }
639}
640
641void UIFileManagerTable::sltGoHome()
642{
643 goToHomeDirectory();
644}
645
646void UIFileManagerTable::sltGoForward()
647{
648 if (m_pNavigationWidget)
649 m_pNavigationWidget->goForwardInHistory();
650}
651
652void UIFileManagerTable::sltGoBackward()
653{
654 if (m_pNavigationWidget)
655 m_pNavigationWidget->goBackwardInHistory();
656}
657
658void UIFileManagerTable::sltRefresh()
659{
660 refresh();
661}
662
663void UIFileManagerTable::goIntoDirectory(const QModelIndex &itemIndex)
664{
665 if (!m_pModel)
666 return;
667
668 /* Make sure the colum is 0: */
669 QModelIndex index = m_pModel->index(itemIndex.row(), 0, itemIndex.parent());
670 if (!index.isValid())
671 return;
672
673 UIFileSystemItem *item = static_cast<UIFileSystemItem*>(index.internalPointer());
674 if (!item)
675 return;
676
677 /* check if we need to go up: */
678 if (item->isUpDirectory())
679 {
680 QModelIndex parentIndex = m_pModel->parent(m_pModel->parent(index));
681 if (parentIndex.isValid())
682 changeLocation(parentIndex);
683 return;
684 }
685
686 if (item->isDirectory() || item->isSymLinkToADirectory())
687 {
688 if (!item->isOpened())
689 {
690 if (readDirectory(item->path(),item))
691 changeLocation(index);
692 }
693 else
694 changeLocation(index);
695 }
696}
697
698void UIFileManagerTable::goIntoDirectory(const QStringList &pathTrail)
699{
700 UIFileSystemItem *parent = getStartDirectoryItem();
701
702 for(int i = 0; i < pathTrail.size(); ++i)
703 {
704 if (!parent)
705 return;
706 /* Make sure parent is already opened: */
707 if (!parent->isOpened())
708 if (!readDirectory(parent->path(), parent, parent == getStartDirectoryItem()))
709 return;
710 /* search the current path item among the parent's children: */
711 UIFileSystemItem *item = parent->child(pathTrail.at(i));
712
713 if (!item)
714 return;
715 parent = item;
716 }
717 if (!parent)
718 return;
719 if (!parent->isOpened())
720 {
721 if (!readDirectory(parent->path(), parent, parent == getStartDirectoryItem()))
722 return;
723 }
724 goIntoDirectory(parent);
725}
726
727void UIFileManagerTable::goIntoDirectory(UIFileSystemItem *item)
728{
729 if (!item || !m_pModel)
730 return;
731 goIntoDirectory(m_pModel->index(item));
732}
733
734UIFileSystemItem* UIFileManagerTable::indexData(const QModelIndex &index) const
735{
736 if (!index.isValid())
737 return 0;
738 return static_cast<UIFileSystemItem*>(index.internalPointer());
739}
740
741void UIFileManagerTable::refresh()
742{
743 if (!m_pView || !m_pModel)
744 return;
745 QModelIndex currentIndex = currentRootIndex();
746
747 UIFileSystemItem *treeItem = indexData(currentIndex);
748 if (!treeItem)
749 return;
750 bool isRootDir = (m_pModel->rootIndex() == currentIndex);
751 m_pModel->beginReset();
752 /* For now we clear the whole subtree (that isrecursively) which is an overkill: */
753 treeItem->clearChildren();
754 if (isRootDir)
755 populateStartDirectory(treeItem);
756 else
757 readDirectory(treeItem->path(), treeItem, isRootDir);
758 m_pModel->endReset();
759 m_pView->setRootIndex(m_pProxyModel->mapFromSource(currentIndex));
760 setSelectionDependentActionsEnabled(m_pView->hasSelection());
761}
762
763void UIFileManagerTable::relist()
764{
765 if (!m_pProxyModel)
766 return;
767 m_pProxyModel->invalidate();
768}
769
770void UIFileManagerTable::sltDelete()
771{
772 if (!checkIfDeleteOK())
773 return;
774
775 if (!m_pView || !m_pModel)
776 return;
777
778 if (!m_pView || !m_pModel)
779 return;
780 QItemSelectionModel *selectionModel = m_pView->selectionModel();
781 if (!selectionModel)
782 return;
783
784 QModelIndexList selectedItemIndices = selectionModel->selectedRows();
785 for(int i = 0; i < selectedItemIndices.size(); ++i)
786 {
787 QModelIndex index =
788 m_pProxyModel ? m_pProxyModel->mapToSource(selectedItemIndices.at(i)) : selectedItemIndices.at(i);
789 deleteByIndex(index);
790 }
791 /** @todo dont refresh here, just delete the rows and update the table view: */
792 refresh();
793}
794
795void UIFileManagerTable::sltRename()
796{
797 if (!m_pView || !m_pModel)
798 return;
799 QItemSelectionModel *selectionModel = m_pView->selectionModel();
800 if (!selectionModel)
801 return;
802
803 QModelIndexList selectedItemIndices = selectionModel->selectedRows();
804 if (selectedItemIndices.size() == 0)
805 return;
806 QModelIndex modelIndex =
807 m_pProxyModel ? m_pProxyModel->mapToSource(selectedItemIndices.at(0)) : selectedItemIndices.at(0);
808 UIFileSystemItem *item = indexData(modelIndex);
809 if (!item || item->isUpDirectory())
810 return;
811 m_pView->edit(selectedItemIndices.at(0));
812}
813
814void UIFileManagerTable::sltCreateNewDirectory()
815{
816 if (!m_pModel || !m_pView)
817 return;
818 QModelIndex currentIndex = currentRootIndex();
819 if (!currentIndex.isValid())
820 return;
821 UIFileSystemItem *parentFolderItem = static_cast<UIFileSystemItem*>(currentIndex.internalPointer());
822 if (!parentFolderItem)
823 return;
824 QString strBase(UIFileSystemModel::tr("NewDirectory"));
825 QString newDirectoryName(strBase);
826 QStringList nameList = currentDirectoryListing();
827 int iSuffix = 1;
828 while (nameList.contains(newDirectoryName))
829 newDirectoryName = QString("%1_%2").arg(strBase).arg(QString::number(iSuffix++));
830
831 if (!createDirectory(parentFolderItem->path(), newDirectoryName))
832 return;
833
834 /* Refesh the current directory so that we correctly populate the child list of parentFolderItem: */
835 /** @todo instead of refreshing here (an overkill) just add the
836 rows and update the tabel view: */
837 sltRefresh();
838
839 /* Now we try to edit the newly created item thereby enabling the user to rename the new item: */
840 QList<UIFileSystemItem*> content = parentFolderItem->children();
841 UIFileSystemItem* newItem = 0;
842 /* Search the new item: */
843 foreach (UIFileSystemItem* childItem, content)
844 {
845
846 if (childItem && newDirectoryName == childItem->fileObjectName())
847 newItem = childItem;
848 }
849
850 if (!newItem)
851 return;
852 QModelIndex newItemIndex = m_pProxyModel->mapFromSource(m_pModel->index(newItem));
853 if (!newItemIndex.isValid())
854 return;
855 m_pView->edit(newItemIndex);
856}
857
858void UIFileManagerTable::sltCopy()
859{
860 m_copyCutBuffer = selectedItemPathList();
861 m_eFileOperationType = FileOperationType_Copy;
862 setPasteActionEnabled(true);
863}
864
865void UIFileManagerTable::sltCut()
866{
867 m_copyCutBuffer = selectedItemPathList();
868 m_eFileOperationType = FileOperationType_Cut;
869 setPasteActionEnabled(true);
870}
871
872void UIFileManagerTable::sltPaste()
873{
874 m_copyCutBuffer.clear();
875
876 m_eFileOperationType = FileOperationType_None;
877 setPasteActionEnabled(false);
878}
879
880void UIFileManagerTable::sltShowProperties()
881{
882 showProperties();
883}
884
885void UIFileManagerTable::sltSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
886{
887 Q_UNUSED(selected);
888 Q_UNUSED(deselected);
889 setSelectionDependentActionsEnabled(m_pView->hasSelection());
890}
891
892void UIFileManagerTable::sltSelectAll()
893{
894 if (!m_pModel || !m_pView)
895 return;
896 m_pView->selectAll();
897 deSelectUpDirectoryItem();
898}
899
900void UIFileManagerTable::sltInvertSelection()
901{
902 setSelectionForAll(QItemSelectionModel::Toggle | QItemSelectionModel::Rows);
903 deSelectUpDirectoryItem();
904}
905
906void UIFileManagerTable::sltSearchTextChanged(const QString &strText)
907{
908 performSelectionSearch(strText);
909}
910
911void UIFileManagerTable::sltHandleItemRenameAttempt(UIFileSystemItem *pItem, const QString &strOldPath,
912 const QString &strOldName, const QString &strNewName)
913{
914 Q_UNUSED(strNewName);
915 if (!pItem)
916 return;
917 /* Attempt to chage item name in the file system: */
918 if (!renameItem(pItem, strOldPath))
919 {
920 /* Restore the previous name. relist the view: */
921 pItem->setData(strOldName, static_cast<int>(UIFileSystemModelData_Name));
922 relist();
923 emit sigLogOutput(QString(pItem->path()).append(" could not be renamed"), QString(), FileManagerLogType_Error);
924 }
925}
926
927void UIFileManagerTable::sltCreateFileViewContextMenu(const QPoint &point)
928{
929 QWidget *pSender = qobject_cast<QWidget*>(sender());
930 if (!pSender)
931 return;
932 createFileViewContextMenu(pSender, point);
933}
934
935void UIFileManagerTable::sltHandleNavigationWidgetPathChange(const QString& strPath)
936{
937 goIntoDirectory(UIPathOperations::pathTrail(strPath));
938}
939
940void UIFileManagerTable::sltHandleNavigationWidgetHistoryListChanged()
941{
942 toggleForwardBackwardActions();
943}
944
945void UIFileManagerTable::deSelectUpDirectoryItem()
946{
947 if (!m_pView)
948 return;
949 QItemSelectionModel *pSelectionModel = m_pView->selectionModel();
950 if (!pSelectionModel)
951 return;
952 QModelIndex currentRoot = currentRootIndex();
953 if (!currentRoot.isValid())
954 return;
955
956 /* Make sure that "up directory item" (if exists) is deselected: */
957 for (int i = 0; i < m_pModel->rowCount(currentRoot); ++i)
958 {
959 QModelIndex index = m_pModel->index(i, 0, currentRoot);
960 if (!index.isValid())
961 continue;
962
963 UIFileSystemItem *item = static_cast<UIFileSystemItem*>(index.internalPointer());
964 if (item && item->isUpDirectory())
965 {
966 QModelIndex indexToDeselect = m_pProxyModel ? m_pProxyModel->mapFromSource(index) : index;
967 pSelectionModel->select(indexToDeselect, QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
968 }
969 }
970}
971
972void UIFileManagerTable::setSelectionForAll(QItemSelectionModel::SelectionFlags flags)
973{
974 if (!m_pView)
975 return;
976 QItemSelectionModel *pSelectionModel = m_pView->selectionModel();
977 if (!pSelectionModel)
978 return;
979 QModelIndex currentRoot = currentRootIndex();
980 if (!currentRoot.isValid())
981 return;
982
983 for (int i = 0; i < m_pModel->rowCount(currentRoot); ++i)
984 {
985 QModelIndex index = m_pModel->index(i, 0, currentRoot);
986 if (!index.isValid())
987 continue;
988 QModelIndex indexToSelect = m_pProxyModel ? m_pProxyModel->mapFromSource(index) : index;
989 pSelectionModel->select(indexToSelect, flags);
990 }
991}
992
993void UIFileManagerTable::setSelection(const QModelIndex &indexInProxyModel)
994{
995 if (!m_pView)
996 return;
997 QItemSelectionModel *selectionModel = m_pView->selectionModel();
998 if (!selectionModel)
999 return;
1000 selectionModel->select(indexInProxyModel, QItemSelectionModel::Current | QItemSelectionModel::Rows | QItemSelectionModel::Select);
1001 m_pView->scrollTo(indexInProxyModel, QAbstractItemView::EnsureVisible);
1002}
1003
1004void UIFileManagerTable::deleteByIndex(const QModelIndex &itemIndex)
1005{
1006 UIFileSystemItem *treeItem = indexData(itemIndex);
1007 if (!treeItem)
1008 return;
1009 deleteByItem(treeItem);
1010}
1011
1012void UIFileManagerTable::retranslateUi()
1013{
1014 UIFileSystemItem *pRootItem = rootItem();
1015 if (pRootItem)
1016 {
1017 pRootItem->setData(UIFileManager::tr("Name"), UIFileSystemModelData_Name);
1018 pRootItem->setData(UIFileManager::tr("Size"), UIFileSystemModelData_Size);
1019 pRootItem->setData(UIFileManager::tr("Change Time"), UIFileSystemModelData_ChangeTime);
1020 pRootItem->setData(UIFileManager::tr("Owner"), UIFileSystemModelData_Owner);
1021 pRootItem->setData(UIFileManager::tr("Permissions"), UIFileSystemModelData_Permissions);
1022 }
1023}
1024
1025bool UIFileManagerTable::eventFilter(QObject *pObject, QEvent *pEvent) /* override */
1026{
1027 /* Handle only events sent to m_pView: */
1028 if (pObject != m_pView)
1029 return QIWithRetranslateUI<QWidget>::eventFilter(pObject, pEvent);
1030
1031 if (pEvent->type() == QEvent::KeyPress)
1032 {
1033 QKeyEvent *pKeyEvent = dynamic_cast<QKeyEvent*>(pEvent);
1034 if (pKeyEvent)
1035 {
1036 if (pKeyEvent->key() == Qt::Key_Enter || pKeyEvent->key() == Qt::Key_Return)
1037 {
1038 if (m_pView && m_pModel && !m_pView->isInEditState())
1039 {
1040 /* Get the selected item. If there are 0 or more than 1 selection do nothing: */
1041 QItemSelectionModel *selectionModel = m_pView->selectionModel();
1042 if (selectionModel)
1043 {
1044 QModelIndexList selectedItemIndices = selectionModel->selectedRows();
1045 if (selectedItemIndices.size() == 1 && m_pModel)
1046 goIntoDirectory( m_pProxyModel->mapToSource(selectedItemIndices.at(0)));
1047 }
1048 }
1049 return true;
1050 }
1051 else if (pKeyEvent->key() == Qt::Key_Delete)
1052 {
1053 sltDelete();
1054 return true;
1055 }
1056 else if (pKeyEvent->key() == Qt::Key_Backspace)
1057 {
1058 sltGoUp();
1059 return true;
1060 }
1061 else if (pKeyEvent->text().length() == 1 &&
1062 (pKeyEvent->text().at(0).isDigit() ||
1063 pKeyEvent->text().at(0).isLetter()))
1064 {
1065 if (m_pSearchLineEdit)
1066 {
1067 markUnmarkSearchLineEdit(false);
1068 m_pSearchLineEdit->clear();
1069 m_pSearchLineEdit->show();
1070 m_pSearchLineEdit->setFocus();
1071 m_pSearchLineEdit->setText(pKeyEvent->text());
1072 }
1073 }
1074 else if (pKeyEvent->key() == Qt::Key_Tab)
1075 {
1076 return true;
1077 }
1078 }
1079 }
1080 else if (pEvent->type() == QEvent::FocusOut)
1081 {
1082 disableSelectionSearch();
1083 }
1084
1085 /* Call to base-class: */
1086 return QIWithRetranslateUI<QWidget>::eventFilter(pObject, pEvent);
1087}
1088
1089UIFileSystemItem *UIFileManagerTable::getStartDirectoryItem()
1090{
1091 UIFileSystemItem* pRootItem = rootItem();
1092 if (!pRootItem)
1093 return 0;
1094 if (pRootItem->childCount() <= 0)
1095 return 0;
1096 return pRootItem->child(0);
1097}
1098
1099QString UIFileManagerTable::currentDirectoryPath() const
1100{
1101 if (!m_pView)
1102 return QString();
1103 QModelIndex currentRoot = currentRootIndex();
1104 if (!currentRoot.isValid())
1105 return QString();
1106 UIFileSystemItem *item = static_cast<UIFileSystemItem*>(currentRoot.internalPointer());
1107 if (!item)
1108 return QString();
1109 /* be paranoid: */
1110 if (!item->isDirectory())
1111 return QString();
1112 return item->path();
1113}
1114
1115QStringList UIFileManagerTable::selectedItemPathList()
1116{
1117 QItemSelectionModel *selectionModel = m_pView->selectionModel();
1118 if (!selectionModel)
1119 return QStringList();
1120
1121 QStringList pathList;
1122 QModelIndexList selectedItemIndices = selectionModel->selectedRows();
1123 for(int i = 0; i < selectedItemIndices.size(); ++i)
1124 {
1125 QModelIndex index =
1126 m_pProxyModel ? m_pProxyModel->mapToSource(selectedItemIndices.at(i)) : selectedItemIndices.at(i);
1127 UIFileSystemItem *item = static_cast<UIFileSystemItem*>(index.internalPointer());
1128 if (!item)
1129 continue;
1130 pathList.push_back(item->path());
1131 }
1132 return pathList;
1133}
1134
1135CGuestFsObjInfo UIFileManagerTable::guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const
1136{
1137 if (comGuestSession.isNull())
1138 return CGuestFsObjInfo();
1139 CGuestFsObjInfo comFsObjInfo = comGuestSession.FsObjQueryInfo(path, true /*aFollowSymlinks*/);
1140 if (!comFsObjInfo.isOk())
1141 return CGuestFsObjInfo();
1142 return comFsObjInfo;
1143}
1144
1145void UIFileManagerTable::setSelectionDependentActionsEnabled(bool fIsEnabled)
1146{
1147 foreach (QAction *pAction, m_selectionDependentActions)
1148 pAction->setEnabled(fIsEnabled);
1149 if (m_pView)
1150 emit sigSelectionChanged(m_pView->hasSelection());
1151}
1152
1153UIFileSystemItem* UIFileManagerTable::rootItem()
1154{
1155 if (!m_pModel)
1156 return 0;
1157 return m_pModel->rootItem();
1158}
1159
1160void UIFileManagerTable::setPathSeparator(const QChar &separator)
1161{
1162 m_pathSeparator = separator;
1163 if (m_pNavigationWidget)
1164 m_pNavigationWidget->setPathSeparator(m_pathSeparator);
1165}
1166
1167QHBoxLayout* UIFileManagerTable::toolBarLayout()
1168{
1169 return m_pToolBarLayout;
1170}
1171
1172bool UIFileManagerTable::event(QEvent *pEvent)
1173{
1174 if (pEvent->type() == QEvent::EnabledChange)
1175 retranslateUi();
1176 return QIWithRetranslateUI<QWidget>::event(pEvent);
1177}
1178
1179QString UIFileManagerTable::fileTypeString(KFsObjType type)
1180{
1181 QString strType = UIFileManager::tr("Unknown");
1182 switch (type)
1183 {
1184 case KFsObjType_File:
1185 strType = UIFileManager::tr("File");
1186 break;
1187 case KFsObjType_Directory:
1188 strType = UIFileManager::tr("Directory");
1189 break;
1190 case KFsObjType_Symlink:
1191 strType = UIFileManager::tr("Symbolic Link");
1192 break;
1193 case KFsObjType_Unknown:
1194 default:
1195 strType = UIFileManager::tr("Unknown");
1196 break;
1197 }
1198 return strType;
1199}
1200
1201/* static */ QString UIFileManagerTable::humanReadableSize(ULONG64 size)
1202{
1203 return UITranslator::formatSize(size);
1204}
1205
1206void UIFileManagerTable::optionsUpdated()
1207{
1208 UIFileManagerOptions *pOptions = UIFileManagerOptions::instance();
1209 if (pOptions)
1210 {
1211 if (m_pProxyModel)
1212 {
1213 m_pProxyModel->setListDirectoriesOnTop(pOptions->fListDirectoriesOnTop);
1214 m_pProxyModel->setShowHiddenObjects(pOptions->fShowHiddenObjects);
1215 }
1216 if (m_pModel)
1217 m_pModel->setShowHumanReadableSizes(pOptions->fShowHumanReadableSizes);
1218 }
1219 relist();
1220}
1221
1222bool UIFileManagerTable::hasSelection() const
1223{
1224 if (m_pView)
1225 return m_pView->hasSelection();
1226 return false;
1227}
1228
1229void UIFileManagerTable::setDragDropMode(QAbstractItemView::DragDropMode behavior)
1230{
1231 if (m_pView)
1232 m_pView->setDragDropMode(behavior);
1233}
1234
1235void UIFileManagerTable::sltReceiveDirectoryStatistics(UIDirectoryStatistics statistics)
1236{
1237 if (!m_pPropertiesDialog)
1238 return;
1239 m_pPropertiesDialog->addDirectoryStatistics(statistics);
1240}
1241
1242QModelIndex UIFileManagerTable::currentRootIndex() const
1243{
1244 if (!m_pView)
1245 return QModelIndex();
1246 if (!m_pProxyModel)
1247 return m_pView->rootIndex();
1248 return m_pProxyModel->mapToSource(m_pView->rootIndex());
1249}
1250
1251void UIFileManagerTable::performSelectionSearch(const QString &strSearchText)
1252{
1253 if (!m_pProxyModel | !m_pView)
1254 return;
1255
1256 if (strSearchText.isEmpty())
1257 {
1258 markUnmarkSearchLineEdit(false);
1259 return;
1260 }
1261
1262 int rowCount = m_pProxyModel->rowCount(m_pView->rootIndex());
1263 UIFileSystemItem *pFoundItem = 0;
1264 QModelIndex index;
1265 for (int i = 0; i < rowCount && !pFoundItem; ++i)
1266 {
1267 index = m_pProxyModel->index(i, 0, m_pView->rootIndex());
1268 if (!index.isValid())
1269 continue;
1270 pFoundItem = static_cast<UIFileSystemItem*>(m_pProxyModel->mapToSource(index).internalPointer());
1271 if (!pFoundItem)
1272 continue;
1273 const QString &strName = pFoundItem->fileObjectName();
1274 if (!strName.startsWith(m_pSearchLineEdit->text(), Qt::CaseInsensitive))
1275 pFoundItem = 0;
1276 }
1277 if (pFoundItem)
1278 {
1279 /* Deselect anything that is already selected: */
1280 m_pView->clearSelection();
1281 setSelection(index);
1282 }
1283 markUnmarkSearchLineEdit(!pFoundItem);
1284}
1285
1286void UIFileManagerTable::disableSelectionSearch()
1287{
1288 if (!m_pSearchLineEdit)
1289 return;
1290 m_pSearchLineEdit->blockSignals(true);
1291 m_pSearchLineEdit->clear();
1292 m_pSearchLineEdit->hide();
1293 m_pSearchLineEdit->blockSignals(false);
1294}
1295
1296bool UIFileManagerTable::checkIfDeleteOK()
1297{
1298 UIFileManagerOptions *pFileManagerOptions = UIFileManagerOptions::instance();
1299 if (!pFileManagerOptions)
1300 return true;
1301 if (!pFileManagerOptions->fAskDeleteConfirmation)
1302 return true;
1303 UIFileDeleteConfirmationDialog *pDialog =
1304 new UIFileDeleteConfirmationDialog(this);
1305
1306 bool fContinueWithDelete = (pDialog->execute() == QDialog::Accepted);
1307 bool bAskNextTime = pDialog->askDeleteConfirmationNextTime();
1308
1309 /* Update the file manager options only if it is necessary: */
1310 if (pFileManagerOptions->fAskDeleteConfirmation != bAskNextTime)
1311 {
1312 pFileManagerOptions->fAskDeleteConfirmation = bAskNextTime;
1313 /* Notify file manager options panel so that the check box there is updated: */
1314 emit sigDeleteConfirmationOptionChanged();
1315 }
1316
1317 delete pDialog;
1318
1319 return fContinueWithDelete;
1320
1321}
1322
1323void UIFileManagerTable::markUnmarkSearchLineEdit(bool fMark)
1324{
1325 if (!m_pSearchLineEdit)
1326 return;
1327 QPalette palette = m_pSearchLineEdit->palette();
1328
1329 if (fMark)
1330 palette.setColor(QPalette::Base, m_searchLineMarkColor);
1331 else
1332 palette.setColor(QPalette::Base, m_searchLineUnmarkColor);
1333 m_pSearchLineEdit->setPalette(palette);
1334}
1335
1336void UIFileManagerTable::setSessionWidgetsEnabled(bool fEnabled)
1337{
1338 foreach (QWidget *pWidget, m_sessionWidgets)
1339 {
1340 if (pWidget)
1341 pWidget->setEnabled(fEnabled);
1342 }
1343}
1344
1345QStringList UIFileManagerTable::currentDirectoryListing() const
1346{
1347 UIFileSystemItem *pItem = static_cast<UIFileSystemItem*>(currentRootIndex().internalPointer());
1348 if (!pItem)
1349 return QStringList();
1350 QStringList list;
1351 foreach (const UIFileSystemItem *pChild, pItem->children())
1352 {
1353 if (pChild)
1354 list << pChild->fileObjectName();
1355 }
1356 return list;
1357}
1358
1359void UIFileManagerTable::setModelFileSystem(bool fIsWindowsFileSystem)
1360{
1361 if (m_pModel)
1362 m_pModel->setIsWindowsFileSystem(fIsWindowsFileSystem);
1363 /* On Windows it is generally desired to sort file objects case insensitively: */
1364 if (m_pProxyModel)
1365 {
1366 if (fIsWindowsFileSystem)
1367 m_pProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
1368 else
1369 m_pProxyModel->setSortCaseSensitivity(Qt::CaseSensitive);
1370 }
1371}
1372
1373#include "UIFileManagerTable.moc"
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette