~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kugar/kudesigner/kudesigner_view.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* This file is part of the KDE project
2
 
   Copyright (C) 2002 Alexander Dymo <cloudtemple@mksat.net>
3
 
 
4
 
   This library is free software; you can redistribute it and/or
5
 
   modify it under the terms of the GNU Library General Public
6
 
   License as published by the Free Software Foundation; either
7
 
   version 2 of the License, or (at your option) any later version.
8
 
 
9
 
   This library is distributed in the hope that it will be useful,
10
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 
   Library General Public License for more details.
13
 
 
14
 
   You should have received a copy of the GNU Library General Public License
15
 
   along with this library; see the file COPYING.LIB.  If not, write to
16
 
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 
   Boston, MA 02111-1307, USA.
 
2
  Copyright (C) 2002-2004 Alexander Dymo <cloudtemple@mksat.net>
 
3
 
 
4
  This library is free software; you can redistribute it and/or
 
5
  modify it under the terms of the GNU Library General Public
 
6
  License as published by the Free Software Foundation; either
 
7
  version 2 of the License, or (at your option) any later version.
 
8
 
 
9
  This library is distributed in the hope that it will be useful,
 
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
  MEm_viewHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
  Library General Public License for more details.
 
13
 
 
14
  You should have received a copy of the GNU Library General Public License
 
15
  along with this library; see the file COPYING.LIB.  If not, write to
 
16
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
 * Boston, MA 02110-1301, USA.
18
18
*/
19
 
 
20
19
#include "kudesigner_view.h"
21
20
#include "kudesigner_factory.h"
22
21
#include "kudesigner_doc.h"
23
 
#include <kudesigner_command.h>
24
22
 
25
23
#include <map>
26
24
 
27
25
#include <qpainter.h>
28
26
#include <qiconset.h>
29
27
#include <qinputdialog.h>
 
28
#include <qevent.h>
 
29
#include <qmainwindow.h>
 
30
#include <qaction.h>
 
31
#include <qlayout.h>
 
32
#include <qdockwindow.h>
 
33
#include <qmenubar.h>
 
34
#include <qmessagebox.h>
 
35
#include <qspinbox.h>
 
36
#include <qlabel.h>
30
37
 
31
38
#include <kaction.h>
32
39
#include <kstdaction.h>
33
40
#include <klocale.h>
34
41
#include <kdebug.h>
35
42
 
36
 
#include <koMainWindow.h>
37
 
 
38
 
#include <cv.h>
39
 
 
40
 
#include <canvdefs.h>
41
 
#include <cfield.h>
42
 
#include <ccalcfield.h>
43
 
#include <clabel.h>
44
 
#include <cline.h>
45
 
#include <cspecialfield.h>
46
 
#include <mycanvas.h>
47
 
#include <propertyeditor.h>
48
 
#include <property.h>
49
 
 
50
 
#include <canvkutemplate.h>
51
 
#include <canvreportheader.h>
52
 
#include <canvreportfooter.h>
53
 
#include <canvpageheader.h>
54
 
#include <canvpagefooter.h>
55
 
#include <canvdetailheader.h>
56
 
#include <canvdetailfooter.h>
57
 
#include <canvdetail.h>
 
43
#include <KoMainWindow.h>
 
44
 
 
45
#include <commdefs.h>
 
46
#include <view.h>
 
47
#include <structurewidget.h>
 
48
#include <canvas.h>
 
49
#include <command.h>
 
50
 
 
51
#include <field.h>
 
52
#include <calcfield.h>
 
53
#include <label.h>
 
54
#include <line.h>
 
55
#include <specialfield.h>
 
56
 
 
57
#include <kugartemplate.h>
 
58
#include <reportheader.h>
 
59
#include <reportfooter.h>
 
60
#include <pageheader.h>
 
61
#include <pagefooter.h>
 
62
#include <detailheader.h>
 
63
#include <detailfooter.h>
 
64
#include <detail.h>
 
65
 
 
66
#include <koproperty/editor.h>
 
67
#include <koproperty/property.h>
 
68
 
 
69
using namespace Kudesigner;
58
70
 
59
71
KudesignerView::KudesignerView( KudesignerDoc* part, QWidget* parent, const char* name )
60
 
    : KoView( part, parent, name ),pe(0),m_doc(part)
 
