From: Max Waterman Date: Sun, 16 May 2010 14:05:51 +0000 (+0300) Subject: Changes: removed locations singleton. X-Git-Url: http://vcs.maemo.org/git/?p=ptas;a=commitdiff_plain;h=5789808b3e0c9a6a1d779270ecfbf0854f4d1b1e Changes: removed locations singleton. --- diff --git a/zouba/src/gpscontroller_p.cpp b/zouba/src/gpscontroller_p.cpp index 831aacf..41086b0 100644 --- a/zouba/src/gpscontroller_p.cpp +++ b/zouba/src/gpscontroller_p.cpp @@ -63,8 +63,8 @@ Location *GpsControllerPrivate::liveLocation() Location *GpsControllerPrivate::fakeLocation() { - Locations *locations = Locations::instance(); - Location *location = locations->location( fakeLocationLabel() ); + Locations locations; + Location *location = locations.location( fakeLocationLabel() ); m_mostRecentlyReportedLocation = location; return location; } diff --git a/zouba/src/locations.cpp b/zouba/src/locations.cpp index 04cf6ab..358a2cc 100644 --- a/zouba/src/locations.cpp +++ b/zouba/src/locations.cpp @@ -8,26 +8,24 @@ #include QHash Locations::locationHash; -Locations Locations::singleton; +bool Locations::initialised = false; Locations::Locations() { - QCoreApplication::setOrganizationName("ZouBa"); - QCoreApplication::setOrganizationDomain("zouba.yi.org"); - QCoreApplication::setOrganizationName("ZouBa"); - - restoreLocations(); + if ( !initialised ) { + QCoreApplication::setOrganizationName("ZouBa"); + QCoreApplication::setOrganizationDomain("zouba.yi.org"); + QCoreApplication::setOrganizationName("ZouBa"); + + restoreLocations(); + initialised = true; + } } Locations::~Locations() { } -Locations *Locations::instance() -{ - return &singleton; -} - bool Locations::addLocation( Location *location ) { bool succeeded=false; diff --git a/zouba/src/locations.h b/zouba/src/locations.h index 40f8be0..fa74faa 100644 --- a/zouba/src/locations.h +++ b/zouba/src/locations.h @@ -26,7 +26,7 @@ public Q_SLOTS: private: void restoreLocations(); static QHash locationHash; - static Locations singleton; + static bool initialised; void saveLocation( Location *location ); }; diff --git a/zouba/src/ui.cpp b/zouba/src/ui.cpp index 8e269c1..ee18f3a 100644 --- a/zouba/src/ui.cpp +++ b/zouba/src/ui.cpp @@ -147,8 +147,8 @@ void Ui::useLiveGps() void Ui::setAddress( const QString &label ) { - Locations *locations=Locations::instance(); - Location *location=locations->location( label ); + Locations locations; + Location *location=locations.location( label ); bool ok; QString address = QInputDialog::getText( @@ -162,8 +162,8 @@ void Ui::setAddress( const QString &label ) if ( ok ) { qDebug() << "new address" << address; - Locations *locations = Locations::instance(); - Location *location = locations->location( label ); + Locations locations; + Location *location = locations.location( label ); qDebug() << "location" << location; if ( location ) { location->resolveAddress( address ); diff --git a/zouba/src/uicontroller.cpp b/zouba/src/uicontroller.cpp index 333a1d8..8365378 100644 --- a/zouba/src/uicontroller.cpp +++ b/zouba/src/uicontroller.cpp @@ -20,20 +20,20 @@ UiController::UiController( Ui *ui ) : m_currentDestination(-1), m_currentRoute(-1) { - Locations *locations = Locations::instance(); - Location *homeLocation = locations->location( "home" ); - Location *workLocation = locations->location( "work" ); + Locations locations; + Location *homeLocation = locations.location( "home" ); + Location *workLocation = locations.location( "work" ); if ( homeLocation==0 ) { homeLocation = new Location( "home" ); - locations->addLocation( homeLocation ); + locations.addLocation( homeLocation ); } else if ( homeLocation->isValid() ) { setHomeButtonValid(); } if ( workLocation==0 ) { workLocation = new Location( "work" ); - locations->addLocation( workLocation ); + locations.addLocation( workLocation ); } else if ( workLocation->isValid() ) { setWorkButtonValid(); } @@ -48,7 +48,7 @@ UiController::UiController( Ui *ui ) : ); connect( homeLocation, SIGNAL( becomeValid() ), - locations, SLOT( saveLocation() ) + &locations, SLOT( saveLocation() ) ); connect( homeLocation, SIGNAL( busy( bool ) ), @@ -65,7 +65,7 @@ UiController::UiController( Ui *ui ) : ); connect( workLocation, SIGNAL( becomeValid() ), - locations, SLOT( saveLocation() ) + &locations, SLOT( saveLocation() ) ); connect( workLocation, SIGNAL( busy( bool ) ), diff --git a/zouba/tests/ut_gpscontroller/Makefile b/zouba/tests/ut_gpscontroller/Makefile deleted file mode 100644 index 0cf86ed..0000000 --- a/zouba/tests/ut_gpscontroller/Makefile +++ /dev/null @@ -1,299 +0,0 @@ -############################################################################# -# Makefile for building: ut_gpscontroller -# Generated by qmake (2.01a) (Qt 4.6.2) on: Sun Apr 25 07:10:29 2010 -# Project: ut_gpscontroller.pro -# Template: app -# Command: /usr/bin/qmake -unix -o Makefile ut_gpscontroller.pro -############################################################################# - -####### Compiler, tools and options - -CC = gcc -CXX = g++ -DEFINES = -DQT_GL_NO_SCISSOR_TEST -DQT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH=1024 -DQT_MAEMO5_LIB -DQT_TESTLIB_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -CFLAGS = -pipe -g -D_REENTRANT -Wall -W $(DEFINES) -CXXFLAGS = -pipe -g -D_REENTRANT -Wall -W $(DEFINES) -INCPATH = -I/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/linux-g++-maemo5 -I. -I/targets/FREMANTLE_ARMEL/usr/include/QtCore -I/targets/FREMANTLE_ARMEL/usr/include/QtNetwork -I/targets/FREMANTLE_ARMEL/usr/include/QtGui -I/targets/FREMANTLE_ARMEL/usr/include/QtTest -I/targets/FREMANTLE_ARMEL/usr/include/QtMaemo5 -I/targets/FREMANTLE_ARMEL/usr/include -I../../src -I. -LINK = g++ -LFLAGS = -Wl,-rpath-link,/usr/lib -Wl,-rpath,/usr/lib -LIBS = $(SUBLIBS) -L/usr/lib /usr/lib/libQtLocation.so -lQtMaemo5 -L/usr/lib -L/usr/X11R6/lib -lQtTest -lQtGui -lQtNetwork -lQtDBus -lQtXml -lQtCore -lpthread -AR = ar cqs -RANLIB = -QMAKE = /usr/bin/qmake -TAR = tar -cf -COMPRESS = gzip -9f -COPY = cp -f -SED = sed -COPY_FILE = $(COPY) -COPY_DIR = $(COPY) -r -STRIP = strip -INSTALL_FILE = install -m 644 -p -INSTALL_DIR = $(COPY_DIR) -INSTALL_PROGRAM = install -m 755 -p -DEL_FILE = rm -f -SYMLINK = ln -f -s -DEL_DIR = rmdir -MOVE = mv -f -CHK_DIR_EXISTS= test -d -MKDIR = mkdir -p - -####### Output directory - -OBJECTS_DIR = ./ - -####### Files - -SOURCES = ut_gpscontroller.cpp \ - ../../src/gpscontroller.cpp \ - ../../src/gpscontroller_p.cpp \ - ../../src/locations.cpp \ - ../../src/location.cpp \ - ../../src/location_p.cpp moc_ut_gpscontroller.cpp \ - moc_gpscontroller.cpp \ - moc_gpscontroller_p.cpp \ - moc_locations.cpp \ - moc_location.cpp \ - moc_location_p.cpp -OBJECTS = ut_gpscontroller.o \ - gpscontroller.o \ - gpscontroller_p.o \ - locations.o \ - location.o \ - location_p.o \ - moc_ut_gpscontroller.o \ - moc_gpscontroller.o \ - moc_gpscontroller_p.o \ - moc_locations.o \ - moc_location.o \ - moc_location_p.o -DIST = /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/common/unix.conf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/common/linux.conf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/qconfig.pri \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt_functions.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt_config.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/exclusive_builds.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/default_pre.prf \ - ../tests.pri \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/debug.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/default_post.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/unix/thread.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/moc.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/warn_on.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/resources.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/uic.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/yacc.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/lex.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/include_source_dir.prf \ - ut_gpscontroller.pro -QMAKE_TARGET = ut_gpscontroller -DESTDIR = -TARGET = ut_gpscontroller - -first: all -####### Implicit rules - -.SUFFIXES: .o .c .cpp .cc .cxx .C - -.cpp.o: - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" - -.cc.o: - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" - -.cxx.o: - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" - -.C.o: - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" - -.c.o: - $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" - -####### Build rules - -all: Makefile $(TARGET) - -$(TARGET): $(OBJECTS) - $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) - -Makefile: ut_gpscontroller.pro /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/linux-g++-maemo5/qmake.conf /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/common/unix.conf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/common/linux.conf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/qconfig.pri \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt_functions.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt_config.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/exclusive_builds.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/default_pre.prf \ - ../tests.pri \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/debug.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/default_post.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/unix/thread.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/moc.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/warn_on.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/resources.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/uic.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/yacc.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/lex.prf \ - /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/include_source_dir.prf \ - /usr/lib/libQtMaemo5.prl \ - /usr/lib/libQtDBus.prl \ - /usr/lib/libQtXml.prl \ - /usr/lib/libQtCore.prl \ - /usr/lib/libQtGui.prl \ - /usr/lib/libQtTest.prl \ - /usr/lib/libQtNetwork.prl - $(QMAKE) -unix -o Makefile ut_gpscontroller.pro -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/common/unix.conf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/common/linux.conf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/qconfig.pri: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt_functions.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt_config.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/exclusive_builds.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/default_pre.prf: -../tests.pri: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/debug.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/default_post.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/unix/thread.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/moc.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/warn_on.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/resources.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/uic.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/yacc.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/lex.prf: -/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/include_source_dir.prf: -/usr/lib/libQtMaemo5.prl: -/usr/lib/libQtDBus.prl: -/usr/lib/libQtXml.prl: -/usr/lib/libQtCore.prl: -/usr/lib/libQtGui.prl: -/usr/lib/libQtTest.prl: -/usr/lib/libQtNetwork.prl: -qmake: FORCE - @$(QMAKE) -unix -o Makefile ut_gpscontroller.pro - -dist: - @$(CHK_DIR_EXISTS) .tmp/ut_gpscontroller1.0.0 || $(MKDIR) .tmp/ut_gpscontroller1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/ut_gpscontroller1.0.0/ && $(COPY_FILE) --parents ut_gpscontroller.h ../../src/gpscontroller.h ../../src/gpscontroller_p.h ../../src/locations.h ../../src/location.h ../../src/location_p.h .tmp/ut_gpscontroller1.0.0/ && $(COPY_FILE) --parents ut_gpscontroller.cpp ../../src/gpscontroller.cpp ../../src/gpscontroller_p.cpp ../../src/locations.cpp ../../src/location.cpp ../../src/location_p.cpp .tmp/ut_gpscontroller1.0.0/ && (cd `dirname .tmp/ut_gpscontroller1.0.0` && $(TAR) ut_gpscontroller1.0.0.tar ut_gpscontroller1.0.0 && $(COMPRESS) ut_gpscontroller1.0.0.tar) && $(MOVE) `dirname .tmp/ut_gpscontroller1.0.0`/ut_gpscontroller1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/ut_gpscontroller1.0.0 - - -clean:compiler_clean - -$(DEL_FILE) $(OBJECTS) - -$(DEL_FILE) *~ core *.core - - -####### Sub-libraries - -distclean: clean - -$(DEL_FILE) $(TARGET) - -$(DEL_FILE) Makefile - - -check: ut_gpscontroller - ./ut_gpscontroller - -mocclean: compiler_moc_header_clean compiler_moc_source_clean - -mocables: compiler_moc_header_make_all compiler_moc_source_make_all - -compiler_moc_header_make_all: moc_ut_gpscontroller.cpp moc_gpscontroller.cpp moc_gpscontroller_p.cpp moc_locations.cpp moc_location.cpp moc_location_p.cpp -compiler_moc_header_clean: - -$(DEL_FILE) moc_ut_gpscontroller.cpp moc_gpscontroller.cpp moc_gpscontroller_p.cpp moc_locations.cpp moc_location.cpp moc_location_p.cpp -moc_ut_gpscontroller.cpp: ut_gpscontroller.h - /usr/bin/moc $(DEFINES) $(INCPATH) ut_gpscontroller.h -o moc_ut_gpscontroller.cpp - -moc_gpscontroller.cpp: ../../src/location.h \ - ../../src/location_p.h \ - ../../src/gpscontroller_p.h \ - ../../src/gpscontroller.h - /usr/bin/moc $(DEFINES) $(INCPATH) ../../src/gpscontroller.h -o moc_gpscontroller.cpp - -moc_gpscontroller_p.cpp: ../../src/gpscontroller_p.h - /usr/bin/moc $(DEFINES) $(INCPATH) ../../src/gpscontroller_p.h -o moc_gpscontroller_p.cpp - -moc_locations.cpp: ../../src/location.h \ - ../../src/location_p.h \ - ../../src/locations.h - /usr/bin/moc $(DEFINES) $(INCPATH) ../../src/locations.h -o moc_locations.cpp - -moc_location.cpp: ../../src/location_p.h \ - ../../src/location.h - /usr/bin/moc $(DEFINES) $(INCPATH) ../../src/location.h -o moc_location.cpp - -moc_location_p.cpp: ../../src/location_p.h - /usr/bin/moc $(DEFINES) $(INCPATH) ../../src/location_p.h -o moc_location_p.cpp - -compiler_rcc_make_all: -compiler_rcc_clean: -compiler_image_collection_make_all: qmake_image_collection.cpp -compiler_image_collection_clean: - -$(DEL_FILE) qmake_image_collection.cpp -compiler_moc_source_make_all: -compiler_moc_source_clean: -compiler_uic_make_all: -compiler_uic_clean: -compiler_yacc_decl_make_all: -compiler_yacc_decl_clean: -compiler_yacc_impl_make_all: -compiler_yacc_impl_clean: -compiler_lex_make_all: -compiler_lex_clean: -compiler_clean: compiler_moc_header_clean - -####### Compile - -ut_gpscontroller.o: ut_gpscontroller.cpp ut_gpscontroller.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ut_gpscontroller.o ut_gpscontroller.cpp - -gpscontroller.o: ../../src/gpscontroller.cpp ../../src/gpscontroller.h \ - ../../src/location.h \ - ../../src/location_p.h \ - ../../src/gpscontroller_p.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o gpscontroller.o ../../src/gpscontroller.cpp - -gpscontroller_p.o: ../../src/gpscontroller_p.cpp ../../src/gpscontroller_p.h \ - ../../src/location.h \ - ../../src/location_p.h \ - ../../src/locations.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o gpscontroller_p.o ../../src/gpscontroller_p.cpp - -locations.o: ../../src/locations.cpp ../../src/locations.h \ - ../../src/location.h \ - ../../src/location_p.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o locations.o ../../src/locations.cpp - -location.o: ../../src/location.cpp ../../src/location.h \ - ../../src/location_p.h \ - ../../src/ytv.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o location.o ../../src/location.cpp - -location_p.o: ../../src/location_p.cpp ../../src/location_p.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o location_p.o ../../src/location_p.cpp - -moc_ut_gpscontroller.o: moc_ut_gpscontroller.cpp - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_ut_gpscontroller.o moc_ut_gpscontroller.cpp - -moc_gpscontroller.o: moc_gpscontroller.cpp - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_gpscontroller.o moc_gpscontroller.cpp - -moc_gpscontroller_p.o: moc_gpscontroller_p.cpp - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_gpscontroller_p.o moc_gpscontroller_p.cpp - -moc_locations.o: moc_locations.cpp - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_locations.o moc_locations.cpp - -moc_location.o: moc_location.cpp - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_location.o moc_location.cpp - -moc_location_p.o: moc_location_p.cpp - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_location_p.o moc_location_p.cpp - -####### Install - -install: FORCE - -uninstall: FORCE - -FORCE: - diff --git a/zouba/tests/ut_gpscontroller/ut_gpscontroller b/zouba/tests/ut_gpscontroller/ut_gpscontroller deleted file mode 100755 index 995b503..0000000 Binary files a/zouba/tests/ut_gpscontroller/ut_gpscontroller and /dev/null differ