本文整理汇总了C++中directoryChanged函数的典型用法代码示例。如果您正苦于以下问题:C++ directoryChanged函数的具体用法?C++ directoryChanged怎么用?C++ directoryChanged使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了directoryChanged函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QFileSystemWatcher
QFileSystemWatcher* KFileSystemWatcher::availableWatcher()
{
QFileSystemWatcher* watcher = m_recentWatcher;
if (!watcher || m_usedObjects.value(watcher) >= MAXIMUM_WAIT_OBJECTS) {
uint i = 0;
watcher = 0;
for (QList<QFileSystemWatcher*>::ConstIterator watchersIt(m_watchers.constBegin());
watchersIt!=m_watchers.constEnd(); ++watchersIt, i++)
{
if (m_usedObjects.value(*watchersIt) < MAXIMUM_WAIT_OBJECTS) {
watcher = *watchersIt;
m_recentWatcher = watcher;
return watcher;
}
}
}
if (!watcher) { //new one needed
watcher = new QFileSystemWatcher();
connect(watcher, SIGNAL(directoryChanged(QString)), this, SIGNAL(directoryChanged(QString)));
connect(watcher, SIGNAL(fileChanged(QString)), this, SIGNAL(fileChanged(QString)));
m_watchers.append( watcher );
m_usedObjects.insert(watcher, 0);
m_recentWatcher = watcher;
}
return watcher;
}
示例2: ioctl
void QInotifyFileSystemWatcherEngine::readFromInotify()
{
// qDebug() << "QInotifyFileSystemWatcherEngine::readFromInotify";
int buffSize = 0;
ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
QVarLengthArray<char, 4096> buffer(buffSize);
buffSize = read(inotifyFd, buffer.data(), buffSize);
char *at = buffer.data();
char * const end = at + buffSize;
QHash<int, inotify_event *> eventForId;
while (at < end) {
inotify_event *event = reinterpret_cast<inotify_event *>(at);
if (eventForId.contains(event->wd))
eventForId[event->wd]->mask |= event->mask;
else
eventForId.insert(event->wd, event);
at += sizeof(inotify_event) + event->len;
}
QHash<int, inotify_event *>::const_iterator it = eventForId.constBegin();
while (it != eventForId.constEnd()) {
const inotify_event &event = **it;
++it;
// qDebug() << "inotify event, wd" << event.wd << "mask" << hex << event.mask;
int id = event.wd;
QString path = getPathFromID(id);
if (path.isEmpty()) {
// perhaps a directory?
id = -id;
path = getPathFromID(id);
if (path.isEmpty())
continue;
}
// qDebug() << "event for path" << path;
if ((event.mask & (IN_DELETE_SELF | IN_MOVE_SELF | IN_UNMOUNT)) != 0) {
pathToID.remove(path);
idToPath.remove(id, getPathFromID(id));
if (!idToPath.contains(id))
inotify_rm_watch(inotifyFd, event.wd);
if (id < 0)
emit directoryChanged(path, true);
else
emit fileChanged(path, true);
} else {
if (id < 0)
emit directoryChanged(path, false);
else
emit fileChanged(path, false);
}
}
}
示例3: connect
Condition4DirMonitorAll::Condition4DirMonitorAll(void)
{
m_QFileSystemWatcher = new QFileSystemWatcher;
connect(m_QFileSystemWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(directoryChanged(QString)), Qt::QueuedConnection);
m_xmlEleName = "MonitorDirAll";
}
示例4: QObject
LocalFileMonitor::LocalFileMonitor(QObject *parent) :
QObject(parent)
{
this->refreshTimer.start(30000000);
this->fsWatch = new QFileSystemWatcher(this);
connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(refreshTimerEvent()));
connect(this->fsWatch, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString)));
connect(this->fsWatch, SIGNAL(directoryChanged(QString)), this, SLOT(directoryChanged(QString)));
}
示例5: ImageViewer
PicManager::PicManager(QWidget *parent)
: ImageViewer(parent), curImage(ImageFactory::getImageWrapper(QString::null)),
listMode(FileNameListMode), currentIndex(-1), fsWatcher(this)
{
// state = NoFileNoPicture;
connect(&fsWatcher, SIGNAL(directoryChanged(QString)),
SLOT(directoryChanged()));
connect(&fsWatcher, SIGNAL(fileChanged(QString)),
SLOT(fileChanged(QString)));
}
示例6: d_ptr
MFileDataStore::MFileDataStore(const QString &filePath) :
d_ptr(new MFileDataStorePrivate(filePath))
{
Q_D(MFileDataStore);
takeSnapshot();
addPathsToWatcher(filePath, d->watcher);
connect(d->watcher.data(), SIGNAL(fileChanged(QString)),
this, SLOT(fileChanged(QString)));
connect(d->watcher.data(), SIGNAL(directoryChanged(QString)),
this, SLOT(directoryChanged(QString)));
}
示例7: QAbstractListModel
ModList::ModList ( const QString& dir, const QString& list_file )
: QAbstractListModel(), m_dir(dir), m_list_file(list_file)
{
m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs | QDir::NoSymLinks);
m_dir.setSorting(QDir::Name);
m_list_id = QUuid::createUuid().toString();
m_watcher = new QFileSystemWatcher(this);
is_watching = false;
connect(m_watcher,SIGNAL(directoryChanged(QString)), this, SLOT(directoryChanged(QString)));
update();
}
示例8: connect
void MainWindow::start(bool isTrue)
{
if (isTrue) {
isStart_ = true;
pbStart_->setText(tr("Stop"));
connect(watcher_, SIGNAL(fileChanged(QString)), this, SLOT(slotFileChanged(QString)));
connect(watcher_, SIGNAL(directoryChanged(QString)), this, SLOT(slotDirectoryChanged(QString)));
Common::asyncCopy(leFrom_->text(), leTo_->text());
} else {
isStart_ = false;
pbStart_->setText(tr("Start"));
disconnect(watcher_, SIGNAL(fileChanged(QString)), this, SLOT(slotFileChanged(QString)));
disconnect(watcher_, SIGNAL(directoryChanged(QString)), this, SLOT(slotDirectoryChanged(QString)));
}
}
示例9: setupGoodExtension
void Ut_MApplicationExtensionManager::testMonitorRemoveExtension()
{
gDesktopEntryList.clear();
// Fire up a couple of extensions
gDesktopEntryList << "test1.desktop" << "test2.desktop";
gDefaultMApplicationExtensionMetaDataStub.stubSetReturnValue("isValid", true);
gDefaultMApplicationExtensionMetaDataStub.stubSetReturnValue("interface", interfaceName);
gDefaultMApplicationExtensionMetaDataStub.stubSetExtensionBinaryMultiple("test1");
gDefaultMApplicationExtensionMetaDataStub.stubSetExtensionBinaryMultiple("test2");
setupGoodExtension(true, NULL, "1st extension");
setupGoodExtension(true, NULL, "2nd extension");
setupTestSubject();
// Remove one extension from the file system
gDesktopEntryList.clear();
gDesktopEntryList << "test1.desktop";
// The test subject asks the library name from the removed meta data
gDefaultMApplicationExtensionMetaDataStub.stubSetReturnValue("extensionBinary", QString("test2"));
// Notify about a file system change
emit directoryChanged(APPLICATION_EXTENSION_DATA_DIR);
// Observe that the correct extension was removed
QCOMPARE(signalListener.removedExtensions.count(), 1);
QCOMPARE(signalListener.removedExtensions.at(0).second, QString("2nd extension"));
}
示例10: mOutDated
XdgMenuPrivate::XdgMenuPrivate(XdgMenu *parent):
mOutDated(true),
q_ptr(parent)
{
this->connect(&mWatcher, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString)));
this->connect(&mWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(fileChanged(QString)));
}
示例11: MApplicationExtensionManager
void Ut_MApplicationExtensionManager::setupTestSubject(const QString &inProcessFilter, const QString &outOfProcessFilter,
const QStringList &order)
{
delete manager;
manager = new MApplicationExtensionManager(interfaceName);
if (!inProcessFilter.isEmpty()) {
manager->setInProcessFilter(QRegExp(inProcessFilter));
}
if (!outOfProcessFilter.isEmpty()) {
manager->setOutOfProcessFilter(QRegExp(outOfProcessFilter));
}
if (!order.isEmpty()) {
manager->setOrder(order);
}
manager->init();
connect(this, SIGNAL(directoryChanged(QString)), manager, SLOT(updateAvailableExtensions(QString)));
connect(manager, SIGNAL(extensionInstantiated(MApplicationExtensionInterface *)), &signalListener, SLOT(extensionInstantiated(MApplicationExtensionInterface *)));
connect(manager, SIGNAL(extensionRemoved(MApplicationExtensionInterface *)), &signalListener, SLOT(extensionRemoved(MApplicationExtensionInterface *)));
connect(manager, SIGNAL(widgetCreated(QGraphicsWidget*, MDataStore&)), &signalListener, SLOT(widgetCreated(QGraphicsWidget*, MDataStore&)));
connect(manager, SIGNAL(widgetRemoved(QGraphicsWidget*)), &signalListener, SLOT(widgetRemoved(QGraphicsWidget*)));
connect(this,
SIGNAL(extensionChanged(
const MDesktopEntry &)),
manager,
SLOT(updateExtension(
const MDesktopEntry &)));
}
示例12: QObject
FsWatcher::FsWatcher(boost::asio::io_service& io, QString dirPath, LocalFile_Change_Callback onChange,
LocalFile_Change_Callback onDelete, QObject* parent)
: QObject(parent)
, m_watcher(new QFileSystemWatcher(this))
, m_scheduler(io)
, m_dirPath(dirPath)
, m_onChange(onChange)
, m_onDelete(onDelete)
{
_LOG_DEBUG("Monitor dir: " << m_dirPath.toStdString());
// add main directory to monitor
initFileStateDb();
m_watcher->addPath(m_dirPath);
// register signals(callback functions)
connect(m_watcher, SIGNAL(directoryChanged(QString)), this, SLOT(DidDirectoryChanged(QString)));
connect(m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(DidFileChanged(QString)));
rescheduleEvent("rescan", m_dirPath.toStdString(), time::seconds(0),
bind(&FsWatcher::ScanDirectory_NotifyUpdates_Execute, this, m_dirPath));
rescheduleEvent("rescan-r", m_dirPath.toStdString(), time::seconds(0),
bind(&FsWatcher::ScanDirectory_NotifyRemovals_Execute, this, m_dirPath));
}
示例13: QObject
Directory_watcher::Directory_watcher(Core *c) :
QObject(0)
, Core_ally(c)
{
connect(&watcher, SIGNAL(directoryChanged(QString)), this, SIGNAL(directory_changed(QString)));
fs = core->get_file_system_engine();
}
示例14: AbstractFileInfoGatherer
/*!
Creates thread
*/
RemoteFileInfoGatherer::RemoteFileInfoGatherer(QObject *parent)
: AbstractFileInfoGatherer(parent), abort(false)
#ifndef QT_NO_FILESYSTEMWATCHER
, watcher(0)
#endif
{
qDebug() << "new RemoteFileInfoGatherer";
#ifndef QT_NO_FILESYSTEMWATCHER
watcher = new QFileSystemWatcher(this);
connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(list(QString)));
connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));
# if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
const QVariant listener = watcher->property("_q_driveListener");
if (listener.canConvert<QObject *>()) {
if (QObject *driveListener = listener.value<QObject *>()) {
connect(driveListener, SIGNAL(driveAdded()), this, SLOT(driveAdded()));
connect(driveListener, SIGNAL(driveRemoved()), this, SLOT(driveRemoved()));
}
}
# endif // Q_OS_WIN && !Q_OS_WINRT
#endif
start(LowPriority);
emit initialized();
}
示例15: QRegExp
void OutputDirectory::selectDir()
{
QString dir = cDir->currentText();
QString startDir = dir;
QString params;
int i = dir.indexOf( QRegExp("%[aAbBcCdDfFgGnNpPtTyY]{1,1}") );
if( i != -1 && cMode->currentIndex() == 0 )
{
i = dir.lastIndexOf( "/", i );
startDir = dir.left( i );
params = dir.mid( i );
}
QString directory = KFileDialog::getExistingDirectory( startDir, this, i18n("Choose an output directory") );
if( !directory.isEmpty() )
{
if( i != -1 && cMode->currentIndex() == 0 )
{
cDir->setEditText( directory + params );
}
else
{
cDir->setEditText( directory );
}
emit directoryChanged( cDir->currentText() );
}
}