blob: c2c1fdebf7f254bb337eb9b16ee65f92cc989c97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
**************************************************************************
description
--------------------
copyright : (C) 2004 by Leon Pennington
email : leon@leonscape.co.uk
**************************************************************************
**************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
**************************************************************************/
#include "pmdetailobjectedit.h"
#include "pmdetailobject.h"
#include <tqlayout.h>
#include <tqcheckbox.h>
#include <tqlabel.h>
#include <tqcombobox.h>
#include <tdelocale.h>
PMDetailObjectEdit::PMDetailObjectEdit( TQWidget* parent, const char* name )
: Base( parent, name )
{
m_pDisplayedObject = 0;
}
void PMDetailObjectEdit::createTopWidgets( )
{
Base::createTopWidgets( );
TQHBoxLayout* layout = new TQHBoxLayout( topLayout( ) );
m_pGlobalDetail = new TQCheckBox( i18n( "Global detail" ), this );
m_pLocalDetailLevelLabel = new TQLabel( i18n( "Detail level:" ), this );
m_pLocalDetailLevel = new TQComboBox( this );
m_pLocalDetailLevel->insertItem( i18n( "Very Low" ) );
m_pLocalDetailLevel->insertItem( i18n( "Low" ) );
m_pLocalDetailLevel->insertItem( i18n( "Medium" ) );
m_pLocalDetailLevel->insertItem( i18n( "High" ) );
m_pLocalDetailLevel->insertItem( i18n( "Very High" ) );
layout->addWidget( m_pGlobalDetail );
layout->addWidget( m_pLocalDetailLevelLabel );
layout->addWidget( m_pLocalDetailLevel );
layout->addStretch( );
connect( m_pGlobalDetail, TQT_SIGNAL( clicked( ) ), TQT_SLOT( slotGlobalDetailClicked( ) ) );
connect( m_pLocalDetailLevel, TQT_SIGNAL( activated( int ) ), TQT_SIGNAL( dataChanged( ) ) );
}
void PMDetailObjectEdit::displayObject( PMObject* o )
{
if( o->isA( "DetailObject" ) )
{
bool readOnly = o->isReadOnly( );
m_pDisplayedObject = ( PMDetailObject* ) o;
if( !m_pDisplayedObject->hasDisplayDetail( ) )
{
m_pGlobalDetail->hide( );
m_pLocalDetailLevelLabel->hide( );
m_pLocalDetailLevel->hide( );
}
if( m_pDisplayedObject->globalDetail( ) )
{
m_pGlobalDetail->setChecked( true );
m_pLocalDetailLevelLabel->setEnabled( false );
m_pLocalDetailLevel->setEnabled( false );
}
else
{
m_pGlobalDetail->setChecked( false );
m_pLocalDetailLevelLabel->setEnabled( !readOnly );
m_pLocalDetailLevel->setEnabled( !readOnly );
}
m_pGlobalDetail->setEnabled( !readOnly );
m_pLocalDetailLevel->setCurrentItem( m_pDisplayedObject->localDetailLevel( ) - 1 );
Base::displayObject( o );
}
else
kdError( PMArea ) << "PMNamedObjectEdit: Can't display object\n";
}
void PMDetailObjectEdit::saveContents( )
{
if( m_pDisplayedObject )
{
Base::saveContents( );
m_pDisplayedObject->setGlobalDetail( m_pGlobalDetail->isChecked( ) );
m_pDisplayedObject->setLocalDetailLevel( m_pLocalDetailLevel->currentItem( ) + 1 );
}
}
bool PMDetailObjectEdit::isDataValid( )
{
return Base::isDataValid( );
}
void PMDetailObjectEdit::slotGlobalDetailClicked( )
{
if( m_pGlobalDetail->isChecked( ) )
{
m_pLocalDetailLevelLabel->setEnabled( false );
m_pLocalDetailLevel->setEnabled( false );
}
else
{
bool readOnly = m_pDisplayedObject->isReadOnly( );
m_pLocalDetailLevelLabel->setEnabled( !readOnly );
m_pLocalDetailLevel->setEnabled( !readOnly );
}
emit dataChanged( );
}
#include "pmdetailobjectedit.moc"
|