72
        : KoView( part, parent, name ), m_propertyEditor( 0 ), m_doc( part )
61
73
{
62
74
    setInstance( KudesignerFactory::global() );
63
 
    if ( !part->isReadWrite() ) // readonly case, e.g. when embedded into konqueror
 
75
    if ( !part->isReadWrite() )  // readonly case, e.g. when embedded into konqueror
64
76
        setXMLFile( "kudesigner_readonly.rc" ); // simplified GUI
65
77
    else
66
78
        setXMLFile( "kudesignerui.rc" );
67
79
 
 
80
    QVBoxLayout *l = new QVBoxLayout( this, 0, 0 );
 
81
    m_view = new Kudesigner::View( part->canvas(), this );
 
82
    if ( part->plugin() )
 
83
    {
 
84
        m_view->setAcceptDrops( part->plugin() ->acceptsDrops() );
 
85
        m_view->viewport() ->setAcceptDrops( part->plugin() ->acceptsDrops() );
 
86
        m_view->setPlugin( part->plugin() );
 
87
    }
 
88
    l->addWidget( m_view );
 
89
 
 
90
    m_view->viewport() ->setFocusProxy( m_view );
 
91
    m_view->viewport() ->setFocusPolicy( WheelFocus );
 
92
    m_view->setFocus();
 
93
 
 
94
    m_view->itemToInsert = 0;
 
95
 
 
96
    QDockWindow *dw1 = new QDockWindow( QDockWindow::OutsideDock, shell() );
 
97
    QDockWindow *dw2 = new QDockWindow( QDockWindow::OutsideDock, shell() );
 
98
    m_structure = new Kudesigner::StructureWidget( dw1 );
 
99
    m_propertyEditor = new Editor( dw2 );
 
100
    dw1->boxLayout() ->addWidget( m_structure, 1 );
 
101
    dw2->boxLayout() ->addWidget( m_propertyEditor, 1 );
 
102
    dw1->setFixedExtentWidth( 400 );
 
103
    dw1->setResizeEnabled( true );
 
104
    dw2->setFixedExtentWidth( 400 );
 
105
    dw2->setResizeEnabled( true );
 
106
 
 
107
    if ( m_doc->plugin() )
 
108
    {
 
109
        //                 connect( m_propertyEditor, SIGNAL(createPluggedInEditor(QWidget*&, Editor *, Property*, Box *)),
 
110
        //                          m_doc->plugin(), SLOT(createPluggedInEditor(QWidget*&, Editor *, Property*, Box *)));
 
111
 
 
112
        kdDebug() << "*************Property and plugin have been connected" << endl;
 
113
    }
 
114
 
 
115
    shell() ->addDockWindow( dw1, m_doc->propertyPosition() );
 
116
    shell() ->addDockWindow( dw2, m_doc->propertyPosition() );
 
117
 
 
118
    m_structure->setDocument( m_doc->canvas() );
 
119
 
 
120
    connect( m_doc, SIGNAL( canvasChanged( Kudesigner::Canvas * ) ),
 
121
             m_structure, SLOT( setDocument( Kudesigner::Canvas * ) ) );
 
122
    connect( m_doc->canvas(), SIGNAL( structureModified() ),
 
123
             m_structure, SLOT( refresh() ) );
 
124
 
 
125
    connect( m_view, SIGNAL( selectionMade( Buffer* ) ),
 
126
             this, SLOT( populateProperties( Buffer* ) ) );
 
127
 
 
128
    connect( m_view, SIGNAL( selectionClear() ),
 
129
             m_propertyEditor, SLOT( clear() ) );
 
130
 
 
131
    connect( m_view, SIGNAL( changed() ),
 
132
             m_doc, SLOT( setModified() ) );
 
133
 
 
134
    connect( m_view, SIGNAL( selectionMade( Buffer* ) ),
 
135
             m_structure, SLOT( selectionMade() ) );
 
136
    connect( m_view, SIGNAL( selectionClear() ),
 
137
             m_structure, SLOT( selectionClear() ) );
 
138
 
 
139
    connect( m_view, SIGNAL( selectedActionProcessed() ), this, SLOT( unselectItemAction() ) );
 
140
    connect( m_view, SIGNAL( modificationPerformed() ), part, SLOT( setModified() ) );
 
141
    connect( m_view, SIGNAL( itemPlaced( int, int, int, int ) ), this, SLOT( placeItem( int, int, int, int ) ) );
 
142
 
 
143
    gridLabel = new QLabel( i18n( "Grid size:" ), shell() );
 
144
    gridBox = new QSpinBox( 1, 100, 1, shell() );
 
145
    gridBox->setValue( 10 );
 
146
    connect( gridBox, SIGNAL( valueChanged( int ) ), m_view, SLOT( setGridSize( int ) ) );
 
147
 
68
148
    initActions();
69
149
 
70
 
    rc = new ReportCanvas((QCanvas *)(part->canvas()), this);
71
 
    if (part->plugin())
72
 
    {
73
 
       rc->setAcceptDrops(part->plugin()->acceptsDrops());
74
 
       rc->viewport()->setAcceptDrops(part->plugin()->acceptsDrops());
75
 
       rc->setPlugin(part->plugin());
76
 
    }
77
 
    rc->viewport()->setFocusProxy(rc);
78
 
    rc->viewport()->setFocusPolicy(WheelFocus);
79
 
    rc->setFocus();
80
 
 
81
 
    rc->itemToInsert = 0;
82
 
 
83
 
    connect(rc, SIGNAL(selectedActionProcessed()), this, SLOT(unselectItemAction()));
84
 
    connect(rc, SIGNAL(modificationPerformed()), part, SLOT(setModified()));
85
 
    connect(rc, SIGNAL(itemPlaced(int, int, int, int)), this, SLOT(placeItem(int, int, int, int)));
 
150
    show();
 
151
    m_view->show();
 
152
    m_structure->refresh();
86
153
}
87
154
 
