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"));
967 while (it != locationEditCurrentTextList.constEnd()) {
972 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"));
980 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"));
982 d->ops->setUrl(url,
true);
983 const bool signalsBlocked = d->locationEdit->lineEdit()->blockSignals(
true);
984 d->locationEdit->lineEdit()->setText(QString());
985 d->locationEdit->lineEdit()->blockSignals(signalsBlocked);
999 if ((d->operationMode ==
Saving) && d->confirmOverwrite && !d->toOverwrite(url)) {
1015 *lastDirectory = d->ops->url();
1016 if (!d->fileClass.isEmpty())
1020 d->locationEdit->setItemText( 0, QString() );
1024 int atmost = d->locationEdit->maxItems();
1025 for ( ; it != list.end() && atmost > 0; ++it ) {
1026 const KUrl& url = *it;
1033 for (
int i = 1; i < d->locationEdit->count(); i++ ) {
1034 if ( d->locationEdit->itemText( i ) == file ) {
1035 d->locationEdit->removeItem( i-- );
1042 d->locationEdit->insertItem( 1,file);
1046 d->writeViewConfig();
1047 d->saveRecentFiles();
1049 d->addToRecentDocuments();
1060 void KFileWidgetPrivate::_k_fileHighlighted(
const KFileItem &i)
1066 const bool modified =
locationEdit->lineEdit()->isModified();
1071 setLocationText(
KUrl());
1079 setLocationText( url );
1082 emit q->fileHighlighted(url.url());
1083 emit q->fileHighlighted(url);
1085 multiSelectionChanged();
1086 emit q->selectionChanged();
1093 void KFileWidgetPrivate::_k_fileSelected(
const KFileItem &i)
1101 setLocationText(
KUrl());
1104 setLocationText(i.
url());
1106 multiSelectionChanged();
1107 emit q->selectionChanged();
1122 void KFileWidgetPrivate::multiSelectionChanged()
1130 if (list.isEmpty()) {
1131 setLocationText(
KUrl());
1135 setLocationText(list.
urlList());
1138 void KFileWidgetPrivate::setDummyHistoryEntry(
const QString& text,
const QPixmap& icon,
1139 bool usePreviousPixmapIfNull )
1144 QObject::disconnect(
locationEdit, SIGNAL(editTextChanged(QString)),
1145 q, SLOT(_k_slotLocationChanged(QString)) );
1147 bool dummyExists = dummyAdded;
1152 if ( !icon.isNull() ) {
1156 if ( !usePreviousPixmapIfNull ) {
1162 if ( !text.isEmpty() ) {
1163 if ( !icon.isNull() ) {
1166 if ( !usePreviousPixmapIfNull ) {
1177 if ( dummyExists && !text.isEmpty() ) {
1181 locationEdit->lineEdit()->setCursorPosition( cursorPosition );
1183 QObject::connect(
locationEdit, SIGNAL(editTextChanged(QString)),
1184 q, SLOT(_k_slotLocationChanged(QString)) );
1187 void KFileWidgetPrivate::removeDummyHistoryEntry()
1189 if ( !dummyAdded ) {
1196 QObject::disconnect(
locationEdit, SIGNAL(editTextChanged(QString)),
1197 q, SLOT(_k_slotLocationChanged(QString)) );
1205 QObject::connect(
locationEdit, SIGNAL(editTextChanged(QString)),
1206 q, SLOT(_k_slotLocationChanged(QString)) );
1209 void KFileWidgetPrivate::setLocationText(
const KUrl& url)
1211 if (!url.isEmpty()) {
1218 q->setUrl(u,
false);
1221 q->setUrl(url.
path(),
false);
1224 setDummyHistoryEntry(url.
fileName() , mimeTypeIcon);
1226 removeDummyHistoryEntry();
1231 setNonExtSelection();
1244 if (relPath.startsWith(
"./")) {
1245 relPath = relPath.mid(2);
1253 void KFileWidgetPrivate::setLocationText(
const KUrl::List& urlList )
1255 const KUrl currUrl = ops->
url();
1257 if ( urlList.count() > 1 ) {
1259 foreach (
const KUrl &url, urlList) {
1262 urls = urls.left( urls.size() - 1 );
1264 setDummyHistoryEntry( urls, QPixmap(),
false );
1265 }
else if ( urlList.count() == 1 ) {
1269 removeDummyHistoryEntry();
1274 setNonExtSelection();
1277 void KFileWidgetPrivate::updateLocationWhatsThis()
1279 QString whatsThisText;
1282 whatsThisText =
"<qt>" +
i18n(
"This is the name to save the file as.") +
1283 i18n (autocompletionWhatsThisText);
1287 whatsThisText =
"<qt>" +
i18n(
"This is the list of files to open. More than " 1288 "one file can be specified by listing several " 1289 "files, separated by spaces.") +
1290 i18n (autocompletionWhatsThisText);
1294 whatsThisText =
"<qt>" +
i18n(
"This is the name of the file to open.") +
1295 i18n (autocompletionWhatsThisText);
1298 locationLabel->setWhatsThis(whatsThisText);
1302 void KFileWidgetPrivate::initSpeedbar()
1308 placesDock =
new QDockWidget(
i18nc(
"@title:window",
"Places"), q);
1309 placesDock->setFeatures(QDockWidget::DockWidgetClosable);
1312 placesView->setModel(model);
1313 placesView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1315 placesView->setObjectName(QLatin1String(
"url bar"));
1316 QObject::connect(placesView, SIGNAL(urlChanged(
KUrl)),
1317 q, SLOT(_k_enterUrl(
KUrl)));
1323 placesView->setUrl(url);
1325 placesDock->setWidget(placesView);
1326 placesViewSplitter->insertWidget(0, placesDock);
1329 placesViewWidth = configGroup.readEntry(
SpeedbarWidth, placesView->sizeHint().width());
1331 QList<int> sizes = placesViewSplitter->sizes();
1332 if (placesViewWidth > 0) {
1333 sizes[0] = placesViewWidth + 1;
1334 sizes[1] = q->width() - placesViewWidth -1;
1335 placesViewSplitter->setSizes(sizes);
1338 QObject::connect(placesDock, SIGNAL(visibilityChanged(
bool)),
1339 q, SLOT(_k_toggleSpeedbar(
bool)));
1342 void KFileWidgetPrivate::initGUI()
1346 boxLayout =
new QVBoxLayout( q);
1347 boxLayout->setMargin(0);
1349 placesViewSplitter =
new QSplitter(q);
1350 placesViewSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
1351 placesViewSplitter->setChildrenCollapsible(
false);
1352 boxLayout->addWidget(placesViewSplitter);
1354 QObject::connect(placesViewSplitter, SIGNAL(splitterMoved(
int,
int)),
1355 q, SLOT(_k_placesViewSplitterMoved(
int,
int)));
1356 placesViewSplitter->insertWidget(0, opsWidget);
1358 vbox =
new QVBoxLayout();
1360 boxLayout->addLayout(vbox);
1362 lafBox =
new QGridLayout();
1364 lafBox->addWidget(locationLabel, 0, 0, Qt::AlignVCenter | Qt::AlignRight);
1365 lafBox->addWidget(
locationEdit, 0, 1, Qt::AlignVCenter);
1366 lafBox->addWidget(
okButton, 0, 2, Qt::AlignVCenter);
1368 lafBox->addWidget(filterLabel, 1, 0, Qt::AlignVCenter | Qt::AlignRight);
1369 lafBox->addWidget(
filterWidget, 1, 1, Qt::AlignVCenter);
1370 lafBox->addWidget(
cancelButton, 1, 2, Qt::AlignVCenter);
1372 lafBox->setColumnStretch(1, 4);
1374 vbox->addLayout(lafBox);
1377 vbox->addWidget(autoSelectExtCheckBox);
1379 q->setTabOrder(ops, autoSelectExtCheckBox);
1385 q->setTabOrder(urlNavigator, ops);
1387 q->setTabOrder(urlNavigator, ops);
1391 void KFileWidgetPrivate::_k_slotFilterChanged()
1395 filterDelayTimer.stop();
1400 if ( filter.contains(
'/') ) {
1401 QStringList
types = filter.split(
' ', QString::SkipEmptyParts);
1402 types.prepend(
"inode/directory");
1403 ops->setMimeFilter( types );
1405 else if ( filter.contains(
'*') || filter.contains(
'?') || filter.contains(
'[') ) {
1406 ops->setNameFilter( filter );
1409 ops->setNameFilter(
'*' + filter.replace(
' ',
'*') +
'*');
1414 updateAutoSelectExtension();
1416 emit q->filterChanged(filter);
1424 d->ops->setUrl(url, clearforward);
1428 void KFileWidgetPrivate::_k_urlEntered(
const KUrl& url)
1432 QString filename = locationEditCurrentText();
1435 if (pathCombo->count() != 0) {
1447 urlNavigator->setLocationUrl(url);
1456 placesView->setUrl( url );
1460 void KFileWidgetPrivate::_k_locationAccepted(
const QString &url)
1467 void KFileWidgetPrivate::_k_enterUrl(
const KUrl& url )
1471 KUrl fixedUrl( url );
1475 q->setUrl( fixedUrl );
1480 void KFileWidgetPrivate::_k_enterUrl(
const QString& url )
1487 bool KFileWidgetPrivate::toOverwrite(
const KUrl &url)
1496 i18n(
"The file \"%1\" already exists. Do you wish to overwrite it?" ,
1513 if (url.isEmpty()) {
1517 KUrl u = d->getCompleteUrl(url);
1519 kWarning() << url <<
" is not a correct argument for setSelection!";
1527 d->setLocationText(url);
1530 void KFileWidgetPrivate::_k_slotLoadingFinished()
1536 ops->blockSignals(
true);
1540 ops->setCurrentItem(url.
url());
1541 ops->blockSignals(
false);
1544 void KFileWidgetPrivate::_k_fileCompletion(
const QString& match )
1555 void KFileWidgetPrivate::_k_slotLocationChanged(
const QString& text )
1561 if (text.isEmpty() && ops->view()) {
1562 ops->view()->clearSelection();
1565 if (text.isEmpty()) {
1566 removeDummyHistoryEntry();
1568 setDummyHistoryEntry( text );
1573 QStringList stringList;
1574 foreach (
const KUrl &url, urlList) {
1575 stringList << url.
url();
1577 ops->setCurrentItems(stringList);
1598 if ( d->inAccept ) {
1600 list = d->parseSelectedUrls();
1602 list.append( d->url );
1608 KUrl::List& KFileWidgetPrivate::parseSelectedUrls()
1612 if ( filenames.isEmpty() ) {
1617 if ( filenames.contains(
'/' )) {
1625 urlList.append( u );
1628 i18n(
"The chosen filenames do not\n" 1629 "appear to be valid."),
1630 i18n(
"Invalid Filenames") );
1634 urlList = tokenize( filenames );
1643 KUrl::List KFileWidgetPrivate::tokenize(
const QString& line )
const 1648 KUrl u( ops->url() );
1652 const int count = line.count( QLatin1Char(
'"' ) );
1654 if (!QDir::isAbsolutePath(line)) {
1655 u.setFileName( line );
1666 int index1 = -1, index2 = -1;
1668 index1 = line.indexOf(
'"', start );
1669 index2 = line.indexOf(
'"', index1 + 1 );
1671 if ( index1 < 0 || index2 < 0 )
1675 name = line.mid( index1 + 1, index2 - index1 - 1 );
1679 KUrl currUrl( name );
1681 if ( !QDir::isAbsolutePath(currUrl.
url()) ) {
1689 if ( _u.isValid() ) {
1704 if ( d->inAccept ) {
1705 const KUrl url = d->mostLocalUrl(d->url);
1710 i18n(
"You can only select local files."),
1711 i18n(
"Remote Files Not Accepted") );
1725 const KUrl::List urls = d->parseSelectedUrls();
1727 while (it != urls.end()) {
1728 KUrl url = d->mostLocalUrl(*it);
1736 if ( d->url.isLocalFile() )
1737 list.append( d->url.toLocalFile() );
1746 return d->ops->url();
1751 QWidget::resizeEvent(event);
1753 if (d->placesDock) {
1756 QList<int> sizes = d->placesViewSplitter->sizes();
1757 sizes[0] = d->placesViewWidth + 1;
1758 sizes[1] = width() - d->placesViewWidth - 1;
1759 d->placesViewSplitter->setSizes( sizes );
1765 if ( !d->hasView ) {
1769 d->ops->view()->setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ) );
1772 d->ops->clearHistory();
1774 QWidget::showEvent(event);
1779 const bool res = QWidget::eventFilter(watched, event);
1781 QKeyEvent *keyEvent =
dynamic_cast<QKeyEvent*
>(event);
1782 if (watched == d->iconSizeSlider && keyEvent) {
1783 if (keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Up ||
1784 keyEvent->key() == Qt::Key_Right || keyEvent->key() == Qt::Key_Down) {
1785 d->_k_slotIconSizeSliderMoved(d->iconSizeSlider->value());
1787 }
else if (watched == d->locationEdit && event->type() == QEvent::KeyPress) {
1788 if (keyEvent->modifiers() & Qt::AltModifier) {
1789 switch (keyEvent->key()) {
1791 d->ops->actionCollection()->action(
"up")->trigger();
1794 d->ops->actionCollection()->action(
"back")->trigger();
1797 d->ops->actionCollection()->action(
"forward")->trigger();
1813 if ( d->ops->dirOnlyMode() ) {
1814 d->filterWidget->setDefaultFilter(
i18n(
"*|All Folders") );
1817 d->filterWidget->setDefaultFilter(
i18n(
"*|All Files") );
1820 d->updateAutoSelectExtension();
1825 return d->ops->mode();
1829 void KFileWidgetPrivate::readViewConfig()
1831 ops->setViewConfig(configGroup);
1832 ops->readConfig(configGroup);
1851 _k_toggleSpeedbar( configGroup.readEntry(
ShowSpeedbar,
true ) );
1854 _k_toggleBookmarks( configGroup.readEntry(
ShowBookmarks,
false) );
1858 updateAutoSelectExtension();
1864 urlNavigator->setShowFullPath( configGroup.readEntry(
ShowFullPath,
false) );
1866 int w1 = q->minimumSize().width();
1867 int w2 = toolbar->sizeHint().width();
1869 q->setMinimumWidth(w2);
1872 void KFileWidgetPrivate::writeViewConfig()
1887 const bool showSpeedbar = placesDock && !placesDock->isHidden();
1890 const QList<int> sizes = placesViewSplitter->sizes();
1891 Q_ASSERT( sizes.count() > 0 );
1900 ops->writeConfig( tmpGroup );
1907 void KFileWidgetPrivate::readRecentFiles()
1911 QObject::disconnect(
locationEdit, SIGNAL(editTextChanged(QString)),
1912 q, SLOT(_k_slotLocationChanged(QString)));
1919 QObject::connect(
locationEdit, SIGNAL(editTextChanged(QString)),
1920 q, SLOT(_k_slotLocationChanged(QString)));
1925 combo->
setUrl(ops->url());
1930 completion->
setDir(ops->url().url());
1935 void KFileWidgetPrivate::saveRecentFiles()
1951 return d->cancelButton;
1961 d->writeViewConfig();
1966 d->keepLocation = keep;
1971 return d->keepLocation;
1978 d->operationMode =
mode;
1979 d->keepLocation = (mode ==
Saving);
1980 d->filterWidget->setEditable( !d->hasDefaultFilter || mode !=
Saving );
1983 d->okButton->setGuiItem(
KGuiItem(
i18n(
"&Open" ),
"document-open") );
1986 }
else if ( mode ==
Saving ) {
1988 d->setNonExtSelection();
1992 d->updateLocationWhatsThis();
1993 d->updateAutoSelectExtension();
1996 d->ops->setIsSaving(mode ==
Saving);
2002 return d->operationMode;
2005 void KFileWidgetPrivate::_k_slotAutoSelectExtClicked()
2011 autoSelectExtChecked = autoSelectExtCheckBox->isChecked();
2014 updateLocationEditExtension (extension );
2017 void KFileWidgetPrivate::_k_placesViewSplitterMoved(
int pos,
int index)
2023 if (placesDock && index == 1) {
2024 placesViewWidth = pos;
2026 lafBox->setColumnMinimumWidth(0, placesViewWidth);
2030 void KFileWidgetPrivate::_k_activateUrlNavigator()
2034 urlNavigator->setUrlEditable(!urlNavigator->isUrlEditable());
2035 if(urlNavigator->isUrlEditable()) {
2036 urlNavigator->setFocus();
2037 urlNavigator->editor()->lineEdit()->selectAll();
2041 void KFileWidgetPrivate::_k_zoomOutIconsSize()
2043 const int currValue = ops->iconsZoom();
2044 const int futValue = qMax(0, currValue - 10);
2045 iconSizeSlider->setValue(futValue);
2046 _k_slotIconSizeSliderMoved(futValue);
2049 void KFileWidgetPrivate::_k_zoomInIconsSize()
2051 const int currValue = ops->iconsZoom();
2052 const int futValue = qMin(100, currValue + 10);
2053 iconSizeSlider->setValue(futValue);
2054 _k_slotIconSizeSliderMoved(futValue);
2057 void KFileWidgetPrivate::_k_slotIconSizeChanged(
int _value)
2060 int value = (maxSize * _value / 100) + KIconLoader::SizeSmall;
2062 case KIconLoader::SizeSmall:
2068 iconSizeSlider->setToolTip(
i18n(
"Icon size: %1 pixels (standard size)", value));
2071 iconSizeSlider->setToolTip(
i18n(
"Icon size: %1 pixels", value));
2076 void KFileWidgetPrivate::_k_slotIconSizeSliderMoved(
int _value)
2080 _k_slotIconSizeChanged(_value);
2082 QPoint global(iconSizeSlider->rect().topLeft());
2083 global.ry() += iconSizeSlider->height() / 2;
2084 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), iconSizeSlider->mapToGlobal(global));
2085 QApplication::sendEvent(iconSizeSlider, &toolTipEvent);
2095 QStringList::ConstIterator patternListEnd = patternList.end();
2096 for (QStringList::ConstIterator it = patternList.begin();
2097 it != patternListEnd;
2109 if ((*it).startsWith (QLatin1String(
"*.")) &&
2110 (*it).length() > 2 &&
2111 (*it).indexOf(
'*', 2) < 0 && (*it).indexOf (
'?', 2) < 0)
2113 ret = (*it).mid (1);
2123 QString ret = string;
2137 void KFileWidgetPrivate::updateAutoSelectExtension()
2139 if (!autoSelectExtCheckBox)
return;
2149 QString lastExtension = extension;
2160 if (!filter.isEmpty())
2166 if ( currentExtension.isEmpty() )
2167 currentExtension = locationEditCurrentText().section(QLatin1Char(
'.'), -1, -1);
2168 kDebug (
kfile_area) <<
"filter:" << filter <<
"locationEdit:" << locationEditCurrentText()
2169 <<
"currentExtension:" << currentExtension;
2171 QString defaultExtension;
2172 QStringList extensionList;
2175 if (filter.indexOf (
'/') < 0)
2177 extensionList = filter.split(
' ', QString::SkipEmptyParts);
2191 if ( !currentExtension.isEmpty() && extensionList.contains(QLatin1String(
"*.") + currentExtension) )
2192 extension = QLatin1Char(
'.') + currentExtension;
2194 extension = defaultExtension;
2196 kDebug (
kfile_area) <<
"List:" << extensionList <<
"auto-selected extension:" << extension;
2204 QString whatsThisExtension;
2205 if (!extension.isEmpty())
2208 autoSelectExtCheckBox->setText (
i18n (
"Automatically select filename e&xtension (%1)", extension));
2209 whatsThisExtension =
i18n (
"the extension <b>%1</b>", extension);
2211 autoSelectExtCheckBox->setEnabled (
true);
2212 autoSelectExtCheckBox->setChecked (autoSelectExtChecked);
2217 autoSelectExtCheckBox->setText (
i18n (
"Automatically select filename e&xtension"));
2218 whatsThisExtension =
i18n (
"a suitable extension");
2220 autoSelectExtCheckBox->setChecked (
false);
2221 autoSelectExtCheckBox->setEnabled (
false);
2226 autoSelectExtCheckBox->setWhatsThis(
"<qt>" +
2228 "This option enables some convenient features for " 2229 "saving files with extensions:<br />" 2231 "<li>Any extension specified in the <b>%1</b> text " 2232 "area will be updated if you change the file type " 2235 "<li>If no extension is specified in the <b>%2</b> " 2236 "text area when you click " 2237 "<b>Save</b>, %3 will be added to the end of the " 2238 "filename (if the filename does not already exist). " 2239 "This extension is based on the file type that you " 2240 "have chosen to save in.<br />" 2242 "If you do not want KDE to supply an extension for the " 2243 "filename, you can either turn this option off or you " 2244 "can suppress it by adding a period (.) to the end of " 2245 "the filename (the period will be automatically " 2249 "If unsure, keep this option enabled as it makes your " 2250 "files more manageable." 2258 autoSelectExtCheckBox->show();
2262 updateLocationEditExtension (lastExtension);
2267 autoSelectExtCheckBox->setChecked (
false);
2268 autoSelectExtCheckBox->hide();
2275 void KFileWidgetPrivate::updateLocationEditExtension (
const QString &lastExtension)
2277 if (!autoSelectExtCheckBox->isChecked() || extension.isEmpty())
2280 QString urlStr = locationEditCurrentText();
2281 if (urlStr.isEmpty())
2284 KUrl url = getCompleteUrl(urlStr);
2287 const int fileNameOffset = urlStr.lastIndexOf (
'/') + 1;
2288 QString fileName = urlStr.mid (fileNameOffset);
2290 const int dot = fileName.lastIndexOf (
'.');
2291 const int len = fileName.length();
2319 if (lastExtension.length() && fileName.endsWith (lastExtension))
2320 fileName.truncate (len - lastExtension.length());
2321 else if (extension.length() && fileName.endsWith (extension))
2322 fileName.truncate (len - extension.length());
2325 fileName.truncate (dot);
2328 const QString newText = urlStr.left (fileNameOffset) + fileName + extension;
2329 if ( newText != locationEditCurrentText() )
2339 void KFileWidgetPrivate::updateFilter()
2344 QString urlStr = locationEditCurrentText();
2345 if (urlStr.isEmpty())
2356 QString filename = urlStr.mid( urlStr.lastIndexOf( KDIR_SEPARATOR ) + 1 );
2358 QStringList patterns = filter.left( filter.indexOf(
'|' )).split (
' ', QString::SkipEmptyParts );
2359 foreach (
const QString& p, patterns ) {
2373 void KFileWidgetPrivate::appendExtension (
KUrl &url)
2377 if (!autoSelectExtCheckBox->isChecked() || extension.isEmpty())
2381 if (fileName.isEmpty())
2386 const int len = fileName.length();
2387 const int dot = fileName.lastIndexOf (
'.');
2389 const bool suppressExtension = (dot == len - 1);
2390 const bool unspecifiedExtension = (dot <= 0);
2393 if (!(suppressExtension || unspecifiedExtension))
2406 if (suppressExtension)
2422 else if (unspecifiedExtension)
2432 void KFileWidgetPrivate::addToRecentDocuments()
2434 int m = ops->mode();
2439 const QStringList files = q->selectedFiles();
2440 QStringList::ConstIterator it = files.begin();
2441 for ( ; it != files.end() && atmost > 0; ++it ) {
2449 KUrl::List::ConstIterator it = urls.begin();
2450 for ( ; it != urls.end() && atmost > 0; ++it ) {
2451 if ( (*it).isValid() ) {
2461 return d->locationEdit;
2466 return d->filterWidget;
2471 return d->ops->actionCollection();
2474 void KFileWidgetPrivate::_k_toggleSpeedbar(
bool show)
2479 lafBox->setColumnMinimumWidth(0, placesViewWidth);
2483 homeURL.
setPath( QDir::homePath() );
2485 for (
int rowIndex = 0 ; rowIndex < model->
rowCount() ; rowIndex++) {
2486 QModelIndex index = model->
index(rowIndex, 0);
2490 toolbar->removeAction( ops->actionCollection()->action(
"home" ) );
2495 if (q->sender() == placesDock && placesDock && placesDock->isVisibleTo(q)) {
2505 QAction* homeAction = ops->actionCollection()->action(
"home");
2506 QAction* reloadAction = ops->actionCollection()->action(
"reload");
2507 if (!toolbar->actions().contains(homeAction)) {
2508 toolbar->insertAction(reloadAction, homeAction);
2512 lafBox->setColumnMinimumWidth(0, 0);
2515 static_cast<KToggleAction *
>(q->actionCollection()->action(
"toggleSpeedbar"))->setChecked(show);
2518 urlNavigator->setPlacesSelectorVisible(!show);
2521 void KFileWidgetPrivate::_k_toggleBookmarks(
bool show)
2525 if (bookmarkHandler)
2531 q->connect( bookmarkHandler, SIGNAL(openUrl(QString)),
2532 SLOT(_k_enterUrl(QString)));
2535 bookmarkButton->setDelayed(
false);
2536 q->actionCollection()->addAction(
"bookmark", bookmarkButton);
2537 bookmarkButton->setMenu(bookmarkHandler->menu());
2538 bookmarkButton->setWhatsThis(
i18n(
"<qt>This button allows you to bookmark specific locations. " 2539 "Click on this button to open the bookmark menu where you may add, " 2540 "edit or select a bookmark.<br /><br />" 2541 "These bookmarks are specific to the file dialog, but otherwise operate " 2542 "like bookmarks elsewhere in KDE.</qt>"));
2543 toolbar->addAction(bookmarkButton);
2545 else if (bookmarkHandler)
2547 delete bookmarkHandler;
2548 bookmarkHandler = 0;
2549 delete bookmarkButton;
2553 static_cast<KToggleAction *
>(q->actionCollection()->action(
"toggleBookmarks"))->setChecked( show );
2559 QString& recentDirClass )
2562 return getStartUrl( startDir, recentDirClass, fileName );
2568 QString& recentDirClass,
2571 recentDirClass.clear();
2575 bool useDefaultStartDir = startDir.isEmpty();
2576 if ( !useDefaultStartDir )
2578 if ( startDir.
protocol() ==
"kfiledialog" )
2592 QString urlFile = startDir.
fileName();
2593 if ( urlDir ==
"/" )
2600 keyword = urlDir.mid( 1 );
2604 if ( startDir.
query() ==
"?global" )
2605 recentDirClass = QString(
"::%1" ).arg( keyword );
2607 recentDirClass = QString(
":%1" ).arg( keyword );
2626 useDefaultStartDir =
true;
2633 useDefaultStartDir =
true;
2638 if ( useDefaultStartDir )
2640 if (lastDirectory->isEmpty()) {
2643 home.
setPath( QDir::homePath() );
2649 QDir::currentPath() != QDir::homePath() ||
2651 lastDirectory->setPath(QDir::currentPath());
2653 ret = *lastDirectory;
2656 kDebug(
kfile_area) <<
"for" << startDir <<
"->" << ret <<
"recentDirClass" << recentDirClass <<
"fileName" << fileName;
2662 if ( directory.isValid() )
2663 *lastDirectory = directory;
2666 void KFileWidgetPrivate::setNonExtSelection()
2669 QString filename = locationEditCurrentText();
2672 if ( !extension.isEmpty() )
2673 locationEdit->lineEdit()->setSelection( 0, filename.length() - extension.length() - 1 );
2676 int lastDot = filename.lastIndexOf(
'.' );
2689 delete d->bottomCustomWidget;
2690 d->bottomCustomWidget = widget;
2695 d->bottomCustomWidget->setParent(
this );
2697 d->vbox->addWidget( d->bottomCustomWidget );
2705 setTabOrder(d->cancelButton, d->bottomCustomWidget);
2706 setTabOrder(d->bottomCustomWidget, d->urlNavigator);
2711 delete d->labeledCustomWidget;
2712 d->labeledCustomWidget = widget;
2715 label->setAlignment(Qt::AlignRight);
2716 d->lafBox->addWidget(label, 2, 0, Qt::AlignVCenter);
2717 d->lafBox->addWidget(widget, 2, 1, Qt::AlignVCenter);
2729 bool *enable =
static_cast<bool*
>(data);
2730 d->confirmOverwrite = *enable;
2734 bool *show =
static_cast<bool*
>(data);
2735 d->setInlinePreviewShown(*show);
2750 d->configGroup = group;
2751 d->readViewConfig();
2752 d->readRecentFiles();
2755 QString KFileWidgetPrivate::locationEditCurrentText()
const 2757 return QDir::fromNativeSeparators(
locationEdit->currentText());
2760 KUrl KFileWidgetPrivate::mostLocalUrl(
const KUrl &url)
2774 if (!path.isEmpty()) {
2783 void KFileWidgetPrivate::setInlinePreviewShown(
bool show)
2785 ops->setInlinePreviewShown(show);
2789 #include "kfilewidget.moc"
KUrl url(const QModelIndex &index) const
QString i18n(const char *text)
void adjustPath(AdjustPathOption trailing)
static QString iconNameForUrl(const KUrl &url, mode_t mode=0)
QString directory(const DirectoryOptions &options=IgnoreTrailingSlash) const
static QString relativeUrl(const KUrl &base_url, const KUrl &url)
static bool matchFileName(const QString &filename, const QString &pattern)
static QString relativePath(const QString &base_dir, const QString &path, bool *isParent=0)
virtual void setCompletionObject(KCompletion *compObj, bool hsig=true)
Generates previews for files of an item view.
static KIconLoader * global()
bool isMimeFilter() const
Returns true if the filter has been set using setMimeFilter().
static bool isKnownProtocol(const KUrl &url)
static QString desktopPath()
KAction * copy(const QObject *recvr, const char *slot, QObject *parent)
#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)
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.
QString currentFilter() const
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)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Get the children model index for the given row and column.
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)
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) const
bool contains(const QString &text) 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)
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
bool isParentOf(const KUrl &u) const
int cursorPosition() const
#define BreadcrumbNavigation
int rowCount(const QModelIndex &parent=QModelIndex()) const
Get the number of rows for a model index.
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)
QStringList filters() 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)
QString buildErrorString(int errorCode, const QString &errorText)
virtual void setCompletionMode(KGlobalSettings::Completion mode)
QString pathOrUrl() const
QString mainExtension() const
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 stringValue(uint field) const
KAction * home(const QObject *recvr, const char *slot, QObject *parent)
virtual void setDir(const QString &dir)
void copyTo(KConfigBase *other, WriteConfigFlags pFlags=Normal) const
void setAutoDeleteCompletionObject(bool autoDelete)
QString path(AdjustPathOption trailing=LeaveTrailingSlash) const
void removeAction(QAction *action)
#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)
bool isPreviewShown() const
QString removeAcceleratorMarker(const QString &label) const
void changeUrl(int index, const KUrl &url)
void setFileName(const QString &_txt)
QString dir(const QString &fileClass)
QString replacedPath(const QString &text) const
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
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)
QAction * action(int index) const
static Ptr mimeType(const QString &name, FindByNameOption options=ResolveAliases)
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
Widget that allows to navigate through the paths of an URL.
static bool supportsListing(const KUrl &url)
static Completion completionMode()
const UDSEntry & statResult() const
static int maximumItems()
bool equals(const KUrl &u, const EqualsOptions &options=0) 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)
QStringList patterns() const
QString prettyUrl(AdjustPathOption trailing=LeaveTrailingSlash) const
KUrl::List urlList() const
KGlobalSettings::Completion completionMode() const
static void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
#define DefaultRecentURLsNumber
#define AutoSelectExtChecked
QStringList list(const QString &fileClass)
This class is a list view model.