QXRD  0.11.16
Public Slots | Public Member Functions | Private Attributes | List of all members
QcepSettingsSaver Class Reference

#include <qcepsettingssaver.h>

Inheritance diagram for QcepSettingsSaver:
Inheritance graph
[legend]
Collaboration diagram for QcepSettingsSaver:
Collaboration graph
[legend]

Public Slots

void start ()
 
void performSave ()
 
void printMessage (QString msg, QDateTime ts=QDateTime::currentDateTime())
 

Public Member Functions

 QcepSettingsSaver (QObject *owner)
 
 ~QcepSettingsSaver ()
 
void changed (QcepProperty *prop=NULL)
 

Private Attributes

QMutex m_Mutex
 
QObject * m_Owner
 
QAtomicInt m_ChangeCount
 
QTimer m_Timer
 
int m_SaveDelay
 

Detailed Description

Definition at line 12 of file qcepsettingssaver.h.

Constructor & Destructor Documentation

QcepSettingsSaver::QcepSettingsSaver ( QObject *  owner)
explicit

Definition at line 9 of file qcepsettingssaver.cpp.

References DEBUG_CONSTRUCTORS, m_Timer, performSave(), and qcepDebug().

9  :
10  QObject(),
11  m_Owner(owner),
12  m_SaveDelay(5000)
13 {
15  printf("QcepSettingsSaver::QcepSettingsSaver(%p)\n", this);
16  }
17 
18  connect(&m_Timer, SIGNAL(timeout()), this, SLOT(performSave()));
19 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26

Here is the call graph for this function:

QcepSettingsSaver::~QcepSettingsSaver ( )

Definition at line 21 of file qcepsettingssaver.cpp.

References DEBUG_CONSTRUCTORS, and qcepDebug().

22 {
24  printf("QcepSettingsSaver::~QcepSettingsSaver(%p)\n", this);
25  }
26 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26

Here is the call graph for this function:

Member Function Documentation

void QcepSettingsSaver::changed ( QcepProperty prop = NULL)

Definition at line 61 of file qcepsettingssaver.cpp.

References m_ChangeCount.

62 {
63  m_ChangeCount.fetchAndAddOrdered(1);
64 }
QAtomicInt m_ChangeCount
void QcepSettingsSaver::performSave ( )
slot

Definition at line 39 of file qcepsettingssaver.cpp.

References DEBUG_PREFS, INVOKE_CHECK, m_ChangeCount, m_Mutex, m_Owner, printMessage(), and qcepDebug().

Referenced by QcepSettingsSaver().

40 {
41  int nupdates = m_ChangeCount.fetchAndStoreOrdered(0);
42 
43  if (nupdates > 0) {
44  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
45 
46  if (qcepDebug(DEBUG_PREFS)) {
47  printMessage(tr("Settings Saver saving %1 updates").arg(nupdates));
48  }
49 
50  QTime tic;
51  tic.start();
52 
53  INVOKE_CHECK(QMetaObject::invokeMethod(m_Owner, "writeSettings", Qt::DirectConnection));
54 
55  if (qcepDebug(DEBUG_PREFS)) {
56  printMessage(tr("Saving settings took %1 msec").arg(tic.elapsed()));
57  }
58  }
59 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QAtomicInt m_ChangeCount
void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime())
#define INVOKE_CHECK(res)
Definition: qcepmacros.h:13

Here is the call graph for this function:

Here is the caller graph for this function:

void QcepSettingsSaver::printMessage ( QString  msg,
QDateTime  ts = QDateTime::currentDateTime() 
)
slot

Definition at line 66 of file qcepsettingssaver.cpp.

References INVOKE_CHECK, and m_Owner.

Referenced by performSave().

67 {
68  INVOKE_CHECK(QMetaObject::invokeMethod(m_Owner, "printMessage", Q_ARG(QString, msg), Q_ARG(QDateTime, ts)));
69 }
#define INVOKE_CHECK(res)
Definition: qcepmacros.h:13

Here is the caller graph for this function:

void QcepSettingsSaver::start ( )
slot

Definition at line 28 of file qcepsettingssaver.cpp.

References INVOKE_CHECK, m_SaveDelay, and m_Timer.

29 {
30  if (QThread::currentThread() != thread()) {
31  INVOKE_CHECK(QMetaObject::invokeMethod(this, "start"));
32  } else {
33  m_Timer.setSingleShot(false);
34 
35  m_Timer.start(m_SaveDelay);
36  }
37 }
#define INVOKE_CHECK(res)
Definition: qcepmacros.h:13

Member Data Documentation

QAtomicInt QcepSettingsSaver::m_ChangeCount
private

Definition at line 29 of file qcepsettingssaver.h.

Referenced by changed(), and performSave().

QMutex QcepSettingsSaver::m_Mutex
private

Definition at line 27 of file qcepsettingssaver.h.

Referenced by performSave().

QObject* QcepSettingsSaver::m_Owner
private

Definition at line 28 of file qcepsettingssaver.h.

Referenced by performSave(), and printMessage().

int QcepSettingsSaver::m_SaveDelay
private

Definition at line 31 of file qcepsettingssaver.h.

Referenced by start().

QTimer QcepSettingsSaver::m_Timer
private

Definition at line 30 of file qcepsettingssaver.h.

Referenced by QcepSettingsSaver(), and start().


The documentation for this class was generated from the following files: