Commit f7a4fceb authored by Christian Kandeler's avatar Christian Kandeler Committed by Daniel Teske
Browse files

Maemo: Fix package file watching.

Had been broken by 45c9cf7a ff.
This change uses the FileManager and thereby also improves interaction
with external editors that change the inode (e.g. emacs).

Change-Id: I6d889d435931eb0199de93610bea643e50e9f025
Reviewed-on: http://codereview.qt.nokia.com/24


Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent a395022a
......@@ -35,6 +35,7 @@
#include "maemodeviceconfigurations.h"
#include <coreplugin/ifile.h>
#include <utils/environment.h>
#include <projectexplorer/buildstep.h>
......@@ -59,6 +60,32 @@ namespace Qt4ProjectManager {
class BaseQtVersion;
namespace Internal {
class WatchableFile : public Core::IFile
{
Q_OBJECT
public:
WatchableFile(const QString &fileName, QObject *parent = 0)
: Core::IFile(parent), m_fileName(fileName) {}
bool save(QString *, const QString &, bool) { return false; }
QString fileName() const { return m_fileName; }
QString defaultPath() const { return QString(); }
QString suggestedFileName() const { return QString(); }
QString mimeType() const { return QLatin1String("text/plain"); }
bool isModified() const { return false; }
bool isReadOnly() const { return false; }
bool isSaveAsAllowed() const { return false; }
ReloadBehavior reloadBehavior(ChangeTrigger, ChangeType) const { return BehaviorSilent; }
bool reload(QString *, ReloadFlag, ChangeType) { emit modified(); return true; }
void rename(const QString &) {}
signals:
void modified();
private:
QString m_fileName;
};
class MaemoGlobal
{
Q_DECLARE_TR_FUNCTIONS(Qt4ProjectManager::Internal::MaemoGlobal)
......
......@@ -662,15 +662,17 @@ void AbstractDebBasedQt4MaemoTarget::handleTargetAddedSpecial()
setPackageManagerIcon(iconPath);
}
m_filesWatcher->addDirectory(debianDirPath(), Utils::FileSystemWatcher::WatchAllChanges);
m_filesWatcher->addFile(changeLogFilePath(), Utils::FileSystemWatcher::WatchAllChanges);
m_filesWatcher->addFile(controlFilePath(), Utils::FileSystemWatcher::WatchAllChanges);
m_controlFile = new WatchableFile(controlFilePath(), this);
connect(m_controlFile, SIGNAL(modified()), SIGNAL(controlChanged()));
m_changeLogFile = new WatchableFile(changeLogFilePath(), this);
connect(m_changeLogFile, SIGNAL(modified()), SIGNAL(changeLogChanged()));
Core::FileManager::instance()->addFiles(QList<Core::IFile *>()
<< m_controlFile << m_changeLogFile);
connect(m_filesWatcher, SIGNAL(directoryChanged(QString)), this,
SLOT(handleDebianDirContentsChanged()));
connect(m_filesWatcher, SIGNAL(fileChanged(QString)), this,
SLOT(handleDebianFileChanged(QString)));
handleDebianDirContentsChanged();
handleDebianFileChanged(changeLogFilePath());
handleDebianFileChanged(controlFilePath());
emit controlChanged();
emit changeLogChanged();
}
bool AbstractDebBasedQt4MaemoTarget::targetCanBeRemoved() const
......@@ -685,14 +687,6 @@ void AbstractDebBasedQt4MaemoTarget::removeTarget()
qDebug("%s", qPrintable(error));
}
void AbstractDebBasedQt4MaemoTarget::handleDebianFileChanged(const QString &filePath)
{
if (filePath == changeLogFilePath())
emit changeLogChanged();
else if (filePath == controlFilePath())
emit controlChanged();
}
void AbstractDebBasedQt4MaemoTarget::handleDebianDirContentsChanged()
{
emit debianDirContentsChanged();
......@@ -985,9 +979,10 @@ AbstractQt4MaemoTarget::ActionStatus AbstractRpmBasedQt4MaemoTarget::createSpeci
void AbstractRpmBasedQt4MaemoTarget::handleTargetAddedSpecial()
{
m_filesWatcher->addFile(specFilePath(), Utils::FileSystemWatcher::WatchAllChanges);
connect(m_filesWatcher, SIGNAL(fileChanged(QString)), this,
SIGNAL(specFileChanged()));
m_specFile = new WatchableFile(specFilePath(), this);
connect(m_specFile, SIGNAL(modified()), SIGNAL(specFileChanged()));
Core::FileManager::instance()->addFile(m_specFile);
emit specFileChanged();
}
bool AbstractRpmBasedQt4MaemoTarget::targetCanBeRemoved() const
......
......@@ -48,6 +48,7 @@ namespace Qt4ProjectManager {
class Qt4Project;
namespace Internal {
class Qt4MaemoDeployConfigurationFactory;
class WatchableFile;
class AbstractQt4MaemoTarget : public Qt4BaseTarget
{
......@@ -141,7 +142,6 @@ protected:
private slots:
void handleDebianDirContentsChanged();
void handleDebianFileChanged(const QString &filePath);
private:
virtual bool setProjectVersionInternal(const QString &version,
......@@ -172,6 +172,9 @@ private:
QString *error = 0);
QString defaultPackageFileName() const;
bool setPackageManagerNameInternal(const QString &name, QString *error = 0);
WatchableFile *m_controlFile;
WatchableFile *m_changeLogFile;
};
......@@ -213,6 +216,8 @@ private:
QByteArray getValueForTag(const QByteArray &tag, QString *error) const;
bool setValueForTag(const QByteArray &tag, const QByteArray &value,
QString *error);
WatchableFile *m_specFile;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment