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 &);
134 void readRecentFiles();
138 void saveRecentFiles();
143 void multiSelectionChanged();
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()));
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);
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();
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);
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)
1062 (locationEdit->hasFocus() && !locationEdit->currentText().isEmpty()))
1065 const bool modified = locationEdit->lineEdit()->isModified();
1070 setLocationText(
KUrl());
1077 if (!locationEdit->hasFocus()) {
1078 setLocationText( url );
1081 emit q->fileHighlighted(url.url());
1082 emit q->fileHighlighted(url);
1084 multiSelectionChanged();
1085 emit q->selectionChanged();
1088 locationEdit->lineEdit()->setModified(
false );
1089 locationEdit->lineEdit()->selectAll();
1092 void KFileWidgetPrivate::_k_fileSelected(
const KFileItem &i)
1100 setLocationText(
KUrl());
1103 setLocationText(i.
url());
1105 multiSelectionChanged();
1106 emit q->selectionChanged();
1112 locationEdit->setFocus();
1121 void KFileWidgetPrivate::multiSelectionChanged()
1123 if (locationEdit->hasFocus() && !locationEdit->currentText().isEmpty()) {
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;
1148 int cursorPosition = locationEdit->lineEdit()->cursorPosition();
1151 if ( !icon.isNull() ) {
1152 locationEdit->setItemIcon( 0, icon );
1153 locationEdit->setItemText( 0, text );
1155 if ( !usePreviousPixmapIfNull ) {
1156 locationEdit->setItemIcon( 0, QPixmap() );
1158 locationEdit->setItemText( 0, text );
1161 if ( !text.isEmpty() ) {
1162 if ( !icon.isNull() ) {
1163 locationEdit->insertItem( 0, icon, text );
1165 if ( !usePreviousPixmapIfNull ) {
1166 locationEdit->insertItem( 0, QPixmap(), text );
1168 locationEdit->insertItem( 0, text );
1176 if ( dummyExists && !text.isEmpty() ) {
1177 locationEdit->setCurrentIndex( 0 );
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)) );
1198 if (locationEdit->count()) {
1199 locationEdit->removeItem( 0 );
1201 locationEdit->setCurrentIndex( -1 );
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()
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);
1298 locationEdit->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);
1379 q->setTabOrder(autoSelectExtCheckBox, locationEdit);
1380 q->setTabOrder(locationEdit, filterWidget);
1381 q->setTabOrder(filterWidget, okButton);
1382 q->setTabOrder(okButton, cancelButton);
1383 q->setTabOrder(cancelButton, urlNavigator);
1384 q->setTabOrder(urlNavigator, ops);
1385 q->setTabOrder(cancelButton, urlNavigator);
1386 q->setTabOrder(urlNavigator, ops);
1390 void KFileWidgetPrivate::_k_slotFilterChanged()
1394 filterDelayTimer.stop();
1396 QString filter = filterWidget->currentFilter();
1399 if ( filter.contains(
'/') ) {
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) {
1438 bool blocked = locationEdit->blockSignals(
true);
1440 locationEdit->changeUrl(0,
KIcon(KMimeType::iconNameForUrl(filename)), filename);
1441 locationEdit->lineEdit()->setModified(
true);
1444 locationEdit->blockSignals( blocked );
1446 urlNavigator->setLocationUrl(url);
1451 completion->setDir( url.
path() );
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 );
1475 if (!locationEdit->hasFocus())
1479 void KFileWidgetPrivate::_k_enterUrl(
const QString& url )
1483 _k_enterUrl(
KUrl( KUrlCompletion::replacedPath( url,
true,
true )) );
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()
1531 if (locationEdit->currentText().isEmpty()) {
1535 ops->blockSignals(
true);
1539 ops->setCurrentItem(url.
url());
1540 ops->blockSignals(
false);
1543 void KFileWidgetPrivate::_k_fileCompletion(
const QString& match )
1547 if (match.isEmpty() || locationEdit->currentText().contains(
'"')) {
1554 void KFileWidgetPrivate::_k_slotLocationChanged(
const QString& text )
1558 locationEdit->lineEdit()->setModified(
true);
1560 if (text.isEmpty() && ops->view()) {
1561 ops->view()->clearSelection();
1564 if (text.isEmpty()) {
1565 removeDummyHistoryEntry();
1567 setDummyHistoryEntry( text );
1570 if (!locationEdit->lineEdit()->text().isEmpty()) {
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 );
1647 KUrl u( ops->url() );
1651 const int count = line.count( QLatin1Char(
'"' ) );
1653 if (!QDir::isAbsolutePath(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()) ) {
1681 _u.setFileName( name );
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);
1834 autoDirectoryFollowing = configGroup.readEntry(AutoDirectoryFollowing,
1835 DefaultDirectoryFollowing);
1838 configGroup.readEntry( PathComboCompletionMode,
1844 configGroup.readEntry( LocationComboCompletionMode,
1847 locationEdit->setCompletionMode( cm );
1850 _k_toggleSpeedbar( configGroup.readEntry( ShowSpeedbar,
true ) );
1853 _k_toggleBookmarks( configGroup.readEntry(ShowBookmarks,
false) );
1856 autoSelectExtChecked = configGroup.readEntry (AutoSelectExtChecked, DefaultAutoSelectExtChecked);
1857 updateAutoSelectExtension();
1860 urlNavigator->setUrlEditable( !configGroup.readEntry(BreadcrumbNavigation,
true) );
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()
1883 tmpGroup.writeEntry( PathComboCompletionMode, static_cast<int>(pathCombo->
completionMode()) );
1884 tmpGroup.writeEntry( LocationComboCompletionMode, static_cast<int>(locationEdit->completionMode()) );
1886 const bool showSpeedbar = placesDock && !placesDock->isHidden();
1887 tmpGroup.writeEntry( ShowSpeedbar, showSpeedbar );
1889 const QList<int> sizes = placesViewSplitter->sizes();
1890 Q_ASSERT( sizes.count() > 0 );
1891 tmpGroup.writeEntry( SpeedbarWidth, sizes[0] );
1894 tmpGroup.writeEntry( ShowBookmarks, bookmarkHandler != 0 );
1895 tmpGroup.writeEntry( AutoSelectExtChecked, autoSelectExtChecked );
1896 tmpGroup.writeEntry( BreadcrumbNavigation, !urlNavigator->isUrlEditable() );
1897 tmpGroup.writeEntry( ShowFullPath, urlNavigator->showFullPath() );
1899 ops->writeConfig( tmpGroup );
1902 tmpGroup.copyTo( &configGroup, KConfigGroup::Persistent | KConfigGroup::Global );
1906 void KFileWidgetPrivate::readRecentFiles()
1910 QObject::disconnect(locationEdit, SIGNAL(editTextChanged(
QString)),
1911 q, SLOT(_k_slotLocationChanged(
QString)));
1913 locationEdit->setMaxItems(configGroup.readEntry(RecentFilesNumber, DefaultRecentURLsNumber));
1914 locationEdit->setUrls(configGroup.readPathEntry(RecentFiles,
QStringList()),
1916 locationEdit->setCurrentIndex(-1);
1918 QObject::connect(locationEdit, SIGNAL(editTextChanged(
QString)),
1919 q, SLOT(_k_slotLocationChanged(
QString)));
1923 combo->
setMaxItems(configGroup.readEntry(RecentURLsNumber, DefaultRecentURLsNumber));
1924 combo->
setUrl(ops->url());
1929 completion->setDir(ops->url().url());
1934 void KFileWidgetPrivate::saveRecentFiles()
1937 configGroup.writePathEntry(RecentFiles, locationEdit->urls());
1940 configGroup.writePathEntry(RecentURLs, pathCombo->
urls());
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);
2136 void KFileWidgetPrivate::updateAutoSelectExtension()
2138 if (!autoSelectExtCheckBox)
return;
2148 QString lastExtension = extension;
2158 QString filter = filterWidget->currentFilter();
2159 if (!filter.isEmpty())
2164 QString currentExtension = KMimeType::extractKnownExtension(locationEditCurrentText());
2165 if ( currentExtension.isEmpty() )
2166 currentExtension = locationEditCurrentText().section(QLatin1Char(
'.'), -1, -1);
2167 kDebug (kfile_area) <<
"filter:" << filter <<
"locationEdit:" << locationEditCurrentText()
2168 <<
"currentExtension:" << currentExtension;
2174 if (filter.indexOf (
'/') < 0)
2176 extensionList = filter.split(
' ', QString::SkipEmptyParts);
2182 KMimeType::Ptr mime = KMimeType::mimeType (filter);
2185 extensionList = mime->patterns();
2186 defaultExtension = mime->mainExtension();
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;
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() )
2330 locationEdit->setItemText(locationEdit->currentIndex(),urlStr.left (fileNameOffset) + fileName + extension);
2331 locationEdit->lineEdit()->setModified (
true);
2338 void KFileWidgetPrivate::updateFilter()
2343 QString urlStr = locationEditCurrentText();
2344 if (urlStr.isEmpty())
2347 if( filterWidget->isMimeFilter()) {
2348 KMimeType::Ptr mime = KMimeType::findByPath(urlStr, 0,
true);
2349 if (mime && mime->name() != KMimeType::defaultMimeType()) {
2350 if (filterWidget->currentFilter() != mime->name() &&
2351 filterWidget->filters().indexOf(mime->name()) != -1)
2352 filterWidget->setCurrentFilter(mime->name());
2355 QString filename = urlStr.mid( urlStr.lastIndexOf( KDIR_SEPARATOR ) + 1 );
2356 foreach(
const QString& filter, filterWidget->filters()) {
2357 QStringList patterns = filter.left( filter.indexOf(
'|' )).split (
' ', QString::SkipEmptyParts );
2358 foreach (
const QString& p, patterns ) {
2359 if( KMimeType::matchFileName( filename, p )) {
2361 filterWidget->setCurrentFilter( filter );
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();
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)),
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 );
2561 return getStartUrl( startDir, recentDirClass, fileName );
2570 recentDirClass.clear();
2574 bool useDefaultStartDir = startDir.isEmpty();
2575 if ( !useDefaultStartDir )
2577 if ( startDir.
protocol() ==
"kfiledialog" )
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();
2669 QString extension = KMimeType::extractKnownExtension( filename );
2671 if ( !extension.isEmpty() )
2672 locationEdit->lineEdit()->setSelection( 0, filename.length() - extension.length() - 1 );
2675 int lastDot = filename.lastIndexOf(
'.' );
2677 locationEdit->lineEdit()->setSelection( 0, lastDot );
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"
KUrl url(const QModelIndex &index) const
QString i18n(const char *text)
void adjustPath(AdjustPathOption trailing)
QString directory(const DirectoryOptions &options=IgnoreTrailingSlash) const
static QString relativeUrl(const KUrl &base_url, const KUrl &url)
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()
static bool isKnownProtocol(const KUrl &url)
static QString desktopPath()
KAction * copy(const QObject *recvr, const char *slot, QObject *parent)
QString label(StandardShortcut id)
static void information(QWidget *parent, const QString &text, const QString &caption=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
This class allows to display a KFilePlacesModel.
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)
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)
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) 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)
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 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()
void setPath(const QString &path)
void addPath(const QString &txt)
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
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)
void setAutoDeleteCompletionObject(bool autoDelete)
QString path(AdjustPathOption trailing=LeaveTrailingSlash) const
void removeAction(QAction *action)
QStringList types(Mode mode=Writing)
void setShortcut(const KShortcut &shortcut, ShortcutTypes type=ShortcutTypes(ActiveShortcut|DefaultShortcut))
static QString documentPath()
bool isPreviewShown() const
QString removeAcceleratorMarker(const QString &label) const
void setFileName(const QString &_txt)
QString dir(const QString &fileClass)
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
void setUrl(const KUrl &url)
void addAssociatedWidget(QWidget *widget)
QString tildeExpand(const QString &path)
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QAction * action(int index) const
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)
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)
QStringList list(const QString &fileClass)
This class is a list view model.