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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
/***************************************************************************
* Copyright (C) 2003-2004 by David Saxton *
* david@bluehaze.org *
* *
* 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 "cnitem.h"
#include "cnitemgroup.h"
#include "itemeditor.h"
#include "orientationwidget.h"
#include "propertieslistview.h"
#include <klocale.h>
#include <kstandarddirs.h>
#include <tqlayout.h>
#include <tqlabel.h>
#include <tqpushbutton.h>
#include <tqwhatsthis.h>
#include <assert.h>
ItemEditor * ItemEditor::m_pSelf = 0l;
ItemEditor * ItemEditor::self( KateMDI::ToolView * parent )
{
if (!m_pSelf)
{
assert(parent);
m_pSelf = new ItemEditor(parent);
}
return m_pSelf;
}
ItemEditor::ItemEditor( KateMDI::ToolView * parent )
: TQWidget( (TQWidget*)parent, "Item Editor" )
{
TQWhatsThis::add( this, i18n("This allows editing of advanced properties of the selected item(s). Right click on the picture of the item to set the orientation.") );
TQVBoxLayout *vlayout = new TQVBoxLayout( this, 0, 6 );
m_nameLbl = new TQLabel( this, "" );
vlayout->addWidget(m_nameLbl);
vlayout->addSpacing(8);
propList = new PropertiesListView(this);
vlayout->addWidget(propList);
TQWhatsThis::add(propList,i18n("<qt>Shows properties associated with the currently selected item(s).<p>Select a property to change its value. If multiple items are selected with different values then the property will appear greyed out, use ""Merge Properties"" to make them the same.<p>Select ""Defaults to set all properties to their default values"""));
TQHBoxLayout *h1Layout = new TQHBoxLayout( vlayout, 4 );
TQSpacerItem *spacer1 = new TQSpacerItem( 1, 1 );
h1Layout->addItem(spacer1);
m_defaultsBtn = new TQPushButton( i18n("Defaults"), this);
m_defaultsBtn->setEnabled(false);
connect(m_defaultsBtn,TQT_SIGNAL(clicked()),propList,TQT_SLOT(slotSetDefaults()));
h1Layout->addWidget(m_defaultsBtn);
m_mergeBtn = new TQPushButton( i18n("Merge properties"), this );
m_mergeBtn->setEnabled(false);
connect(m_mergeBtn,TQT_SIGNAL(clicked()),this,TQT_SLOT(mergeProperties()));
h1Layout->addWidget(m_mergeBtn);
// Qt::Orientation widget stuff
TQHBoxLayout *h2Layout = new TQHBoxLayout( vlayout, 6 );
TQSpacerItem *spacer2 = new TQSpacerItem( 1, 1 );
h2Layout->addItem(spacer2);
m_orientationWidget = new OrientationWidget(this);
h2Layout->addWidget(m_orientationWidget);
TQWhatsThis::add(m_orientationWidget,i18n("Change the orientation of the selected item by selecting the appropriate button"));
TQSpacerItem *spacer3 = new TQSpacerItem( 1, 1 );
h2Layout->addItem(spacer3);
slotClear();
}
ItemEditor::~ItemEditor()
{
}
void ItemEditor::mergeProperties()
{
propList->slotMergeProperties();
m_mergeBtn->setEnabled(false);
}
void ItemEditor::slotClear()
{
propList->slotClear();
m_orientationWidget->slotClear();
m_defaultsBtn->setEnabled(false);
m_mergeBtn->setEnabled(false);
updateNameLabel(0l);
}
void ItemEditor::slotMultipleSelected()
{
slotClear();
m_nameLbl->setText( i18n("<h2>Multiple Items</h2>") );
}
void ItemEditor::slotUpdate( ItemGroup *itemGroup )
{
if (!itemGroup) {
slotClear();
return;
}
updateMergeDefaults(itemGroup);
propList->slotCreate(itemGroup);
updateNameLabel(itemGroup->activeItem());
}
void ItemEditor::updateMergeDefaults( ItemGroup *itemGroup )
{
if (!itemGroup)
{
m_defaultsBtn->setEnabled(false);
m_mergeBtn->setEnabled(false);
return;
}
m_mergeBtn->setEnabled( !itemGroup->itemsHaveSameData() );
m_defaultsBtn->setEnabled( !itemGroup->itemsHaveDefaultData() );
propList->slotUpdate(itemGroup);
}
void ItemEditor::slotUpdate( CNItem *item )
{
m_orientationWidget->slotUpdate(item);
}
void ItemEditor::updateNameLabel( Item *item )
{
if (item) {
m_nameLbl->setText( "<h2>" + item->name() + "</h2>" );
} else {
m_nameLbl->setText( i18n("<h2>No Item Selected</h2>") );
}
}
#include "itemeditor.moc"
|