88
155
KudesignerView::~KudesignerView()
89
156
{
90
 
    delete pe;
 
157
    delete gridLabel;
 
158
    delete gridBox;
91
159
}
92
160
 
93
161
void KudesignerView::paintEvent( QPaintEvent* ev )
98
166
    // ### TODO: Scaling
99
167
 
100
168
    // Let the document do the drawing
101
 
    koDocument()->paintEverything( painter, ev->rect(), FALSE, this );
 
169
    koDocument() ->paintEverything( painter, ev->rect(), FALSE, this );
102
170
 
103
171
    painter.end();
104
172
}
105
173
 
 
174
void KudesignerView::resizeEvent( QResizeEvent* /*_ev*/ )
 
175
{
 
176
    m_view->setGeometry( 0, 0, width(), height() );
 
177
}
106
178
 
107
179
void KudesignerView::initActions()
108
180
{
109
 
    cutAction = KStdAction::cut(this, SLOT(cut()), actionCollection());
110
 
    copyAction = KStdAction::copy(this, SLOT(copy()), actionCollection());
111
 
    pasteAction = KStdAction::paste(this, SLOT(paste()), actionCollection());
112
 
    selectAllAction = KStdAction::selectAll(this, SLOT(selectAll()), actionCollection());
113
 
    deleteAction = new KAction(i18n("Delete"), "editdelete", 0, this,
114
 
        SLOT(deleteItems()), actionCollection(), "edit_delete");
115
 
    cutAction->setEnabled(false);
116
 
    copyAction->setEnabled(false);
117
 
    pasteAction->setEnabled(false);
118
 
//    deleteAction->setEnabled(false);
119
 
 
120
 
    sectionsReportHeader = new KAction(i18n("Report Header"), "irh", 0, this,
121
 
        SLOT(slotAddReportHeader()), actionCollection(), "rheader");
122
 
    sectionsReportFooter = new KAction(i18n("Report Footer"), "irf", 0, this,
123
 
        SLOT(slotAddReportFooter()), actionCollection(), "rfooter");
124
 
    sectionsPageHeader = new KAction(i18n("Page Header"), "iph", 0, this,
125
 
        SLOT(slotAddPageHeader()), actionCollection(), "pheader");
126
 
    sectionsPageFooter = new KAction(i18n("Page Footer"), "ipf", 0, this,
127
 
        SLOT(slotAddPageFooter()), actionCollection(), "pfooter");
128
 
    sectionsDetailHeader = new KAction(i18n("Detail Header"), "idh", 0, this,
129
 
        SLOT(slotAddDetailHeader()), actionCollection(), "dheader");
130
 
    sectionsDetail = new KAction(i18n("Detail"), "id", 0, this,
131
 
        SLOT(slotAddDetail()), actionCollection(), "detail");
132
 
    sectionsDetailFooter = new KAction(i18n("Detail Footer"), "idf", 0, this,
133
 
        SLOT(slotAddDetailFooter()), actionCollection(), "dfooter");
134
 
 
135
 
    itemsNothing = new KRadioAction(i18n("Clear Selection"), "frame_edit", 0, this,
136
 
        SLOT(slotAddItemNothing()), actionCollection(), "nothing");
137
 
    itemsNothing->setExclusiveGroup("itemsToolBar");
138
 
    itemsNothing->setChecked(true);
139
 
    itemsLabel = new KRadioAction(i18n("Label"), "frame_text", 0, this,
140
 
        SLOT(slotAddItemLabel()), actionCollection(), "label");
141
 
    itemsLabel->setExclusiveGroup("itemsToolBar");
142
 
    itemsField = new KRadioAction(i18n("Field"), "frame_field", 0, this,
143
 
        SLOT(slotAddItemField()), actionCollection(), "field");
144
 
    itemsField->setExclusiveGroup("itemsToolBar");
145
 
    itemsSpecial = new KRadioAction(i18n("Special Field"), "frame_query", 0, this,
146
 
        SLOT(slotAddItemSpecial()), actionCollection(), "special");
147
 
    itemsSpecial->setExclusiveGroup("itemsToolBar");
148
 
    itemsCalculated = new KRadioAction(i18n("Calculated Field"), "frame_formula", 0, this,
149
 
        SLOT(slotAddItemCalculated()), actionCollection(), "calcfield");
150
 
    itemsCalculated->setExclusiveGroup("itemsToolBar");
151
 
    itemsLine = new KRadioAction(i18n("Line"), "frame_chart", 0, this,
152
 
        SLOT(slotAddItemLine()), actionCollection(), "line");
153
 
    itemsLine->setExclusiveGroup("itemsToolBar");
 
181
    cutAction = KStdAction::cut( this, SLOT( cut() ), actionCollection() );
 
182
    copyAction = KStdAction::copy( this, SLOT( copy() ), actionCollection() );
 
183
    pasteAction = KStdAction::paste( this, SLOT( paste() ), actionCollection() );
 
184
    selectAllAction = KStdAction::selectAll( this, SLOT( selectAll() ), actionCollection() );
 
185
    deleteAction = new KAction( i18n( "Delete" ), "editdelete", 0, this,
 
186
                                SLOT( deleteItems() ), actionCollection(), "edit_delete" );
 
187
    cutAction->setEnabled( false );
 
188
    copyAction->setEnabled( false );
 
189
    pasteAction->setEnabled( false );
 
190
    //    deleteAction->setEnabled(false);
 
191
 
 
192
    sectionsReportHeader = new KAction( i18n( "Report Header" ), "irh", 0, this,
 
193
                                        SLOT( slotAddReportHeader() ), actionCollection(), "rheader" );
 
194
    sectionsReportFooter = new KAction( i18n( "Report Footer" ), "irf", 0, this,
 
195
                                        SLOT( slotAddReportFooter() ), actionCollection(), "rfooter" );
 
196
    sectionsPageHeader = new KAction( i18n( "Page Header" ), "iph", 0, this,
 
197
                                      SLOT( slotAddPageHeader() ), actionCollection(), "pheader" );
 
198
    sectionsPageFooter = new KAction( i18n( "Page Footer" ), "ipf", 0, this,
 
199
                                      SLOT( slotAddPageFooter() ), actionCollection(), "pfooter" );
 
200
    sectionsDetailHeader = new KAction( i18n( "Detail Header" ), "idh", 0, this,
 
201
                                        SLOT( slotAddDetailHeader() ), actionCollection(), "dheader" );
 
202
    sectionsDetail = new KAction( i18n( "Detail" ), "id", 0, this,
 
203
                                  SLOT( slotAddDetail() ), actionCollection(), "detail" );
 
204
    sectionsDetailFooter = new KAction( i18n( "Detail Footer" ), "idf", 0, this,
 
205
                                        SLOT( slotAddDetailFooter() ), actionCollection(), "dfooter" );
 
206
 
 
207
    itemsNothing = new KRadioAction( i18n( "Clear Selection" ), "frame_edit", 0, this,
 
208
                                     SLOT( slotAddItemNothing() ), actionCollection(), "nothing" );
 
209
    itemsNothing->setExclusiveGroup( "itemsToolBar" );
 
210
    itemsNothing->setChecked( true );
 
211
    itemsLabel = new KRadioAction( i18n( "Label" ), "frame_text", 0, this,
 
212
                                   SLOT( slotAddItemLabel() ), actionCollection(), "label" );
 
213
    itemsLabel->setExclusiveGroup( "itemsToolBar" );
 
214
    itemsField = new KRadioAction( i18n( "Field" ), "frame_field", 0, this,
 
215
                                   SLOT( slotAddItemField() ), actionCollection(), "field" );
 
216
    itemsField->setExclusiveGroup( "itemsToolBar" );
 
217
    itemsSpecial = new KRadioAction( i18n( "Special Field" ), "frame_query", 0, this,
 
218
                                     SLOT( slotAddItemSpecial() ), actionCollection(), "special" );
 
219
    itemsSpecial->setExclusiveGroup( "itemsToolBar" );
 
220
    itemsCalculated = new KRadioAction( i18n( "Calculated Field" ), "frame_formula", 0, this,
 
221
                                        SLOT( slotAddItemCalculated() ), actionCollection(), "calcfield" );
 
222
    itemsCalculated->setExclusiveGroup( "itemsToolBar" );
 
223
    itemsLine = new KRadioAction( i18n( "Line" ), "frame_chart", 0, this,
 
224
                                  SLOT( slotAddItemLine() ), actionCollection(), "line" );
 
225
    itemsLine->setExclusiveGroup( "itemsToolBar" );
 
226
 
 
227
    gridActionLabel = new KWidgetAction( gridLabel, i18n( "Grid Label" ), 0, this,
 
228
                                         0, actionCollection(), "gridlabel" );
 
229
 
 
230
    gridAction = new KWidgetAction( gridBox, i18n( "Grid Size" ), 0, this,
 
231
                                    0, actionCollection(), "gridaction" );
154
232
}
155
233
 
