mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kfile: add the selected directory to recent directories from KFileWidget
note that if class was not empty any URL selected was added to recent dirs (which could be a file, duh). now directories will be added only for directory mode and when the class (see KFileWidget about starting directory) is not empty Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
4cc96022e8
commit
978cf7f0dd
1 changed files with 17 additions and 10 deletions
|
@ -186,7 +186,7 @@ public:
|
|||
void _k_slotIconSizeSliderMoved(int);
|
||||
void _k_slotIconSizeChanged(int);
|
||||
|
||||
void addToRecentDocuments();
|
||||
void addToRecent();
|
||||
|
||||
QString locationEditCurrentText() const;
|
||||
|
||||
|
@ -970,8 +970,6 @@ void KFileWidget::accept()
|
|||
d->inAccept = true; // parseSelectedUrls() checks that
|
||||
|
||||
*lastDirectory = d->ops->url();
|
||||
if (!d->fileClass.isEmpty())
|
||||
KRecentDirs::add(d->fileClass, d->ops->url().url());
|
||||
|
||||
// clear the topmost item, we insert it as full path later on as item 1
|
||||
d->locationEdit->setItemText( 0, QString() );
|
||||
|
@ -1003,7 +1001,7 @@ void KFileWidget::accept()
|
|||
d->writeViewConfig();
|
||||
d->saveRecentFiles();
|
||||
|
||||
d->addToRecentDocuments();
|
||||
d->addToRecent();
|
||||
|
||||
if (!(mode() & KFile::Files)) { // single selection
|
||||
emit fileSelected(d->url);
|
||||
|
@ -2365,22 +2363,31 @@ void KFileWidgetPrivate::appendExtension (KUrl &url)
|
|||
|
||||
|
||||
// adds the selected files/urls to 'recent documents'
|
||||
void KFileWidgetPrivate::addToRecentDocuments()
|
||||
void KFileWidgetPrivate::addToRecent()
|
||||
{
|
||||
int m = ops->mode();
|
||||
int atmost = KRecentDocument::maximumItems();
|
||||
//don't add more than we need. KRecentDocument::add() is pretty slow
|
||||
int atmost = KRecentDocument::maximumItems();
|
||||
|
||||
if (m & KFile::LocalOnly) {
|
||||
if (m & KFile::Directory) {
|
||||
if (!fileClass.isEmpty()) {
|
||||
const KUrl::List urls = q->selectedUrls();
|
||||
KUrl::List::ConstIterator it = urls.begin();
|
||||
for ( ; it != urls.end(); ++it ) {
|
||||
if ( (*it).isValid() ) {
|
||||
KRecentDirs::add(fileClass, it->url());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (m & KFile::LocalOnly) {
|
||||
const QStringList files = q->selectedFiles();
|
||||
QStringList::ConstIterator it = files.begin();
|
||||
for ( ; it != files.end() && atmost > 0; ++it ) {
|
||||
KRecentDocument::add( *it );
|
||||
atmost--;
|
||||
}
|
||||
}
|
||||
|
||||
else { // urls
|
||||
} else {
|
||||
// urls
|
||||
const KUrl::List urls = q->selectedUrls();
|
||||
KUrl::List::ConstIterator it = urls.begin();
|
||||
for ( ; it != urls.end() && atmost > 0; ++it ) {
|
||||
|
|
Loading…
Add table
Reference in a new issue