kfile: merge it into kio

once upon a time it was either part of it or was separated from it

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-03-23 16:49:05 +02:00
parent 30eedcf057
commit a65bd3b685
68 changed files with 175 additions and 1013 deletions

View file

@ -459,7 +459,6 @@ add_subdirectory( kdecore )
add_subdirectory( kded ) add_subdirectory( kded )
add_subdirectory( kdeui ) add_subdirectory( kdeui )
add_subdirectory( kdewidgets ) add_subdirectory( kdewidgets )
add_subdirectory( kfile )
add_subdirectory( kimgio ) add_subdirectory( kimgio )
add_subdirectory( kinit ) add_subdirectory( kinit )
add_subdirectory( kio ) add_subdirectory( kio )

View file

@ -22,7 +22,6 @@
185 kdecore (KAuthorization) 185 kdecore (KAuthorization)
200 kdeui (KMainWindow) 200 kdeui (KMainWindow)
240 kdeui (kdelibs) 240 kdeui (kdelibs)
250 kfile (kdelibs)
260 kdeui (KXmlGui) 260 kdeui (KXmlGui)
264 kdeui (KIconLoader) 264 kdeui (KIconLoader)
265 kdeui (KIconEffect) 265 kdeui (KIconEffect)

View file

@ -1,97 +0,0 @@
project(kfile)
include_directories(
${KDE4_KIO_INCLUDES}
${CMAKE_SOURCE_DIR}/solid
${CMAKE_BINARY_DIR}/solid
${CMAKE_CURRENT_BINARY_DIR}
)
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=250)
if(ENABLE_TESTING)
add_subdirectory(tests)
endif()
set(kfile_LIB_SRCS
kdiroperator.cpp
kdiroperatordetailview.cpp
# used in combination with kio/kio/kdirmodel.cpp
kdirsortfilterproxymodel.cpp
kfilebookmarkhandler.cpp
kfilefiltercombo.cpp
kfilewidget.cpp
kfileplacesitem.cpp
kfileplacesmodel.cpp
kfileplacesview.cpp
kfileplaceeditdialog.cpp
kfilepreviewgenerator.cpp
knameandurlinputdialog.cpp
knewfilemenu.cpp
kurlnavigatordropdownbutton.cpp
kurlnavigatorbuttonbase.cpp
kurlnavigatorbutton.cpp
kurlnavigatorplacesselector.cpp
kurlnavigatorprotocolcombo.cpp
kurlnavigatortogglebutton.cpp
kurlnavigator.cpp
kurlnavigatormenu.cpp
kdefaultviewadapter.cpp
)
add_library(kfile SHARED ${kfile_LIB_SRCS})
target_link_libraries(kfile PUBLIC
kdecore
kdeui
kio
solid
)
set_target_properties(kfile PROPERTIES
VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_SOVERSION}
)
install(
TARGETS kfile
EXPORT kdelibsTargets
DESTINATION ${KDE4_LIB_INSTALL_DIR}
)
generate_export_header(kfile)
install(
FILES
kdiroperator.h
kdirsortfilterproxymodel.h
kfilefiltercombo.h
kfileplacesmodel.h
kfileplacesview.h
kfilepreviewgenerator.h
kfilewidget.h
kurlnavigator.h
knewfilemenu.h
knameandurlinputdialog.h
${CMAKE_CURRENT_BINARY_DIR}/kfile_export.h
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}
)
############ module used by KFileDialog ##########
kde4_add_plugin(kfilemodule kfilemodule.cpp)
target_link_libraries(kfilemodule
kfile
kio
)
install(
TARGETS kfilemodule
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
)
install(
FILES kfilemodule.desktop
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
)

View file

@ -1,2 +0,0 @@
#! /usr/bin/env bash
# they get into kio4.pot

View file

@ -1,47 +0,0 @@
/* This file is part of the KDE libraries
Copyright 2007 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kfilemodule.h"
#include "kfilewidget.h"
#include "kpluginfactory.h"
K_PLUGIN_FACTORY(KFileModuleFactory, registerPlugin<KFileModule>();)
K_EXPORT_PLUGIN(KFileModuleFactory("kfilemodule", "kio4"))
KFileModule::KFileModule(QObject* parent, const QVariantList&)
: KAbstractFileModule(parent)
{
}
QWidget* KFileModule::createFileWidget(const KUrl& startDir, QWidget *parent)
{
return new KFileWidget(startDir, parent);
}
KUrl KFileModule::getStartUrl( const KUrl& startDir, QString& recentDirClass )
{
return KFileWidget::getStartUrl(startDir, recentDirClass);
}
void KFileModule::setStartDir( const KUrl& directory )
{
KFileWidget::setStartDir(directory);
}
#include "moc_kfilemodule.cpp"

View file

@ -1,141 +0,0 @@
[Desktop Entry]
Name=KFileModule
Name[ar]=KFileModule
Name[ast]=KFileModule
Name[bg]=Модул KFile
Name[bn]=- ি
Name[bs]=KFileModule
Name[ca]=KFileModule
Name[ca@valencia]=KFileModule
Name[cs]=Modul KFile
Name[da]=KFileModule
Name[de]=KFile-Modul
Name[el]=Άρθρωμα KFile
Name[en_GB]=KFileModule
Name[es]=KFileModule
Name[et]=KFileModule
Name[eu]=KFileModulua
Name[fa]=KFileModule
Name[fi]=KFileModule
Name[fr]=KFileModule
Name[ga]=KFileModule
Name[gl]=KFileModule
Name[gu]=KFile
Name[he]=מודול KFile
Name[hi]=KFileModule
Name[hr]=KModulDatoteke
Name[hu]=KFileModule
Name[hy]=KFileModule
Name[ia]=Modulo KFile
Name[id]=KFileModule
Name[is]=KFile eining
Name[it]=Modulo KFile
Name[ja]=KFile
Name[kk]=KFileModule
Name[km]=KFileModule
Name[kn]=KFileModule
Name[ko]=KFileModule
Name[ku]=ModûlaKFile
Name[lt]=KFileModulis
Name[lv]=KFileModule
Name[mr]=KFile ि
Name[ms]=KFileModule
Name[nb]=KFileModule
Name[nds]=K-Dateimoduul
Name[nl]=KFileModule
Name[nn]=KFileModule
Name[pa]=KFileModule
Name[pl]=Moduł KFile
Name[pt]=KFileModule
Name[pt_BR]=KFileModule
Name[ro]=KFileModule
Name[ru]=KFileModule
Name[se]=KFileModule
Name[si]=KDED
Name[sk]=KFile modul
Name[sl]=Modul KFile
Name[sr]=Модул кфајла
Name[sr@ijekavian]=Модул кфајла
Name[sr@ijekavianlatin]=Modul KFilea
Name[sr@latin]=Modul KFilea
Name[sv]=Kfil-modul
Name[ta]=KFileModule
Name[tg]=KFileModule
Name[th]=KFileModule
Name[tr]=KFile Modülü
Name[tt]=KFileModule
Name[ug]=KFile بۆلىكى
Name[uk]=KFileModule
Name[vi]=KFileModule
Name[wa]=Module KFile
Name[x-test]=xxKFileModulexx
Name[zh_CN]=KFile
Name[zh_TW]=KFile
Comment=The default KDE file module providing the standard file dialog
Comment[ar]=وحدة ملف كدي الافتراضية التي تعطي مربع الملف القياسي
Comment[bg]=Подразбиращият се файлов модул на KDE, осигуряващ стандартния диалогов прозорец за файлове
Comment[bs]=Podrazumijevani KDEov modul datoteka koji daje standardnu datoteku dijalog
Comment[ca]=El mòdul de fitxers per defecte del KDE que proporciona el diàleg de fitxer estàndard
Comment[ca@valencia]=El mòdul de fitxers per defecte del KDE que proporciona el diàleg de fitxer estàndard
Comment[cs]=Výchozí souborový modul poskytující standardní souborový dialog
Comment[da]=KDE's standard filmodul som giver standard fildialogen
Comment[de]=Das Standard-KDE-Dateimodul, das den Standard-Dateidialog bereitstellt
Comment[el]=Το προεπιλεγμένο άρθρωμα KDE που παρέχει τον τυπικό διάλογο αρχείων
Comment[en_GB]=The default KDE file module providing the standard file dialogue
Comment[es]=El módulo de archivos por omisión de KDE que proporciona el diálogo de archivos estándar
Comment[et]=KDE vaikimisi failimoodul, mis pakub standardset failidialoogi
Comment[eu]=Fitxategi elkarrizketa koadro estandarra eskeintzen duen KDE fitxategi modulu lehenetsia
Comment[fi]=KDE:n oletustiedostoikkunan toteuttava moduuli
Comment[fr]=Le module de fichiers KDE par défaut fournissant la boîte de dialogue standard d'ouverture de fichiers
Comment[ga]=Modúl réamhshocraithe comhad KDE a sholáthraíonn an gnáthdhialóg comhad
Comment[gl]=O módulo predeterminado de KDE para ficheiros, que fornece o diálogo normal de ficheiros
Comment[gu]= KDE
Comment[he]=מודול ברירת מחדל של KDE המספק את חלון הקבצים
Comment[hr]=Uobičajeni KDE modul za datoteke koji pruža standardni dijalog
Comment[hu]=A KDE alapértelmezett, standard fájlkezelő ablakait tartalmazó modul
Comment[ia]=Le modulo KDEFile predefinite que forni le file standard de dialogo
Comment[id]=Modul berkas KDE standar menyediakan dialog berkas standar
Comment[is]=Sjálfgefna KDE skráareiningin sem sér um staðlaða skráagluggann
Comment[it]=Il modulo file standard di KDE che fornisce la finestra di dialogo per i file
Comment[ja]= KDE
Comment[kk]=Стандартты файл диалогын қамтамасыз ететін KDE файл модулі
Comment[km]= KDE
Comment[ko]= KDE
Comment[ku]=KDE modula pelê ya standard, paceya pelê ya standard peyde dike
Comment[lt]=Numatytasis KDE failų dialogo modulis
Comment[lv]=Noklusētais KDE failu modulis, kas nodrošina standarta failu dialogu
Comment[mr]=ि ि
Comment[nb]=KDE standard filmodul som skaffer standard fildialog
Comment[nds]=Dat KDE-Standarddateimoduul, dat den Standard-Dateidialoog praatstellt
Comment[nl]=De standaard KDE-bestandsmodule die de standaard bestandsdialoog levert
Comment[nn]=Standard KDE-filmodul for opna/lagra-vindauge
Comment[pa]=ਿ KDE ਿ
Comment[pl]=Domyślny moduł plików KDE dostarczający standardowe okno dialogowe plików
Comment[pt]=O módulo de ficheiros predefinido do KDE, que fornece a janela de ficheiros normal
Comment[pt_BR]=O módulo de arquivos padrão do KDE, que fornece o diálogo de arquivos padronizado
Comment[ro]=Modulul de fișier KDE implicit, furnizînd dialogul standard de fișiere
Comment[ru]=Модуль по умолчанию диалогового окна выбора файла
Comment[se]=Standárda KDE-fiilamodula mii sisttisdoallá standárdafiilaláseža
Comment[sk]=Štandardný súborový modul KDE, ktorý poskytuje štandardný súborový dialóg
Comment[sl]=Privzeti modul KDE za datoteke, ki ponuja standardno pogovorno okno za datoteke
Comment[sr]=Подразумевани КДЕов модул фајлова који даје стандардни фајл дијалог
Comment[sr@ijekavian]=Подразумијевани КДЕов модул фајлова који даје стандардни фајл дијалог
Comment[sr@ijekavianlatin]=Podrazumijevani KDEov modul fajlova koji daje standardni fajl dijalog
Comment[sr@latin]=Podrazumevani KDEov modul fajlova koji daje standardni fajl dijalog
Comment[sv]=KDE:s standardmodul för filer som tillhandahåller standarddialogrutan för filer
Comment[ta]= ி ி
Comment[tg]=Файли стандартии модули KDE барои намоиши диалогҳо
Comment[th]= KDE
Comment[tr]=Standart dosya penceresini sağlayan KDE öntanımlı dosya modülü
Comment[tt]=Баштан ук билгеләнгән файл сайлау диалог тәрәзәсе модуле
Comment[ug]=سۈكۈتتىكى KDE ھۆججەت بۆلىكى ئۆلچەملىك ھۆججەت سۆزلەشكۈ تەمىنلىدى
Comment[uk]=Типовий модуль KDE, що забезпечує роботу стандартного діалогового вікна роботи з файлами
Comment[vi]=Mô-đun tp tin KDE mc đnh cung cp hp thoi tp tin chun
Comment[wa]=Li module fitchî prémetou di KDE et ki dene li dvize di fitchî standård
Comment[x-test]=xxThe default KDE file module providing the standard file dialogxx
Comment[zh_CN]= KDE
Comment[zh_TW]= KDE
X-KDE-ServiceTypes=KIO/FileModule
Type=Service
X-KDE-Library=kfilemodule

View file

@ -1,39 +0,0 @@
/* This file is part of the KDE libraries
Copyright 2007 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KFILEMODULE_H
#define KFILEMODULE_H
#include <kabstractfilemodule.h>
class KFileModule : public KAbstractFileModule
{
Q_OBJECT
public:
KFileModule(QObject* parent, const QVariantList&);
virtual QWidget* createFileWidget(const KUrl& startDir, QWidget *parent);
virtual KUrl getStartUrl( const KUrl& startDir, QString& recentDirClass );
virtual void setStartDir( const KUrl& directory );
};
#endif /* KFILEMODULE_H */