156
 
 
157
234
void KudesignerView::updateReadWrite( bool /*readwrite*/ )
158
235
{
159
 
#ifdef __GNUC__
160
 
#warning TODO
161
 
#endif
162
 
}
163
 
 
164
 
void KudesignerView::copy()
165
 
{
166
 
    kdDebug(31000) << "KudesignerView::copy(): COPY called" << endl;
167
 
}
168
 
 
169
 
void KudesignerView::cut()
170
 
{
171
 
    kdDebug(31000) << "KudesignerView::cut(): CUT called" << endl;
172
 
}
173
 
 
174
 
void KudesignerView::resizeEvent(QResizeEvent* /*_ev*/)
175
 
{
176
 
    rc->setGeometry(0, 0, width(), height());
177
 
}
178
 
 
179
 
void KudesignerView::slotAddReportHeader(){
180
 
    if (!(((KudesignerDoc *)(koDocument())))->canvas()->templ->reportHeader)
181
 
    {
182
 
        m_doc->addCommand( new AddReportHeaderCommand(m_doc->canvas()) );
183
 
    }
184
 
}
185
 
 
186
 
void KudesignerView::slotAddReportFooter(){
187
 
    if (!m_doc->canvas()->templ->reportFooter)
188
 
    {
189
 
        m_doc->addCommand( new AddReportFooterCommand(m_doc->canvas()) );
190
 
    }
191
 
}
192
 
 
193
 
