mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
generic: adjust to KDirWatch changes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
ea611115c4
commit
5ca5e4ea2d
19 changed files with 62 additions and 197 deletions
|
@ -148,15 +148,11 @@ KateFileTemplates::KateFileTemplates( QObject* parent, const QList<QVariant> &du
|
||||||
const QStringList dirs = KGlobal::dirs()->findDirs("data", "kate/plugins/katefiletemplates/templates");
|
const QStringList dirs = KGlobal::dirs()->findDirs("data", "kate/plugins/katefiletemplates/templates");
|
||||||
for ( QStringList::const_iterator it = dirs.begin(); it != dirs.end(); ++it )
|
for ( QStringList::const_iterator it = dirs.begin(); it != dirs.end(); ++it )
|
||||||
{
|
{
|
||||||
m_dw->addDir( *it, KDirWatch::WatchFiles );
|
m_dw->addDir( *it );
|
||||||
}
|
}
|
||||||
|
|
||||||
connect( m_dw, SIGNAL(dirty(QString)),
|
connect( m_dw, SIGNAL(dirty(QString)),
|
||||||
this, SLOT(updateTemplateDirs(QString)) );
|
this, SLOT(updateTemplateDirs(QString)) );
|
||||||
connect( m_dw, SIGNAL(created(QString)),
|
|
||||||
this, SLOT(updateTemplateDirs(QString)) );
|
|
||||||
connect( m_dw, SIGNAL(deleted(QString)),
|
|
||||||
this, SLOT(updateTemplateDirs(QString)) );
|
|
||||||
|
|
||||||
// m_templates.setAutoDelete( true );
|
// m_templates.setAutoDelete( true );
|
||||||
updateTemplateDirs();
|
updateTemplateDirs();
|
||||||
|
|
|
@ -183,12 +183,6 @@ KateDocument::KateDocument ( bool bSingleViewMode, bool bBrowserView,
|
||||||
connect( KateGlobal::self()->dirWatch(), SIGNAL(dirty(QString)),
|
connect( KateGlobal::self()->dirWatch(), SIGNAL(dirty(QString)),
|
||||||
this, SLOT(slotModOnHdDirty(QString)) );
|
this, SLOT(slotModOnHdDirty(QString)) );
|
||||||
|
|
||||||
connect( KateGlobal::self()->dirWatch(), SIGNAL(created(QString)),
|
|
||||||
this, SLOT(slotModOnHdCreated(QString)) );
|
|
||||||
|
|
||||||
connect( KateGlobal::self()->dirWatch(), SIGNAL(deleted(QString)),
|
|
||||||
this, SLOT(slotModOnHdDeleted(QString)) );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load handling
|
* load handling
|
||||||
* this is needed to ensure we signal the user if a file ist still loading
|
* this is needed to ensure we signal the user if a file ist still loading
|
||||||
|
@ -4363,36 +4357,6 @@ void KateDocument::slotModOnHdDirty (const QString &path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KateDocument::slotModOnHdCreated (const QString &path)
|
|
||||||
{
|
|
||||||
if ((path == m_dirWatchFile) && (!m_modOnHd || m_modOnHdReason != OnDiskCreated))
|
|
||||||
{
|
|
||||||
m_modOnHd = true;
|
|
||||||
m_modOnHdReason = OnDiskCreated;
|
|
||||||
|
|
||||||
// reenable dialog if not running atm
|
|
||||||
if (m_isasking == -1)
|
|
||||||
m_isasking = false;
|
|
||||||
|
|
||||||
emit modifiedOnDisk (this, m_modOnHd, m_modOnHdReason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void KateDocument::slotModOnHdDeleted (const QString &path)
|
|
||||||
{
|
|
||||||
if ((path == m_dirWatchFile) && (!m_modOnHd || m_modOnHdReason != OnDiskDeleted))
|
|
||||||
{
|
|
||||||
m_modOnHd = true;
|
|
||||||
m_modOnHdReason = OnDiskDeleted;
|
|
||||||
|
|
||||||
// reenable dialog if not running atm
|
|
||||||
if (m_isasking == -1)
|
|
||||||
m_isasking = false;
|
|
||||||
|
|
||||||
emit modifiedOnDisk (this, m_modOnHd, m_modOnHdReason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const QByteArray &KateDocument::digest () const
|
const QByteArray &KateDocument::digest () const
|
||||||
{
|
{
|
||||||
return m_buffer->digest();
|
return m_buffer->digest();
|
||||||
|
@ -4427,13 +4391,10 @@ QString KateDocument::reasonedMOHString() const
|
||||||
{
|
{
|
||||||
case OnDiskModified:
|
case OnDiskModified:
|
||||||
return i18n("The file '%1' was modified by another program.", str );
|
return i18n("The file '%1' was modified by another program.", str );
|
||||||
break;
|
|
||||||
case OnDiskCreated:
|
case OnDiskCreated:
|
||||||
return i18n("The file '%1' was created by another program.", str );
|
return i18n("The file '%1' was created by another program.", str );
|
||||||
break;
|
|
||||||
case OnDiskDeleted:
|
case OnDiskDeleted:
|
||||||
return i18n("The file '%1' was deleted by another program.", str );
|
return i18n("The file '%1' was deleted by another program.", str );
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -904,8 +904,6 @@ Q_SIGNALS:
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void slotModOnHdDirty (const QString &path);
|
void slotModOnHdDirty (const QString &path);
|
||||||
void slotModOnHdCreated (const QString &path);
|
|
||||||
void slotModOnHdDeleted (const QString &path);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -100,14 +100,11 @@ KfindDlg::KfindDlg(const KUrl & url, QWidget *parent)
|
||||||
|
|
||||||
KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::mainComponent().aboutData(), true);
|
KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::mainComponent().aboutData(), true);
|
||||||
setButtonMenu( Help, helpMenu->menu() );
|
setButtonMenu( Help, helpMenu->menu() );
|
||||||
dirwatch=NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KfindDlg::~KfindDlg()
|
KfindDlg::~KfindDlg()
|
||||||
{
|
{
|
||||||
stopSearch();
|
stopSearch();
|
||||||
|
|
||||||
delete dirwatch;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KfindDlg::finishAndClose()
|
void KfindDlg::finishAndClose()
|
||||||
|
@ -144,33 +141,6 @@ void KfindDlg::startSearch()
|
||||||
enableButton(User2, true); // Enable "Stop"
|
enableButton(User2, true); // Enable "Stop"
|
||||||
enableButton(User1, false); // Disable "Save As..."
|
enableButton(User1, false); // Disable "Save As..."
|
||||||
|
|
||||||
delete dirwatch;
|
|
||||||
dirwatch=new KDirWatch();
|
|
||||||
connect(dirwatch, SIGNAL(created(QString)), this, SLOT(slotNewItems(QString)));
|
|
||||||
connect(dirwatch, SIGNAL(deleted(QString)), this, SLOT(slotDeleteItem(QString)));
|
|
||||||
dirwatch->addDir(query->url().path(), KDirWatch::WatchFiles);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// waba: Watching for updates is disabled for now because even with FAM it causes too
|
|
||||||
// much problems. See BR68220, BR77854, BR77846, BR79512 and BR85802
|
|
||||||
// There are 3 problems:
|
|
||||||
// 1) addDir() keeps looping on recursive symlinks
|
|
||||||
// 2) addDir() scans all subdirectories, so it basically does the same as the process that
|
|
||||||
// is started by KQuery but in-process, undoing the advantages of using a separate find process
|
|
||||||
// A solution could be to let KQuery emit all the directories it has searched in.
|
|
||||||
// Either way, putting dirwatchers on a whole file system is probably just too much.
|
|
||||||
// 3) FAM has a tendency to deadlock with so many files (See BR77854) This has hopefully
|
|
||||||
// been fixed in KDirWatch, but that has not yet been confirmed.
|
|
||||||
|
|
||||||
//Getting a list of all subdirs
|
|
||||||
if(tabWidget->isSearchRecursive() && (dirwatch->internalMethod() == KDirWatch::FAM))
|
|
||||||
{
|
|
||||||
const QStringList subdirs=getAllSubdirs(query->url().path());
|
|
||||||
for(QStringList::const_iterator it = subdirs.constBegin(); it != subdirs.constEnd(); ++it)
|
|
||||||
dirwatch->addDir(*it,true);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
win->beginSearch(query->url());
|
win->beginSearch(query->url());
|
||||||
tabWidget->beginSearch();
|
tabWidget->beginSearch();
|
||||||
|
|
||||||
|
@ -258,32 +228,6 @@ void KfindDlg::about ()
|
||||||
dlg.exec ();
|
dlg.exec ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KfindDlg::slotDeleteItem(const QString& file)
|
|
||||||
{
|
|
||||||
kDebug()<<QString("Will remove one item: %1").arg(file);
|
|
||||||
|
|
||||||
KUrl url;
|
|
||||||
url.setPath( file );
|
|
||||||
|
|
||||||
win->removeItem( url );
|
|
||||||
|
|
||||||
QString str = i18np("one file found", "%1 files found", win->itemCount());
|
|
||||||
setProgressMsg( str );
|
|
||||||
}
|
|
||||||
|
|
||||||
void KfindDlg::slotNewItems( const QString& file )
|
|
||||||
{
|
|
||||||
kDebug()<<QString("Will add this item") << file;
|
|
||||||
|
|
||||||
if( file.indexOf(query->url().path(KUrl::AddTrailingSlash))==0 )
|
|
||||||
{
|
|
||||||
KUrl url;
|
|
||||||
url.setPath ( file );
|
|
||||||
if ( !win->isInserted( url ) )
|
|
||||||
query->slotListEntries( QStringList() << file );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList KfindDlg::getAllSubdirs(QDir d)
|
QStringList KfindDlg::getAllSubdirs(QDir d)
|
||||||
{
|
{
|
||||||
QStringList dirs;
|
QStringList dirs;
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include <kdialog.h>
|
#include <kdialog.h>
|
||||||
#include <kdirlister.h>
|
#include <kdirlister.h>
|
||||||
#include <kdirwatch.h>
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
@ -58,8 +57,6 @@ public Q_SLOTS:
|
||||||
void slotResult(int);
|
void slotResult(int);
|
||||||
// void slotSearchDone();
|
// void slotSearchDone();
|
||||||
void about ();
|
void about ();
|
||||||
void slotDeleteItem(const QString&);
|
|
||||||
void slotNewItems( const QString& );
|
|
||||||
|
|
||||||
void finishAndClose();
|
void finishAndClose();
|
||||||
|
|
||||||
|
@ -74,7 +71,6 @@ private:
|
||||||
bool isResultReported;
|
bool isResultReported;
|
||||||
KQuery *query;
|
KQuery *query;
|
||||||
KStatusBar *mStatusBar;
|
KStatusBar *mStatusBar;
|
||||||
KDirWatch *dirwatch;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -44,7 +44,7 @@ Workspace::Workspace( QWidget* parent)
|
||||||
KAcceleratorManager::setNoAccel(this);
|
KAcceleratorManager::setNoAccel(this);
|
||||||
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
|
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
|
||||||
setDocumentMode(true);
|
setDocumentMode(true);
|
||||||
connect(&mDirWatch, SIGNAL(deleted(QString)), this, SLOT(removeWorkSheet(QString)));
|
connect(&mDirWatch, SIGNAL(dirty(QString)), this, SLOT(maybeRemoveWorkSheet(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Workspace::~Workspace()
|
Workspace::~Workspace()
|
||||||
|
@ -143,20 +143,26 @@ void Workspace::newWorkSheet()
|
||||||
insertTab(-1, sheet, dlg.sheetTitle() );
|
insertTab(-1, sheet, dlg.sheetTitle() );
|
||||||
mSheetList.append( sheet );
|
mSheetList.append( sheet );
|
||||||
setCurrentIndex(indexOf( sheet ));
|
setCurrentIndex(indexOf( sheet ));
|
||||||
connect( sheet, SIGNAL(titleChanged(QWidget*)),
|
connect( sheet, SIGNAL(titleChanged(QWidget*)), SLOT(updateSheetTitle(QWidget*)));
|
||||||
SLOT(updateSheetTitle(QWidget*)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Workspace::contextMenu (int index, const QPoint &point) {
|
void Workspace::contextMenu (int index, const QPoint &point)
|
||||||
// KMenu pm;
|
{
|
||||||
|
// KMenu pm;
|
||||||
Q_UNUSED(index);
|
Q_UNUSED(index);
|
||||||
Q_UNUSED(point);
|
Q_UNUSED(point);
|
||||||
// QAction *new_worksheet = pm.addAction( Toplevel->actionCollection()->action("new_worksheet") );
|
// QAction *new_worksheet = pm.addAction( Toplevel->actionCollection()->action("new_worksheet") );
|
||||||
|
|
||||||
// QAction *action = pm.exec( point );
|
// QAction *action = pm.exec( point );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Workspace::maybeRemoveWorkSheet( const QString &fileName )
|
||||||
|
{
|
||||||
|
if (!QFile::exists(fileName)) {
|
||||||
|
removeWorkSheet(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Workspace::updateSheetTitle( QWidget* wdg )
|
void Workspace::updateSheetTitle( QWidget* wdg )
|
||||||
{
|
{
|
||||||
if ( wdg )
|
if ( wdg )
|
||||||
|
|
|
@ -22,12 +22,12 @@
|
||||||
#ifndef KSG_WORKSPACE_H
|
#ifndef KSG_WORKSPACE_H
|
||||||
#define KSG_WORKSPACE_H
|
#define KSG_WORKSPACE_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
#include <KTabWidget>
|
#include <KTabWidget>
|
||||||
#include <kdirwatch.h>
|
#include <kdirwatch.h>
|
||||||
|
|
||||||
class KConfig;
|
class KConfig;
|
||||||
class KUrl;
|
class KUrl;
|
||||||
#include <QString>
|
|
||||||
class WorkSheet;
|
class WorkSheet;
|
||||||
|
|
||||||
class Workspace : public KTabWidget
|
class Workspace : public KTabWidget
|
||||||
|
@ -67,6 +67,7 @@ class Workspace : public KTabWidget
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
virtual void contextMenu (int, const QPoint &);
|
virtual void contextMenu (int, const QPoint &);
|
||||||
|
void maybeRemoveWorkSheet( const QString &fileName );
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void setCaption( const QString &text);
|
void setCaption( const QString &text);
|
||||||
|
|
|
@ -128,8 +128,6 @@ TaskManager::TaskManager()
|
||||||
d->watcher = new KDirWatch(this);
|
d->watcher = new KDirWatch(this);
|
||||||
d->watcher->addFile(KGlobal::dirs()->locateLocal("config", "klaunchrc"));
|
d->watcher->addFile(KGlobal::dirs()->locateLocal("config", "klaunchrc"));
|
||||||
connect(d->watcher, SIGNAL(dirty(QString)), this, SLOT(configureStartup()));
|
connect(d->watcher, SIGNAL(dirty(QString)), this, SLOT(configureStartup()));
|
||||||
connect(d->watcher, SIGNAL(created(QString)), this, SLOT(configureStartup()));
|
|
||||||
connect(d->watcher, SIGNAL(deleted(QString)), this, SLOT(configureStartup()));
|
|
||||||
|
|
||||||
configureStartup();
|
configureStartup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ void IconApplet::setUrl(const KUrl& url, bool fromConfigDialog)
|
||||||
if (m_url.isLocalFile()) {
|
if (m_url.isLocalFile()) {
|
||||||
m_watcher = new KDirWatch;
|
m_watcher = new KDirWatch;
|
||||||
m_watcher->addFile(m_url.toLocalFile());
|
m_watcher->addFile(m_url.toLocalFile());
|
||||||
connect(m_watcher, SIGNAL(deleted(QString)), this, SLOT(delayedDestroy()));
|
connect(m_watcher, SIGNAL(dirty(QString)), this, SLOT(delayedDestroy()));
|
||||||
|
|
||||||
QFileInfo fi(m_url.toLocalFile());
|
QFileInfo fi(m_url.toLocalFile());
|
||||||
KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown, m_url.toLocalFile());
|
KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown, m_url.toLocalFile());
|
||||||
|
|
|
@ -163,9 +163,8 @@ RecentlyUsedModel::RecentlyUsedModel(QObject *parent, RecentType recenttype, int
|
||||||
|
|
||||||
// listen for changes to the list of recent documents
|
// listen for changes to the list of recent documents
|
||||||
KDirWatch *recentDocWatch = new KDirWatch(this);
|
KDirWatch *recentDocWatch = new KDirWatch(this);
|
||||||
recentDocWatch->addDir(KRecentDocument::recentDocumentDirectory(), KDirWatch::WatchFiles);
|
recentDocWatch->addDir(KRecentDocument::recentDocumentDirectory());
|
||||||
connect(recentDocWatch, SIGNAL(created(QString)), this, SLOT(recentDocumentAdded(QString)));
|
connect(recentDocWatch, SIGNAL(dirty(QString)), this, SLOT(recentDocumentDirty(QString)));
|
||||||
connect(recentDocWatch, SIGNAL(deleted(QString)), this, SLOT(recentDocumentRemoved(QString)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,15 +218,20 @@ DisplayOrder RecentlyUsedModel::nameDisplayOrder() const
|
||||||
return d->displayOrder;
|
return d->displayOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecentlyUsedModel::recentDocumentAdded(const QString& path)
|
void RecentlyUsedModel::recentDocumentDirty(const QString& path)
|
||||||
{
|
{
|
||||||
kDebug() << "Recent document added" << path;
|
kDebug() << "Recent document dirty" << path;
|
||||||
d->addRecentDocument(path, false);
|
|
||||||
}
|
d->itemsByPath.clear();
|
||||||
void RecentlyUsedModel::recentDocumentRemoved(const QString& path)
|
clear();
|
||||||
{
|
|
||||||
kDebug() << "Recent document removed" << path;
|
if (d->recenttype != DocumentsOnly) {
|
||||||
d->removeExistingItem(path);
|
d->loadRecentApplications();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d->recenttype != ApplicationsOnly) {
|
||||||
|
d->loadRecentDocuments();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecentlyUsedModel::recentApplicationAdded(KService::Ptr service, int)
|
void RecentlyUsedModel::recentApplicationAdded(KService::Ptr service, int)
|
||||||
|
|
|
@ -61,8 +61,7 @@ public Q_SLOTS:
|
||||||
void clearRecentDocumentsAndApplications();
|
void clearRecentDocumentsAndApplications();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void recentDocumentAdded(const QString& path);
|
void recentDocumentDirty(const QString& path);
|
||||||
void recentDocumentRemoved(const QString& path);
|
|
||||||
void recentApplicationAdded(KService::Ptr, int startCount);
|
void recentApplicationAdded(KService::Ptr, int startCount);
|
||||||
void recentApplicationRemoved(KService::Ptr);
|
void recentApplicationRemoved(KService::Ptr);
|
||||||
void recentApplicationsCleared();
|
void recentApplicationsCleared();
|
||||||
|
|
|
@ -36,12 +36,10 @@ FileBrowserEngine::FileBrowserEngine(QObject* parent, const QVariantList& args)
|
||||||
Q_UNUSED(args)
|
Q_UNUSED(args)
|
||||||
|
|
||||||
m_dirWatch = new KDirWatch(this);
|
m_dirWatch = new KDirWatch(this);
|
||||||
connect(m_dirWatch, SIGNAL(created(
|
connect(
|
||||||
const QString &)), this, SLOT(dirCreated(QString)));
|
m_dirWatch, SIGNAL(dirty(QString)),
|
||||||
connect(m_dirWatch, SIGNAL(deleted(
|
this, SLOT(updateData(QString))
|
||||||
const QString &)), this, SLOT(dirDeleted(QString)));
|
);
|
||||||
connect(m_dirWatch, SIGNAL(dirty(
|
|
||||||
const QString &)), this, SLOT(dirDirty(QString)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileBrowserEngine::~FileBrowserEngine()
|
FileBrowserEngine::~FileBrowserEngine()
|
||||||
|
@ -59,29 +57,12 @@ bool FileBrowserEngine::sourceRequestEvent(const QString &path)
|
||||||
kDebug() << "source requested() called: "<< path;
|
kDebug() << "source requested() called: "<< path;
|
||||||
m_dirWatch->addDir(path);
|
m_dirWatch->addDir(path);
|
||||||
setData(path, "type", QVariant("unknown"));
|
setData(path, "type", QVariant("unknown"));
|
||||||
updateData (path, INIT);
|
updateData(path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowserEngine::dirDirty(const QString &path)
|
void FileBrowserEngine::updateData(const QString &path)
|
||||||
{
|
{
|
||||||
updateData(path, DIRTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileBrowserEngine::dirCreated(const QString &path)
|
|
||||||
{
|
|
||||||
updateData(path, CREATED);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileBrowserEngine::dirDeleted(const QString &path)
|
|
||||||
{
|
|
||||||
updateData(path, DELETED);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileBrowserEngine::updateData(const QString &path, EventType event)
|
|
||||||
{
|
|
||||||
Q_UNUSED(event)
|
|
||||||
|
|
||||||
ObjectType type = NOTHING;
|
ObjectType type = NOTHING;
|
||||||
if (QDir(path).exists()) {
|
if (QDir(path).exists()) {
|
||||||
type = DIRECTORY;
|
type = DIRECTORY;
|
||||||
|
|
|
@ -40,16 +40,13 @@ protected:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void dirDirty (const QString &path);
|
void dirDirty(const QString &path);
|
||||||
void dirCreated(const QString &path);
|
|
||||||
void dirDeleted(const QString &path);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum EventType {INIT, DIRTY, CREATED, DELETED};
|
enum ObjectType { NOTHING, FILE, DIRECTORY };
|
||||||
enum ObjectType {NOTHING, FILE, DIRECTORY};
|
|
||||||
|
|
||||||
KDirWatch * m_dirWatch;
|
KDirWatch * m_dirWatch;
|
||||||
void updateData(const QString &path, EventType event);
|
void updateData(const QString &path);
|
||||||
void clearData(const QString &path);
|
void clearData(const QString &path);
|
||||||
|
|
||||||
//QMap < QString, QStringList > m_regiteredListeners;
|
//QMap < QString, QStringList > m_regiteredListeners;
|
||||||
|
|
|
@ -47,7 +47,7 @@ HotplugEngine::HotplugEngine(QObject* parent, const QVariantList& args)
|
||||||
{
|
{
|
||||||
QStringList folders = KGlobal::dirs()->findDirs("data", "solid/actions/");
|
QStringList folders = KGlobal::dirs()->findDirs("data", "solid/actions/");
|
||||||
foreach (const QString &folder, folders) {
|
foreach (const QString &folder, folders) {
|
||||||
m_dirWatch->addDir(folder, KDirWatch::WatchFiles);
|
m_dirWatch->addDir(folder);
|
||||||
}
|
}
|
||||||
connect(m_dirWatch, SIGNAL(dirty(QString)), this, SLOT(updatePredicates(QString)));
|
connect(m_dirWatch, SIGNAL(dirty(QString)), this, SLOT(updatePredicates(QString)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,7 @@ RecentDocuments::RecentDocuments(QObject *parent, const QVariantList& args)
|
||||||
loadRecentDocuments();
|
loadRecentDocuments();
|
||||||
// listen for changes to the list of recent documents
|
// listen for changes to the list of recent documents
|
||||||
KDirWatch *recentDocWatch = new KDirWatch(this);
|
KDirWatch *recentDocWatch = new KDirWatch(this);
|
||||||
recentDocWatch->addDir(KRecentDocument::recentDocumentDirectory(), KDirWatch::WatchFiles);
|
recentDocWatch->addDir(KRecentDocument::recentDocumentDirectory());
|
||||||
connect(recentDocWatch,SIGNAL(created(QString)),this,SLOT(loadRecentDocuments()));
|
|
||||||
connect(recentDocWatch,SIGNAL(deleted(QString)),this,SLOT(loadRecentDocuments()));
|
|
||||||
connect(recentDocWatch,SIGNAL(dirty(QString)),this,SLOT(loadRecentDocuments()));
|
connect(recentDocWatch,SIGNAL(dirty(QString)),this,SLOT(loadRecentDocuments()));
|
||||||
addSyntax(Plasma::RunnerSyntax(":q:", i18n("Looks for documents recently used with names matching :q:.")));
|
addSyntax(Plasma::RunnerSyntax(":q:", i18n("Looks for documents recently used with names matching :q:.")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ BackgroundListModel::BackgroundListModel(Image *listener, QObject *parent)
|
||||||
m_size(0,0),
|
m_size(0,0),
|
||||||
m_resizeMethod(Plasma::Wallpaper::ScaledResize)
|
m_resizeMethod(Plasma::Wallpaper::ScaledResize)
|
||||||
{
|
{
|
||||||
connect(&m_dirwatch, SIGNAL(deleted(QString)), this, SLOT(removeBackground(QString)));
|
connect(&m_dirwatch, SIGNAL(dirty(QString)), this, SLOT(reload()));
|
||||||
m_previewUnavailablePix.fill(Qt::transparent);
|
m_previewUnavailablePix.fill(Qt::transparent);
|
||||||
//m_previewUnavailablePix = KIcon("unknown").pixmap(m_previewUnavailablePix.size());
|
//m_previewUnavailablePix = KIcon("unknown").pixmap(m_previewUnavailablePix.size());
|
||||||
}
|
}
|
||||||
|
@ -56,20 +56,6 @@ BackgroundListModel::~BackgroundListModel()
|
||||||
qDeleteAll(m_packages);
|
qDeleteAll(m_packages);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackgroundListModel::removeBackground(const QString &path)
|
|
||||||
{
|
|
||||||
QModelIndex index;
|
|
||||||
while ((index = indexOf(path)).isValid()) {
|
|
||||||
beginRemoveRows(QModelIndex(), index.row(), index.row());
|
|
||||||
Plasma::Package *package = m_packages.at(index.row());
|
|
||||||
m_packages.removeAt(index.row());
|
|
||||||
m_sizeCache.remove(package);
|
|
||||||
m_previews.remove(package);
|
|
||||||
delete package;
|
|
||||||
endRemoveRows();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BackgroundListModel::reload()
|
void BackgroundListModel::reload()
|
||||||
{
|
{
|
||||||
reload(QStringList());
|
reload(QStringList());
|
||||||
|
@ -96,6 +82,12 @@ void BackgroundListModel::reload(const QStringList &selected)
|
||||||
|
|
||||||
const QStringList dirs = KGlobal::dirs()->findDirs("wallpaper", "");
|
const QStringList dirs = KGlobal::dirs()->findDirs("wallpaper", "");
|
||||||
kDebug() << "going looking in" << dirs;
|
kDebug() << "going looking in" << dirs;
|
||||||
|
|
||||||
|
// add wallpaper dirs to dirwatch (recursively)
|
||||||
|
foreach (const QString &dir, dirs) {
|
||||||
|
m_dirwatch.addDir(dir);
|
||||||
|
}
|
||||||
|
|
||||||
BackgroundFinder *finder = new BackgroundFinder(m_structureParent.data(), dirs);
|
BackgroundFinder *finder = new BackgroundFinder(m_structureParent.data(), dirs);
|
||||||
connect(finder, SIGNAL(backgroundsFound(QStringList)), this, SLOT(processPaths(QStringList)));
|
connect(finder, SIGNAL(backgroundsFound(QStringList)), this, SLOT(processPaths(QStringList)));
|
||||||
finder->start();
|
finder->start();
|
||||||
|
@ -120,13 +112,6 @@ void BackgroundListModel::processPaths(const QStringList &paths)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add new files to dirwatch
|
|
||||||
foreach (Plasma::Package *b, newPackages) {
|
|
||||||
if (!m_dirwatch.contains(b->path())) {
|
|
||||||
m_dirwatch.addFile(b->path());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!newPackages.isEmpty()) {
|
if (!newPackages.isEmpty()) {
|
||||||
const int start = rowCount();
|
const int start = rowCount();
|
||||||
beginInsertRows(QModelIndex(), start, start + newPackages.size());
|
beginInsertRows(QModelIndex(), start, start + newPackages.size());
|
||||||
|
@ -195,8 +180,7 @@ QSize BackgroundListModel::bestSize(Plasma::Package *package) const
|
||||||
QSize size(-1, -1);
|
QSize size(-1, -1);
|
||||||
m_sizeCache.insert(package, size);
|
m_sizeCache.insert(package, size);
|
||||||
ImageSizeFinder *finder = new ImageSizeFinder(image, const_cast<BackgroundListModel *>(this));
|
ImageSizeFinder *finder = new ImageSizeFinder(image, const_cast<BackgroundListModel *>(this));
|
||||||
connect(finder, SIGNAL(sizeFound(QString,QSize)), this,
|
connect(finder, SIGNAL(sizeFound(QString,QSize)), this, SLOT(sizeFound(QString,QSize)));
|
||||||
SLOT(sizeFound(QString,QSize)));
|
|
||||||
finder->start();
|
finder->start();
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,6 @@ public:
|
||||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
Plasma::Package *package(int index) const;
|
Plasma::Package *package(int index) const;
|
||||||
|
|
||||||
void reload();
|
|
||||||
void reload(const QStringList &selected);
|
void reload(const QStringList &selected);
|
||||||
void addBackground(const QString &path);
|
void addBackground(const QString &path);
|
||||||
QModelIndex indexOf(const QString &path) const;
|
QModelIndex indexOf(const QString &path) const;
|
||||||
|
@ -66,7 +65,7 @@ public:
|
||||||
void setResizeMethod(Plasma::Wallpaper::ResizeMethod resizeMethod);
|
void setResizeMethod(Plasma::Wallpaper::ResizeMethod resizeMethod);
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void removeBackground(const QString &path);
|
void reload();
|
||||||
void showPreview(const KFileItem &item, const QPixmap &preview);
|
void showPreview(const KFileItem &item, const QPixmap &preview);
|
||||||
void previewFailed(const KFileItem &item);
|
void previewFailed(const KFileItem &item);
|
||||||
void sizeFound(const QString &path, const QSize &s);
|
void sizeFound(const QString &path, const QSize &s);
|
||||||
|
|
|
@ -399,9 +399,12 @@ void Image::updateDirWatch(const QStringList &newDirs)
|
||||||
|
|
||||||
if (!m_dirWatch) {
|
if (!m_dirWatch) {
|
||||||
m_dirWatch = new KDirWatch(this);
|
m_dirWatch = new KDirWatch(this);
|
||||||
connect(m_dirWatch, SIGNAL(created(QString)), SLOT(pathCreated(QString)));
|
|
||||||
connect(m_dirWatch, SIGNAL(dirty(QString)), SLOT(pathDirty(QString)));
|
connect(m_dirWatch, SIGNAL(dirty(QString)), SLOT(pathDirty(QString)));
|
||||||
|
#warning FIXME: update the whole list on dirty() signal
|
||||||
|
#if 0
|
||||||
|
connect(m_dirWatch, SIGNAL(created(QString)), SLOT(pathCreated(QString)));
|
||||||
connect(m_dirWatch, SIGNAL(deleted(QString)), SLOT(pathDeleted(QString)));
|
connect(m_dirWatch, SIGNAL(deleted(QString)), SLOT(pathDeleted(QString)));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const QString &oldDir, m_dirs) {
|
foreach (const QString &oldDir, m_dirs) {
|
||||||
|
@ -412,7 +415,7 @@ void Image::updateDirWatch(const QStringList &newDirs)
|
||||||
|
|
||||||
foreach (const QString &newDir, newDirs) {
|
foreach (const QString &newDir, newDirs) {
|
||||||
if (!m_dirWatch->contains(newDir)) {
|
if (!m_dirWatch->contains(newDir)) {
|
||||||
m_dirWatch->addDir(newDir, KDirWatch::WatchSubDirs | KDirWatch::WatchFiles);
|
m_dirWatch->addDir(newDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue