File indexing completed on 2024-12-22 04:17:23

0001 /***************************************************************************
0002  *                                                                         *
0003  *   copyright : (C) 2013 C. Barth Netterfield                             *
0004  *                   netterfield@astro.utoronto.ca                         *
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  ***************************************************************************/
0012 #include "updateserver.h"
0013 #include <qapplication.h>
0014 
0015 namespace Kst {
0016 
0017 UpdateServer *UpdateServer::_self = UpdateServer::self();
0018 
0019 
0020 UpdateServer* UpdateServer::self() {
0021   if (!_self) {
0022     _self = new UpdateServer;
0023     qAddPostRoutine(UpdateServer::cleanup);
0024   }
0025   return _self;
0026 }
0027 
0028 
0029 void UpdateServer::cleanup() {
0030     delete _self;
0031     _self = 0;
0032 }
0033 
0034 UpdateServer::UpdateServer(): _signalSuspendDepthCounter(0) {
0035 
0036 }
0037 
0038 UpdateServer::~UpdateServer() {
0039 }
0040 
0041 
0042 void UpdateServer::endSuspendSignals() {
0043   if (_signalSuspendDepthCounter>0) {
0044     _signalSuspendDepthCounter--;
0045   }
0046   if (_signalRequested) {
0047     requestUpdateSignal();
0048   }
0049 }
0050 
0051 void UpdateServer::requestUpdateSignal() {
0052   if (_signalSuspendDepthCounter==0) {
0053     emit objectListsChanged();
0054     _signalRequested = false;
0055   } else {
0056     _signalRequested = true;
0057   }
0058 }
0059 
0060 }