void KudesignerView::slotAddPageHeader(){
194
 
    if (!m_doc->canvas()->templ->pageHeader)
195
 
    {
196
 
        m_doc->addCommand( new AddPageHeaderCommand(m_doc->canvas()) );
197
 
    }
198
 
}
199
 
 
200
 
void KudesignerView::slotAddPageFooter(){
201
 
    if (!m_doc->canvas()->templ->pageFooter)
202
 
    {
203
 
        m_doc->addCommand( new AddPageFooterCommand(m_doc->canvas()) );
204
 
    }
205
 
}
206
 
 
207
 
void KudesignerView::slotAddDetailHeader(){
208
 
    bool Ok = false;
209
 
    unsigned int level = QInputDialog::getInteger(i18n("Add Detail Header"), i18n("Enter detail level:"),
210
 
        0, 0, 100, 1, &Ok, this);
211
 
    if (!Ok) return;
212
 
    if (m_doc->canvas()->templ->detailsCount >= level)
213
 
    {
214
 
        m_doc->addCommand( new AddDetailHeaderCommand(level, m_doc->canvas()) );
215
 
    }
216
 
}
217
 
 
218
 
void KudesignerView::slotAddDetail(){
219
 
    bool Ok = false;
220
 
    unsigned int level = QInputDialog::getInteger(i18n("Add Detail"), i18n("Enter detail level:"),
221
 
        0, 0, 100, 1, &Ok, this);
222
 
    if (!Ok) return;
223
 
    if ( ((level == 0) && (m_doc->canvas()->templ->detailsCount == 0))
224
 
        || (m_doc->canvas()->templ->detailsCount == level))
225
 
    {
226
 
        m_doc->addCommand( new AddDetailCommand(level, m_doc->canvas()) );
227
 
    }
228
 
}
229
 
 
230
 
