File indexing completed on 2024-06-02 04:34:52

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 
0013 /** this class will provide a signal when an update to object lists in
0014  * dialogs is needed.  For instance, when a new vector is added, or its
0015  * name has been changed. */
0016 
0017 #ifndef UPDATESERVER_H
0018 #define UPDATESERVER_H
0019 
0020 #include "kst_export.h"
0021 
0022 #include <QObject>
0023 
0024 namespace Kst {
0025 
0026 /** A signal is requested by a call to requestUpdateSignal.  The signal
0027  * will be emitted when the _signalSuspendDepthCounter is zero.  If multiple
0028  * signals are requested while _signalSuspendDepthCounter is non zero, only one
0029  * will be emitted.  beginSuspendSignals() increments _signalSuspendDepthCounter.
0030  * endSuspendSignals() decrements it. */
0031 class KSTCORE_EXPORT UpdateServer : public QObject
0032 {
0033     Q_OBJECT
0034   public:
0035     static UpdateServer* self();
0036     void beginSuspendSignals() {_signalSuspendDepthCounter++;}
0037     void endSuspendSignals();
0038     void requestUpdateSignal();
0039 
0040   private:
0041     UpdateServer();
0042     ~UpdateServer();
0043 
0044     static UpdateServer* _self;
0045     static void cleanup();
0046 
0047     int _signalSuspendDepthCounter;
0048     bool _signalRequested;
0049 
0050   Q_SIGNALS:
0051     void objectListsChanged();
0052 
0053   public slots:
0054 
0055 
0056 };
0057 
0058 }
0059 #endif // UPDATESERVER_H