59 #include <QtGui/QCheckBox> 60 #include <QtGui/QDockWidget> 61 #include <QtGui/QLayout> 62 #include <QtGui/QLabel> 63 #include <QtGui/QLineEdit> 64 #include <QtGui/QSplitter> 65 #include <QtGui/QAbstractProxyModel> 66 #include <QtGui/QHelpEvent> 67 #include <QtGui/QApplication> 68 #include <QtCore/QFSFileEngine> 73 class KFileWidgetPrivate
81 placesViewSplitter(0),
83 labeledCustomWidget(0),
84 bottomCustomWidget(0),
85 autoSelectExtCheckBox(0),
92 autoSelectExtChecked(false),
95 hasDefaultFilter(false),
98 confirmOverwrite(false),
99 differentHierarchyLevelItemsEntered(false),
105 ~KFileWidgetPrivate()
107 delete bookmarkHandler;
111 void updateLocationWhatsThis();
112 void updateAutoSelectExtension();
115 void readViewConfig();
116 void writeViewConfig();
117 void setNonExtSelection();
118 void setLocationText(
const KUrl&);
120 void appendExtension(
KUrl &url);
121 void updateLocationEditExtension(
const QString &);
130 KUrl::List tokenize(
const QString& line)
const;
134 void readRecentFiles();
138 void saveRecentFiles();
143 void multiSelectionChanged();
148 KUrl getCompleteUrl(
const QString&)
const;
154 void setDummyHistoryEntry(
const QString& text,
const QPixmap& icon = QPixmap(),
155 bool usePreviousPixmapIfNull =
true);
160 void removeDummyHistoryEntry();
168 bool toOverwrite(
const KUrl&);
171 void _k_slotLocationChanged(
const QString& );
172 void _k_urlEntered(
const KUrl& );
173 void _k_enterUrl(
const KUrl& );
174 void _k_enterUrl(
const QString& );
175 void _k_locationAccepted(
const QString& );
176 void _k_slotFilterChanged();
177 void _k_fileHighlighted(
const KFileItem& );
178 void _k_fileSelected(
const KFileItem& );
179 void _k_slotLoadingFinished();
180 void _k_fileCompletion(
const QString& );
181 void _k_toggleSpeedbar(
bool );
182 void _k_toggleBookmarks(
bool );
183 void _k_slotAutoSelectExtClicked();
184 void _k_placesViewSplitterMoved(
int,
int);
185 void _k_activateUrlNavigator();
186 void _k_zoomOutIconsSize();
187 void _k_zoomInIconsSize();
188 void _k_slotIconSizeSliderMoved(
int);
189 void _k_slotIconSizeChanged(
int);
191 void addToRecentDocuments();
193 QString locationEditCurrentText()
const;
202 void setInlinePreviewShown(
bool show);
214 QBoxLayout *boxLayout;
225 QDockWidget *placesDock;
227 QSplitter *placesViewSplitter;
237 QCheckBox *autoSelectExtCheckBox;
257 QTimer filterDelayTimer;
262 bool autoSelectExtChecked : 1;
266 bool keepLocation : 1;
272 bool hasDefaultFilter : 1;
273 bool autoDirectoryFollowing : 1;
277 bool confirmOverwrite : 1;
278 bool differentHierarchyLevelItemsEntered;
281 QSlider *iconSizeSlider;
290 static const
char autocompletionWhatsThisText[] = I18N_NOOP("<qt>While typing in the text area, you may be presented "
291 "with possible matches. "
292 "This feature can be controlled by clicking with the right mouse button "
293 "and selecting a preferred mode from the <b>Text Completion</b> menu.</qt>");
298 int len =
string.length();
299 static const char prot[] =
":/";
300 for (
int i=0; i < len;) {
301 i =
string.indexOf( QLatin1String(prot), i );
305 for (; j >= 0; j--) {
306 const QChar& ch(
string[j] );
307 if (ch.toLatin1() == 0 || !ch.isLetter())
309 if (ch.isSpace() && (i-j-1) >= 2)
322 KUrl startDir(_startDir);
327 d->okButton->setDefault(
true);
331 d->cancelButton->hide();
333 d->opsWidget =
new QWidget(
this);
334 QVBoxLayout *opsWidgetLayout =
new QVBoxLayout(d->opsWidget);
335 opsWidgetLayout->setMargin(0);
336 opsWidgetLayout->setSpacing(0);
338 d->toolbar =
new KToolBar(d->opsWidget,
true);
339 d->toolbar->setObjectName(
"KFileWidget::toolbar");
340 d->toolbar->setMovable(
false);
341 opsWidgetLayout->addWidget(d->toolbar);
347 d->url =
getStartUrl( startDir, d->fileClass, filename );
357 d->urlNavigator->setPlacesSelectorVisible(
false);
358 opsWidgetLayout->addWidget(d->urlNavigator);
363 foreach(
const QFileInfo &drive,QFSFileEngine::drives() )
397 d->ops->setObjectName(
"KFileWidget::ops" );
398 d->ops->setIsSaving(d->operationMode ==
Saving);
399 opsWidgetLayout->addWidget(d->ops);
400 connect(d->ops, SIGNAL(urlEntered(
KUrl)),
401 SLOT(_k_urlEntered(
KUrl)));
406 connect(d->ops, SIGNAL(finishedLoading()),
407 SLOT(_k_slotLoadingFinished()));
423 coll->
action(
"up" )->setWhatsThis(
i18n(
"<qt>Click this button to enter the parent folder.<br /><br />" 424 "For instance, if the current location is file:/home/%1 clicking this " 425 "button will take you to file:/home.</qt>",
KUser().loginName() ));
427 coll->
action(
"back" )->setWhatsThis(
i18n(
"Click this button to move backwards one step in the browsing history."));
428 coll->
action(
"forward" )->setWhatsThis(
i18n(
"Click this button to move forward one step in the browsing history."));
430 coll->
action(
"reload" )->setWhatsThis(
i18n(
"Click this button to reload the contents of the current location."));
431 coll->
action(
"mkdir" )->setShortcut( QKeySequence(Qt::Key_F10) );
432 coll->
action(
"mkdir" )->setWhatsThis(
i18n(
"Click this button to create a new folder."));
434 KAction *goToNavigatorAction = coll->
addAction(
"gotonavigator",
this, SLOT(_k_activateUrlNavigator()) );
435 goToNavigatorAction->
setShortcut( QKeySequence(Qt::CTRL + Qt::Key_L) );
439 coll->
addAction(
"toggleSpeedbar", showSidebarAction);
440 showSidebarAction->
setShortcut( QKeySequence(Qt::Key_F9) );
441 connect( showSidebarAction, SIGNAL(toggled(
bool)),
442 SLOT(_k_toggleSpeedbar(
bool)) );
446 coll->
addAction(
"toggleBookmarks", showBookmarksAction);
447 connect( showBookmarksAction, SIGNAL(toggled(
bool)),
448 SLOT(_k_toggleBookmarks(
bool)) );
452 menu->setWhatsThis(
i18n(
"<qt>This is the preferences menu for the file dialog. " 453 "Various options can be accessed from this menu including: <ul>" 454 "<li>how files are sorted in the list</li>" 455 "<li>types of view, including icon and list</li>" 456 "<li>showing of hidden files</li>" 457 "<li>the Places navigation panel</li>" 458 "<li>file previews</li>" 459 "<li>separating folders from files</li></ul></qt>"));
468 KShortcut( QKeySequence(Qt::ALT + Qt::Key_Period), QKeySequence(Qt::Key_F8) ) );
473 coll->
action(
"inline preview" )->setShortcut( QKeySequence(Qt::Key_F11) );
477 connect( menu->
menu(), SIGNAL(aboutToShow()),
478 d->ops, SLOT(updateSelectionDependentActions()));
480 d->iconSizeSlider =
new QSlider(
this);
481 d->iconSizeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
482 d->iconSizeSlider->setOrientation(Qt::Horizontal);
483 d->iconSizeSlider->setMinimum(0);
484 d->iconSizeSlider->setMaximum(100);
485 d->iconSizeSlider->installEventFilter(
this);
486 connect(d->iconSizeSlider, SIGNAL(valueChanged(
int)),
487 d->ops, SLOT(setIconsZoom(
int)));
488 connect(d->iconSizeSlider, SIGNAL(valueChanged(
int)),
489 this, SLOT(_k_slotIconSizeChanged(
int)));
490 connect(d->iconSizeSlider, SIGNAL(sliderMoved(
int)),
491 this, SLOT(_k_slotIconSizeSliderMoved(
int)));
492 connect(d->ops, SIGNAL(currentIconSizeChanged(
int)),
493 d->iconSizeSlider, SLOT(setValue(
int)));
496 connect(furtherAction, SIGNAL(triggered()), SLOT(_k_zoomOutIconsSize()));
498 connect(closerAction, SIGNAL(triggered()), SLOT(_k_zoomInIconsSize()));
501 midSpacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
504 separator->setSeparator(
true);
507 separator2->setSeparator(
true);
509 d->toolbar->addAction(coll->
action(
"back" ));
510 d->toolbar->addAction(coll->
action(
"forward"));
511 d->toolbar->addAction(coll->
action(
"up"));
512 d->toolbar->addAction(coll->
action(
"reload"));
513 d->toolbar->addAction(separator);
514 d->toolbar->addAction(coll->
action(
"inline preview"));
515 d->toolbar->addWidget(midSpacer);
516 d->toolbar->addAction(furtherAction);
517 d->toolbar->addWidget(d->iconSizeSlider);
518 d->toolbar->addAction(closerAction);
519 d->toolbar->addAction(separator2);
520 d->toolbar->addAction(coll->
action(
"mkdir"));
521 d->toolbar->addAction(menu);
523 d->toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
524 d->toolbar->setMovable(
false);
530 connect( d->urlNavigator, SIGNAL(urlChanged(
KUrl)),
531 this, SLOT(_k_enterUrl(
KUrl)));
532 connect( d->urlNavigator, SIGNAL(returnPressed()),
533 d->ops, SLOT(setFocus()));
535 QString whatsThisText;
538 d->locationLabel =
new QLabel(
i18n(
"&Name:"),
this);
540 d->locationEdit->installEventFilter(
this);
544 d->locationEdit->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
545 connect( d->locationEdit, SIGNAL(editTextChanged(QString)),
546 SLOT(_k_slotLocationChanged(QString)) );
548 d->updateLocationWhatsThis();
549 d->locationLabel->setBuddy(d->locationEdit);
552 d->locationEdit->setCompletionObject( fileCompletionObj );
553 d->locationEdit->setAutoDeleteCompletionObject(
true );
554 connect( fileCompletionObj, SIGNAL(match(QString)),
555 SLOT(_k_fileCompletion(QString)) );
557 connect(d->locationEdit, SIGNAL(returnPressed(QString)),
558 this, SLOT(_k_locationAccepted(QString)));
561 whatsThisText =
i18n(
"<qt>This is the filter to apply to the file list. " 562 "File names that do not match the filter will not be shown.<p>" 563 "You may select from one of the preset filters in the " 564 "drop down menu, or you may enter a custom filter " 565 "directly into the text area.</p><p>" 566 "Wildcards such as * and ? are allowed.</p></qt>");
567 d->filterLabel =
new QLabel(
i18n(
"&Filter:"),
this);
568 d->filterLabel->setWhatsThis(whatsThisText);
573 d->filterWidget->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
574 d->filterWidget->setWhatsThis(whatsThisText);
575 d->filterLabel->setBuddy(d->filterWidget);
576 connect(d->filterWidget, SIGNAL(
filterChanged()), SLOT(_k_slotFilterChanged()));
578 d->filterDelayTimer.setSingleShot(
true);
579 d->filterDelayTimer.setInterval(300);
580 connect(d->filterWidget, SIGNAL(editTextChanged(QString)), &d->filterDelayTimer, SLOT(start()));
581 connect(&d->filterDelayTimer, SIGNAL(
timeout()), SLOT(_k_slotFilterChanged()));
585 d->autoSelectExtCheckBox =
new QCheckBox (
this);
586 d->autoSelectExtCheckBox->setStyleSheet(QString(
"QCheckBox { padding-top: %1px; }").arg(
KDialog::spacingHint()));
587 connect(d->autoSelectExtCheckBox, SIGNAL(clicked()), SLOT(_k_slotAutoSelectExtClicked()));
596 coll->
action(
"inline preview")->setChecked(d->ops->isInlinePreviewShown());
597 d->iconSizeSlider->setValue(d->ops->iconsZoom());
611 bool statRes =
false;
612 if ( filename.isEmpty() )
620 kDebug(
kfile_area) <<
"statJob -> startDir" << startDir <<
"filename" << filename;
624 d->ops->setUrl(startDir,
true);
625 d->urlNavigator->setLocationUrl(startDir);
627 d->placesView->setUrl(startDir);
632 if (!filename.isEmpty()) {
633 QLineEdit* lineEdit = d->locationEdit->lineEdit();
636 d->setLocationText(filename);
638 lineEdit->setText(filename);
640 lineEdit->setModified(
true);
642 lineEdit->selectAll();
645 d->locationEdit->setFocus();
658 d->locationLabel->setText(text);
663 int pos = filter.indexOf(
'/');
668 if (pos > 0 && filter[pos - 1] !=
'\\') {
669 QStringList filters = filter.split(
' ', QString::SkipEmptyParts);
677 QString
copy (filter);
678 for (pos = 0; (pos = copy.indexOf(
"\\/", pos)) != -1; ++pos)
681 d->ops->clearFilter();
682 d->filterWidget->setFilter(copy);
683 d->ops->setNameFilter(d->filterWidget->currentFilter());
685 d->hasDefaultFilter =
false;
686 d->filterWidget->setEditable(
true );
688 d->updateAutoSelectExtension ();
693 return d->filterWidget->currentFilter();
697 const QString& defaultType )
699 d->filterWidget->setMimeFilter( mimeTypes, defaultType );
701 QStringList
types = d->filterWidget->currentFilter().split(
' ', QString::SkipEmptyParts);
702 types.append( QLatin1String(
"inode/directory" ));
703 d->ops->clearFilter();
704 d->ops->setMimeFilter( types );
705 d->hasDefaultFilter = !defaultType.isEmpty();
706 d->filterWidget->setEditable( !d->hasDefaultFilter ||
707 d->operationMode !=
Saving );
709 d->updateAutoSelectExtension ();
714 d->filterWidget->setFilter( QString() );
715 d->ops->clearFilter();
716 d->hasDefaultFilter =
false;
717 d->filterWidget->setEditable(
true );
719 d->updateAutoSelectExtension ();
724 int i = d->filterWidget->currentIndex();
725 if (d->filterWidget->showsAllTypes() && i == 0)
728 return d->filterWidget->filters()[i];
737 d->ops->setPreviewWidget(w);
738 d->ops->clearHistory();
742 KUrl KFileWidgetPrivate::getCompleteUrl(
const QString &_url)
const 749 if (QDir::isAbsolutePath(url)) {
752 KUrl relativeUrlTest(ops->url());
754 if (!ops->dirLister()->findByUrl(relativeUrlTest).isNull() ||
773 KUrl::List locationEditCurrentTextList(d->tokenize(locationEditCurrentText));
774 KFile::Modes
mode = d->ops->mode();
777 if (!locationEditCurrentTextList.count()) {
789 if (locationEditCurrentTextList.count() > 1) {
790 if (mode & KFile::File) {
792 i18n(
"You can only select one file"),
793 i18n(
"More than one file provided"));
817 if (!d->differentHierarchyLevelItemsEntered) {
828 while (!res && start < locationEditCurrentTextList.count()) {
829 topMostUrl = locationEditCurrentTextList.at(start);
845 for (
int i = start; i < locationEditCurrentTextList.count(); ++i) {
846 KUrl currUrl = locationEditCurrentTextList.at(i);
857 topMostUrl = topMostUrl.
upUrl();
863 for (
int i = 0; i < locationEditCurrentTextList.count(); ++i) {
864 locationEditCurrentTextList[i] =
KUrl::relativeUrl(topMostUrl, locationEditCurrentTextList[i]);
867 d->ops->setUrl(topMostUrl,
true);
868 const bool signalsBlocked = d->locationEdit->lineEdit()->blockSignals(
true);
869 QStringList stringList;
870 foreach (
const KUrl &url, locationEditCurrentTextList) {
873 d->locationEdit->lineEdit()->setText(QString(
"\"%1\"").arg(stringList.join(
"\" \"")));
874 d->locationEdit->lineEdit()->blockSignals(signalsBlocked);
876 d->differentHierarchyLevelItemsEntered =
true;
883 }
else if (locationEditCurrentTextList.count()) {
887 (QDir::isAbsolutePath(locationEditCurrentText) ||
891 KUrl url(locationEditCurrentText);
892 if (d->operationMode ==
Opening) {
905 KUrl directory = url;
918 d->ops->setUrl(url,
true);
919 const bool signalsBlocked = d->locationEdit->lineEdit()->blockSignals(
true);
920 d->locationEdit->lineEdit()->setText(fileName);
921 d->locationEdit->lineEdit()->blockSignals(signalsBlocked);
928 d->differentHierarchyLevelItemsEntered =
false;
934 bool onlyDirectoryMode = directoryMode && !(mode &
KFile::File) && !(mode & KFile::Files);
935 KUrl::List::ConstIterator it = locationEditCurrentTextList.constBegin();
936 bool filesInList =
false;
937 while (it != locationEditCurrentTextList.constEnd()) {
940 if (d->operationMode ==
Saving && !directoryMode) {
941 d->appendExtension(url);
957 i18n(
"You can only select local files"),
958 i18n(
"Remote files not accepted"));
962 if ((d->operationMode ==
Saving) && d->confirmOverwrite && !d->toOverwrite(url)) {
971 while (it != locationEditCurrentTextList.constEnd()) {
976 KMessageBox::sorry(
this,
i18n(
"More than one folder has been selected and this dialog does not accept folders, so it is not possible to decide which one to enter. Please select only one folder to list it."),
i18n(
"More than one folder provided"));
984 KMessageBox::information(
this,
i18n(
"At least one folder and one file has been selected. Selected files will be ignored and the selected folder will be listed"),
i18n(
"Files and folders selected"));
986 d->ops->setUrl(url,
true);
987 const bool signalsBlocked = d->locationEdit->lineEdit()->blockSignals(
true);
988 d->locationEdit->lineEdit()->setText(QString());
989 d->locationEdit->lineEdit()->blockSignals(signalsBlocked);
1014 *lastDirectory = d->ops->url();
1015 if (!d->fileClass.isEmpty())
1019 d->locationEdit->setItemText( 0, QString() );
1023 int atmost = d->locationEdit->maxItems();
1024 for ( ; it != list.end() && atmost > 0; ++it ) {
1025 const KUrl& url = *it;
1032 for (
int i = 1; i < d->locationEdit->count(); i++ ) {
1033 if ( d->locationEdit->itemText( i ) == file ) {
1034 d->locationEdit->removeItem( i-- );
1041 d->locationEdit->insertItem( 1,file);
1045 d->writeViewConfig();
1046 d->saveRecentFiles();
1048 d->addToRecentDocuments();
1059 void KFileWidgetPrivate::_k_fileHighlighted(
const KFileItem &i)
1065 const bool modified =
locationEdit->lineEdit()->isModified();
1070 setLocationText(
KUrl());
1078 setLocationText( url );
1081 emit q->fileHighlighted(url.url());
1082 emit q->fileHighlighted(url);
1084 multiSelectionChanged();
1085 emit q->selectionChanged();
1092 void KFileWidgetPrivate::_k_fileSelected(
const KFileItem &i)
1100 setLocationText(
KUrl());
1103 setLocationText(i.
url());
1105 multiSelectionChanged();
1106 emit q->selectionChanged();
1121 void KFileWidgetPrivate::multiSelectionChanged()
1129 if (list.isEmpty()) {
1130 setLocationText(
KUrl());
1134 setLocationText(list.
urlList());
1137 void KFileWidgetPrivate::setDummyHistoryEntry(
const QString& text,
const QPixmap& icon,
1138 bool usePreviousPixmapIfNull )
1143 QObject::disconnect(
locationEdit, SIGNAL(editTextChanged(QString)),
1144 q, SLOT(_k_slotLocationChanged(QString)) );
1146 bool dummyExists = dummyAdded;
1151 if ( !icon.isNull() ) {
1155 if ( !usePreviousPixmapIfNull ) {
1161 if ( !text.isEmpty() ) {
1162 if ( !icon.isNull() ) {
1165 if ( !usePreviousPixmapIfNull ) {
1176 if ( dummyExists && !text.isEmpty() ) {
1180 locationEdit->lineEdit()->setCursorPosition( cursorPosition );
1182 QObject::connect(
locationEdit, SIGNAL(editTextChanged(QString)),
1183 q, SLOT(_k_slotLocationChanged(QString)) );
1186 void KFileWidgetPrivate::removeDummyHistoryEntry()
1188 if ( !dummyAdded ) {
1195 QObject::disconnect(
locationEdit, SIGNAL(editTextChanged(QString)),
1196 q, SLOT(_k_slotLocationChanged(QString)) );
1204 QObject::connect(
locationEdit, SIGNAL(editTextChanged(QString)),
1205 q, SLOT(_k_slotLocationChanged(QString)) );
1208 void KFileWidgetPrivate::setLocationText(
const KUrl& url)
1210 if (!url.isEmpty()) {
1217 q->setUrl(u,
false);
1220 q->setUrl(url.
path(),
false);
1223 setDummyHistoryEntry(url.
fileName() , mimeTypeIcon);
1225 removeDummyHistoryEntry();
1230 setNonExtSelection();
1243 if (relPath.startsWith(
"./")) {
1244 relPath = relPath.mid(2);
1252 void KFileWidgetPrivate::setLocationText(
const KUrl::List& urlList )
1254 const KUrl currUrl = ops->
url();
1256 if ( urlList.count() > 1 ) {
1258 foreach (
const KUrl &url, urlList) {
1261 urls = urls.left( urls.size() - 1 );
1263 setDummyHistoryEntry( urls, QPixmap(),
false );
1264 }
else if ( urlList.count() == 1 ) {
1268 removeDummyHistoryEntry();
1273 setNonExtSelection();
1276 void KFileWidgetPrivate::updateLocationWhatsThis()
1278 QString whatsThisText;
1281 whatsThisText =
"<qt>" +
i18n(
"This is the name to save the file as.") +
1282 i18n (autocompletionWhatsThisText);
1286 whatsThisText =
"<qt>" +
i18n(
"This is the list of files to open. More than " 1287 "one file can be specified by listing several " 1288 "files, separated by spaces.") +
1289 i18n (autocompletionWhatsThisText);
1293 whatsThisText =
"<qt>" +
i18n(
"This is the name of the file to open.") +
1294 i18n (autocompletionWhatsThisText);
1297 locationLabel->setWhatsThis(whatsThisText);
1301 void KFileWidgetPrivate::initSpeedbar()
1307 placesDock =
new QDockWidget(
i18nc(
"@title:window",
"Places"), q);
1308 placesDock->setFeatures(QDockWidget::DockWidgetClosable);
1311 placesView->setModel(model);
1312 placesView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1314 placesView->setObjectName(QLatin1String(
"url bar"));
1315 QObject::connect(placesView, SIGNAL(urlChanged(
KUrl)),
1316 q, SLOT(_k_enterUrl(
KUrl)));
1322 placesView->setUrl(url);
1324 placesDock->setWidget(placesView);
1325 placesViewSplitter->insertWidget(0, placesDock);
1328 placesViewWidth = configGroup.readEntry(
SpeedbarWidth, placesView->sizeHint().width());
1330 QList<int> sizes = placesViewSplitter->sizes();
1331 if (placesViewWidth > 0) {
1332 sizes[0] = placesViewWidth + 1;
1333 sizes[1] = q->width() - placesViewWidth -1;
1334 placesViewSplitter->setSizes(sizes);
1337 QObject::connect(placesDock, SIGNAL(visibilityChanged(
bool)),
1338 q, SLOT(_k_toggleSpeedbar(
bool)));
1341 void KFileWidgetPrivate::initGUI()
1345 boxLayout =
new QVBoxLayout( q);
1346 boxLayout->setMargin(0);
1348 placesViewSplitter =
new QSplitter(q);
1349 placesViewSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
1350 placesViewSplitter->setChildrenCollapsible(
false);
1351 boxLayout->addWidget(placesViewSplitter);
1353 QObject::connect(placesViewSplitter, SIGNAL(splitterMoved(
int,
int)),
1354 q, SLOT(_k_placesViewSplitterMoved(
int,
int)));
1355 placesViewSplitter->insertWidget(0, opsWidget);
1357 vbox =
new QVBoxLayout();
1359 boxLayout->addLayout(vbox);
1361 lafBox =
new QGridLayout();
1363 lafBox->addWidget(locationLabel, 0, 0, Qt::AlignVCenter | Qt::AlignRight);
1364 lafBox->addWidget(
locationEdit, 0, 1, Qt::AlignVCenter);
1365 lafBox->addWidget(
okButton, 0, 2, Qt::AlignVCenter);
1367 lafBox->addWidget(filterLabel, 1, 0, Qt::AlignVCenter | Qt::AlignRight);
1368 lafBox->addWidget(
filterWidget, 1, 1, Qt::AlignVCenter);
1369 lafBox->addWidget(
cancelButton, 1, 2, Qt::AlignVCenter);
1371 lafBox->setColumnStretch(1, 4);
1373 vbox->addLayout(lafBox);
1376 vbox->addWidget(autoSelectExtCheckBox);
1378 q->setTabOrder(ops, autoSelectExtCheckBox);
1384 q->setTabOrder(urlNavigator, ops);
1386 q->setTabOrder(urlNavigator, ops);
1390 void KFileWidgetPrivate::_k_slotFilterChanged()
1394 filterDelayTimer.stop();
1399 if ( filter.contains(
'/') ) {
1400 QStringList
types = filter.split(
' ', QString::SkipEmptyParts);
1401 types.prepend(
"inode/directory");
1402 ops->setMimeFilter( types );
1404 else if ( filter.contains(
'*') || filter.contains(
'?') || filter.contains(
'[') ) {
1405 ops->setNameFilter( filter );
1408 ops->setNameFilter(
'*' + filter.replace(
' ',
'*') +
'*');
1413 updateAutoSelectExtension();
1415 emit q->filterChanged(filter);
1423 d->ops->setUrl(url, clearforward);
1427 void KFileWidgetPrivate::_k_urlEntered(
const KUrl& url)
1431 QString filename = locationEditCurrentText();
1434 if (pathCombo->count() != 0) {
1446 urlNavigator->setLocationUrl(url);
1455 placesView->setUrl( url );
1459 void KFileWidgetPrivate::_k_locationAccepted(
const QString &url)
1466 void KFileWidgetPrivate::_k_enterUrl(
const KUrl& url )
1470 KUrl fixedUrl( url );
1474 q->setUrl( fixedUrl );
1479 void KFileWidgetPrivate::_k_enterUrl(
const QString& url )
1486 bool KFileWidgetPrivate::toOverwrite(
const KUrl &url)
1495 i18n(
"The file \"%1\" already exists. Do you wish to overwrite it?" ,
1512 if (url.isEmpty()) {
1516 KUrl u = d->getCompleteUrl(url);
1518 kWarning() << url <<
" is not a correct argument for setSelection!";
1526 d->setLocationText(url);
1529 void KFileWidgetPrivate::_k_slotLoadingFinished()
1535 ops->blockSignals(
true);
1539 ops->setCurrentItem(url.
url());
1540 ops->blockSignals(
false);
1543 void KFileWidgetPrivate::_k_fileCompletion(
const QString& match )
1554 void KFileWidgetPrivate::_k_slotLocationChanged(
const QString& text )
1560 if (text.isEmpty() && ops->view()) {
1561 ops->view()->clearSelection();
1564 if (text.isEmpty()) {
1565 removeDummyHistoryEntry();
1567 setDummyHistoryEntry( text );
1572 QStringList stringList;
1573 foreach (
const KUrl &url, urlList) {
1574 stringList << url.
url();
1576 ops->setCurrentItems(stringList);
1597 if ( d->inAccept ) {
1599 list = d->parseSelectedUrls();
1601 list.append( d->url );
1607 KUrl::List& KFileWidgetPrivate::parseSelectedUrls()
1611 if ( filenames.isEmpty() ) {
1616 if ( filenames.contains(
'/' )) {
1624 urlList.append( u );
1627 i18n(
"The chosen filenames do not\n" 1628 "appear to be valid."),
1629 i18n(
"Invalid Filenames") );
1633 urlList = tokenize( filenames );
1642 KUrl::List KFileWidgetPrivate::tokenize(
const QString& line )
const 1647 KUrl u( ops->url() );
1651 const int count = line.count( QLatin1Char(
'"' ) );
1653 if (!QDir::isAbsolutePath(line)) {
1654 u.setFileName( line );
1665 int index1 = -1, index2 = -1;
1667 index1 = line.indexOf(
'"', start );
1668 index2 = line.indexOf(
'"', index1 + 1 );
1670 if ( index1 < 0 || index2 < 0 )
1674 name = line.mid( index1 + 1, index2 - index1 - 1 );
1678 KUrl currUrl( name );
1680 if ( !QDir::isAbsolutePath(currUrl.
url()) ) {
1688 if ( _u.isValid() ) {
1703 if ( d->inAccept ) {
1704 const KUrl url = d->mostLocalUrl(d->url);
1709 i18n(
"You can only select local files."),
1710 i18n(
"Remote Files Not Accepted") );
1724 const KUrl::List urls = d->parseSelectedUrls();
1726 while (it != urls.end()) {
1727 KUrl url = d->mostLocalUrl(*it);
1735 if ( d->url.isLocalFile() )
1736 list.append( d->url.toLocalFile() );
1745 return d->ops->url();
1750 QWidget::resizeEvent(event);
1752 if (d->placesDock) {
1755 QList<int> sizes = d->placesViewSplitter->sizes();
1756 sizes[0] = d->placesViewWidth + 1;
1757 sizes[1] = width() - d->placesViewWidth - 1;
1758 d->placesViewSplitter->setSizes( sizes );
1764 if ( !d->hasView ) {
1768 d->ops->view()->setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ) );
1771 d->ops->clearHistory();
1773 QWidget::showEvent(event);
1778 const bool res = QWidget::eventFilter(watched, event);
1780 QKeyEvent *keyEvent =
dynamic_cast<QKeyEvent*
>(event);
1781 if (watched == d->iconSizeSlider && keyEvent) {
1782 if (keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Up ||
1783 keyEvent->key() == Qt::Key_Right || keyEvent->key() == Qt::Key_Down) {
1784 d->_k_slotIconSizeSliderMoved(d->iconSizeSlider->value());
1786 }
else if (watched == d->locationEdit && event->type() == QEvent::KeyPress) {
1787 if (keyEvent->modifiers() & Qt::AltModifier) {
1788 switch (keyEvent->key()) {
1790 d->ops->actionCollection()->action(
"up")->trigger();
1793 d->ops->actionCollection()->action(
"back")->trigger();
1796 d->ops->actionCollection()->action(
"forward")->trigger();
1812 if ( d->ops->dirOnlyMode() ) {
1813 d->filterWidget->setDefaultFilter(
i18n(
"*|All Folders") );
1816 d->filterWidget->setDefaultFilter(
i18n(
"*|All Files") );
1819 d->updateAutoSelectExtension();
1824 return d->ops->mode();
1828 void KFileWidgetPrivate::readViewConfig()
1830 ops->setViewConfig(configGroup);
1831 ops->readConfig(configGroup);
1850 _k_toggleSpeedbar( configGroup.readEntry(
ShowSpeedbar,
true ) );
1853 _k_toggleBookmarks( configGroup.readEntry(
ShowBookmarks,
false) );
1857 updateAutoSelectExtension();
1863 urlNavigator->setShowFullPath( configGroup.readEntry(
ShowFullPath,
false) );
1865 int w1 = q->minimumSize().width();
1866 int w2 = toolbar->sizeHint().width();
1868 q->setMinimumWidth(w2);
1871 void KFileWidgetPrivate::writeViewConfig()
1886 const bool showSpeedbar = placesDock && !placesDock->isHidden();
1889 const QList<int> sizes = placesViewSplitter->sizes();
1890 Q_ASSERT( sizes.count() > 0 );
1899 ops->writeConfig( tmpGroup );
1906 void KFileWidgetPrivate::readRecentFiles()
1910 QObject::disconnect(
locationEdit, SIGNAL(editTextChanged(QString)),
1911 q, SLOT(_k_slotLocationChanged(QString)));
1918 QObject::connect(
locationEdit, SIGNAL(editTextChanged(QString)),
1919 q, SLOT(_k_slotLocationChanged(QString)));
1924 combo->
setUrl(ops->url());
1929 completion->
setDir(ops->url().url());
1934 void KFileWidgetPrivate::saveRecentFiles()
1950 return d->cancelButton;
1960 d->writeViewConfig();
1965 d->keepLocation = keep;
1970 return d->keepLocation;
1977 d->operationMode =
mode;
1978 d->keepLocation = (mode ==
Saving);
1979 d->filterWidget->setEditable( !d->hasDefaultFilter || mode !=
Saving );
1982 d->okButton->setGuiItem(
KGuiItem(
i18n(
"&Open" ),
"document-open") );
1985 }
else if ( mode ==
Saving ) {
1987 d->setNonExtSelection();
1991 d->updateLocationWhatsThis();
1992 d->updateAutoSelectExtension();
1995 d->ops->setIsSaving(mode ==
Saving);
2001 return d->operationMode;
2004 void KFileWidgetPrivate::_k_slotAutoSelectExtClicked()
2010 autoSelectExtChecked = autoSelectExtCheckBox->isChecked();
2013 updateLocationEditExtension (extension );
2016 void KFileWidgetPrivate::_k_placesViewSplitterMoved(
int pos,
int index)
2022 if (placesDock && index == 1) {
2023 placesViewWidth = pos;
2025 lafBox->setColumnMinimumWidth(0, placesViewWidth);
2029 void KFileWidgetPrivate::_k_activateUrlNavigator()
2033 urlNavigator->setUrlEditable(!urlNavigator->isUrlEditable());
2034 if(urlNavigator->isUrlEditable()) {
2035 urlNavigator->setFocus();
2036 urlNavigator->editor()->lineEdit()->selectAll();
2040 void KFileWidgetPrivate::_k_zoomOutIconsSize()
2042 const int currValue = ops->iconsZoom();
2043 const int futValue = qMax(0, currValue - 10);
2044 iconSizeSlider->setValue(futValue);
2045 _k_slotIconSizeSliderMoved(futValue);
2048 void KFileWidgetPrivate::_k_zoomInIconsSize()
2050 const int currValue = ops->iconsZoom();
2051 const int futValue = qMin(100, currValue + 10);
2052 iconSizeSlider->setValue(futValue);
2053 _k_slotIconSizeSliderMoved(futValue);
2056 void KFileWidgetPrivate::_k_slotIconSizeChanged(
int _value)
2059 int value = (maxSize * _value / 100) + KIconLoader::SizeSmall;
2061 case KIconLoader::SizeSmall:
2067 iconSizeSlider->setToolTip(
i18n(
"Icon size: %1 pixels (standard size)", value));
2070 iconSizeSlider->setToolTip(
i18n(
"Icon size: %1 pixels", value));
2075 void KFileWidgetPrivate::_k_slotIconSizeSliderMoved(
int _value)
2079 _k_slotIconSizeChanged(_value);
2081 QPoint global(iconSizeSlider->rect().topLeft());
2082 global.ry() += iconSizeSlider->height() / 2;
2083 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), iconSizeSlider->mapToGlobal(global));
2084 QApplication::sendEvent(iconSizeSlider, &toolTipEvent);
2094 QStringList::ConstIterator patternListEnd = patternList.end();
2095 for (QStringList::ConstIterator it = patternList.begin();
2096 it != patternListEnd;
2108 if ((*it).startsWith (QLatin1String(
"*.")) &&
2109 (*it).length() > 2 &&
2110 (*it).indexOf(
'*', 2) < 0 && (*it).indexOf (
'?', 2) < 0)
2112 ret = (*it).mid (1);
2122 QString ret = string;
2136 void KFileWidgetPrivate::updateAutoSelectExtension()
2138 if (!autoSelectExtCheckBox)
return;
2148 QString lastExtension = extension;
2159 if (!filter.isEmpty())
2165 if ( currentExtension.isEmpty() )
2166 currentExtension = locationEditCurrentText().section(QLatin1Char(
'.'), -1, -1);
2167 kDebug (
kfile_area) <<
"filter:" << filter <<
"locationEdit:" << locationEditCurrentText()
2168 <<
"currentExtension:" << currentExtension;
2170 QString defaultExtension;
2171 QStringList extensionList;
2174 if (filter.indexOf (
'/') < 0)
2176 extensionList = filter.split(
' ', QString::SkipEmptyParts);
2190 if ( !currentExtension.isEmpty() && extensionList.contains(QLatin1String(
"*.") + currentExtension) )
2191 extension = QLatin1Char(
'.') + currentExtension;
2193 extension = defaultExtension;
2195 kDebug (
kfile_area) <<
"List:" << extensionList <<
"auto-selected extension:" << extension;
2203 QString whatsThisExtension;
2204 if (!extension.isEmpty())
2207 autoSelectExtCheckBox->setText (
i18n (
"Automatically select filename e&xtension (%1)", extension));
2208 whatsThisExtension =
i18n (
"the extension <b>%1</b>", extension);
2210 autoSelectExtCheckBox->setEnabled (
true);
2211 autoSelectExtCheckBox->setChecked (autoSelectExtChecked);
2216 autoSelectExtCheckBox->setText (
i18n (
"Automatically select filename e&xtension"));
2217 whatsThisExtension =
i18n (
"a suitable extension");
2219 autoSelectExtCheckBox->setChecked (
false);
2220 autoSelectExtCheckBox->setEnabled (
false);
2225 autoSelectExtCheckBox->setWhatsThis(
"<qt>" +
2227 "This option enables some convenient features for " 2228 "saving files with extensions:<br />" 2230 "<li>Any extension specified in the <b>%1</b> text " 2231 "area will be updated if you change the file type " 2234 "<li>If no extension is specified in the <b>%2</b> " 2235 "text area when you click " 2236 "<b>Save</b>, %3 will be added to the end of the " 2237 "filename (if the filename does not already exist). " 2238 "This extension is based on the file type that you " 2239 "have chosen to save in.<br />" 2241 "If you do not want KDE to supply an extension for the " 2242 "filename, you can either turn this option off or you " 2243 "can suppress it by adding a period (.) to the end of " 2244 "the filename (the period will be automatically " 2248 "If unsure, keep this option enabled as it makes your " 2249 "files more manageable." 2257 autoSelectExtCheckBox->show();
2261 updateLocationEditExtension (lastExtension);
2266 autoSelectExtCheckBox->setChecked (
false);
2267 autoSelectExtCheckBox->hide();
2274 void KFileWidgetPrivate::updateLocationEditExtension (
const QString &lastExtension)
2276 if (!autoSelectExtCheckBox->isChecked() || extension.isEmpty())
2279 QString urlStr = locationEditCurrentText();
2280 if (urlStr.isEmpty())
2283 KUrl url = getCompleteUrl(urlStr);
2286 const int fileNameOffset = urlStr.lastIndexOf (
'/') + 1;
2287 QString fileName = urlStr.mid (fileNameOffset);
2289 const int dot = fileName.lastIndexOf (
'.');
2290 const int len = fileName.length();
2318 if (lastExtension.length() && fileName.endsWith (lastExtension))
2319 fileName.truncate (len - lastExtension.length());
2320 else if (extension.length() && fileName.endsWith (extension))
2321 fileName.truncate (len - extension.length());
2324 fileName.truncate (dot);
2327 const QString newText = urlStr.left (fileNameOffset) + fileName + extension;
2328 if ( newText != locationEditCurrentText() )
2338 void KFileWidgetPrivate::updateFilter()
2343 QString urlStr = locationEditCurrentText();
2344 if (urlStr.isEmpty())
2355 QString filename = urlStr.mid( urlStr.lastIndexOf( KDIR_SEPARATOR ) + 1 );
2357 QStringList patterns = filter.left( filter.indexOf(
'|' )).split (
' ', QString::SkipEmptyParts );
2358 foreach (
const QString& p, patterns ) {
2372 void KFileWidgetPrivate::appendExtension (
KUrl &url)
2376 if (!autoSelectExtCheckBox->isChecked() || extension.isEmpty())
2380 if (fileName.isEmpty())
2385 const int len = fileName.length();
2386 const int dot = fileName.lastIndexOf (
'.');
2388 const bool suppressExtension = (dot == len - 1);
2389 const bool unspecifiedExtension = (dot <= 0);
2392 if (!(suppressExtension || unspecifiedExtension))
2405 if (suppressExtension)
2421 else if (unspecifiedExtension)
2431 void KFileWidgetPrivate::addToRecentDocuments()
2433 int m = ops->mode();
2438 const QStringList files = q->selectedFiles();
2439 QStringList::ConstIterator it = files.begin();
2440 for ( ; it != files.end() && atmost > 0; ++it ) {
2448 KUrl::List::ConstIterator it = urls.begin();
2449 for ( ; it != urls.end() && atmost > 0; ++it ) {
2450 if ( (*it).isValid() ) {
2460 return d->locationEdit;
2465 return d->filterWidget;
2470 return d->ops->actionCollection();
2473 void KFileWidgetPrivate::_k_toggleSpeedbar(
bool show)
2478 lafBox->setColumnMinimumWidth(0, placesViewWidth);
2482 homeURL.
setPath( QDir::homePath() );
2484 for (
int rowIndex = 0 ; rowIndex < model->
rowCount() ; rowIndex++) {
2485 QModelIndex index = model->
index(rowIndex, 0);
2489 toolbar->removeAction( ops->actionCollection()->action(
"home" ) );
2494 if (q->sender() == placesDock && placesDock && placesDock->isVisibleTo(q)) {
2504 QAction* homeAction = ops->actionCollection()->action(
"home");
2505 QAction* reloadAction = ops->actionCollection()->action(
"reload");
2506 if (!toolbar->actions().contains(homeAction)) {
2507 toolbar->insertAction(reloadAction, homeAction);
2511 lafBox->setColumnMinimumWidth(0, 0);
2514 static_cast<KToggleAction *
>(q->actionCollection()->action(
"toggleSpeedbar"))->setChecked(show);
2517 urlNavigator->setPlacesSelectorVisible(!show);
2520 void KFileWidgetPrivate::_k_toggleBookmarks(
bool show)
2524 if (bookmarkHandler)
2530 q->connect( bookmarkHandler, SIGNAL(openUrl(QString)),
2531 SLOT(_k_enterUrl(QString)));
2534 bookmarkButton->setDelayed(
false);
2535 q->actionCollection()->addAction(
"bookmark", bookmarkButton);
2536 bookmarkButton->setMenu(bookmarkHandler->menu());
2537 bookmarkButton->setWhatsThis(
i18n(
"<qt>This button allows you to bookmark specific locations. " 2538 "Click on this button to open the bookmark menu where you may add, " 2539 "edit or select a bookmark.<br /><br />" 2540 "These bookmarks are specific to the file dialog, but otherwise operate " 2541 "like bookmarks elsewhere in KDE.</qt>"));
2542 toolbar->addAction(bookmarkButton);
2544 else if (bookmarkHandler)
2546 delete bookmarkHandler;
2547 bookmarkHandler = 0;
2548 delete bookmarkButton;
2552 static_cast<KToggleAction *
>(q->actionCollection()->action(
"toggleBookmarks"))->setChecked( show );
2558 QString& recentDirClass )
2561 return getStartUrl( startDir, recentDirClass, fileName );
2567 QString& recentDirClass,
2570 recentDirClass.clear();
2574 bool useDefaultStartDir = startDir.isEmpty();
2575 if ( !useDefaultStartDir )
2577 if ( startDir.
protocol() ==
"kfiledialog" )
2591 QString urlFile = startDir.
fileName();
2592 if ( urlDir ==
"/" )
2599 keyword = urlDir.mid( 1 );
2603 if ( startDir.
query() ==
"?global" )
2604 recentDirClass = QString(
"::%1" ).arg( keyword );
2606 recentDirClass = QString(
":%1" ).arg( keyword );
2625 useDefaultStartDir =
true;
2632 useDefaultStartDir =
true;
2637 if ( useDefaultStartDir )
2639 if (lastDirectory->isEmpty()) {
2642 home.
setPath( QDir::homePath() );
2648 QDir::currentPath() != QDir::homePath() ||
2650 lastDirectory->setPath(QDir::currentPath());
2652 ret = *lastDirectory;
2655 kDebug(
kfile_area) <<
"for" << startDir <<
"->" << ret <<
"recentDirClass" << recentDirClass <<
"fileName" << fileName;
2661 if ( directory.isValid() )
2662 *lastDirectory = directory;
2665 void KFileWidgetPrivate::setNonExtSelection()
2668 QString filename = locationEditCurrentText();
2671 if ( !extension.isEmpty() )
2672 locationEdit->lineEdit()->setSelection( 0, filename.length() - extension.length() - 1 );
2675 int lastDot = filename.lastIndexOf(
'.' );
2688 delete d->bottomCustomWidget;
2689 d->bottomCustomWidget = widget;
2694 d->bottomCustomWidget->setParent(
this );
2696 d->vbox->addWidget( d->bottomCustomWidget );
2704 setTabOrder(d->cancelButton, d->bottomCustomWidget);
2705 setTabOrder(d->bottomCustomWidget, d->urlNavigator);
2710 delete d->labeledCustomWidget;
2711 d->labeledCustomWidget = widget;
2714 label->setAlignment(Qt::AlignRight);
2715 d->lafBox->addWidget(label, 2, 0, Qt::AlignVCenter);
2716 d->lafBox->addWidget(widget, 2, 1, Qt::AlignVCenter);
2728 bool *enable =
static_cast<bool*
>(data);
2729 d->confirmOverwrite = *enable;
2733 bool *show =
static_cast<bool*
>(data);
2734 d->setInlinePreviewShown(*show);
2749 d->configGroup = group;
2750 d->readViewConfig();
2751 d->readRecentFiles();
2754 QString KFileWidgetPrivate::locationEditCurrentText()
const 2756 return QDir::fromNativeSeparators(
locationEdit->currentText());
2759 KUrl KFileWidgetPrivate::mostLocalUrl(
const KUrl &url)
2773 if (!path.isEmpty()) {
2782 void KFileWidgetPrivate::setInlinePreviewShown(
bool show)
2784 ops->setInlinePreviewShown(show);
2788 #include "kfilewidget.moc"
QString i18n(const char *text)
QString stringValue(uint field) const
void adjustPath(AdjustPathOption trailing)
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) const
static QString iconNameForUrl(const KUrl &url, mode_t mode=0)
static QString relativeUrl(const KUrl &base_url, const KUrl &url)
QStringList filters() const
static bool matchFileName(const QString &filename, const QString &pattern)
static QString relativePath(const QString &base_dir, const QString &path, bool *isParent=0)
QString replacedPath(const QString &text) const
virtual void setCompletionObject(KCompletion *compObj, bool hsig=true)
QString mainExtension() const
Generates previews for files of an item view.
static KIconLoader * global()
static bool isKnownProtocol(const KUrl &url)
static QString desktopPath()
KAction * copy(const QObject *recvr, const char *slot, QObject *parent)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Get the children model index for the given row and column.
#define DefaultAutoSelectExtChecked
QString label(StandardShortcut id)
static void information(QWidget *parent, const QString &text, const QString &caption=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
bool equals(const KUrl &u, const EqualsOptions &options=0) const
static Ptr findByPath(const QString &path, mode_t mode=0, bool fast_mode=false, int *accuracy=0)
This class allows to display a KFilePlacesModel.
#define RecentFilesNumber
Note: Ported to new KBookmarkMenu, but untested.
const char * name(StandardAction id)
void add(const QString &fileClass, const QString &directory)
static bool synchronousRun(Job *job, QWidget *window, QByteArray *data=0, KUrl *finalURL=0, QMap< QString, QString > *metaData=0)
StatJob * stat(const KUrl &url, JobFlags flags=DefaultFlags)
QAction * addAction(const QString &name, QAction *action)
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
KGlobalSettings::Completion completionMode() const
QPixmap pixmapForUrl(const KUrl &_url, mode_t _mode=0, KIconLoader::Group _group=KIconLoader::Desktop, int _force_size=0, int _state=0, QString *_path=0)
void setCurrentFilter(const QString &filter)
Sets the current filter.
static QString extractKnownExtension(const QString &fileName)
CompareWithoutTrailingSlash
static void add(const KUrl &url)
StatJob * mostLocalUrl(const KUrl &url, JobFlags flags=DefaultFlags)
int rowCount(const QModelIndex &parent=QModelIndex()) const
Get the number of rows for a model index.
QString pathOrUrl() const
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QPixmap loadMimeTypeIcon(const QString &iconName, KIconLoader::Group group, int size=0, int state=KIconLoader::DefaultState, const QStringList &overlays=QStringList(), QString *path_store=0) const
QString prettyUrl(AdjustPathOption trailing=LeaveTrailingSlash) const
#define BreadcrumbNavigation
QString i18nc(const char *ctxt, const char *text)
void setUrls(const QStringList &urls)
KSharedConfigPtr config()
#define LocationComboCompletionMode
void setPath(const QString &path)
void addPath(const QString &txt)
const UDSEntry & statResult() const
QStringList patterns() const
void addDefaultUrl(const KUrl &url, const QString &text=QString())
bool authorizeUrlAction(const QString &action, const KUrl &baseUrl, const KUrl &destUrl)
This widget works as a network transparent filebrowser.
static void sorry(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
QAction * action(int index) const
QString buildErrorString(int errorCode, const QString &errorText)
virtual void setCompletionMode(KGlobalSettings::Completion mode)
bool isParentOf(const KUrl &u) const
QString directory(const DirectoryOptions &options=IgnoreTrailingSlash) const
KUrl::List urlList() const
KAction * home(const QObject *recvr, const char *slot, QObject *parent)
virtual void setDir(const QString &dir)
KUrl url(const QModelIndex &index) const
void setAutoDeleteCompletionObject(bool autoDelete)
void copyTo(KConfigBase *other, WriteConfigFlags pFlags=Normal) const
void removeAction(QAction *action)
bool isMimeFilter() const
Returns true if the filter has been set using setMimeFilter().
#define PathComboCompletionMode
QStringList types(Mode mode=Writing)
void setShortcut(const KShortcut &shortcut, ShortcutTypes type=ShortcutTypes(ActiveShortcut|DefaultShortcut))
static QString documentPath()
KCompletion * completionObject(bool hsig=true)
void changeUrl(int index, const KUrl &url)
void setFileName(const QString &_txt)
QString dir(const QString &fileClass)
static QString defaultMimeType()
#define AutoDirectoryFollowing
void setUrl(const KUrl &url)
void addAssociatedWidget(QWidget *widget)
#define DefaultDirectoryFollowing
QString tildeExpand(const QString &path)
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
static Ptr mimeType(const QString &name, FindByNameOption options=ResolveAliases)
bool contains(const QString &text) const
Widget that allows to navigate through the paths of an URL.
static bool supportsListing(const KUrl &url)
static Completion completionMode()
int cursorPosition() const
static int maximumItems()
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
const KShortcut & completion()
static int warningContinueCancel(QWidget *parent, const QString &text, const QString &caption=QString(), const KGuiItem &buttonContinue=KStandardGuiItem::cont(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
QString currentFilter() const
bool isPreviewShown() const
QString path(AdjustPathOption trailing=LeaveTrailingSlash) const
static void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
QString removeAcceleratorMarker(const QString &label) const
#define DefaultRecentURLsNumber
#define AutoSelectExtChecked
QStringList list(const QString &fileClass)
This class is a list view model.