QXRD  0.11.16
qxrdglobalpreferencesdialog.cpp
Go to the documentation of this file.
1 #include "qxrddebug.h"
3 #include "ui_qxrdglobalpreferencesdialog.h"
4 #include "qxrdapplication.h"
5 #include "qcepallocator.h"
6 #include <stdio.h>
7 
9  QDialog(parent),
10  m_Application(app)
11 {
13  printf("QxrdGlobalPreferencesDialog::QxrdGlobalPreferencesDialog(%p)\n", this);
14  }
15 
16  setupUi(this);
17 
18 // m_OpenDirectly -> setChecked(m_Application->get_OpenDirectly());
19  m_RecentExperimentsSize -> setValue(m_Application->get_RecentExperimentsSize());
20 
21  qint64 debugLevel = m_Application -> get_Debug();
22 
24 
25  if (alloc) {
26  m_ReservedMemory32 -> setRange(500, 3000);
27  m_ReservedMemory32 -> setValue(alloc->get_TotalBufferSizeMB32());
28  m_ReservedMemory64 -> setRange(500, 60000);
29  m_ReservedMemory64 -> setValue(alloc->get_TotalBufferSizeMB64());
30  m_ExtraReservedMemory -> setRange(0, 500);
31  m_ExtraReservedMemory -> setValue(alloc->get_Reserve());
32  }
33 
34  m_FileBrowserLimit -> setValue(m_Application->get_FileBrowserLimit());
35 
36  m_MessageWindowLines -> setValue(m_Application->get_MessageWindowLines());
37  m_UpdateIntervalMsec -> setValue(m_Application->get_UpdateIntervalMsec());
38 
39  setupDebugWidgets(debugLevel);
40 }
41 
43 {
45  printf("QxrdGlobalPreferencesDialog::~QxrdGlobalPreferencesDialog(%p)\n", this);
46  }
47 }
48 
50 {
51  QDialog::changeEvent(e);
52  switch (e->type()) {
53  case QEvent::LanguageChange:
54  retranslateUi(this);
55  break;
56  default:
57  break;
58  }
59 }
60 
62 {
63  qint64 debugLevel = readDebugWidgets();
64 
65 // m_Application -> set_OpenDirectly(m_OpenDirectly->isChecked());
66  m_Application -> set_RecentExperimentsSize(m_RecentExperimentsSize->value());
67 
68  int bufferSize32 = m_ReservedMemory32 -> value();
69  int bufferSize64 = m_ReservedMemory64 -> value();
70  int extraReserve = m_ExtraReservedMemory -> value();
71 
72 
73  m_Application -> set_Debug(debugLevel);
74 
76 
77  if (alloc) {
78  alloc -> set_TotalBufferSizeMB32(bufferSize32);
79  alloc -> set_TotalBufferSizeMB64(bufferSize64);
80  alloc -> set_Reserve(extraReserve);
81  }
82 
83  m_Application -> set_FileBrowserLimit(m_FileBrowserLimit->value());
84  m_Application -> set_MessageWindowLines(m_MessageWindowLines -> value());
85  m_Application -> set_UpdateIntervalMsec(m_UpdateIntervalMsec -> value());
86 
87  QDialog::accept();
88 }
89 
91 {
92  if (g_DebugLevel == NULL) {
93  printf("g_DebugLevel == NULL in QxrdGlobalPreferencesDialog::setupDebugWidgets\n");
94  } else {
95  QGridLayout *grid = new QGridLayout(m_DebugWidgets);
96 
97  for (int i=0; i<64; i++) {
98  qint64 mask=((qint64)1)<<i;
99  QString msg = g_DebugLevel->message(i);
100 
101  if (msg.length() > 0) {
102  QCheckBox *cb = new QCheckBox(msg);
103  cb->setChecked(dbg & mask);
104 
105  m_DebugWidgetList.append(cb);
106  } else {
107  break;
108  }
109  }
110 
111  int ndebug = m_DebugWidgetList.count();
112  int ncol = ndebug - ndebug/2;
113 
114  for (int i=0; i<ndebug; i++) {
115  QCheckBox *cb = m_DebugWidgetList[i];
116 
117  if (i < ncol) {
118  grid->addWidget(cb, i, 0);
119  } else {
120  grid->addWidget(cb, i - ncol, 1);
121  }
122  }
123  }
124 }
125 
127 {
128  qint64 mask = 1;
129  qint64 newDbg = 0;
130  int ndebug = m_DebugWidgetList.count();
131 
132  for (int i=0; i<ndebug; i++) {
133  if (m_DebugWidgetList[i]->isChecked()) {
134  newDbg |= mask;
135  }
136 
137  mask <<= 1;
138  }
139 
140  return newDbg;
141 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QVector< QCheckBox * > m_DebugWidgetList
QxrdGlobalPreferencesDialog(QxrdApplication *app, QWidget *parent=0)
QSharedPointer< QcepDebugDictionary > g_DebugLevel
Definition: qcepdebug.cpp:4
QSharedPointer< QcepAllocator > QcepAllocatorPtr
QcepAllocatorWPtr allocator() const