added a test that watches test/testfile which can be given the browser as bookmark file - it work's; refs https://dev.swisssign.com/projects/swissstick/ticket/980; refs #150
This commit is contained in:
@@ -17,7 +17,7 @@ dnl refers to ${prefix}. Thus we have to use `eval' twice.
|
|||||||
|
|
||||||
AC_INIT([README])
|
AC_INIT([README])
|
||||||
SRC_DIR=src
|
SRC_DIR=src
|
||||||
TST_DIR=
|
TST_DIR=test
|
||||||
DOC_DIR=doc
|
DOC_DIR=doc
|
||||||
|
|
||||||
m4_define(x_packagename, swissbrowser)
|
m4_define(x_packagename, swissbrowser)
|
||||||
@@ -43,6 +43,7 @@ AM_INIT_AUTOMAKE($PACKAGENAME, $MAJOR.$MINOR.$LEAST, [marc.waeckerlin@tech.swiss
|
|||||||
|
|
||||||
# files to create
|
# files to create
|
||||||
AC_CONFIG_FILES([makefile ${PACKAGENAME}.spec src/version.cxx
|
AC_CONFIG_FILES([makefile ${PACKAGENAME}.spec src/version.cxx
|
||||||
|
test/makefile test/qmake.pro
|
||||||
src/makefile
|
src/makefile
|
||||||
src/qmake.pro src/languages.qrc
|
src/qmake.pro src/languages.qrc
|
||||||
src/qbrowserlib/makefile
|
src/qbrowserlib/makefile
|
||||||
|
@@ -81,8 +81,14 @@ class FileStorage: public Storage {
|
|||||||
}
|
}
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void setupWatcher() {
|
void setupWatcher() {
|
||||||
_watcher.removePaths(_watcher.files());
|
bool watching(_watcher.files().size());
|
||||||
if (readable()) _watcher.addPath(_file.fileName());
|
if (watching) // remove watchlist if already existent
|
||||||
|
_watcher.removePaths(_watcher.files());
|
||||||
|
if (readable()) { // add file to watchlist
|
||||||
|
_watcher.addPath(_file.fileName());
|
||||||
|
if (!watching) // send change event if file is initially created
|
||||||
|
changed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
QFile _file;
|
QFile _file;
|
||||||
|
16
test/filewatch.cxx
Normal file
16
test/filewatch.cxx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/*! @file
|
||||||
|
|
||||||
|
@id $Id$
|
||||||
|
*/
|
||||||
|
// 1 2 3 4 5 6 7 8
|
||||||
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||||
|
|
||||||
|
#include <filewatch.hxx>
|
||||||
|
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
QCoreApplication app(argc, argv);
|
||||||
|
TestFileWatch test("testfile");
|
||||||
|
return app.exec();
|
||||||
|
}
|
24
test/filewatch.hxx
Normal file
24
test/filewatch.hxx
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/*! @file
|
||||||
|
|
||||||
|
@id $Id$
|
||||||
|
*/
|
||||||
|
// 1 2 3 4 5 6 7 8
|
||||||
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||||
|
|
||||||
|
#include <qbrowserlib/filestorage.hxx>
|
||||||
|
|
||||||
|
#include<QtCore/QDebug>
|
||||||
|
|
||||||
|
class TestFileWatch: public QObject {
|
||||||
|
Q_OBJECT;
|
||||||
|
public:
|
||||||
|
TestFileWatch(QString file): _storage(file) {
|
||||||
|
assert(connect(&_storage, SIGNAL(changed()), SLOT(changed())));
|
||||||
|
}
|
||||||
|
private Q_SLOTS:
|
||||||
|
void changed() {
|
||||||
|
qDebug()<<"File has changed: "<<_storage.read().join("; ");
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
FileStorage _storage;
|
||||||
|
};
|
30
test/makefile.am
Normal file
30
test/makefile.am
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
## @id $Id$
|
||||||
|
|
||||||
|
## 1 2 3 4 5 6 7 8
|
||||||
|
## 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||||
|
|
||||||
|
# noinst_PROGRAMS = filewatch
|
||||||
|
|
||||||
|
# filewatch_SOURCES = filewatch.cxx
|
||||||
|
# filewatch_CPPFLAGS = -I${top_srcdir}/src
|
||||||
|
# filewatch_LDFLAGS = -L${top_builddir}/src/qbrowserlib
|
||||||
|
# filewatch_LDADD = -lqbrowserlib
|
||||||
|
|
||||||
|
QMAKE_TARGETS = filewatch
|
||||||
|
QMAKE_PROJECT = qmake.pro
|
||||||
|
QMAKE_MAKEFILE = makefile.qmake
|
||||||
|
TARGETS = ${QMAKE_TARGETS}
|
||||||
|
|
||||||
|
all: ${TARGETS}
|
||||||
|
|
||||||
|
${QMAKE_MAKEFILE}: ${QMAKE_PROJECT} ${ALL_SRC}
|
||||||
|
${QMAKE} -o $@ $<
|
||||||
|
|
||||||
|
${QMAKE_TARGETS}: ${QMAKE_MAKEFILE} ${ALL_SRC} $(LANGS:%=@PACKAGENAME@_%.qm)
|
||||||
|
make -f ${QMAKE_MAKEFILE}
|
||||||
|
|
||||||
|
CLEANFILES = ${TARGETS} ${TARGETS:%=%.exe} \
|
||||||
|
*.o *.obj qrc_*.cpp ui_*.h moc_*.cpp \
|
||||||
|
${QMAKE_TARGETS} .deps
|
||||||
|
MAINTAINERCLEANFILES = makefile.in ${QMAKE_MAKEFILE}
|
||||||
|
|
11
test/qmake.pro.in
Normal file
11
test/qmake.pro.in
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
QMAKE_INCDIR += @top_srcdir@/src
|
||||||
|
QMAKE_LIBDIR += @top_builddir@/src/qbrowserlib
|
||||||
|
QMAKE_LIBDIR += @top_builddir@/src/qbrowserlib/release
|
||||||
|
QMAKE_LIBS += -lqbrowserlib
|
||||||
|
|
||||||
|
HEADERS = @srcdir@/filewatch.hxx
|
||||||
|
|
||||||
|
SOURCES = @srcdir@/filewatch.cxx
|
||||||
|
|
||||||
|
TARGET = filewatch
|
||||||
|
|
Reference in New Issue
Block a user