View file

@ -1,24 +0,0 @@
MACRO(KFILE_UNIT_TESTS)
FOREACH(_testname ${ARGN})
kde4_add_test(kfile-${_testname} ${_testname}.cpp)
target_link_libraries(kfile-${_testname}
${QT_QTTEST_LIBRARY}
${QT_QTXML_LIBRARY}
kfile
kio
)
ENDFOREACH(_testname)
ENDMACRO(KFILE_UNIT_TESTS)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
add_definitions(
-DTEST_DATA="${CMAKE_SOURCE_DIR}/solid/solid/backends/fakehw/fakecomputer.xml"
)
KFILE_UNIT_TESTS(
kfileplacesmodeltest
kurlnavigatortest
kdiroperatortest
knewfilemenutest
)

View file

@ -12,6 +12,9 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${KDE4_KDEUI_INCLUDES} ${KDE4_KDEUI_INCLUDES}
${KDE4_KDECORE_INCLUDES} ${KDE4_KDECORE_INCLUDES}
${CMAKE_SOURCE_DIR}/solid
${CMAKE_BINARY_DIR}/solid
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/kutils/kpasswdstore ${CMAKE_SOURCE_DIR}/kutils/kpasswdstore
${CMAKE_BINARY_DIR}/kutils/kpasswdstore ${CMAKE_BINARY_DIR}/kutils/kpasswdstore
${CMAKE_SOURCE_DIR}/kutils/kexiv2 ${CMAKE_SOURCE_DIR}/kutils/kexiv2
@ -93,7 +96,6 @@ set(kbookmarks_STAT_SRCS
) )
set(kfile_STAT_SRCS set(kfile_STAT_SRCS
kfile/kabstractfilemodule.cpp
kfile/kacleditwidget.cpp kfile/kacleditwidget.cpp
kfile/kdiskfreespaceinfo.cpp kfile/kdiskfreespaceinfo.cpp
kfile/kencodingfiledialog.cpp kfile/kencodingfiledialog.cpp
@ -114,6 +116,29 @@ set(kfile_STAT_SRCS
kfile/kurlrequester.cpp kfile/kurlrequester.cpp
kfile/kurlrequesterdialog.cpp kfile/kurlrequesterdialog.cpp
kfile/kfilemetadataprovider.cpp kfile/kfilemetadataprovider.cpp
kfile/kdiroperator.cpp
kfile/kdiroperatordetailview.cpp
# used in combination with kio/kio/kdirmodel.cpp
kfile/kdirsortfilterproxymodel.cpp
kfile/kfilebookmarkhandler.cpp
kfile/kfilefiltercombo.cpp
kfile/kfilewidget.cpp
kfile/kfileplacesitem.cpp
kfile/kfileplacesmodel.cpp
kfile/kfileplacesview.cpp
kfile/kfileplaceeditdialog.cpp
kfile/kfilepreviewgenerator.cpp
kfile/knameandurlinputdialog.cpp
kfile/knewfilemenu.cpp
kfile/kurlnavigatordropdownbutton.cpp
kfile/kurlnavigatorbuttonbase.cpp
kfile/kurlnavigatorbutton.cpp
kfile/kurlnavigatorplacesselector.cpp
kfile/kurlnavigatorprotocolcombo.cpp
kfile/kurlnavigatortogglebutton.cpp
kfile/kurlnavigator.cpp
kfile/kurlnavigatormenu.cpp
kfile/kdefaultviewadapter.cpp
) )
########### next target ############### ########### next target ###############
@ -133,6 +158,7 @@ target_link_libraries(kio PUBLIC
kdecore kdecore
kdeui kdeui
kpasswdstore kpasswdstore
solid
) )
if(ACL_FOUND) if(ACL_FOUND)
@ -222,8 +248,6 @@ install(
kio/kurifilter.h kio/kurifilter.h
kio/kurlcompletion.h kio/kurlcompletion.h
kio/khttp.h kio/khttp.h
kfile/kabstractfilemodule.h
kfile/kabstractfilewidget.h
kfile/kdiskfreespaceinfo.h kfile/kdiskfreespaceinfo.h
kfile/kencodingfiledialog.h kfile/kencodingfiledialog.h
kfile/kfile.h kfile/kfile.h
@ -240,6 +264,16 @@ install(
kfile/kurlcombobox.h kfile/kurlcombobox.h
kfile/kurlrequester.h kfile/kurlrequester.h
kfile/kurlrequesterdialog.h kfile/kurlrequesterdialog.h
kfile/kdiroperator.h
kfile/kdirsortfilterproxymodel.h
kfile/kfilefiltercombo.h
kfile/kfileplacesmodel.h
kfile/kfileplacesview.h
kfile/kfilepreviewgenerator.h
kfile/kfilewidget.h
kfile/kurlnavigator.h
kfile/knewfilemenu.h
kfile/knameandurlinputdialog.h
bookmarks/kbookmark.h bookmarks/kbookmark.h
bookmarks/kbookmarkmanager.h bookmarks/kbookmarkmanager.h
bookmarks/kbookmarkmenu.h bookmarks/kbookmarkmenu.h

View file

@ -1,3 +1,3 @@
#! /usr/bin/env bash #! /usr/bin/env bash
$EXTRACTRC `find . ../kioslave ../kfile -name \*.rc -o -name \*.ui` >> rc.cpp || exit 11 $EXTRACTRC `find . ../kioslave -name \*.rc -o -name \*.ui` >> rc.cpp || exit 11
$XGETTEXT `find . ../kioslave ../kfile -name "*.cpp" -o -name "*.cc" -o -name "*.h" | grep -v "/tests"` -o $podir/kio4.pot $XGETTEXT `find . ../kioslave -name "*.cpp" -o -name "*.cc" -o -name "*.h" | grep -v "/tests"` -o $podir/kio4.pot

View file

@ -19,8 +19,6 @@
#ifndef CONFIG_KFILE_H #ifndef CONFIG_KFILE_H
#define CONFIG_KFILE_H #define CONFIG_KFILE_H
const int kfile_area = 250;
#define DefaultMixDirsAndFiles false #define DefaultMixDirsAndFiles false
#define DefaultShowHidden false #define DefaultShowHidden false
#define DefaultDirsFirst true #define DefaultDirsFirst true

View file

@ -1,28 +0,0 @@
/* This file is part of the KDE libraries
Copyright 2007 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kabstractfilemodule.h"
KAbstractFileModule::KAbstractFileModule(QObject* parent)
: QObject(parent)
{
}
#include "moc_kabstractfilemodule.cpp"

View file

@ -1,51 +0,0 @@
/* This file is part of the KDE libraries
Copyright 2007 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KABSTRACTFILEMODULE_H
#define KABSTRACTFILEMODULE_H
#include <kio/kio_export.h>
#include <QtCore/QObject>
#include <kurl.h>
#include <QWidget>
/**
* Interface to the module that contains the file widget.
*
* libkfilemodule returns an object that derives from KAbstractFileModule.
*
* This is internal to KFileDialog.
*/
class KIO_EXPORT KAbstractFileModule : public QObject
{
Q_OBJECT
public:
KAbstractFileModule(QObject* parent);
/// the returned widget implements the KAbstractFileWidget interface
virtual QWidget* createFileWidget(const KUrl& startDir, QWidget *parent) = 0;
virtual KUrl getStartUrl( const KUrl& startDir, QString& recentDirClass ) = 0;
virtual void setStartDir( const KUrl& directory ) = 0;
// TODO QFileDialog-like methods
};
#endif /* KABSTRACTFILEMODULE_H */

View file

@ -1,394 +0,0 @@
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1997, 1998 Richard Moore <rich@kde.org>
1998 Stephan Kulow <coolo@kde.org>
1998 Daniel Grana <grana@ie.iwi.unibe.ch>
2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
2001 Frerich Raabe <raabe@kde.org>
2007 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KABSTRACTFILEWIDGET_H
#define KABSTRACTFILEWIDGET_H
class KPreviewWidgetBase;
#include "kurl.h"
#include "kfile.h"
#include <kmimetype.h>
class KPushButton;
class KActionCollection;
class KToolBar;
class KFileWidgetPrivate;
class KUrlComboBox;
class KFileFilterCombo;
/**
* Base class for KFileWidget.
*
* This abstract interface allows KFileDialog (in kio) to call methods
* on the dlopened KFileWidget (from kfilemodule.so)
*
* In addition to the pure virtual methods defined below, the implementations
* of KAbstractFileWidget are expected to define the following signals:
* <ul>
* <li>fileSelected(const KUrl&)</li>
* <li>fileHighlighted(const KUrl&)</li>
* <li>selectionChanged()</li>
* <li>filterChanged(const QString&)</li>
* <li>accepted()</li>
* </ul>
*/
class KIO_EXPORT KAbstractFileWidget
{
public:
virtual ~KAbstractFileWidget() {}
/**
* Defines some default behavior of the filedialog.
* E.g. in mode @p Opening and @p Saving, the selected files/urls will
* be added to the "recent documents" list. The Saving mode also implies
* setKeepLocation() being set.
*
* @p Other means that no default actions are performed.
*
* @see setOperationMode
* @see operationMode
*/
enum OperationMode { Other = 0, Opening, Saving };
/**
* @returns The selected fully qualified filename.
*/
virtual KUrl selectedUrl() const = 0;
/**
* @returns The list of selected URLs.
*/
virtual KUrl::List selectedUrls() const = 0;
/**
* @returns the currently shown directory.
*/
virtual KUrl baseUrl() const = 0;
/**
* Returns the full path of the selected file in the local filesystem.
* (Local files only)
*/
virtual QString selectedFile() const = 0;
/**
* Returns a list of all selected local files.
*/
virtual QStringList selectedFiles() const = 0;
/**
* Sets the directory to view.
*
* @param url URL to show.
* @param clearforward Indicates whether the forward queue
* should be cleared.
*/
virtual void setUrl(const KUrl &url, bool clearforward = true) = 0;
/**
* Sets the file name to preselect to @p name
*
* This takes absolute URLs and relative file names.
*/
virtual void setSelection(const QString& name) = 0;
/**
* Sets the operational mode of the filedialog to @p Saving, @p Opening
* or @p Other. This will set some flags that are specific to loading
* or saving files. E.g. setKeepLocation() makes mostly sense for
* a save-as dialog. So setOperationMode( KFileDialog::Saving ); sets
* setKeepLocation for example.
*
* The mode @p Saving, together with a default filter set via
* setMimeFilter() will make the filter combobox read-only.
*
* The default mode is @p Opening.
*
* Call this method right after instantiating KFileDialog.
*
* @see operationMode
* @see KFileDialog::OperationMode
*/
virtual void setOperationMode( OperationMode ) = 0;
/**
* @returns the current operation mode, Opening, Saving or Other. Default
* is Other.
*
* @see operationMode
* @see KFileDialog::OperationMode
*/
virtual OperationMode operationMode() const = 0;
/**
* Sets whether the filename/url should be kept when changing directories.
* This is for example useful when having a predefined filename where
* the full path for that file is searched.
*
* This is implicitly set when operationMode() is KFileDialog::Saving
*
* getSaveFileName() and getSaveUrl() set this to true by default, so that
* you can type in the filename and change the directory without having
* to type the name again.
*/
virtual void setKeepLocation( bool keep ) = 0;
/**
* @returns whether the contents of the location edit are kept when
* changing directories.
*/
virtual bool keepsLocation() const = 0;
/**
* Sets the filter to be used to @p filter.
*
* You can set more
* filters for the user to select separated by '\n'. Every
* filter entry is defined through namefilter|text to display.
* If no | is found in the expression, just the namefilter is
* shown. Examples:
*
* \code
* kfile->setFilter("*.cpp|C++ Source Files\n*.h|Header files");
* kfile->setFilter("*.cpp");
* kfile->setFilter("*.cpp|Sources (*.cpp)");
* kfile->setFilter("*.cpp|" + i18n("Sources (*.cpp)"));
* kfile->setFilter("*.cpp *.cc *.C|C++ Source Files\n*.h *.H|Header files");
* \endcode
*
* Note: The text to display is not parsed in any way. So, if you
* want to show the suffix to select by a specific filter, you must
* repeat it.
*
* If the filter contains an unescaped '/', a mimetype-filter is assumed.
* If you would like a '/' visible in your filter it can be escaped with
* a '\'. You can specify multiple mimetypes like this (separated with
* space):
*
* \code
* kfile->setFilter( "image/png text/html text/plain" );
* kfile->setFilter( "*.cue|CUE\\/BIN Files (*.cue)" );
* \endcode
*
* @see filterChanged
* @see setMimeFilter
*/
virtual void setFilter(const QString& filter) = 0;
/**
* Returns the current filter as entered by the user or one of the
* predefined set via setFilter().
*
* @see setFilter()
* @see filterChanged()
*/
virtual QString currentFilter() const = 0;
/**
* Returns the mimetype for the desired output format.
*
* This is only valid if setFilterMimeType() has been called
* previously.
*
* @see setFilterMimeType()
*/
virtual KMimeType::Ptr currentFilterMimeType() = 0;
/**
* Sets the filter up to specify the output type.
*
* @param types a list of mimetypes that can be used as output format
* @param defaultType the default mimetype to use as output format, if any.
* If @p defaultType is set, it will be set as the current item.
* Otherwise, a first item showing all the mimetypes will be created.
* Typically, @p defaultType should be empty for loading and set for saving.
*
* Do not use in conjunction with setFilter()
*/
virtual void setMimeFilter( const QStringList& types,
const QString& defaultType = QString() ) = 0;
/**
* The mimetype for the desired output format.
*
* This is only valid if setMimeFilter() has been called
* previously.
*
* @see setMimeFilter()
*/
virtual QString currentMimeFilter() const = 0;
/**
* Clears any mime- or namefilter. Does not reload the directory.
*/
virtual void clearFilter() = 0;
/**
* Adds a preview widget and enters the preview mode.
*
* In this mode the dialog is split and the right part contains your
* preview widget.
*
* Ownership is transferred to KFileDialog. You need to create the
* preview-widget with "new", i.e. on the heap.
*
* @param w The widget to be used for the preview.
*/
virtual void setPreviewWidget(KPreviewWidgetBase *w) = 0;
/**
* Sets the mode of the dialog.
*
* The mode is defined as (in kfile.h):
* \code
* enum Mode {
* File = 1,
* Directory = 2,
* Files = 4,
* ExistingOnly = 8,
* LocalOnly = 16
* };
* \endcode
* You can OR the values, e.g.
* \code
* KFile::Modes mode = KFile::Files |
* KFile::ExistingOnly |
* KFile::LocalOnly );
* setMode( mode );
* \endcode
*/
virtual void setMode( KFile::Modes m ) = 0;
/**
* Returns the mode of the filedialog.
* @see setMode()
*/
virtual KFile::Modes mode() const = 0;
/**
* Sets the text to be displayed in front of the selection.
*
* The default is "Location".
* Most useful if you want to make clear what
* the location is used for.
*/
virtual void setLocationLabel(const QString& text) = 0;
/**
* Returns a pointer to the toolbar.
*
* You can use this to insert custom
* items into it, e.g.:
* \code
* yourAction = new KAction( i18n("Your Action"), 0,
* this, SLOT( yourSlot() ),
* this, "action name" );
* yourAction->plug( kfileDialog->toolBar() );
* \endcode
*/
virtual KToolBar *toolBar() const = 0;
/**
* @returns a pointer to the OK-Button in the filedialog.
* Note that the button is hidden and unconnected when using KFileWidget alone;
* KFileDialog shows it and connects to it.
*/
virtual KPushButton *okButton() const = 0;
/**
* @returns a pointer to the Cancel-Button in the filedialog.
* Note that the button is hidden and unconnected when using KFileWidget alone;
* KFileDialog shows it and connects to it.
*/
virtual KPushButton *cancelButton() const = 0;
/**
* @returns the combobox used to type the filename or full location of the file.
*/
virtual KUrlComboBox *locationEdit() const = 0;
/**
* @returns the combobox that contains the filters
*/
virtual KFileFilterCombo *filterWidget() const = 0;
/**
* @returns a pointer to the action collection, holding all the used
* KActions.
*/
virtual KActionCollection *actionCollection() const = 0;
/**
* Set a custom widget that should be added to the bottom of the file dialog.
* @param widget A widget, or a widget of widgets, for displaying custom
* data in the file widget. This can be used, for example, to
* display a check box with the caption "Open as read-only".
* When creating this widget, you don't need to specify a parent,
* since the widget's parent will be set automatically by KFileWidget.
*/
virtual void setCustomWidget(QWidget* widget) = 0;
/**
* Sets a custom widget that should be added below the location and the filter
* editors.
* @param text Label of the custom widget, which is displayed below the labels
* "Location:" and "Filter:".
* @param widget Any kind of widget, but preferable a combo box or a line editor
* to be compliant with the location and filter layout.
* When creating this widget, you don't need to specify a parent,
* since the widget's parent will be set automatically by KFileWidget.
*/
virtual void setCustomWidget(const QString& text, QWidget* widget) = 0;
/**
* Called when clicking ok (when this widget is used in KFileDialog)
* Might or might not call accept().
*/
virtual void slotOk() = 0;
virtual void accept() = 0;
virtual void slotCancel() = 0;
/**
* Sets whether the user should be asked for confirmation
* when an overwrite might occurr.
*
* @param enable Set this to true to enable checking.
* @since 4.2
*/
virtual void setConfirmOverwrite(bool enable) { Q_UNUSED(enable); };
/**
* Forces the inline previews to be shown or hidden, depending on @p show.
*
* @param show Whether to show inline previews or not.
* @since 4.2
*/
virtual void setInlinePreviewShown(bool show) { Q_UNUSED(show); };
};
Q_DECLARE_INTERFACE(KAbstractFileWidget, "org.kde.KAbstractFileWidget")
#endif /* KABSTRACTFILEWIDGET_H */

View file

@ -1046,7 +1046,7 @@ Qt::SortOrder KDirOperator::Private::sortOrder() const
void KDirOperator::Private::updateSorting(QDir::SortFlags sort) void KDirOperator::Private::updateSorting(QDir::SortFlags sort)
{ {
kDebug(kfile_area) << "changing sort flags from" << sorting << "to" << sort; kDebug() << "changing sort flags from" << sorting << "to" << sort;
if (sort == sorting) { if (sort == sorting) {
return; return;
} }
@ -1556,7 +1556,7 @@ void KDirOperator::setDirLister(KDirLister *lister)
QWidget* mainWidget = window(); QWidget* mainWidget = window();
d->dirLister->setMainWindow(mainWidget); d->dirLister->setMainWindow(mainWidget);
kDebug(kfile_area) << "mainWidget=" << mainWidget; kDebug() << "mainWidget=" << mainWidget;
connect(d->dirLister, SIGNAL(percent(ulong)), connect(d->dirLister, SIGNAL(percent(ulong)),
SLOT(_k_slotProgress(ulong))); SLOT(_k_slotProgress(ulong)));
@ -1593,8 +1593,6 @@ void KDirOperator::highlightFile(const KFileItem &item)
void KDirOperator::setCurrentItem(const QString& url) void KDirOperator::setCurrentItem(const QString& url)
{ {
kDebug(kfile_area);
KFileItem item = d->dirLister->findByUrl(url); KFileItem item = d->dirLister->findByUrl(url);
if (d->shouldFetchForItems && item.isNull()) { if (d->shouldFetchForItems && item.isNull()) {
d->itemsToBeSetAsCurrent << url; d->itemsToBeSetAsCurrent << url;
@ -1607,8 +1605,6 @@ void KDirOperator::setCurrentItem(const QString& url)
void KDirOperator::setCurrentItem(const KFileItem& item) void KDirOperator::setCurrentItem(const KFileItem& item)
{ {
kDebug(kfile_area);
if (!d->itemView) { if (!d->itemView) {
return; return;
} }
@ -1626,8 +1622,6 @@ void KDirOperator::setCurrentItem(const KFileItem& item)
void KDirOperator::setCurrentItems(const QStringList& urls) void KDirOperator::setCurrentItems(const QStringList& urls)
{ {
kDebug(kfile_area);
if (!d->itemView) { if (!d->itemView) {
return; return;
} }
@ -1648,8 +1642,6 @@ void KDirOperator::setCurrentItems(const QStringList& urls)
void KDirOperator::setCurrentItems(const KFileItemList& items) void KDirOperator::setCurrentItems(const KFileItemList& items)
{ {
kDebug(kfile_area);
if (d->itemView == 0) { if (d->itemView == 0) {
return; return;
} }

View file

@ -29,7 +29,7 @@
#include <kdirlister.h> #include <kdirlister.h>
#include <kfileitem.h> #include <kfileitem.h>
#include <kfile.h> #include <kfile.h>
#include <kfile_export.h> #include <kio/kio_export.h>
#include <QAbstractItemView> #include <QAbstractItemView>
#include <QModelIndex> #include <QModelIndex>
@ -95,7 +95,7 @@ class DeleteJob;
* @short A widget for displaying files and browsing directories. * @short A widget for displaying files and browsing directories.
* @author Stephan Kulow <coolo@kde.org>, Carsten Pfeiffer <pfeiffer@kde.org> * @author Stephan Kulow <coolo@kde.org>, Carsten Pfeiffer <pfeiffer@kde.org>
*/ */
class KFILE_EXPORT KDirOperator : public QWidget class KIO_EXPORT KDirOperator : public QWidget
{ {
Q_OBJECT Q_OBJECT

View file

@ -27,7 +27,7 @@
#include <kcategorizedsortfilterproxymodel.h> #include <kcategorizedsortfilterproxymodel.h>
#include <kfile_export.h> #include <kio/kio_export.h>
/** /**
* @brief Acts as proxy model for KDirModel to sort and filter * @brief Acts as proxy model for KDirModel to sort and filter
@ -47,7 +47,7 @@
* *
* @author Dominic Battre, Martin Pool and Peter Penz * @author Dominic Battre, Martin Pool and Peter Penz
*/ */
class KFILE_EXPORT KDirSortFilterProxyModel class KIO_EXPORT KDirSortFilterProxyModel
: public KCategorizedSortFilterProxyModel : public KCategorizedSortFilterProxyModel
{ {
Q_OBJECT Q_OBJECT

View file

@ -23,7 +23,7 @@
#include <config-kfile.h> #include <config-kfile.h>
#include <kabstractfilewidget.h> #include <kfilewidget.h>
#include <kcombobox.h> #include <kcombobox.h>
#include <kglobal.h> #include <kglobal.h>
#include <klocale.h> #include <klocale.h>

View file

@ -40,37 +40,9 @@
#include <krecentdocument.h> #include <krecentdocument.h>
#include <kdebug.h> #include <kdebug.h>
#include <kwindowsystem.h> #include <kwindowsystem.h>
#include "kabstractfilewidget.h"
#include "kabstractfilemodule.h"
#include "krecentdirs.h" #include "krecentdirs.h"
#include "kservice.h" #include "kservice.h"
#include "kfilewidget.h"
static KAbstractFileModule* s_module = 0;
static const char s_defaultFileModuleName[] = "kfilemodule";
static KAbstractFileModule* loadFileModule( const QString& moduleName )
{
KService::Ptr fileModuleService = KService::serviceByDesktopName(moduleName);
if (fileModuleService) {
return fileModuleService->createInstance<KAbstractFileModule>();
}
return nullptr;
}
static KAbstractFileModule* fileModule()
{
if (!s_module) {
QString moduleName = KConfig("kdeglobals").group(ConfigGroup).readEntry("file module", s_defaultFileModuleName);
if (!(s_module = loadFileModule(moduleName))) {
kDebug() << "Failed to load configured file module" << moduleName;
if (moduleName != s_defaultFileModuleName) {
kDebug() << "Falling back to default file module.";
s_module = loadFileModule(s_defaultFileModuleName);
}
}
}
return s_module;
}
class KFileDialogPrivate class KFileDialogPrivate
{ {
@ -81,7 +53,7 @@ public:
{ {
} }
KAbstractFileWidget* w; KFileWidget* w;
KConfigGroup cfgGroup; KConfigGroup cfgGroup;
}; };
@ -91,15 +63,14 @@ KFileDialog::KFileDialog(const KUrl &startDir, const QString &filter,
d(new KFileDialogPrivate()) d(new KFileDialogPrivate())
{ {
QWidget* fileQWidget = fileModule()->createFileWidget(startDir, this); d->w = new KFileWidget(startDir, this);
d->w = ::qobject_cast<KAbstractFileWidget *>(fileQWidget);
setButtons( KDialog::None ); setButtons( KDialog::None );
restoreDialogSize(d->cfgGroup); // call this before the fileQWidget is set as the main widget. restoreDialogSize(d->cfgGroup); // call this before the d->w is set as the main widget.
// otherwise the sizes for the components are not obeyed (ereslibre) // otherwise the sizes for the components are not obeyed (ereslibre)
d->w->setFilter(filter); d->w->setFilter(filter);
setMainWidget(fileQWidget); setMainWidget(d->w);
d->w->okButton()->show(); d->w->okButton()->show();
connect(d->w->okButton(), SIGNAL(clicked()), SLOT(slotOk())); connect(d->w->okButton(), SIGNAL(clicked()), SLOT(slotOk()));
@ -107,23 +78,21 @@ KFileDialog::KFileDialog(const KUrl &startDir, const QString &filter,
connect(d->w->cancelButton(), SIGNAL(clicked()), SLOT(slotCancel())); connect(d->w->cancelButton(), SIGNAL(clicked()), SLOT(slotCancel()));
// Publish signals // Publish signals
// TODO: Move the relevant signal declarations from KFileWidget to the
// KAbstractFileWidget interface?
// Else, all of these connects (including "accepted") are not typesafe. // Else, all of these connects (including "accepted") are not typesafe.
// Answer: you cannot define signals in a non-qobject base class (DF). // Answer: you cannot define signals in a non-qobject base class (DF).
// I simply documentde them in kabstractfilewidget.h now. // I simply documentde them in kfilewidget.h now.
kDebug (kfile_area) << "KFileDialog connecting signals"; kDebug () << "KFileDialog connecting signals";
connect(fileQWidget, SIGNAL(fileSelected(KUrl)), connect(d->w, SIGNAL(fileSelected(KUrl)),
SIGNAL(fileSelected(KUrl))); SIGNAL(fileSelected(KUrl)));
connect(fileQWidget, SIGNAL(fileHighlighted(KUrl)), connect(d->w, SIGNAL(fileHighlighted(KUrl)),
SIGNAL(fileHighlighted(KUrl))); SIGNAL(fileHighlighted(KUrl)));
connect(fileQWidget, SIGNAL(selectionChanged()), connect(d->w, SIGNAL(selectionChanged()),
SIGNAL(selectionChanged())); SIGNAL(selectionChanged()));
connect(fileQWidget, SIGNAL(filterChanged(QString)), connect(d->w, SIGNAL(filterChanged(QString)),
SIGNAL(filterChanged(QString))); SIGNAL(filterChanged(QString)));
connect(fileQWidget, SIGNAL(accepted()), SLOT(accept())); connect(d->w, SIGNAL(accepted()), SLOT(accept()));
//connect(fileQWidget, SIGNAL(canceled()), SLOT(slotCancel())); //connect(d->w, SIGNAL(canceled()), SLOT(slotCancel()));
if (customWidget) { if (customWidget) {
d->w->setCustomWidget(QString(), customWidget); d->w->setCustomWidget(QString(), customWidget);
@ -493,7 +462,7 @@ bool KFileDialog::keepsLocation() const
void KFileDialog::setOperationMode(OperationMode mode) void KFileDialog::setOperationMode(OperationMode mode)
{ {
d->w->setOperationMode(static_cast<KAbstractFileWidget::OperationMode>(mode)); d->w->setOperationMode(static_cast<KFileWidget::OperationMode>(mode));
} }
KFileDialog::OperationMode KFileDialog::operationMode() const KFileDialog::OperationMode KFileDialog::operationMode() const
@ -521,12 +490,12 @@ void KFileDialog::hideEvent(QHideEvent* e)
// static // static
KUrl KFileDialog::getStartUrl(const KUrl &startDir, QString &recentDirClass) KUrl KFileDialog::getStartUrl(const KUrl &startDir, QString &recentDirClass)
{ {
return fileModule()->getStartUrl(startDir, recentDirClass); return KFileWidget::getStartUrl(startDir, recentDirClass);
} }
void KFileDialog::setStartDir(const KUrl& directory) void KFileDialog::setStartDir(const KUrl& directory)
{ {
fileModule()->setStartDir(directory); KFileWidget::setStartDir(directory);
} }
KToolBar* KFileDialog::toolBar() const KToolBar* KFileDialog::toolBar() const
@ -534,7 +503,7 @@ KToolBar* KFileDialog::toolBar() const
return d->w->toolBar(); return d->w->toolBar();
} }
KAbstractFileWidget* KFileDialog::fileWidget() KFileWidget* KFileDialog::fileWidget()
{ {
return d->w; return d->w;
} }

View file

@ -32,16 +32,13 @@
#include <kurl.h> #include <kurl.h>
#include <kmimetype.h> #include <kmimetype.h>
class KAbstractFileWidget;
class KFileWidget; class KFileWidget;
class KActionCollection; class KActionCollection;
class KUrlComboBox; class KUrlComboBox;
class KFileFilterCombo; class KFileFilterCombo;
class KPushButton; class KPushButton;
class KToolBar; class KToolBar;
class KPreviewWidgetBase; class KPreviewWidgetBase;
class KFileDialogPrivate; class KFileDialogPrivate;
/** /**
@ -618,7 +615,7 @@ public:
* Returns the KFileWidget that implements most of this file dialog. * Returns the KFileWidget that implements most of this file dialog.
* If you link to libkfile you can cast this to a KFileWidget*. * If you link to libkfile you can cast this to a KFileWidget*.
*/ */
KAbstractFileWidget* fileWidget(); KFileWidget* fileWidget();
/** /**
* Returns a pointer to the toolbar. * Returns a pointer to the toolbar.

View file

@ -147,11 +147,11 @@ void KFileFilterCombo::setMimeFilter( const QStringList& types,
QString allComments, allTypes; QString allComments, allTypes;
for(QStringList::ConstIterator it = types.begin(); it != types.end(); ++it) for(QStringList::ConstIterator it = types.begin(); it != types.end(); ++it)
{ {
kDebug(kfile_area) << *it; kDebug() << *it;
KMimeType::Ptr type = KMimeType::mimeType( *it ); KMimeType::Ptr type = KMimeType::mimeType( *it );
if (!type) { if (!type) {
kDebug(kfile_area) << "Could not create mimetype!\n"; kDebug() << "Could not create mimetype!\n";
continue; continue;
} }

View file

@ -20,10 +20,10 @@
#ifndef KFILEFILTERCOMBO_H #ifndef KFILEFILTERCOMBO_H
#define KFILEFILTERCOMBO_H #define KFILEFILTERCOMBO_H
#include <kfile_export.h> #include <kio/kio_export.h>
#include <kcombobox.h> #include <kcombobox.h>
class KFILE_EXPORT KFileFilterCombo : public KComboBox class KIO_EXPORT KFileFilterCombo : public KComboBox
{ {
Q_OBJECT Q_OBJECT

View file

@ -21,7 +21,7 @@
#define KFILEPLACEEDITDIALOG_H #define KFILEPLACEEDITDIALOG_H
// Not exported anymore, only used internally. // Not exported anymore, only used internally.
//#include <kfile_export.h> //#include <kio/kio_export.h>
#include <kdialog.h> #include <kdialog.h>
#include <kurl.h> #include <kurl.h>

View file

@ -20,7 +20,7 @@
#ifndef KFILEPLACESMODEL_H #ifndef KFILEPLACESMODEL_H
#define KFILEPLACESMODEL_H #define KFILEPLACESMODEL_H
#include <kfile_export.h> #include <kio/kio_export.h>
#include <QtCore/QAbstractItemModel> #include <QtCore/QAbstractItemModel>
#include <kurl.h> #include <kurl.h>
@ -37,7 +37,7 @@
* where user can access files. Only revelant when * where user can access files. Only revelant when
* used with QListView or QTableView. * used with QListView or QTableView.
*/ */
class KFILE_EXPORT KFilePlacesModel : public QAbstractItemModel class KIO_EXPORT KFilePlacesModel : public QAbstractItemModel
{ {
Q_OBJECT Q_OBJECT
public: public:

View file

@ -19,7 +19,7 @@
#ifndef KFILEPLACESVIEW_H #ifndef KFILEPLACESVIEW_H
#define KFILEPLACESVIEW_H #define KFILEPLACESVIEW_H
#include <kfile_export.h> #include <kio/kio_export.h>
#include <QtGui/QListView> #include <QtGui/QListView>
@ -31,7 +31,7 @@
/** /**
* This class allows to display a KFilePlacesModel. * This class allows to display a KFilePlacesModel.
*/ */
class KFILE_EXPORT KFilePlacesView : public QListView class KIO_EXPORT KFilePlacesView : public QListView
{ {
Q_OBJECT Q_OBJECT
public: public:

View file

@ -20,7 +20,7 @@
#ifndef KFILEPREVIEWGENERATOR_H #ifndef KFILEPREVIEWGENERATOR_H
#define KFILEPREVIEWGENERATOR_H #define KFILEPREVIEWGENERATOR_H
#include <kfile_export.h> #include <kio/kio_export.h>
#include <QObject> #include <QObject>
#include <QAbstractItemView> #include <QAbstractItemView>
@ -47,7 +47,7 @@ class KDirModel;
* *
* @since 4.2 * @since 4.2
*/ */
class KFILE_EXPORT KFilePreviewGenerator : public QObject class KIO_EXPORT KFilePreviewGenerator : public QObject
{ {
Q_OBJECT Q_OBJECT

View file

@ -291,10 +291,10 @@ static const char autocompletionWhatsThisText[] = I18N_NOOP("<qt>While typing in
"and selecting a preferred mode from the <b>Text Completion</b> menu.</qt>"); "and selecting a preferred mode from the <b>Text Completion</b> menu.</qt>");
KFileWidget::KFileWidget( const KUrl& _startDir, QWidget *parent ) KFileWidget::KFileWidget( const KUrl& _startDir, QWidget *parent )
: QWidget(parent), KAbstractFileWidget(), d(new KFileWidgetPrivate(this)) : QWidget(parent), d(new KFileWidgetPrivate(this))
{ {
KUrl startDir(_startDir); KUrl startDir(_startDir);
kDebug(kfile_area) << "startDir" << startDir; kDebug() << "startDir" << startDir;
QString filename; QString filename;
d->okButton = new KPushButton(KStandardGuiItem::ok(), this); d->okButton = new KPushButton(KStandardGuiItem::ok(), this);
@ -577,11 +577,11 @@ KFileWidget::KFileWidget( const KUrl& _startDir, QWidget *parent )
{ {
KIO::StatJob *statJob = KIO::stat(startDir, KIO::HideProgressInfo); KIO::StatJob *statJob = KIO::stat(startDir, KIO::HideProgressInfo);
statRes = KIO::NetAccess::synchronousRun(statJob, this); statRes = KIO::NetAccess::synchronousRun(statJob, this);
kDebug(kfile_area) << "stat of" << startDir << "-> statRes" << statRes << "isDir" << statJob->statResult().isDir(); kDebug() << "stat of" << startDir << "-> statRes" << statRes << "isDir" << statJob->statResult().isDir();
if (!statRes || !statJob->statResult().isDir()) { if (!statRes || !statJob->statResult().isDir()) {
filename = startDir.fileName(); filename = startDir.fileName();
startDir.setPath(startDir.directory()); startDir.setPath(startDir.directory());
kDebug(kfile_area) << "statJob -> startDir" << startDir << "filename" << filename; kDebug() << "statJob -> startDir" << startDir << "filename" << filename;
} }
} }
@ -595,7 +595,7 @@ KFileWidget::KFileWidget( const KUrl& _startDir, QWidget *parent )
// we could stat it and it is not a directory. Set it. // we could stat it and it is not a directory. Set it.
if (!filename.isEmpty()) { if (!filename.isEmpty()) {
QLineEdit* lineEdit = d->locationEdit->lineEdit(); QLineEdit* lineEdit = d->locationEdit->lineEdit();
kDebug(kfile_area) << "selecting filename" << filename; kDebug() << "selecting filename" << filename;
if (statRes) { if (statRes) {
d->setLocationText(filename); d->setLocationText(filename);
} else { } else {
@ -705,7 +705,7 @@ void KFileWidget::setPreviewWidget(KPreviewWidgetBase *w) {
KUrl KFileWidgetPrivate::getCompleteUrl(const QString &_url) const KUrl KFileWidgetPrivate::getCompleteUrl(const QString &_url) const
{ {
// kDebug(kfile_area) << "got url " << _url; // kDebug() << "got url " << _url;
const QString url = KShell::tildeExpand(_url); const QString url = KShell::tildeExpand(_url);
KUrl u; KUrl u;
@ -729,7 +729,7 @@ KUrl KFileWidgetPrivate::getCompleteUrl(const QString &_url) const
// Called by KFileDialog // Called by KFileDialog
void KFileWidget::slotOk() void KFileWidget::slotOk()
{ {
// kDebug(kfile_area) << "slotOk\n"; // kDebug() << "slotOk";
const KFileItemList items = d->ops->selectedItems(); const KFileItemList items = d->ops->selectedItems();
const QString locationEditCurrentText(KShell::tildeExpand(d->locationEditCurrentText())); const QString locationEditCurrentText(KShell::tildeExpand(d->locationEditCurrentText()));
@ -745,7 +745,7 @@ void KFileWidget::slotOk()
// Make sure that one of the modes was provided // Make sure that one of the modes was provided
if (!((mode & KFile::File) || (mode & KFile::Directory) || (mode & KFile::Files))) { if (!((mode & KFile::File) || (mode & KFile::Directory) || (mode & KFile::Files))) {
mode |= KFile::File; mode |= KFile::File;
kDebug(kfile_area) << "No mode() provided"; kDebug() << "No mode() provided";
} }
// if we are on file mode, and the list of provided files/folder is greater than one, inform // if we are on file mode, and the list of provided files/folder is greater than one, inform
@ -1357,8 +1357,6 @@ void KFileWidgetPrivate::initGUI()
void KFileWidgetPrivate::_k_slotFilterChanged() void KFileWidgetPrivate::_k_slotFilterChanged()
{ {
// kDebug(kfile_area);
filterDelayTimer.stop(); filterDelayTimer.stop();
QString filter = filterWidget->currentFilter(); QString filter = filterWidget->currentFilter();
@ -1386,16 +1384,12 @@ void KFileWidgetPrivate::_k_slotFilterChanged()
void KFileWidget::setUrl(const KUrl& url, bool clearforward) void KFileWidget::setUrl(const KUrl& url, bool clearforward)
{ {
// kDebug(kfile_area);
d->ops->setUrl(url, clearforward); d->ops->setUrl(url, clearforward);
} }
// Protected // Protected
void KFileWidgetPrivate::_k_urlEntered(const KUrl& url) void KFileWidgetPrivate::_k_urlEntered(const KUrl& url)
{ {
// kDebug(kfile_area);
QString filename = locationEditCurrentText(); QString filename = locationEditCurrentText();
KUrlComboBox* pathCombo = urlNavigator->editor(); KUrlComboBox* pathCombo = urlNavigator->editor();
@ -1427,14 +1421,11 @@ void KFileWidgetPrivate::_k_urlEntered(const KUrl& url)
void KFileWidgetPrivate::_k_locationAccepted(const QString &url) void KFileWidgetPrivate::_k_locationAccepted(const QString &url)
{ {
Q_UNUSED(url); Q_UNUSED(url);
// kDebug(kfile_area);
q->slotOk(); q->slotOk();
} }
void KFileWidgetPrivate::_k_enterUrl( const KUrl& url ) void KFileWidgetPrivate::_k_enterUrl( const KUrl& url )
{ {
// kDebug(kfile_area);
KUrl fixedUrl( url ); KUrl fixedUrl( url );
// append '/' if needed: url combo does not add it // append '/' if needed: url combo does not add it
// tokenize() expects it because uses KUrl::setFileName() // tokenize() expects it because uses KUrl::setFileName()
@ -1446,15 +1437,11 @@ void KFileWidgetPrivate::_k_enterUrl( const KUrl& url )
void KFileWidgetPrivate::_k_enterUrl( const QString& url ) void KFileWidgetPrivate::_k_enterUrl( const QString& url )
{ {
// kDebug(kfile_area);
_k_enterUrl( KUrl( KUrlCompletion::replacedPath( url, true, true )) ); _k_enterUrl( KUrl( KUrlCompletion::replacedPath( url, true, true )) );
} }
bool KFileWidgetPrivate::toOverwrite(const KUrl &url) bool KFileWidgetPrivate::toOverwrite(const KUrl &url)
{ {
// kDebug(kfile_area);
KIO::StatJob *statJob = KIO::stat(url, KIO::HideProgressInfo); KIO::StatJob *statJob = KIO::stat(url, KIO::HideProgressInfo);
bool res = KIO::NetAccess::synchronousRun(statJob, q); bool res = KIO::NetAccess::synchronousRun(statJob, q);
@ -1475,7 +1462,7 @@ bool KFileWidgetPrivate::toOverwrite(const KUrl &url)
void KFileWidget::setSelection(const QString& url) void KFileWidget::setSelection(const QString& url)
{ {
// kDebug(kfile_area) << "setSelection " << url; // kDebug() << "setSelection " << url;
if (url.isEmpty()) { if (url.isEmpty()) {
return; return;
@ -1510,8 +1497,6 @@ void KFileWidgetPrivate::_k_slotLoadingFinished()
void KFileWidgetPrivate::_k_fileCompletion( const QString& match ) void KFileWidgetPrivate::_k_fileCompletion( const QString& match )
{ {
// kDebug(kfile_area);
if (match.isEmpty() || locationEdit->currentText().contains('"')) { if (match.isEmpty() || locationEdit->currentText().contains('"')) {
return; return;
} }
@ -1521,8 +1506,6 @@ void KFileWidgetPrivate::_k_fileCompletion( const QString& match )
void KFileWidgetPrivate::_k_slotLocationChanged( const QString& text ) void KFileWidgetPrivate::_k_slotLocationChanged( const QString& text )
{ {
// kDebug(kfile_area);
locationEdit->lineEdit()->setModified(true); locationEdit->lineEdit()->setModified(true);
if (text.isEmpty() && ops->view()) { if (text.isEmpty() && ops->view()) {
@ -1549,8 +1532,6 @@ void KFileWidgetPrivate::_k_slotLocationChanged( const QString& text )
KUrl KFileWidget::selectedUrl() const KUrl KFileWidget::selectedUrl() const
{ {
// kDebug(kfile_area);
if ( d->inAccept ) if ( d->inAccept )
return d->url; return d->url;
else else
@ -1559,8 +1540,6 @@ KUrl KFileWidget::selectedUrl() const
KUrl::List KFileWidget::selectedUrls() const KUrl::List KFileWidget::selectedUrls() const
{ {
// kDebug(kfile_area);
KUrl::List list; KUrl::List list;
if ( d->inAccept ) { if ( d->inAccept ) {
if (d->ops->mode() & KFile::Files) if (d->ops->mode() & KFile::Files)
@ -1574,8 +1553,6 @@ KUrl::List KFileWidget::selectedUrls() const
KUrl::List& KFileWidgetPrivate::parseSelectedUrls() KUrl::List& KFileWidgetPrivate::parseSelectedUrls()
{ {
// kDebug(kfile_area);
if ( filenames.isEmpty() ) { if ( filenames.isEmpty() ) {
return urlList; return urlList;
} }
@ -1609,8 +1586,6 @@ KUrl::List& KFileWidgetPrivate::parseSelectedUrls()
// FIXME: current implementation drawback: a filename can't contain quotes // FIXME: current implementation drawback: a filename can't contain quotes
KUrl::List KFileWidgetPrivate::tokenize( const QString& line ) const KUrl::List KFileWidgetPrivate::tokenize( const QString& line ) const
{ {
// kDebug(kfile_area);
KUrl::List urls; KUrl::List urls;
KUrl u( ops->url() ); KUrl u( ops->url() );
u.adjustPath(KUrl::AddTrailingSlash); u.adjustPath(KUrl::AddTrailingSlash);
@ -1666,8 +1641,6 @@ KUrl::List KFileWidgetPrivate::tokenize( const QString& line ) const
QString KFileWidget::selectedFile() const QString KFileWidget::selectedFile() const
{ {
// kDebug(kfile_area);
if ( d->inAccept ) { if ( d->inAccept ) {
const KUrl url = d->mostLocalUrl(d->url); const KUrl url = d->mostLocalUrl(d->url);
if (url.isLocalFile()) if (url.isLocalFile())
@ -1683,8 +1656,6 @@ QString KFileWidget::selectedFile() const
QStringList KFileWidget::selectedFiles() const QStringList KFileWidget::selectedFiles() const
{ {
// kDebug(kfile_area);
QStringList list; QStringList list;
if (d->inAccept) { if (d->inAccept) {
@ -1774,8 +1745,6 @@ bool KFileWidget::eventFilter(QObject* watched, QEvent* event)
void KFileWidget::setMode( KFile::Modes m ) void KFileWidget::setMode( KFile::Modes m )
{ {
// kDebug(kfile_area);
d->ops->setMode(m); d->ops->setMode(m);
if ( d->ops->dirOnlyMode() ) { if ( d->ops->dirOnlyMode() ) {
d->filterWidget->setFilter( i18n("*|All Folders") ); d->filterWidget->setFilter( i18n("*|All Folders") );
@ -1874,8 +1843,6 @@ void KFileWidgetPrivate::writeViewConfig()
void KFileWidgetPrivate::readRecentFiles() void KFileWidgetPrivate::readRecentFiles()
{ {
// kDebug(kfile_area);
QObject::disconnect(locationEdit, SIGNAL(editTextChanged(QString)), QObject::disconnect(locationEdit, SIGNAL(editTextChanged(QString)),
q, SLOT(_k_slotLocationChanged(QString))); q, SLOT(_k_slotLocationChanged(QString)));
@ -1902,7 +1869,6 @@ void KFileWidgetPrivate::readRecentFiles()
void KFileWidgetPrivate::saveRecentFiles() void KFileWidgetPrivate::saveRecentFiles()
{ {
// kDebug(kfile_area);
configGroup.writePathEntry(RecentFiles, locationEdit->urls()); configGroup.writePathEntry(RecentFiles, locationEdit->urls());
KUrlComboBox *pathCombo = urlNavigator->editor(); KUrlComboBox *pathCombo = urlNavigator->editor();
@ -1922,8 +1888,6 @@ KPushButton * KFileWidget::cancelButton() const
// Called by KFileDialog // Called by KFileDialog
void KFileWidget::slotCancel() void KFileWidget::slotCancel()
{ {
// kDebug(kfile_area);
d->ops->close(); d->ops->close();
d->writeViewConfig(); d->writeViewConfig();
@ -1941,8 +1905,6 @@ bool KFileWidget::keepsLocation() const
void KFileWidget::setOperationMode( OperationMode mode ) void KFileWidget::setOperationMode( OperationMode mode )
{ {
// kDebug(kfile_area);
d->operationMode = mode; d->operationMode = mode;
d->keepLocation = (mode == Saving); d->keepLocation = (mode == Saving);
d->filterWidget->setEditable( !d->hasDefaultFilter || mode != Saving ); d->filterWidget->setEditable( !d->hasDefaultFilter || mode != Saving );
@ -1972,8 +1934,7 @@ KFileWidget::OperationMode KFileWidget::operationMode() const
void KFileWidgetPrivate::_k_slotAutoSelectExtClicked() void KFileWidgetPrivate::_k_slotAutoSelectExtClicked()
{ {
// kDebug (kfile_area) << "slotAutoSelectExtClicked(): " // kDebug () << "slotAutoSelectExtClicked()" << autoSelectExtCheckBox->isChecked();
// << autoSelectExtCheckBox->isChecked();
// whether the _user_ wants it on/off // whether the _user_ wants it on/off
autoSelectExtChecked = autoSelectExtCheckBox->isChecked(); autoSelectExtChecked = autoSelectExtCheckBox->isChecked();
@ -1984,21 +1945,17 @@ void KFileWidgetPrivate::_k_slotAutoSelectExtClicked()
void KFileWidgetPrivate::_k_placesViewSplitterMoved(int pos, int index) void KFileWidgetPrivate::_k_placesViewSplitterMoved(int pos, int index)
{ {
// kDebug(kfile_area);
// we need to record the size of the splitter when the splitter changes size // we need to record the size of the splitter when the splitter changes size
// so we can keep the places box the right size! // so we can keep the places box the right size!
if (placesDock && index == 1) { if (placesDock && index == 1) {
placesViewWidth = pos; placesViewWidth = pos;
// kDebug() << "setting lafBox minwidth to" << placesViewWidth; // kDebug() << "setting lafBox minwidth to" << placesViewWidth;
lafBox->setColumnMinimumWidth(0, placesViewWidth); lafBox->setColumnMinimumWidth(0, placesViewWidth);
} }
} }
void KFileWidgetPrivate::_k_activateUrlNavigator() void KFileWidgetPrivate::_k_activateUrlNavigator()
{ {
// kDebug(kfile_area);
urlNavigator->setUrlEditable(!urlNavigator->isUrlEditable()); urlNavigator->setUrlEditable(!urlNavigator->isUrlEditable());
if(urlNavigator->isUrlEditable()) { if(urlNavigator->isUrlEditable()) {
urlNavigator->setFocus(); urlNavigator->setFocus();
@ -2080,7 +2037,7 @@ void KFileWidgetPrivate::updateAutoSelectExtension()
// COPYING.txt ...) // COPYING.txt ...)
// //
// kDebug (kfile_area) << "Figure out an extension: "; // kDebug () << "Figure out an extension: ";
QString lastExtension = extension; QString lastExtension = extension;
extension.clear(); extension.clear();
@ -2100,8 +2057,8 @@ void KFileWidgetPrivate::updateAutoSelectExtension()
QString currentExtension = KMimeType::extractKnownExtension(locationEditCurrentText()); QString currentExtension = KMimeType::extractKnownExtension(locationEditCurrentText());
if ( currentExtension.isEmpty() ) if ( currentExtension.isEmpty() )
currentExtension = locationEditCurrentText().section(QLatin1Char('.'), -1, -1); currentExtension = locationEditCurrentText().section(QLatin1Char('.'), -1, -1);
kDebug (kfile_area) << "filter:" << filter << "locationEdit:" << locationEditCurrentText() kDebug () << "filter:" << filter << "locationEdit:" << locationEditCurrentText()
<< "currentExtension:" << currentExtension; << "currentExtension:" << currentExtension;
QString defaultExtension; QString defaultExtension;
QStringList extensionList; QStringList extensionList;
@ -2142,7 +2099,7 @@ void KFileWidgetPrivate::updateAutoSelectExtension()
else else
extension = defaultExtension; extension = defaultExtension;
kDebug (kfile_area) << "List:" << extensionList << "auto-selected extension:" << extension; kDebug() << "List:" << extensionList << "auto-selected extension:" << extension;
} }
@ -2231,7 +2188,7 @@ void KFileWidgetPrivate::updateLocationEditExtension (const QString &lastExtensi
return; return;
KUrl url = getCompleteUrl(urlStr); KUrl url = getCompleteUrl(urlStr);
// kDebug (kfile_area) << "updateLocationEditExtension (" << url << ")"; // kDebug() << "updateLocationEditExtension (" << url << ")";
const int fileNameOffset = urlStr.lastIndexOf ('/') + 1; const int fileNameOffset = urlStr.lastIndexOf ('/') + 1;
QString fileName = urlStr.mid (fileNameOffset); QString fileName = urlStr.mid (fileNameOffset);
@ -2248,11 +2205,11 @@ void KFileWidgetPrivate::updateLocationEditExtension (const QString &lastExtensi
bool result = KIO::NetAccess::synchronousRun(statJob, q); bool result = KIO::NetAccess::synchronousRun(statJob, q);
if (result) if (result)
{ {
// kDebug (kfile_area) << "\tfile exists"; // kDebug () << "\tfile exists";
if (statJob->statResult().isDir()) if (statJob->statResult().isDir())
{ {
// kDebug (kfile_area) << "\tisDir - won't alter extension"; // kDebug () << "\tisDir - won't alter extension";
return; return;
} }
@ -2287,8 +2244,6 @@ void KFileWidgetPrivate::updateLocationEditExtension (const QString &lastExtensi
// (this prevents you from accidently saving "file.kwd" as RTF, for example) // (this prevents you from accidently saving "file.kwd" as RTF, for example)
void KFileWidgetPrivate::updateFilter() void KFileWidgetPrivate::updateFilter()
{ {
// kDebug(kfile_area);
if ((operationMode == KFileWidget::Saving) && (ops->mode() & KFile::File) ) { if ((operationMode == KFileWidget::Saving) && (ops->mode() & KFile::File) ) {
QString urlStr = locationEditCurrentText(); QString urlStr = locationEditCurrentText();
if (urlStr.isEmpty()) if (urlStr.isEmpty())
@ -2321,8 +2276,6 @@ void KFileWidgetPrivate::updateFilter()
// applies only to a file that doesn't already exist // applies only to a file that doesn't already exist
void KFileWidgetPrivate::appendExtension (KUrl &url) void KFileWidgetPrivate::appendExtension (KUrl &url)
{ {
// kDebug(kfile_area);
if (!autoSelectExtCheckBox->isChecked() || extension.isEmpty()) if (!autoSelectExtCheckBox->isChecked() || extension.isEmpty())
return; return;
@ -2330,7 +2283,7 @@ void KFileWidgetPrivate::appendExtension (KUrl &url)
if (fileName.isEmpty()) if (fileName.isEmpty())
return; return;
// kDebug (kfile_area) << "appendExtension(" << url << ")"; // kDebug () << "appendExtension(" << url << ")";
const int len = fileName.length(); const int len = fileName.length();
const int dot = fileName.lastIndexOf ('.'); const int dot = fileName.lastIndexOf ('.');
@ -2347,14 +2300,13 @@ void KFileWidgetPrivate::appendExtension (KUrl &url)
bool res = KIO::NetAccess::synchronousRun(statJob, q); bool res = KIO::NetAccess::synchronousRun(statJob, q);
if (res) if (res)
{ {
// kDebug (kfile_area) << "\tfile exists - won't append extension"; // kDebug () << "\tfile exists - won't append extension";
return; return;
} }
// suppress automatically append extension? // suppress automatically append extension?
if (suppressExtension) if (suppressExtension)
{ {
//
// Strip trailing dot // Strip trailing dot
// This allows lazy people to have autoSelectExtCheckBox->isChecked // This allows lazy people to have autoSelectExtCheckBox->isChecked
// but don't want a file extension to be appended // but don't want a file extension to be appended
@ -2364,15 +2316,15 @@ void KFileWidgetPrivate::appendExtension (KUrl &url)
// and the trailing dot will be removed (or just stop being lazy and // and the trailing dot will be removed (or just stop being lazy and
// turn off this feature so that you can type "README.") // turn off this feature so that you can type "README.")
// //
// kDebug (kfile_area) << "\tstrip trailing dot"; // kDebug () << "\tstrip trailing dot";
url.setFileName (fileName.left (len - 1)); url.setFileName (fileName.left (len - 1));
} }
// evilmatically append extension :) if the user hasn't specified one // evilmatically append extension :) if the user hasn't specified one
else if (unspecifiedExtension) else if (unspecifiedExtension)
{ {
// kDebug (kfile_area) << "\tappending extension \'" << extension << "\'..."; // kDebug () << "\tappending extension \'" << extension << "\'...";
url.setFileName (fileName + extension); url.setFileName (fileName + extension);
// kDebug (kfile_area) << "\tsaving as \'" << url << "\'"; // kDebug () << "\tsaving as \'" << url << "\'";
} }
} }
@ -2623,7 +2575,7 @@ KUrl KFileWidget::getStartUrl( const KUrl& startDir,
ret = *lastDirectory; ret = *lastDirectory;
} }
kDebug(kfile_area) << "for" << startDir << "->" << ret << "recentDirClass" << recentDirClass << "fileName" << fileName; kDebug() << "for" << startDir << "->" << ret << "recentDirClass" << recentDirClass << "fileName" << fileName;
return ret; return ret;
} }

View file

@ -30,19 +30,40 @@
#include <QtGui/qwidget.h> #include <QtGui/qwidget.h>
#include "kfile_export.h" #include "kio/kio_export.h"
#include "kabstractfilewidget.h" #include "kmimetype.h"
#include "kurl.h"
#include "kfile.h"
#include "kconfiggroup.h" #include "kconfiggroup.h"
class KPreviewWidgetBase;
class KPushButton;
class KActionCollection;
class KToolBar;
class KFileWidgetPrivate;
class KUrlComboBox;
class KFileFilterCombo;
class KJob; class KJob;
class KFileItem; class KFileItem;
class KDirOperator; class KDirOperator;
class KFILE_EXPORT KFileWidget : public QWidget, public KAbstractFileWidget class KIO_EXPORT KFileWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(KAbstractFileWidget)
public: public:
/**
* Defines some default behavior of the filedialog.
* E.g. in mode @p Opening and @p Saving, the selected files/urls will
* be added to the "recent documents" list. The Saving mode also implies
* setKeepLocation() being set.
*
* @p Other means that no default actions are performed.
*
* @see setOperationMode
* @see operationMode
*/
enum OperationMode { Other = 0, Opening, Saving };
/** /**
* Constructs a file selector widget. * Constructs a file selector widget.
* *
@ -414,6 +435,24 @@ public:
*/ */
virtual void setCustomWidget(const QString& text, QWidget* widget); virtual void setCustomWidget(const QString& text, QWidget* widget);
/**
* Sets whether the user should be asked for confirmation
* when an overwrite might occurr.
*
* @param enable Set this to true to enable checking.
* @since 4.2
*/
virtual void setConfirmOverwrite(bool enable) { Q_UNUSED(enable); };
/**
* Forces the inline previews to be shown or hidden, depending on @p show.
*
* @param show Whether to show inline previews or not.
* @since 4.2
*/
virtual void setInlinePreviewShown(bool show) { Q_UNUSED(show); };
public Q_SLOTS: public Q_SLOTS:
/** /**
* Called when clicking ok (when this widget is used in KFileDialog) * Called when clicking ok (when this widget is used in KFileDialog)
@ -513,5 +552,5 @@ private:
Q_PRIVATE_SLOT(d, void _k_slotIconSizeChanged(int)) Q_PRIVATE_SLOT(d, void _k_slotIconSizeChanged(int))
}; };
#endif /* KABSTRACTFILEWIDGET_H */ #endif /* KFILEWIDGET_H */

View file

@ -21,7 +21,7 @@
#ifndef KNAMEANDURLINPUTDIALOG_H #ifndef KNAMEANDURLINPUTDIALOG_H
#define KNAMEANDURLINPUTDIALOG_H #define KNAMEANDURLINPUTDIALOG_H
#include <kfile_export.h> #include <kio/kio_export.h>
#include <kdialog.h> #include <kdialog.h>
#include <kurl.h> #include <kurl.h>
@ -35,7 +35,7 @@ class KNameAndUrlInputDialogPrivate;
* @since 4.5 * @since 4.5
* @author David Faure <faure@kde.org> * @author David Faure <faure@kde.org>
*/ */
class KFILE_EXPORT KNameAndUrlInputDialog : public KDialog class KIO_EXPORT KNameAndUrlInputDialog : public KDialog
{ {
Q_OBJECT Q_OBJECT
public: public:

View file

@ -139,7 +139,6 @@ public:
void KNewFileMenuSingleton::parseFiles() void KNewFileMenuSingleton::parseFiles()
{ {
//kDebug(kfile_area);
filesParsed = true; filesParsed = true;
QMutableListIterator<KNewFileMenuSingleton::Entry> templIter(*templatesList); QMutableListIterator<KNewFileMenuSingleton::Entry> templIter(*templatesList);
while (templIter.hasNext()) { while (templIter.hasNext()) {
@ -172,7 +171,7 @@ void KNewFileMenuSingleton::parseFiles()
{ {
// A relative path, then (that's the default in the files we ship) // A relative path, then (that's the default in the files we ship)
QString linkDir = filePath.left(filePath.lastIndexOf('/') + 1 /*keep / */); QString linkDir = filePath.left(filePath.lastIndexOf('/') + 1 /*keep / */);
//kDebug(kfile_area) << "linkDir=" << linkDir; // kDebug() << "linkDir=" << linkDir;
templatePath = linkDir + templatePath; templatePath = linkDir + templatePath;
} }
} }
@ -195,9 +194,9 @@ void KNewFileMenuSingleton::parseFiles()
text.truncate(text.length() - 8); text.truncate(text.length() - 8);
} }
templ.text = text; templ.text = text;
/*kDebug(kfile_area) << "Updating entry with text=" << text /* kDebug() << "Updating entry with text=" << text
<< "entryType=" << templ.entryType << "entryType=" << templ.entryType
<< "templatePath=" << templ.templatePath;*/ << "templatePath=" << templ.templatePath;*/
} }
else { else {
templ.entryType = KNewFileMenuSingleton::Separator; templ.entryType = KNewFileMenuSingleton::Separator;
@ -362,7 +361,7 @@ public:
bool KNewFileMenuPrivate::checkSourceExists(const QString& src) bool KNewFileMenuPrivate::checkSourceExists(const QString& src)
{ {
if (!QFile::exists(src)) { if (!QFile::exists(src)) {
kWarning(kfile_area) << src << "doesn't exist" ; kWarning() << src << "doesn't exist" ;
KDialog* dialog = new KDialog(m_parentWidget); KDialog* dialog = new KDialog(m_parentWidget);
dialog->setCaption( i18n("Sorry") ); dialog->setCaption( i18n("Sorry") );
@ -529,7 +528,7 @@ void KNewFileMenuPrivate::executeStrategy()
if (srcFile.open(QIODevice::ReadOnly)) { if (srcFile.open(QIODevice::ReadOnly)) {
KMimeType::Ptr wantedMime = KMimeType::findByUrl(uSrc); KMimeType::Ptr wantedMime = KMimeType::findByUrl(uSrc);
KMimeType::Ptr mime = KMimeType::findByNameAndContent(m_copyData.m_chosenFileName, srcFile.read(1024)); KMimeType::Ptr mime = KMimeType::findByNameAndContent(m_copyData.m_chosenFileName, srcFile.read(1024));
//kDebug() << "mime=" << mime->name() << "wantedMime=" << wantedMime->name(); // kDebug() << "mime=" << mime->name() << "wantedMime=" << wantedMime->name();
if (!mime->is(wantedMime->name())) if (!mime->is(wantedMime->name()))
chosenFileName += wantedMime->mainExtension(); chosenFileName += wantedMime->mainExtension();
} }
@ -553,7 +552,7 @@ void KNewFileMenuPrivate::executeStrategy()
// which KIO::symlink obviously doesn't emit... Needs code in FileUndoManager. // which KIO::symlink obviously doesn't emit... Needs code in FileUndoManager.
//KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Link, lstSrc, dest, kjob); //KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Link, lstSrc, dest, kjob);
} else { } else {
//kDebug(kfile_area) << "KIO::copyAs(" << uSrc.url() << "," << dest.url() << ")"; // kDebug() << "KIO::copyAs(" << uSrc.url() << "," << dest.url() << ")";
KIO::CopyJob * job = KIO::copyAs(uSrc, dest); KIO::CopyJob * job = KIO::copyAs(uSrc, dest);
job->setDefaultPermissions(true); job->setDefaultPermissions(true);
kjob = job; kjob = job;
@ -602,7 +601,7 @@ void KNewFileMenuPrivate::fillMenu()
const bool bSkip = seenTexts.contains(entry.text); const bool bSkip = seenTexts.contains(entry.text);
if (bSkip) { if (bSkip) {
kDebug(kfile_area) << "skipping" << entry.filePath; kDebug() << "skipping" << entry.filePath;
} else { } else {
seenTexts.insert(entry.text); seenTexts.insert(entry.text);
//const KNewFileMenuSingleton::Entry entry = templatesList->at(i-1); //const KNewFileMenuSingleton::Entry entry = templatesList->at(i-1);
@ -636,7 +635,7 @@ void KNewFileMenuPrivate::fillMenu()
if (entry.mimeType.isEmpty()) { if (entry.mimeType.isEmpty()) {
mime = KMimeType::findByPath(entry.templatePath); mime = KMimeType::findByPath(entry.templatePath);
if (mime) { if (mime) {
//kDebug() << entry.templatePath << "is" << mime->name(); // kDebug() << entry.templatePath << "is" << mime->name();
entry.mimeType = mime->name(); entry.mimeType = mime->name();
} else { } else {
entry.mimeType = KMimeType::defaultMimeType(); entry.mimeType = KMimeType::defaultMimeType();
@ -653,7 +652,7 @@ void KNewFileMenuPrivate::fillMenu()
} }
if (!keep) { if (!keep) {
//kDebug() << "Not keeping" << entry.templatePath; // kDebug() << "Not keeping" << entry.templatePath;
continue; continue;
} }
} }
@ -664,7 +663,7 @@ void KNewFileMenuPrivate::fillMenu()
act->setText(i18nc("@item:inmenu Create New", "%1", entry.text)); act->setText(i18nc("@item:inmenu Create New", "%1", entry.text));
act->setActionGroup(m_newMenuGroup); act->setActionGroup(m_newMenuGroup);
//kDebug() << templatePath << entry.filePath; // kDebug() << templatePath << entry.filePath;
if (templatePath.endsWith("/URL.desktop")) { if (templatePath.endsWith("/URL.desktop")) {
linkURL = act; linkURL = act;
@ -798,13 +797,12 @@ void KNewFileMenuPrivate::_k_slotCreateHiddenDirectory()
void KNewFileMenuPrivate::_k_slotFillTemplates() void KNewFileMenuPrivate::_k_slotFillTemplates()
{ {
KNewFileMenuSingleton* s = kNewMenuGlobals; KNewFileMenuSingleton* s = kNewMenuGlobals;
//kDebug(kfile_area);
// Ensure any changes in the templates dir will call this // Ensure any changes in the templates dir will call this
if (! s->dirWatch) { if (! s->dirWatch) {
s->dirWatch = new KDirWatch; s->dirWatch = new KDirWatch;
const QStringList dirs = m_actionCollection->componentData().dirs()->resourceDirs("templates"); const QStringList dirs = m_actionCollection->componentData().dirs()->resourceDirs("templates");
for (QStringList::const_iterator it = dirs.constBegin() ; it != dirs.constEnd() ; ++it) { for (QStringList::const_iterator it = dirs.constBegin() ; it != dirs.constEnd() ; ++it) {
//kDebug(kfile_area) << "Templates resource dir:" << *it; // kDebug() << "Templates resource dir:" << *it;
s->dirWatch->addDir(*it); s->dirWatch->addDir(*it);
} }
QObject::connect(s->dirWatch, SIGNAL(dirty(QString)), QObject::connect(s->dirWatch, SIGNAL(dirty(QString)),
@ -820,7 +818,7 @@ void KNewFileMenuPrivate::_k_slotFillTemplates()
const QStringList files = m_actionCollection->componentData().dirs()->findAllResources("templates"); const QStringList files = m_actionCollection->componentData().dirs()->findAllResources("templates");
QMap<QString, KNewFileMenuSingleton::Entry> slist; // used for sorting QMap<QString, KNewFileMenuSingleton::Entry> slist; // used for sorting
Q_FOREACH(const QString& file, files) { Q_FOREACH(const QString& file, files) {
//kDebug(kfile_area) << file; // kDebug() << file;
if (file[0] != '.') { if (file[0] != '.') {
KNewFileMenuSingleton::Entry e; KNewFileMenuSingleton::Entry e;
e.filePath = file; e.filePath = file;
@ -966,17 +964,17 @@ KNewFileMenu::KNewFileMenu(KActionCollection* collection, const QString& name, Q
KNewFileMenu::~KNewFileMenu() KNewFileMenu::~KNewFileMenu()
{ {
//kDebug(kfile_area) << this; // kDebug() << this;
delete d; delete d;
} }
void KNewFileMenu::checkUpToDate() void KNewFileMenu::checkUpToDate()
{ {
KNewFileMenuSingleton* s = kNewMenuGlobals; KNewFileMenuSingleton* s = kNewMenuGlobals;
//kDebug(kfile_area) << this << "m_menuItemsVersion=" << d->m_menuItemsVersion // kDebug() << this << "m_menuItemsVersion=" << d->m_menuItemsVersion
// << "s->templatesVersion=" << s->templatesVersion; // << "s->templatesVersion=" << s->templatesVersion;
if (d->m_menuItemsVersion < s->templatesVersion || s->templatesVersion == 0) { if (d->m_menuItemsVersion < s->templatesVersion || s->templatesVersion == 0) {
//kDebug(kfile_area) << "recreating actions"; // kDebug() << "recreating actions";
// We need to clean up the action collection // We need to clean up the action collection
// We look for our actions using the group // We look for our actions using the group
foreach (QAction* action, d->m_newMenuGroup->actions()) foreach (QAction* action, d->m_newMenuGroup->actions())

View file

@ -23,7 +23,7 @@
#include <kactionmenu.h> #include <kactionmenu.h>
#include <kurl.h> #include <kurl.h>
#include <kfile_export.h> #include <kio/kio_export.h>
class KJob; class KJob;
@ -51,7 +51,7 @@ class KNewFileMenuPrivate;
* from Christoph Pickart <pickart@iam.uni-bonn.de> * from Christoph Pickart <pickart@iam.uni-bonn.de>
* @since 4.5 * @since 4.5
*/ */
class KFILE_EXPORT KNewFileMenu : public KActionMenu class KIO_EXPORT KNewFileMenu : public KActionMenu
{ {
Q_OBJECT Q_OBJECT
public: public:

View file

@ -23,7 +23,7 @@
#ifndef KURLNAVIGATOR_H #ifndef KURLNAVIGATOR_H
#define KURLNAVIGATOR_H #define KURLNAVIGATOR_H
#include <kfile_export.h> #include <kio/kio_export.h>
#include <kurl.h> #include <kurl.h>
#include <QWidget> #include <QWidget>
@ -71,7 +71,7 @@ class KUrlComboBox;
* the application to restore the view state by getting the values from * the application to restore the view state by getting the values from
* KUrlNavigator::locationState(). * KUrlNavigator::locationState().
*/ */
class KFILE_EXPORT KUrlNavigator : public QWidget class KIO_EXPORT KUrlNavigator : public QWidget
{ {
Q_OBJECT Q_OBJECT

View file

@ -2,10 +2,14 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
# for <kio/global.h> # for <kio/global.h>
include_directories(${KDE4_KIO_INCLUDES}) include_directories(${KDE4_KIO_INCLUDES})
add_definitions(
-DTEST_DATA="${CMAKE_SOURCE_DIR}/solid/solid/backends/fakehw/fakecomputer.xml"
)
MACRO(KIO_UNIT_TESTS) MACRO(KIO_UNIT_TESTS)
FOREACH(_testname ${ARGN}) FOREACH(_testname ${ARGN})
kde4_add_test(kio-${_testname} ${_testname}.cpp) kde4_add_test(kio-${_testname} ${_testname}.cpp)
target_link_libraries(kio-${_testname} ${QT_QTTEST_LIBRARY} kio) target_link_libraries(kio-${_testname} ${QT_QTTEST_LIBRARY} ${QT_QTXML_LIBRARY} kio)
ENDFOREACH(_testname) ENDFOREACH(_testname)
ENDMACRO(KIO_UNIT_TESTS) ENDMACRO(KIO_UNIT_TESTS)
@ -27,4 +31,8 @@ KIO_UNIT_TESTS(
globaltest globaltest
udsentrytest udsentrytest
kfilemetainfotest kfilemetainfotest
kfileplacesmodeltest
kurlnavigatortest
kdiroperatortest
knewfilemenutest
) )