void KudesignerView::slotAddDetailFooter(){
231
 
    bool Ok = false;
232
 
    unsigned int level = QInputDialog::getInteger(i18n("Add Detail Footer"), i18n("Enter detail level:"),
233
 
        0, 0, 100, 1, &Ok, this);
234
 
    if (!Ok) return;
235
 
 
236
 
    if (m_doc->canvas()->templ->detailsCount >= level)
237
 
    {
238
 
        m_doc->addCommand( new AddDetailFooterCommand(level, m_doc->canvas()) );
239
 
    }
240
 
}
241
 
 
242
 
void KudesignerView::slotAddItemNothing(){
243
 
    if (m_doc->canvas())
244
 
    {
245
 
        if (rc->itemToInsert)
246
 
        {
247
 
            rc->itemToInsert = 0;
248
 
        }
249
 
    }
250
 
}
251
 
 
252
 
void KudesignerView::slotAddItemLabel(){
253
 
    if (m_doc->canvas())
254
 
    {
255
 
        rc->itemToInsert = KuDesignerRttiCanvasLabel;
256
 
    }
257
 
}
258
 
 
259
 
void KudesignerView::slotAddItemField(){
260
 
    if (m_doc->canvas())
261
 
    {
262
 
        rc->itemToInsert = KuDesignerRttiCanvasField;
263
 
    }
264
 
}
265
 
 
266
 
void KudesignerView::slotAddItemSpecial(){
267
 
    if (m_doc->canvas())
268
 
    {
269
 
        rc->itemToInsert = KuDesignerRttiCanvasSpecial;
270
 
    }
271
 
}
272
 
 
273
 
void KudesignerView::slotAddItemCalculated(){
274
 
    if (m_doc->canvas())
275
 
    {
276
 
        rc->itemToInsert = KuDesignerRttiCanvasCalculated;
277
 
    }
278
 
}
279
 
 
280
 
void KudesignerView::slotAddItemLine(){
281
 
    if (m_doc->canvas())
282
 
    {
283
 
        rc->itemToInsert = KuDesignerRttiCanvasLine;
284
 
    }
285
 
}
286
 
 
287
 
void KudesignerView::unselectItemAction(){
288
 
    itemsNothing->setChecked(true);
289
236
}
290
237
 
