19#include "kivio_protection_panel.h"
20#include "kivio_protection_panel.moc"
23#include "kivio_layer.h"
24#include "kivio_page.h"
25#include "kivio_stencil.h"
26#include "kivio_view.h"
27#include "kivio_command.h"
29#include <tqbitarray.h>
30#include <tqcheckbox.h>
35KivioProtectionPanel::KivioProtectionPanel( KivioView *view, TQWidget *parent,
const char *name )
36 : KivioProtectionPanelBase(parent, name), m_pView(view)
38 TQObject::connect( m_checkWidth, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togWidth(
bool)) );
39 TQObject::connect( m_checkHeight, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togHeight(
bool)) );
40 TQObject::connect( m_checkAspect, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togAspect(
bool)) );
41 TQObject::connect( m_checkDeletion, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togDelete(
bool)) );
42 TQObject::connect( m_checkXPosition, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togX(
bool)) );
43 TQObject::connect( m_checkYPosition, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togY(
bool)) );
46KivioProtectionPanel::~KivioProtectionPanel()
50void KivioProtectionPanel::togWidth(
bool on)
52 KivioStencil* pStencil = m_pView->activePage()->selectedStencils()->first();
53 KMacroCommand * macro =
new KMacroCommand(i18n(
"Change Protection Attribute"));
54 bool createMacro =
false;
57 if(pStencil->canProtect()->at(kpWidth) ==
true) {
58 KivioChangeStencilProtectCommand* cmd =
new KivioChangeStencilProtectCommand(i18n(
"Change Protection Attribute"),
59 m_pView->activePage(), pStencil, on, KivioChangeStencilProtectCommand::KV_WIDTH);
60 macro->addCommand(cmd);
63 kdDebug(43000) <<
"Attempt to set width-protection of a stencil which does not support it.\n";
66 pStencil = m_pView->activePage()->selectedStencils()->next();
71 m_pView->doc()->addCommand(macro);
77void KivioProtectionPanel::togHeight(
bool on)
79 KMacroCommand* macro =
new KMacroCommand(i18n(
"Change Protection Attribute"));
80 bool createMacro =
false;
81 KivioStencil* pStencil = m_pView->activePage()->selectedStencils()->first();
84 if(pStencil->canProtect()->at(kpHeight) ==
true) {
85 KivioChangeStencilProtectCommand* cmd =
new KivioChangeStencilProtectCommand(i18n(
"Change Protection Attribute"),
86 m_pView->activePage(), pStencil, on, KivioChangeStencilProtectCommand::KV_HEIGHT);
87 macro->addCommand(cmd);
90 kdDebug(43000) <<
"Attempt to set height-protection of a stencil which does not support it.\n";
93 pStencil = m_pView->activePage()->selectedStencils()->next();
98 m_pView->doc()->addCommand(macro);
104void KivioProtectionPanel::togAspect(
bool on)
106 KMacroCommand* macro =
new KMacroCommand(i18n(
"Change Protection Attribute"));
107 bool createMacro =
false;
108 KivioStencil* pStencil = m_pView->activePage()->selectedStencils()->first();
111 if(pStencil->canProtect()->at(kpAspect) ==
true) {
112 KivioChangeStencilProtectCommand* cmd =
new KivioChangeStencilProtectCommand(i18n(
"Change Protection Attribute"),
113 m_pView->activePage(), pStencil, on, KivioChangeStencilProtectCommand::KV_ASPECT);
114 macro->addCommand(cmd);
117 kdDebug(43000) <<
"Attempt to set height-protection of a stencil which does not support it.\n";
120 pStencil = m_pView->activePage()->selectedStencils()->next();
125 m_pView->doc()->addCommand(macro);
131void KivioProtectionPanel::togDelete(
bool on)
133 KMacroCommand * macro =
new KMacroCommand(i18n(
"Change Protection Attribute"));
134 bool createMacro=
false;
135 KivioStencil* pStencil = m_pView->activePage()->selectedStencils()->first();
138 if(pStencil->canProtect()->at(kpDeletion) ==
true) {
139 KivioChangeStencilProtectCommand* cmd =
new KivioChangeStencilProtectCommand(i18n(
"Change Protection Attribute"),
140 m_pView->activePage(), pStencil, on, KivioChangeStencilProtectCommand::KV_DELETE);
141 macro->addCommand(cmd);
144 kdDebug(43000) <<
"Attempt to set delete-protection of a stencil which does not support it.\n";
147 pStencil = m_pView->activePage()->selectedStencils()->next();
152 m_pView->doc()->addCommand(macro);
158void KivioProtectionPanel::togX(
bool on)
160 KMacroCommand * macro =
new KMacroCommand(i18n(
"Change Protection Attribute"));
161 bool createMacro=
false;
162 KivioStencil* pStencil = m_pView->activePage()->selectedStencils()->first();
165 if(pStencil->canProtect()->at(kpX) ==
true) {
166 KivioChangeStencilProtectCommand* cmd =
new KivioChangeStencilProtectCommand(i18n(
"Change Protection Attribute"),
167 m_pView->activePage(), pStencil, on, KivioChangeStencilProtectCommand::KV_POSX);
168 macro->addCommand(cmd);
171 kdDebug(43000) <<
"Attempt to set X-protection of a stencil which does not support it.\n";
174 pStencil = m_pView->activePage()->selectedStencils()->next();
179 m_pView->doc()->addCommand(macro);
186void KivioProtectionPanel::togY(
bool on)
188 KMacroCommand * macro =
new KMacroCommand(i18n(
"Change Protection Attribute"));
189 bool createMacro=
false;
190 KivioStencil* pStencil = m_pView->activePage()->selectedStencils()->first();
193 if(pStencil->canProtect()->at(kpY) ==
true) {
194 KivioChangeStencilProtectCommand* cmd =
new KivioChangeStencilProtectCommand(i18n(
"Change Protection Attribute"),
195 m_pView->activePage(), pStencil, on, KivioChangeStencilProtectCommand::KV_POSY);
196 macro->addCommand(cmd);
199 kdDebug(43000) <<
"Attempt to set Y-protection of a stencil which does not support it.\n";
202 pStencil = m_pView->activePage()->selectedStencils()->next();
207 m_pView->doc()->addCommand(macro);
213void KivioProtectionPanel::updateCheckBoxes()
217 if(m_pView->activePage()->selectedStencils()->count() == 0)
219 m_checkAspect->setEnabled(
false);
220 m_checkXPosition->setEnabled(
false);
221 m_checkYPosition->setEnabled(
false);
222 m_checkDeletion->setEnabled(
false);
223 m_checkHeight->setEnabled(
false);
224 m_checkWidth->setEnabled(
false);
226 m_checkAspect->setChecked(
false);
227 m_checkXPosition->setChecked(
false);
228 m_checkYPosition->setChecked(
false);
229 m_checkDeletion->setChecked(
false);
230 m_checkHeight->setChecked(
false);
231 m_checkWidth->setChecked(
false);
236 TQBitArray bits( NUM_PROTECTIONS );
240 for(i = 0; i < NUM_PROTECTIONS; i++) {
245 KivioStencil* pStencil = m_pView->activePage()->selectedStencils()->first();
251 for(i = 0; i < NUM_PROTECTIONS; i++) {
252 if(pStencil->canProtect()->at(i) ==
false) {
257 pStencil = m_pView->activePage()->selectedStencils()->next();
260 TQObject::disconnect(m_checkWidth, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togWidth(
bool)));
261 TQObject::disconnect(m_checkHeight, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togHeight(
bool)));
262 TQObject::disconnect(m_checkAspect, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togAspect(
bool)));
263 TQObject::disconnect(m_checkDeletion, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togDelete(
bool)));
264 TQObject::disconnect(m_checkXPosition, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togX(
bool)));
265 TQObject::disconnect(m_checkYPosition, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togY(
bool)));
268 for(i = 0; i < NUM_PROTECTIONS; i++) {
269 bool on = bits.at(i);
273 m_checkXPosition->setEnabled(on);
277 m_checkYPosition->setEnabled(on);
281 m_checkWidth->setEnabled(on);
285 m_checkHeight->setEnabled(on);
289 m_checkDeletion->setEnabled(on);
293 m_checkAspect->setEnabled(on);
304 if(m_pView->activePage()->selectedStencils()->count() > 1) {
305 m_checkAspect->setChecked(
false);
306 m_checkXPosition->setChecked(
false);
307 m_checkYPosition->setChecked(
false);
308 m_checkDeletion->setChecked(
false);
309 m_checkHeight->setChecked(
false);
310 m_checkWidth->setChecked(
false);
312 pStencil = m_pView->activePage()->selectedStencils()->first();
314 m_checkAspect->setChecked( pStencil->protection()->at(kpAspect) );
315 m_checkDeletion->setChecked( pStencil->protection()->at(kpDeletion) );
316 m_checkXPosition->setChecked( pStencil->protection()->at(kpX) );
317 m_checkYPosition->setChecked( pStencil->protection()->at(kpY) );
318 m_checkWidth->setChecked( pStencil->protection()->at(kpWidth) );
319 m_checkHeight->setChecked( pStencil->protection()->at(kpHeight) );
322 TQObject::connect(m_checkWidth, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togWidth(
bool)));
323 TQObject::connect(m_checkHeight, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togHeight(
bool)));
324 TQObject::connect(m_checkAspect, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togAspect(
bool)));
325 TQObject::connect(m_checkDeletion, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togDelete(
bool)));
326 TQObject::connect(m_checkXPosition, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togX(
bool)));
327 TQObject::connect(m_checkYPosition, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(togY(
bool)));