mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
72 lines
2.3 KiB
C++
72 lines
2.3 KiB
C++
/* This file is part of the KDE libraries
|
|
Copyright 1998 Sven Radej <sven@lisa.exp.univie.ac.at>
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Library General Public
|
|
License version 2 as published by the Free Software Foundation.
|
|
|
|
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 "kdirwatchtest.h"
|
|
|
|
#include <QtCore/QCoreApplication>
|
|
#include <QtCore/QFile>
|
|
|
|
#include <kdebug.h>
|
|
#include <kcmdlineargs.h>
|
|
|
|
int main (int argc, char **argv)
|
|
{
|
|
KCmdLineOptions options;
|
|
options.add("+[directory ...]", ki18n("Directory(ies) to watch"));
|
|
|
|
KCmdLineArgs::init(argc, argv, "kdirwatchtest", 0, ki18n("KDirWatchTest"),
|
|
"1.0", ki18n("Test for KDirWatch"));
|
|
KCmdLineArgs::addCmdLineOptions( options );
|
|
KCmdLineArgs::addStdCmdLineOptions();
|
|
|
|
QCoreApplication a(argc, argv);
|
|
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
|
|
|
myTest testObject;
|
|
|
|
KDirWatch *dirwatch1 = KDirWatch::self();
|
|
KDirWatch *dirwatch2 = new KDirWatch;
|
|
|
|
testObject.connect(dirwatch1, SIGNAL(dirty(QString)), SLOT(dirty(QString)) );
|
|
testObject.connect(dirwatch1, SIGNAL(created(QString)), SLOT(created(QString)) );
|
|
testObject.connect(dirwatch1, SIGNAL(deleted(QString)), SLOT(deleted(QString)) );
|
|
|
|
if (args->count() >0) {
|
|
for(int i = 0; i < args->count(); i++) {
|
|
kDebug() << "Watching: " << args->arg(i);
|
|
dirwatch2->addDir( args->arg(i));
|
|
}
|
|
}
|
|
|
|
QString home = QString(getenv ("HOME")) + '/';
|
|
QString desk = home + "Desktop/";
|
|
kDebug() << "Watching: " << home;
|
|
dirwatch1->addDir(home);
|
|
kDebug() << "Watching file: " << home << "foo ";
|
|
dirwatch1->addFile(home+"foo");
|
|
kDebug() << "Watching: " << desk;
|
|
dirwatch1->addDir(desk);
|
|
QString test = home + "test/";
|
|
kDebug() << "Watching: (but skipped) " << test;
|
|
dirwatch1->addDir(test);
|
|
|
|
delete dirwatch2;
|
|
|
|
return a.exec();
|
|
}
|
|
#include "moc_kdirwatchtest.cpp"
|