mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kio: log KRecentDirs and KRecentDocument actions
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
8e0c1f8dfc
commit
85205ccecf
10 changed files with 114 additions and 94 deletions
|
@ -26,6 +26,9 @@
|
|||
#include "kglobal.h"
|
||||
#include "kdebug.h"
|
||||
|
||||
// see kdebug.areas
|
||||
static const int s_kcoreconfigskeletonarea = 184;
|
||||
|
||||
KConfigSkeletonItem::KConfigSkeletonItem(const QString & _group,
|
||||
const QString & _key)
|
||||
: mGroup(_group)
|
||||
|
@ -937,14 +940,11 @@ QVariant KCoreConfigSkeleton::ItemIntList::property() const
|
|||
return qVariantFromValue< QList<int> >(mReference);
|
||||
}
|
||||
|
||||
// see kdebug.areas
|
||||
static int kCoreConfigSkeletionDebugArea() { return 184; }
|
||||
|
||||
KCoreConfigSkeleton::KCoreConfigSkeleton(const QString &configname, QObject* parent)
|
||||
: QObject(parent),
|
||||
d( new Private )
|
||||
{
|
||||
//kDebug(kCoreConfigSkeletionDebugArea()) << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
|
||||
//kDebug(s_kcoreconfigskeletonarea) << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
|
||||
|
||||
if ( !configname.isEmpty() )
|
||||
{
|
||||
|
@ -960,7 +960,7 @@ KCoreConfigSkeleton::KCoreConfigSkeleton(KSharedConfig::Ptr pConfig, QObject* pa
|
|||
: QObject(parent),
|
||||
d( new Private )
|
||||
{
|
||||
//kDebug(kCoreConfigSkeletionDebugArea()) << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
|
||||
//kDebug(s_kcoreconfigskeletonarea) << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
|
||||
d->mConfig = pConfig;
|
||||
}
|
||||
|
||||
|
@ -1026,7 +1026,7 @@ void KCoreConfigSkeleton::setDefaults()
|
|||
|
||||
void KCoreConfigSkeleton::readConfig()
|
||||
{
|
||||
// kDebug(kCoreConfigSkeletionDebugArea());
|
||||
// kDebug(s_kcoreconfigskeletonarea);
|
||||
d->mConfig->reparseConfiguration();
|
||||
KConfigSkeletonItem::List::ConstIterator it;
|
||||
for( it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it )
|
||||
|
@ -1038,7 +1038,7 @@ void KCoreConfigSkeleton::readConfig()
|
|||
|
||||
void KCoreConfigSkeleton::writeConfig()
|
||||
{
|
||||
kDebug(kCoreConfigSkeletionDebugArea());
|
||||
kDebug(s_kcoreconfigskeletonarea);
|
||||
KConfigSkeletonItem::List::ConstIterator it;
|
||||
for( it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it )
|
||||
{
|
||||
|
|
|
@ -36,13 +36,14 @@ static const char s_kdeUriListMime[] = "application/x-kde4-urilist";
|
|||
// sure they are not a thing
|
||||
// #define KURL_COMPAT_CHECK
|
||||
#ifdef KURL_COMPAT_CHECK
|
||||
static const int kurlDebugArea = 181; // see kdebug.areas
|
||||
// see kdebug.areas
|
||||
static const int s_kurlarea = 181;
|
||||
|
||||
void kCheckLocalFile(const KUrl *kurl)
|
||||
{
|
||||
if (kurl->isLocalFile()) {
|
||||
if (kurl->hasQuery() || kurl->hasFragment()) {
|
||||
kFatal(kurlDebugArea) << "Query or fragment detected in" << kurl->prettyUrl();
|
||||
kFatal(s_kurlarea) << "Query or fragment detected in" << kurl->prettyUrl();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
7001 kio (KDirWatch)
|
||||
7002 kio (Slave)
|
||||
7003 kio (KDirLister)
|
||||
7004 kio (KRecentDirs)
|
||||
7005 kio (KRecentDocument)
|
||||
7006 kio (Scheduler)
|
||||
7007 kio (KIOJob)
|
||||
7008 kio (KDirModel)
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#define KAUTHORIZATION_SLEEPTIME 50
|
||||
|
||||
// see kdebug.areas
|
||||
static const int s_kauthorization_area = 185;
|
||||
static const int s_kauthorizationarea = 185;
|
||||
|
||||
void kAuthMessageHandler(QtMsgType type, const char *msg)
|
||||
{
|
||||
|
@ -62,12 +62,12 @@ static bool isDBusServiceRegistered(const QString &helper)
|
|||
{
|
||||
QDBusConnectionInterface* dbusinterface = QDBusConnection::systemBus().interface();
|
||||
if (!dbusinterface) {
|
||||
kDebug(s_kauthorization_area) << "Null D-Bus interface" << helper;
|
||||
kDebug(s_kauthorizationarea) << "Null D-Bus interface" << helper;
|
||||
return false;
|
||||
}
|
||||
QDBusReply<bool> reply = dbusinterface->isServiceRegistered(helper);
|
||||
if (reply.value() == false) {
|
||||
kDebug(s_kauthorization_area) << "Service not registered" << helper;
|
||||
kDebug(s_kauthorizationarea) << "Service not registered" << helper;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -102,7 +102,7 @@ int KAuthorizationAdaptor::execute(const QString &method, const QVariantMap &arg
|
|||
Q_RETURN_ARG(int, result), Q_ARG(QVariantMap, arguments)
|
||||
);
|
||||
if (!success) {
|
||||
kWarning(s_kauthorization_area) << "Invalid method" << method;
|
||||
kWarning(s_kauthorizationarea) << "Invalid method" << method;
|
||||
delayedStop();
|
||||
return KAuthorization::MethodError;
|
||||
}
|
||||
|
@ -148,19 +148,19 @@ bool KAuthorization::isAuthorized(const QString &helper)
|
|||
QDBusReply<void> reply = kauthorizationinterface.call(QString::fromLatin1("stop"));
|
||||
bool result = true;
|
||||
if (!reply.isValid()) {
|
||||
kWarning(s_kauthorization_area) << reply.error().message();
|
||||
kWarning(s_kauthorizationarea) << reply.error().message();
|
||||
result = false;
|
||||
}
|
||||
kDebug(s_kauthorization_area) << "Result is" << result;
|
||||
kDebug(s_kauthorizationarea) << "Result is" << result;
|
||||
return result;
|
||||
}
|
||||
|
||||
int KAuthorization::execute(const QString &helper, const QString &method, const QVariantMap &arguments)
|
||||
{
|
||||
kDebug(s_kauthorization_area) << "Executing" << helper << "method" << method;
|
||||
kDebug(s_kauthorizationarea) << "Executing" << helper << "method" << method;
|
||||
|
||||
while (isDBusServiceRegistered(helper)) {
|
||||
kDebug(s_kauthorization_area) << "Waiting for service to unregister" << helper;
|
||||
kDebug(s_kauthorizationarea) << "Waiting for service to unregister" << helper;
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, KAUTHORIZATION_TIMEOUT);
|
||||
QThread::msleep(KAUTHORIZATION_SLEEPTIME);
|
||||
}
|
||||
|
@ -171,21 +171,21 @@ int KAuthorization::execute(const QString &helper, const QString &method, const
|
|||
);
|
||||
QDBusPendingReply<int> reply = kauthorizationinterface.asyncCall(QString::fromLatin1("execute"), method, arguments);
|
||||
while (!reply.isFinished()) {
|
||||
kDebug(s_kauthorization_area) << "Waiting for service call to finish" << helper;
|
||||
kDebug(s_kauthorizationarea) << "Waiting for service call to finish" << helper;
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, KAUTHORIZATION_TIMEOUT);
|
||||
QThread::msleep(KAUTHORIZATION_SLEEPTIME);
|
||||
}
|
||||
int result = KAuthorization::NoError;
|
||||
if (!reply.isValid()) {
|
||||
result = KAuthorization::DBusError;
|
||||
kWarning(s_kauthorization_area) << reply.error().message();
|
||||
kWarning(s_kauthorizationarea) << reply.error().message();
|
||||
if (reply.error().type() == QDBusError::AccessDenied) {
|
||||
result = KAuthorization::AuthorizationError;
|
||||
}
|
||||
} else {
|
||||
result = reply.value();
|
||||
}
|
||||
kDebug(s_kauthorization_area) << "Result is" << result;
|
||||
kDebug(s_kauthorizationarea) << "Result is" << result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,11 +27,15 @@
|
|||
#include <QList>
|
||||
#include <kconfiggroup.h>
|
||||
|
||||
|
||||
// see kdebug.areas
|
||||
static const int s_kplugininfoarea = 182;
|
||||
|
||||
//#ifndef NDEBUG
|
||||
#define KPLUGININFO_ISVALID_ASSERTION \
|
||||
do { \
|
||||
if (!d) { \
|
||||
kFatal(KPluginInfoPrivate::debugArea()) << "Accessed invalid KPluginInfo object"; \
|
||||
kFatal(s_kplugininfoarea) << "Accessed invalid KPluginInfo object"; \
|
||||
} \
|
||||
} while (false)
|
||||
//#else
|
||||
|
@ -40,40 +44,35 @@
|
|||
|
||||
class KPluginInfoPrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
KPluginInfoPrivate()
|
||||
: hidden( false )
|
||||
, enabledbydefault( false )
|
||||
, pluginenabled( false )
|
||||
, kcmservicesCached( false )
|
||||
{}
|
||||
public:
|
||||
KPluginInfoPrivate()
|
||||
: hidden( false )
|
||||
, enabledbydefault( false )
|
||||
, pluginenabled( false )
|
||||
, kcmservicesCached( false )
|
||||
{}
|
||||
|
||||
QString entryPath; // the filename of the file containing all the info
|
||||
QString name;
|
||||
QString comment;
|
||||
QString icon;
|
||||
QString author;
|
||||
QString email;
|
||||
QString pluginName; // the name attribute in the .rc file
|
||||
QString version;
|
||||
QString website; // URL to the website of the plugin/author
|
||||
QString category;
|
||||
QString license;
|
||||
QStringList dependencies;
|
||||
QString entryPath; // the filename of the file containing all the info
|
||||
QString name;
|
||||
QString comment;
|
||||
QString icon;
|
||||
QString author;
|
||||
QString email;
|
||||
QString pluginName; // the name attribute in the .rc file
|
||||
QString version;
|
||||
QString website; // URL to the website of the plugin/author
|
||||
QString category;
|
||||
QString license;
|
||||
QStringList dependencies;
|
||||
|
||||
bool hidden : 1;
|
||||
bool enabledbydefault : 1;
|
||||
bool pluginenabled : 1;
|
||||
mutable bool kcmservicesCached : 1;
|
||||
bool hidden : 1;
|
||||
bool enabledbydefault : 1;
|
||||
bool pluginenabled : 1;
|
||||
mutable bool kcmservicesCached : 1;
|
||||
|
||||
KConfigGroup config;
|
||||
KService::Ptr service;
|
||||
mutable QList<KService::Ptr> kcmservices;
|
||||
|
||||
// see kdebug.areas
|
||||
static int debugArea() {
|
||||
return 182;
|
||||
}
|
||||
KConfigGroup config;
|
||||
KService::Ptr service;
|
||||
mutable QList<KService::Ptr> kcmservices;
|
||||
};
|
||||
|
||||
KPluginInfo::KPluginInfo( const QString & filename, const char* resource )
|
||||
|
@ -226,21 +225,21 @@ bool KPluginInfo::isHidden() const
|
|||
void KPluginInfo::setPluginEnabled( bool enabled )
|
||||
{
|
||||
KPLUGININFO_ISVALID_ASSERTION;
|
||||
//kDebug( d->debugArea() ) ;
|
||||
//kDebug( s_kplugininfoarea ) ;
|
||||
d->pluginenabled = enabled;
|
||||
}
|
||||
|
||||
bool KPluginInfo::isPluginEnabled() const
|
||||
{
|
||||
KPLUGININFO_ISVALID_ASSERTION;
|
||||
//kDebug( d->debugArea() ) ;
|
||||
//kDebug( s_kplugininfoarea ) ;
|
||||
return d->pluginenabled;
|
||||
}
|
||||
|
||||
bool KPluginInfo::isPluginEnabledByDefault() const
|
||||
{
|
||||
KPLUGININFO_ISVALID_ASSERTION;
|
||||
//kDebug( d->debugArea() ) ;
|
||||
//kDebug( s_kplugininfoarea ) ;
|
||||
return d->enabledbydefault;
|
||||
}
|
||||
|
||||
|
@ -335,7 +334,7 @@ QList<KService::Ptr> KPluginInfo::kcmServices() const
|
|||
{
|
||||
d->kcmservices = KServiceTypeTrader::self()->query( QLatin1String("KCModule"), QLatin1Char('\'') + d->pluginName +
|
||||
QString::fromLatin1("' in [X-KDE-ParentComponents]") );
|
||||
kDebug(d->debugArea()) << "found" << d->kcmservices.count() << "offers for" << d->pluginName;
|
||||
kDebug(s_kplugininfoarea) << "found" << d->kcmservices.count() << "offers for" << d->pluginName;
|
||||
|
||||
d->kcmservicesCached = true;
|
||||
}
|
||||
|
@ -367,12 +366,12 @@ QVariant KPluginInfo::property( const QString & key ) const
|
|||
void KPluginInfo::save(KConfigGroup config)
|
||||
{
|
||||
KPLUGININFO_ISVALID_ASSERTION;
|
||||
//kDebug( d->debugArea() ) ;
|
||||
//kDebug( s_kplugininfoarea ) ;
|
||||
if (config.isValid()) {
|
||||
config.writeEntry(d->pluginName + QString::fromLatin1("Enabled"), isPluginEnabled());
|
||||
} else {
|
||||
if (!d->config.isValid()) {
|
||||
kWarning( d->debugArea() ) << "no KConfigGroup, cannot save";
|
||||
kWarning( s_kplugininfoarea ) << "no KConfigGroup, cannot save";
|
||||
return;
|
||||
}
|
||||
d->config.writeEntry(d->pluginName + QString::fromLatin1("Enabled"), isPluginEnabled());
|
||||
|
@ -382,12 +381,12 @@ void KPluginInfo::save(KConfigGroup config)
|
|||
void KPluginInfo::load(const KConfigGroup &config)
|
||||
{
|
||||
KPLUGININFO_ISVALID_ASSERTION;
|
||||
//kDebug( d->debugArea() ) ;
|
||||
//kDebug( s_kplugininfoarea ) ;
|
||||
if (config.isValid()) {
|
||||
setPluginEnabled(config.readEntry(d->pluginName + QString::fromLatin1("Enabled"), isPluginEnabledByDefault()));
|
||||
} else {
|
||||
if (!d->config.isValid()) {
|
||||
kWarning( d->debugArea() ) << "no KConfigGroup, cannot load";
|
||||
kWarning( s_kplugininfoarea ) << "no KConfigGroup, cannot load";
|
||||
return;
|
||||
}
|
||||
setPluginEnabled(d->config.readEntry(d->pluginName + QString::fromLatin1("Enabled"), isPluginEnabledByDefault()));
|
||||
|
@ -396,7 +395,7 @@ void KPluginInfo::load(const KConfigGroup &config)
|
|||
|
||||
void KPluginInfo::defaults()
|
||||
{
|
||||
//kDebug( d->debugArea() ) ;
|
||||
//kDebug( s_kplugininfoarea ) ;
|
||||
setPluginEnabled( isPluginEnabledByDefault() );
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
#include "kservicetypefactory.h"
|
||||
|
||||
// see kdebug.areas
|
||||
int servicesDebugArea() {
|
||||
int servicesDebugArea()
|
||||
{
|
||||
return 183;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,9 @@ typedef QHash<QString, QByteArray> MyHash;
|
|||
K_GLOBAL_STATIC(MyHash, s_propertyMap)
|
||||
K_GLOBAL_STATIC(MyHash, s_changedMap)
|
||||
|
||||
// see kdebug.areas
|
||||
static const int s_kconfigdialogmanagerarea = 300;
|
||||
|
||||
class KConfigDialogManager::Private {
|
||||
|
||||
public:
|
||||
|
@ -48,9 +51,6 @@ public:
|
|||
public:
|
||||
KConfigDialogManager *q;
|
||||
|
||||
// see kdebug.areas
|
||||
static int debugArea() { return 300; }
|
||||
|
||||
/**
|
||||
* KConfigSkeleton object used to store settings
|
||||
*/
|
||||
|
@ -268,7 +268,7 @@ bool KConfigDialogManager::parseChildren(const QWidget *widget, bool trackChange
|
|||
|
||||
if (changedIt == s_changedMap->constEnd())
|
||||
{
|
||||
kWarning(d->debugArea()) << "Don't know how to monitor widget '" << childWidget->metaObject()->className() << "' for changes!";
|
||||
kWarning(s_kconfigdialogmanagerarea) << "Don't know how to monitor widget '" << childWidget->metaObject()->className() << "' for changes!";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -289,7 +289,7 @@ bool KConfigDialogManager::parseChildren(const QWidget *widget, bool trackChange
|
|||
}
|
||||
else
|
||||
{
|
||||
kWarning(d->debugArea()) << "A widget named '" << widgetName << "' was found but there is no setting named '" << configId << "'";
|
||||
kWarning(s_kconfigdialogmanagerarea) << "A widget named '" << widgetName << "' was found but there is no setting named '" << configId << "'";
|
||||
}
|
||||
}
|
||||
else if (QLabel *label = qobject_cast<QLabel*>(childWidget))
|
||||
|
@ -313,7 +313,7 @@ bool KConfigDialogManager::parseChildren(const QWidget *widget, bool trackChange
|
|||
{
|
||||
if ((!d->insideGroupBox || !qobject_cast<QRadioButton*>(childWidget)) &&
|
||||
!qobject_cast<QGroupBox*>(childWidget) &&!qobject_cast<QTabWidget*>(childWidget) )
|
||||
kDebug(d->debugArea()) << "Widget '" << widgetName << "' (" << childWidget->metaObject()->className() << ") remains unmanaged.";
|
||||
kDebug(s_kconfigdialogmanagerarea) << "Widget '" << widgetName << "' (" << childWidget->metaObject()->className() << ") remains unmanaged.";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -344,14 +344,14 @@ void KConfigDialogManager::updateWidgets()
|
|||
KConfigSkeletonItem *item = d->m_conf->findItem(it.key());
|
||||
if (!item)
|
||||
{
|
||||
kWarning(d->debugArea()) << "The setting '" << it.key() << "' has disappeared!";
|
||||
kWarning(s_kconfigdialogmanagerarea) << "The setting '" << it.key() << "' has disappeared!";
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!item->isEqual( property(widget) ))
|
||||
{
|
||||
setProperty( widget, item->property() );
|
||||
// kDebug(d->debugArea()) << "The setting '" << it.key() << "' [" << widget->className() << "] has changed";
|
||||
// kDebug(s_kconfigdialogmanagerarea) << "The setting '" << it.key() << "' [" << widget->className() << "] has changed";
|
||||
changed = true;
|
||||
}
|
||||
if (item->isImmutable())
|
||||
|
@ -387,7 +387,7 @@ void KConfigDialogManager::updateSettings()
|
|||
|
||||
KConfigSkeletonItem *item = d->m_conf->findItem(it.key());
|
||||
if (!item) {
|
||||
kWarning(d->debugArea()) << "The setting '" << it.key() << "' has disappeared!";
|
||||
kWarning(s_kconfigdialogmanagerarea) << "The setting '" << it.key() << "' has disappeared!";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -411,7 +411,7 @@ QByteArray KConfigDialogManager::getUserProperty(const QWidget *widget) const
|
|||
const QMetaProperty user = metaObject->userProperty();
|
||||
if ( user.isValid() ) {
|
||||
s_propertyMap->insert( widget->metaObject()->className(), user.name() );
|
||||
//kDebug(d->debugArea()) << "class name: '" << widget->metaObject()->className()
|
||||
//kDebug(s_kconfigdialogmanagerarea) << "class name: '" << widget->metaObject()->className()
|
||||
//<< " 's USER property: " << metaProperty.name();
|
||||
}
|
||||
else {
|
||||
|
@ -438,7 +438,7 @@ QByteArray KConfigDialogManager::getCustomProperty(const QWidget *widget) const
|
|||
QVariant prop(widget->property("kcfg_property"));
|
||||
if (prop.isValid()) {
|
||||
if (!prop.canConvert(QVariant::ByteArray)) {
|
||||
kWarning(d->debugArea()) << "kcfg_property on" << widget->metaObject()->className()
|
||||
kWarning(s_kconfigdialogmanagerarea) << "kcfg_property on" << widget->metaObject()->className()
|
||||
<< "is not of type ByteArray";
|
||||
} else {
|
||||
return prop.toByteArray();
|
||||
|
@ -479,7 +479,7 @@ void KConfigDialogManager::setProperty(QWidget *w, const QVariant &v)
|
|||
}
|
||||
}
|
||||
if (userproperty.isEmpty()) {
|
||||
kWarning(d->debugArea()) << w->metaObject()->className() << " widget not handled!";
|
||||
kWarning(s_kconfigdialogmanagerarea) << w->metaObject()->className() << " widget not handled!";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -507,7 +507,7 @@ QVariant KConfigDialogManager::property(QWidget *w) const
|
|||
}
|
||||
}
|
||||
if (userproperty.isEmpty()) {
|
||||
kWarning(d->debugArea()) << w->metaObject()->className() << " widget not handled!";
|
||||
kWarning(s_kconfigdialogmanagerarea) << w->metaObject()->className() << " widget not handled!";
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
@ -524,12 +524,12 @@ bool KConfigDialogManager::hasChanged() const
|
|||
|
||||
KConfigSkeletonItem *item = d->m_conf->findItem(it.key());
|
||||
if (!item) {
|
||||
kWarning(d->debugArea()) << "The setting '" << it.key() << "' has disappeared!";
|
||||
kWarning(s_kconfigdialogmanagerarea) << "The setting '" << it.key() << "' has disappeared!";
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!item->isEqual( property(widget) )) {
|
||||
// kDebug(d->debugArea()) << "Widget for '" << it.key() << "' has changed.";
|
||||
// kDebug(s_kconfigdialogmanagerarea) << "Widget for '" << it.key() << "' has changed.";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,13 @@
|
|||
#include <ksharedconfig.h>
|
||||
#include <kglobal.h>
|
||||
#include <kglobalsettings.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
#define MAX_DIR_HISTORY 3
|
||||
|
||||
// see kdebug.areas
|
||||
static const int s_krecentdirsarea = 7004;
|
||||
|
||||
static KConfigGroup recentdirs_readList(QString &key, QStringList &result)
|
||||
{
|
||||
KConfigGroup cg(KGlobal::config(), QLatin1String("Recent Dirs"));
|
||||
|
@ -66,6 +70,7 @@ QStringList KRecentDirs::list(const QString &fileClass)
|
|||
QString KRecentDirs::dir(const QString &fileClass)
|
||||
{
|
||||
const QStringList result = list(fileClass);
|
||||
kDebug(s_krecentdirsarea) << "dir for class" << fileClass << "is" << result[0];
|
||||
return result[0];
|
||||
}
|
||||
|
||||
|
@ -80,6 +85,7 @@ void KRecentDirs::add(const QString &fileClass, const QString &directory)
|
|||
while(result.count() > MAX_DIR_HISTORY) {
|
||||
result.removeLast();
|
||||
}
|
||||
kDebug(s_krecentdirsarea) << "adding" << directory << "for" << fileClass;
|
||||
config.writePathEntry(key, result);
|
||||
config.sync();
|
||||
}
|
||||
|
|
|
@ -31,19 +31,23 @@
|
|||
#include <kcomponentdata.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <kurl.h>
|
||||
#include <kdebug.h>
|
||||
#include <kmimetype.h>
|
||||
#include <kdesktopfile.h>
|
||||
#include <kde_file.h>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/QRegExp>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <kconfiggroup.h>
|
||||
#include <ksharedconfig.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QTextStream>
|
||||
#include <QStringList>
|
||||
#include <QRegExp>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
// see kdebug.areas
|
||||
static const int s_krecentdocumentarea = 7005;
|
||||
|
||||
QString KRecentDocument::recentDocumentDirectory()
|
||||
{
|
||||
|
@ -94,22 +98,25 @@ void KRecentDocument::add(const KUrl& url)
|
|||
// ### componentName might not match the service filename...
|
||||
}
|
||||
|
||||
void KRecentDocument::add(const KUrl& url, const QString& desktopEntryName)
|
||||
void KRecentDocument::add(const KUrl &url, const QString &desktopEntryName)
|
||||
{
|
||||
if (url.isLocalFile() && KGlobal::dirs()->relativeLocation("tmp", url.toLocalFile() ) != url.toLocalFile()) {
|
||||
return; // inside tmp resource, do not save
|
||||
if (url.isLocalFile() && KGlobal::dirs()->relativeLocation("tmp", url.toLocalFile()) != url.toLocalFile()) {
|
||||
// inside tmp resource, do not save
|
||||
kDebug(s_krecentdocumentarea) << "temporary resource" << url << "for" << desktopEntryName;
|
||||
return;
|
||||
}
|
||||
|
||||
QString openStr = url.url();
|
||||
openStr.replace( QRegExp("\\$"), "$$" ); // Desktop files with type "Link" are $-variable expanded
|
||||
|
||||
kDebug(250) << "KRecentDocument::add for " << openStr;
|
||||
KConfigGroup config = KGlobal::config()->group(QByteArray("RecentDocuments"));
|
||||
bool useRecent = config.readEntry(QLatin1String("UseRecent"), true);
|
||||
int maxEntries = config.readEntry(QLatin1String("MaxEntries"), 10);
|
||||
|
||||
if(!useRecent || maxEntries <= 0)
|
||||
if (!useRecent || maxEntries <= 0) {
|
||||
kDebug(s_krecentdocumentarea) << "disabled" << url;
|
||||
return;
|
||||
}
|
||||
|
||||
const QString path = recentDocumentDirectory();
|
||||
const QString fileName = url.fileName();
|
||||
|
@ -120,17 +127,19 @@ void KRecentDocument::add(const KUrl& url, const QString& desktopEntryName)
|
|||
|
||||
int i=1;
|
||||
// check for duplicates
|
||||
while(QFile::exists(ddesktop)){
|
||||
while (QFile::exists(ddesktop)){
|
||||
// see if it points to the same file and application
|
||||
KDesktopFile tmp(ddesktop);
|
||||
if (tmp.desktopGroup().readEntry("X-KDE-LastOpenedWith") == desktopEntryName) {
|
||||
KDE::utime(ddesktop, NULL);
|
||||
kDebug(s_krecentdocumentarea) << "duplicate" << url << "for" << desktopEntryName;
|
||||
return;
|
||||
}
|
||||
// if not append a (num) to it
|
||||
++i;
|
||||
if ( i > maxEntries )
|
||||
if (i > maxEntries) {
|
||||
break;
|
||||
}
|
||||
ddesktop = dStr + QString::fromLatin1("[%1].desktop").arg(i);
|
||||
}
|
||||
|
||||
|
@ -147,6 +156,7 @@ void KRecentDocument::add(const KUrl& url, const QString& desktopEntryName)
|
|||
}
|
||||
}
|
||||
|
||||
kDebug(s_krecentdocumentarea) << "adding URL" << url;
|
||||
// create the applnk
|
||||
KDesktopFile configFile(ddesktop);
|
||||
KConfigGroup conf = configFile.desktopGroup();
|
||||
|
@ -163,6 +173,7 @@ void KRecentDocument::clear()
|
|||
const QStringList list = recentDocuments();
|
||||
QDir dir;
|
||||
foreach(const QString &it, list) {
|
||||
kDebug(s_krecentdocumentarea) << "clearing" << it;
|
||||
dir.remove(it);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
*
|
||||
* @param url The url to add.
|
||||
*/
|
||||
static void add(const KUrl& url);
|
||||
static void add(const KUrl &url);
|
||||
|
||||
/**
|
||||
* Add a new item to the Recent Document menu, specifying the application to open it with.
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
* @param url The url to add.
|
||||
* @param desktopEntryName The desktopEntryName of the service to use for opening this document.
|
||||
*/
|
||||
static void add(const KUrl& url, const QString& desktopEntryName);
|
||||
static void add(const KUrl &url, const QString &desktopEntryName);
|
||||
|
||||
/**
|
||||
* Clear the recent document menu of all entries.
|
||||
|
|
Loading…
Add table
Reference in a new issue