291
238
void KudesignerView::guiActivateEvent( KParts::GUIActivateEvent *ev )
292
239
{
293
 
        if ( ev->activated() ) {
294
 
            if ((!pe))
295
 
            {
296
 
                pe = new PropertyEditor(QDockWindow::OutsideDock, shell(), "propedit");
297
 
                if (m_doc->plugin()) {
298
 
                        connect(pe,SIGNAL(createPluggedInEditor(QWidget*&,PropertyEditor *,
299
 
                                Property*,CanvasBox *)),
300
 
                                m_doc->plugin(),
301
 
                                SLOT(createPluggedInEditor(QWidget*&, PropertyEditor *,
302
 
                                Property*,CanvasBox *)));
303
 
 
304
 
                        kdDebug()<<"*************Property and plugin have been connected"<<endl;
305
 
                }
306
 
                shell()->addDockWindow(pe, m_doc->propertyPosition());
307
 
                pe->show();
308
 
 
309
 
                connect(rc, SIGNAL( selectionMade(std::map<QString, PropPtr >*,CanvasBox*) ), pe,
310
 
                    SLOT( populateProperties(std::map<QString, PropPtr >*, CanvasBox*) ));
311
 
                connect(rc, SIGNAL( selectionClear() ), pe, SLOT( clearProperties() ));
312
 
                connect(pe, SIGNAL(propertyChanged(QString, QString)), rc, SLOT(updateProperty(QString, QString)));
313
 
            }
314
 
 
315
 
 
316
 
                pe->show();
317
 
                kdDebug()<<"pe->show()"<<endl;
318
 
        }
319
 
        else
320
 
        {
321
 
                pe->hide();
322
 
                kdDebug()<<"pe->hide()"<<endl;
323
 
        }
 
240
    if ( ev->activated() )
 
241
        m_propertyEditor->show();
 
242
    else
 
243
        m_propertyEditor->hide();
324
244
    KoView::guiActivateEvent( ev );
325
245
}
326
246
 
327
 
void KudesignerView::placeItem( int x, int y, int band, int bandLevel )
328
 
{
329
 
    m_doc->addCommand(new AddReportItemCommand(m_doc->canvas(), rc, x, y, (KuDesignerCanvasRtti)band, bandLevel) );
 
247
void KudesignerView::populateProperties( Buffer *buf )
 
248
{
 
249
    connect( buf, SIGNAL( propertyChanged() ), m_doc->canvas(), SLOT( changed() ) );
 
250
    m_propertyEditor->changeSet( buf );
 
251
}
 
252
 
 
253
void KudesignerView::cut()
 
254
{
 
255
    //    kdDebug(31000) << "KudesignerView::cut(): CUT called" << endl;
 
256
}
 
257
 
 
258
void KudesignerView::copy()
 
259
{
 
260
    //    kdDebug(31000) << "KudesignerView::copy(): COPY called" << endl;
330
261
}
331
262
 
332
263
void KudesignerView::paste( )
333
 
{
334
 
}
 
264
{}
335
265
 
336
266
void KudesignerView::deleteItems( )
337
267
{
338
 
    if (m_doc->canvas()->selected.count() > 0)
339
 
        m_doc->addCommand(new DeleteReportItemsCommand(m_doc->canvas(), m_doc->canvas()->selected));
 
268
    if ( m_doc->canvas() ->selected.count() > 0 )
 
269
        m_doc->addCommand( new DeleteReportItemsCommand( m_doc->canvas(), m_doc->canvas() ->selected ) );
340
270
}
341
271
 
342
272
void KudesignerView::selectAll( )
343
273
{
344
 
    m_doc->canvas()->selectAll();
 
274
    m_doc->canvas() ->selectAll();
 
275
}
 
276
 
 
277
void KudesignerView::slotAddReportHeader()
 
278
{
 
279
    if ( !( ( ( KudesignerDoc * ) ( koDocument() ) ) ) ->canvas() ->kugarTemplate() ->reportHeader )
 
280
    {
 
281
        m_doc->addCommand( new AddReportHeaderCommand( m_doc->canvas() ) );
 
282
    }
 
283
}
 
284
 
 
285
void KudesignerView::slotAddReportFooter()
 
286
{
 
287
    if ( !( ( ( KudesignerDoc * ) ( koDocument() ) ) ) ->canvas() ->kugarTemplate() ->reportFooter )
 
288
    {
 
289
        m_doc->addCommand( new AddReportFooterCommand( m_doc->canvas() ) );
 
290
    }
 
291
}
 
292
 
 
293
void KudesignerView::slotAddPageHeader()
 
294
{
 
295
    if ( !( ( ( KudesignerDoc * ) ( koDocument() ) ) ) ->canvas() ->kugarTemplate() ->pageHeader )
 
296
    {
 
297
        m_doc->addCommand( new AddPageHeaderCommand( m_doc->canvas() ) );
 
298
    }
 
299
}
 
300
 
 
301
void KudesignerView::slotAddPageFooter()
 
302
{
 
303
    if ( !( ( ( KudesignerDoc * ) ( koDocument() ) ) ) ->canvas() ->kugarTemplate() ->pageFooter )
 
304
    {
 
305
        m_doc->addCommand( new AddPageFooterCommand( m_doc->canvas() ) );
 
306
    }
 
307
}
 
308
 
 
309
void KudesignerView::slotAddDetailHeader()
 
310
{
 
311
    bool Ok = false;
 
312
    unsigned int level = QInputDialog::getInteger( tr( "Add Detail Header" ), tr( "Enter detail level:" ),
 
313
                         0, 0, 100, 1, &Ok, this );
 
314
    if ( !Ok )
 
315
        return ;
 
316
    if ( m_doc->canvas() ->kugarTemplate() ->detailsCount >= level )
 
317
    {
 
318
        m_doc->addCommand( new AddDetailHeaderCommand( level, m_doc->canvas() ) );
 
319
    }
 
320
}
 
321
 
 
322
void KudesignerView::slotAddDetail()
 
323
{
 
324
    bool Ok = false;
 
325
    unsigned int level = QInputDialog::getInteger( tr( "Add Detail" ), tr( "Enter detail level:" ),
 
326
                         0, 0, 100, 1, &Ok, this );
 
327
    if ( !Ok )
 
328
        return ;
 
329
    if ( ( ( level == 0 ) && ( m_doc->canvas() ->kugarTemplate() ->detailsCount == 0 ) )
 
330
            || ( m_doc->canvas() ->kugarTemplate() ->detailsCount == level ) )
 
331
    {
 
332
        m_doc->addCommand( new AddDetailCommand( level, m_doc->canvas() ) );
 
333
    }
 
334
}
 
335
 
 
336
void KudesignerView::slotAddDetailFooter()
 
337
{
 
338
    bool Ok = false;
 
339
    unsigned int level = QInputDialog::getInteger( tr( "Add Detail Footer" ), tr( "Enter detail level:" ),
 
340
                         0, 0, 100, 1, &Ok, this );
 
341
    if ( !Ok )
 
342
        return ;
 
343
 
 
344
    if ( m_doc->canvas() ->kugarTemplate() ->detailsCount >= level )
 
345
    {
 
346
        m_doc->addCommand( new AddDetailFooterCommand( level, m_doc->canvas() ) );
 
347
    }
 
348
}
 
349
 
 
350
void KudesignerView::slotAddItemNothing()
 
351
{
 
352
    if ( m_doc->canvas() )
 
353
    {
 
354
        if ( m_view->itemToInsert )
 
355
        {
 
356
            m_view->itemToInsert = 0;
 
357
        }
 
358
    }
 
359
}
 
360
 
 
361
void KudesignerView::slotAddItemLabel()
 
362
{
 
363
    if ( m_doc->canvas() )
 
364
    {
 
365
        m_view->itemToInsert = Rtti_Label;
 
366
    }
 
367
}
 
368
 
 
369
void KudesignerView::slotAddItemField()
 
370
{
 
371
    if ( m_doc->canvas() )
 
372
    {
 
373
        m_view->itemToInsert = Rtti_Field;
 
374
    }
 
375
}
 
376
 
 
377
void KudesignerView::slotAddItemSpecial()
 
378
{
 
379
    if ( m_doc->canvas() )
 
380
    {
 
381
        m_view->itemToInsert = Rtti_Special;
 
382
    }
 
383
}
 
384
 
 
385
void KudesignerView::slotAddItemCalculated()
 
386
{
 
387
    if ( m_doc->canvas() )
 
388
    {
 
389
        m_view->itemToInsert = Rtti_Calculated;
 
390
    }
 
391
}
 
392
 
 
393
void KudesignerView::slotAddItemLine()
 
394
{
 
395
    if ( m_doc->canvas() )
 
396
    {
 
397
        m_view->itemToInsert = Rtti_Line;
 
398
    }
 
399
}
 
400
 
 
401
void KudesignerView::unselectItemAction()
 
402
{
 
403
    /*    itemsNothing->setOn(true);*/
 
404
}
 
405
 
 
406
void KudesignerView::placeItem( int x, int y, int band, int bandLevel )
 
407
{
 
408
    m_doc->addCommand( new AddReportItemCommand( m_doc->canvas(), m_view, x, y, ( Kudesigner::RttiValues ) band, bandLevel ) );
345
409
}
346
410
 
347
411
#include "kudesigner_view.moc"