~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to parts/classview/classtreebase.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 1999 by Jonas Nordin                                    *
 
3
 *   jonas.nordin@syncom.se                                                *
 
4
 *   Copyright (C) 2000-2001 by Bernd Gehrmann                             *
 
5
 *   bernd@kdevelop.org                                                    *
 
6
 *                                                                         *
 
7
 *   This program is free software; you can redistribute it and/or modify  *
 
8
 *   it under the terms of the GNU General Public License as published by  *
 
9
 *   the Free Software Foundation; either version 2 of the License, or     *
 
10
 *   (at your option) any later version.                                   *
 
11
 *                                                                         *
 
12
 ***************************************************************************/
 
13
 
 
14
#include "classtreebase.h"
 
15
 
 
16
#include <qtooltip.h>
 
17
#include <qheader.h>
 
18
#include <qregexp.h>
 
19
#include <kdebug.h>
 
20
#include <kconfig.h>
 
21
#include <kpopupmenu.h>
 
22
#include <klocale.h>
 
23
#include <kiconloader.h>
 
24
 
 
25
#include "kdevcore.h"
 
26
#include "kdevlanguagesupport.h"
 
27
#include "kdevmainwindow.h"
 
28
#include "kdevpartcontroller.h"
 
29
#include "classstore.h"
 
30
 
 
31
#include "classviewpart.h"
 
32
#include "classtooldlg.h"
 
33
 
 
34
KPopupMenu *ClassTreeItem::createPopup()
 
35
{
 
36
    if (!m_item || m_item->itemType() == PIT_SCOPE)
 
37
        return 0;
 
38
 
 
39
    KDevLanguageSupport::Features features = classTree()->m_part->languageSupport()->features();
 
40
 
 
41
    KPopupMenu *popup = new KPopupMenu();
 
42
    if (features & KDevLanguageSupport::Declarations)
 
43
        popup->insertItem( i18n("Go to Declaration"), classTree(), SLOT(slotGotoDeclaration()) );
 
44
    if (m_item->itemType() == PIT_METHOD)
 
45
        popup->insertItem( i18n("Go to Definition"), classTree(), SLOT(slotGotoImplementation()) );
 
46
 
 
47
    QString title;
 
48
    switch(m_item->itemType()) {
 
49
    case PIT_CLASS:
 
50
        {
 
51
            title = i18n("Class");
 
52
            bool hasAddMethod = features & KDevLanguageSupport::AddMethod;
 
53
            bool hasAddAttribute = features & KDevLanguageSupport::AddAttribute;
 
54
            if (hasAddMethod)
 
55
                popup->insertItem( i18n("Add Method..."), classTree(), SLOT(slotAddMethod()));
 
56
            if (hasAddAttribute)
 
57
                popup->insertItem( i18n("Add Attribute..."), classTree(), SLOT(slotAddAttribute()));
 
58
            popup->insertSeparator();
 
59
            popup->insertItem( i18n("Parent Classes..."), classTree(), SLOT(slotClassBaseClasses()));
 
60
            popup->insertItem( i18n("Child Classes..."), classTree(), SLOT(slotClassDerivedClasses()));
 
61
            popup->insertItem( i18n("Class Tool..."), classTree(), SLOT(slotClassTool()));
 
62
            }
 
63
        break;
 
64
    case PIT_STRUCT:
 
65
        title = i18n("Struct");
 
66
        break;
 
67
    case PIT_ATTRIBUTE:
 
68
        if (m_item->isGlobal())
 
69
            title = i18n("Variable");
 
70
        else
 
71
            title = i18n("Attribute");
 
72
        break;
 
73
    case PIT_METHOD:
 
74
        if (static_cast<ParsedMethod*>(m_item)->isSlot())
 
75
            title = i18n("Slot");
 
76
        else if (static_cast<ParsedMethod*>(m_item)->isSignal())
 
77
            title = i18n("Signal");
 
78
        else if (m_item->isGlobal())
 
79
            title = i18n("Function");
 
80
        else
 
81
            title = i18n("Method");
 
82
        break;
 
83
    default:
 
84
        ;
 
85
    }
 
86
    popup->insertSeparator();
 
87
    popup->insertTitle(title, -1, 0);
 
88
        
 
89
    return popup;
 
90
}
 
91
 
 
92
 
 
93
QString ClassTreeItem::scopedText() const
 
94
{
 
95
    if (m_item)
 
96
        return m_item->path();
 
97
 
 
98
    return QString::null;
 
99
}
 
100
 
 
101
 
 
102
void ClassTreeItem::getDeclaration(QString *toFile, int *toLine)
 
103
{
 
104
    if (m_item) {
 
105
        *toFile = m_item->declaredInFile();
 
106
        *toLine = m_item->declaredOnLine();
 
107
    }
 
108
}
 
109
 
 
110
 
 
111
void ClassTreeItem::getImplementation(QString *toFile, int *toLine)
 
112
{
 
113
    if (m_item) {
 
114
        *toFile = m_item->definedInFile();
 
115
        *toLine = m_item->definedOnLine();
 
116
    }
 
117
}
 
118
 
 
119
 
 
120
QString ClassTreeItem::text( int ) const
 
121
{
 
122
    if (m_item)
 
123
        return m_item->asString();
 
124
    return QString::null;
 
125
}
 
126
 
 
127
 
 
128
QString ClassTreeItem::tipText() const
 
129
{
 
130
    // Purposefully avoid virtual dispatch here
 
131
    return ClassTreeItem::text(0);
 
132
}
 
133
 
 
134
 
 
135
void ClassTreeOrganizerItem::init()
 
136
{
 
137
    setExpandable(true);
 
138
    setPixmap(0, SmallIcon("folder"));
 
139
}
 
140
 
 
141
 
 
142
void ClassTreeScopeItem::init()
 
143
{
 
144
    setExpandable(true);
 
145
    setPixmap(0, UserIcon("CVnamespace", KIcon::DefaultState, ClassViewFactory::instance()));
 
146
}
 
147
 
 
148
 
 
149
QString ClassTreeScopeItem::text( int col ) const
 
150
{
 
151
    if (!m_item)
 
152
        return QString::null;
 
153
    if (m_item->name().isEmpty())
 
154
        return i18n("Global");
 
155
    return ClassTreeItem::text( col );
 
156
}
 
157
 
 
158
 
 
159
void ClassTreeScopeItem::setOpen(bool o)
 
160
{
 
161
    if ( !m_item)
 
162
        return;
 
163
 
 
164
    kdDebug(9003) << (o? "Open scope item" : "Close scope item") << endl;
 
165
    if (o && childCount() == 0) {
 
166
 
 
167
        ParsedScopeContainer *pScope = static_cast<ParsedScopeContainer*>(m_item);
 
168
        ClassTreeItem *lastItem = 0;
 
169
 
 
170
        // Ok, this is a hack...
 
171
        KDevLanguageSupport::Features features = classTree()->m_part->languageSupport()->features();
 
172
        
 
173
        // Add namespaces
 
174
        QValueList<ParsedScopeContainer*> scopeList = pScope->getSortedScopeList();
 
175
        QValueList<ParsedScopeContainer*>::ConstIterator it;
 
176
        for (it = scopeList.begin(); it != scopeList.end(); ++it)
 
177
            lastItem = new ClassTreeScopeItem(this, lastItem, *it);
 
178
 
 
179
        if (features & KDevLanguageSupport::Classes) {
 
180
            // Add classes
 
181
            QValueList<ParsedClass*> classList = pScope->getSortedClassList();
 
182
            QValueList<ParsedClass*>::ConstIterator it;
 
183
            for (it = classList.begin(); it != classList.end(); ++it)
 
184
                lastItem = new ClassTreeClassItem(this, lastItem, *it);
 
185
        }
 
186
            
 
187
        if (features & KDevLanguageSupport::Structs) {
 
188
            // Add structs
 
189
            QValueList<ParsedClass*> structList = pScope->getSortedStructList();
 
190
            QValueList<ParsedClass*>::ConstIterator it;
 
191
            for (it = structList.begin(); it != structList.end(); ++it)
 
192
                lastItem = new ClassTreeClassItem(this, lastItem, *it, true);
 
193
        }
 
194
 
 
195
        if (features & KDevLanguageSupport::Functions) {
 
196
            // Add functions
 
197
            QValueList<ParsedMethod*> methodList = pScope->getSortedMethodList();
 
198
            QValueList<ParsedMethod*>::ConstIterator it;
 
199
            for (it = methodList.begin(); it != methodList.end(); ++it)
 
200
                lastItem = new ClassTreeMethodItem(this, lastItem, *it);
 
201
        }
 
202
 
 
203
        if (features & KDevLanguageSupport::Variables) {
 
204
            // Add attributes
 
205
            QValueList<ParsedAttribute*> attrList = pScope->getSortedAttributeList();
 
206
            QValueList<ParsedAttribute*>::ConstIterator it;
 
207
            for (it = attrList.begin(); it != attrList.end(); ++it)
 
208
                lastItem = new ClassTreeAttrItem(this, lastItem, *it);
 
209
        }
 
210
 
 
211
    }
 
212
 
 
213
    ClassTreeItem::setOpen(o);
 
214
}
 
215
 
 
216
 
 
217
void ClassTreeClassItem::init()
 
218
{
 
219
    setExpandable(true);
 
220
    setPixmap(0, UserIcon(m_isStruct ? "CVstruct" : "CVclass", KIcon::DefaultState, ClassViewFactory::instance()));
 
221
}
 
222
 
 
223
 
 
224
void ClassTreeClassItem::setOpen(bool o)
 
225
{
 
226
    if ( !m_item )
 
227
        return;
 
228
    kdDebug(9003) << (o? "Open class item" : "Close class item") << endl;
 
229
    if (o && childCount() == 0) {
 
230
 
 
231
        ParsedClass *pClass = static_cast<ParsedClass*>(m_item);
 
232
        ClassTreeItem *lastItem = 0;
 
233
 
 
234
        // Add nested classes
 
235
        QValueList<ParsedClass*> classList = pClass->getSortedClassList();
 
236
        QValueList<ParsedClass*>::ConstIterator classIt;
 
237
        for (classIt = classList.begin(); classIt != classList.end(); ++classIt)
 
238
            lastItem = new ClassTreeClassItem(this, lastItem, *classIt);
 
239
 
 
240
        // Add nested structs
 
241
        QValueList<ParsedClass*> structList = pClass->getSortedStructList();
 
242
        QValueList<ParsedClass*>::ConstIterator structIt;
 
243
        for (structIt = structList.begin(); structIt != structList.end(); ++structIt)
 
244
            lastItem = new ClassTreeClassItem(this, lastItem, *structIt, true);
 
245
 
 
246
        // Add methods
 
247
        QValueList<ParsedMethod*> methodList = pClass->getSortedMethodList();
 
248
        QValueList<ParsedMethod*>::ConstIterator methodIt;
 
249
        for (methodIt = methodList.begin(); methodIt != methodList.end(); ++methodIt)
 
250
            lastItem = new ClassTreeMethodItem(this, lastItem, *methodIt);
 
251
 
 
252
        // Add slots
 
253
        QValueList<ParsedMethod*> slotList = pClass->getSortedSlotList();
 
254
        QValueList<ParsedMethod*>::ConstIterator slotIt;
 
255
        for (slotIt = slotList.begin(); slotIt != slotList.end(); ++slotIt)
 
256
            lastItem = new ClassTreeMethodItem(this, lastItem, *slotIt);
 
257
 
 
258
        // Add signals
 
259
        QValueList<ParsedMethod*> signalList = pClass->getSortedSignalList();
 
260
        QValueList<ParsedMethod*>::ConstIterator signalIt;
 
261
        for (signalIt = signalList.begin(); signalIt != signalList.end(); ++signalIt)
 
262
            lastItem = new ClassTreeMethodItem(this, lastItem, *signalIt);
 
263
 
 
264
        // Add attributes
 
265
        QValueList<ParsedAttribute*> attrList = pClass->getSortedAttributeList();
 
266
        QValueList<ParsedAttribute*>::ConstIterator attrIt;
 
267
        for (attrIt = attrList.begin(); attrIt != attrList.end(); ++attrIt)
 
268
            lastItem = new ClassTreeAttrItem(this, lastItem, *attrIt);
 
269
        
 
270
    }
 
271
    
 
272
    ClassTreeItem::setOpen(o);
 
273
}
 
274
 
 
275
ClassTreeMethodItem::ClassTreeMethodItem(ClassTreeItem *parent, ClassTreeItem *lastSibling,
 
276
                                         ParsedMethod *parsedMethod)
 
277
    : ClassTreeItem(parent, lastSibling, parsedMethod)
 
278
{
 
279
    QString icon;
 
280
 
 
281
    if ( !parsedMethod )
 
282
      return;
 
283
 
 
284
    if (parsedMethod->isSignal())
 
285
        icon = "CVpublic_signal";
 
286
    else if (parsedMethod->isSlot()) {
 
287
        if (parsedMethod->isPublic())
 
288
            icon = "CVpublic_slot";
 
289
        else if (parsedMethod->isProtected())
 
290
            icon = "CVprotected_slot";
 
291
        else
 
292
            icon = "CVprivate_slot";
 
293
    }
 
294
    else if (parsedMethod->isPublic())
 
295
        icon = "CVpublic_meth";
 
296
    else if (parsedMethod->isProtected())
 
297
        icon = "CVprotected_meth";
 
298
    else if (parsedMethod->isPrivate())
 
299
        icon = "CVprivate_meth";
 
300
    else if (parsedMethod->isPackage())
 
301
        icon = "CVpackage_meth";
 
302
    else
 
303
        icon = "CVglobal_meth";
 
304
 
 
305
    setPixmap(0, UserIcon(icon, KIcon::DefaultState, ClassViewFactory::instance()));
 
306
}
 
307
 
 
308
QString ClassTreeMethodItem::text( int ) const
 
309
{
 
310
    QString str;
 
311
 
 
312
    if ( !m_item )
 
313
        return QString::null;
 
314
 
 
315
    ParsedMethod* method = static_cast<ParsedMethod*>(m_item);
 
316
 
 
317
    str = method->name();
 
318
    
 
319
    if( method->arguments.count() > 0 ) {
 
320
        str += "( ";
 
321
        for ( ParsedArgument *arg = method->arguments.first(); arg != NULL; arg = method->arguments.next() ) {
 
322
            if ( arg != method->arguments.getFirst() )
 
323
                str += ", ";
 
324
 
 
325
            str += arg->toString();
 
326
        }
 
327
        str += " )";
 
328
    } else {
 
329
        str += "()";
 
330
    }
 
331
    
 
332
    if( method->isConst() )
 
333
        str += " const";
 
334
 
 
335
    return str;
 
336
}
 
337
 
 
338
 
 
339
ClassTreeAttrItem::ClassTreeAttrItem(ClassTreeItem *parent, ClassTreeItem *lastSibling,
 
340
                                     ParsedAttribute *parsedAttr)
 
341
    : ClassTreeItem(parent, lastSibling, parsedAttr)
 
342
{
 
343
    QString icon;
 
344
    
 
345
    if ( !parsedAttr )
 
346
      return;
 
347
 
 
348
    if (parsedAttr->isPublic())
 
349
        icon = "CVpublic_var";
 
350
    else if (parsedAttr->isProtected())
 
351
        icon = "CVprotected_var";
 
352
    else if (parsedAttr->isPrivate())
 
353
        icon = "CVprivate_var";
 
354
    else if (parsedAttr->isPackage())
 
355
        icon = "CVpackage_var";
 
356
    else
 
357
        icon = "CVglobal_var";
 
358
 
 
359
    setPixmap(0, UserIcon(icon, KIcon::DefaultState, ClassViewFactory::instance()));
 
360
}
 
361
 
 
362
 
 
363
QString ClassTreeAttrItem::text( int ) const
 
364
{
 
365
    if ( !m_item )
 
366
        return QString::null;
 
367
    return m_item->name();
 
368
}
 
369
 
 
370
ClassTreeScriptItem::ClassTreeScriptItem(ClassTreeItem *parent, ClassTreeItem *lastSibling,
 
371
                                     ParsedScript *parsedScript)
 
372
    : ClassTreeItem(parent, lastSibling, parsedScript)
 
373
{
 
374
    QString icon;
 
375
 
 
376
    if ( !parsedScript )
 
377
      return;
 
378
 
 
379
    setExpandable(true);
 
380
 
 
381
    //need a icon for scripts
 
382
    icon = "CVpublic_var";
 
383
    setPixmap(0, UserIcon(icon, KIcon::DefaultState, ClassViewFactory::instance()));
 
384
}
 
385
 
 
386
 
 
387
QString ClassTreeScriptItem::text( int ) const
 
388
{
 
389
    if ( !m_item )
 
390
        return QString::null;
 
391
    return m_item->name();
 
392
}
 
393
 
 
394
void ClassTreeScriptItem::setOpen(bool o)
 
395
{
 
396
    if ( !m_item )
 
397
        return;
 
398
    kdDebug(9003) << (o? "Open script item" : "Close script item") << endl;
 
399
    if (o && childCount() == 0) {
 
400
 
 
401
        ParsedScript *pClass = static_cast<ParsedScript*>(m_item);
 
402
        ClassTreeItem *lastItem = 0;
 
403
 
 
404
        // Add methods
 
405
        QValueList<ParsedMethod*> methodList = pClass->getSortedMethodList();
 
406
        QValueList<ParsedMethod*>::ConstIterator methodIt;
 
407
        for (methodIt = methodList.begin(); methodIt != methodList.end(); ++methodIt)
 
408
            lastItem = new ClassTreeMethodItem(this, lastItem, *methodIt);
 
409
 
 
410
        // Add attributes
 
411
        QValueList<ParsedAttribute*> attrList = pClass->getSortedAttributeList();
 
412
        QValueList<ParsedAttribute*>::ConstIterator attrIt;
 
413
        for (attrIt = attrList.begin(); attrIt != attrList.end(); ++attrIt)
 
414
            lastItem = new ClassTreeAttrItem(this, lastItem, *attrIt);
 
415
 
 
416
    }
 
417
 
 
418
    ClassTreeItem::setOpen(o);
 
419
}
 
420
 
 
421
 
 
422
class ClassToolTip : public QToolTip
 
423
{
 
424
public:
 
425
    ClassToolTip( QWidget *parent )
 
426
        : QToolTip(parent)
 
427
        {}
 
428
 
 
429
protected:
 
430
    void maybeTip(const QPoint &p);
 
431
};
 
432
 
 
433
 
 
434
void ClassToolTip::maybeTip(const QPoint &p)
 
435
{
 
436
    ClassTreeBase *ctw = static_cast<ClassTreeBase*>(parentWidget());
 
437
 
 
438
    QListViewItem *item = ctw->itemAt(p);
 
439
    QRect r = ctw->itemRect(item);
 
440
 
 
441
    if (item && r.isValid()) {
 
442
        ClassTreeItem *ctitem = static_cast<ClassTreeItem*>(item);
 
443
        QString str = ctitem->tipText();
 
444
        if (!str.isEmpty())
 
445
            tip(r, str);
 
446
    }
 
447
}
 
448
 
 
449
 
 
450
ClassTreeBase::ClassTreeBase(ClassViewPart *part, QWidget *parent, const char *name)
 
451
    : KListView(parent, name)
 
452
{
 
453
    setFocusPolicy(ClickFocus);
 
454
    setRootIsDecorated(true);
 
455
    setResizeMode(QListView::LastColumn);
 
456
    setSorting(-1);
 
457
    header()->hide();
 
458
    addColumn(QString::null);
 
459
 
 
460
    (void) new ClassToolTip(this);
 
461
    
 
462
    connect( this, SIGNAL(executed(QListViewItem*)),
 
463
             this, SLOT(slotItemExecuted(QListViewItem*)) );
 
464
    connect( this, SIGNAL(mouseButtonPressed(int, QListViewItem*, const QPoint&, int)),
 
465
             this, SLOT(slotItemPressed(int, QListViewItem*)) );
 
466
    connect( this, SIGNAL(returnPressed( QListViewItem*)), 
 
467
             SLOT( slotItemExecuted(QListViewItem*)) );
 
468
    connect( this, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)),
 
469
             this, SLOT(slotContextMenuRequested(QListViewItem*, const QPoint&)) );
 
470
 
 
471
    m_part = part;
 
472
}
 
473
 
 
474
 
 
475
ClassTreeBase::~ClassTreeBase()
 
476
{}
 
477
 
 
478
 
 
479
ClassTreeBase::TreeState ClassTreeBase::treeState() const
 
480
{
 
481
    TreeState state;
 
482
 
 
483
    ClassTreeBase *that = const_cast<ClassTreeBase*>(this);
 
484
    QListViewItemIterator it(that);
 
485
    for (; it.current(); ++it)
 
486
        if (it.current()->isOpen()) {
 
487
            QStringList path;
 
488
            QListViewItem *item = it.current();
 
489
            while (item) {
 
490
                path.prepend(item->text(0));
 
491
                item = item->parent();
 
492
            }
 
493
            state.append(path);
 
494
        }
 
495
 
 
496
    return state;
 
497
}
 
498
 
 
499
 
 
500
void ClassTreeBase::setTreeState(TreeState state)
 
501
{
 
502
    TreeStateIterator tsit;
 
503
    for (tsit = state.begin(); tsit != state.end(); ++tsit) {
 
504
        QListViewItemIterator it(this);
 
505
        for (; it.current(); ++it) {
 
506
            QStringList path;
 
507
            QListViewItem *item = it.current();
 
508
            while (item) {
 
509
                path.prepend(item->text(0));
 
510
                item = item->parent();
 
511
            }
 
512
            if (*tsit == path) {
 
513
                it.current()->setOpen(true);
 
514
                break;
 
515
            }
 
516
        }
 
517
    }
 
518
}
 
519
 
 
520
 
 
521
 
 
522
  
 
523
void ClassTreeBase::slotItemExecuted( QListViewItem* item )
 
524
{
 
525
    if (!item)
 
526
        return;
 
527
 
 
528
    // toggle open state for parents
 
529
    if (item->childCount() > 0)
 
530
        setOpen(item, !isOpen(item));
 
531
 
 
532
    // We assume here that ALL (!) items in the list view
 
533
    // are ClassTreeItem's
 
534
    ClassTreeItem *ctitem = static_cast<ClassTreeItem*>(item);
 
535
    if (ctitem->isOrganizer())
 
536
        return;
 
537
        
 
538
    QString toFile;
 
539
    int toLine = -1;
 
540
    if (dynamic_cast<ClassTreeClassItem*>(item)) {
 
541
        ctitem->getDeclaration(&toFile, &toLine);
 
542
    }
 
543
    else {
 
544
        ctitem->getImplementation(&toFile, &toLine);
 
545
    }
 
546
    m_part->partController()->editDocument(toFile, toLine);
 
547
    m_part->mainWindow()->lowerView(this);
 
548
}
 
549
 
 
550
 
 
551
void ClassTreeBase::slotItemPressed(int button, QListViewItem *item)
 
552
{
 
553
    if (!item)
 
554
        return;
 
555
 
 
556
    // We assume here that ALL (!) items in the list view
 
557
    // are ClassTreeItem's
 
558
    ClassTreeItem *ctitem = static_cast<ClassTreeItem*>(item);
 
559
    if (ctitem->isOrganizer())
 
560
        return;
 
561
 
 
562
    if (button == MidButton) {
 
563
        QString toFile;
 
564
        int toLine = -1;
 
565
        ctitem->getDeclaration(&toFile, &toLine);
 
566
        m_part->partController()->editDocument(toFile, toLine);
 
567
        m_part->mainWindow()->lowerView(this);
 
568
    }
 
569
}
 
570
 
 
571
void ClassTreeBase::slotContextMenuRequested(QListViewItem *item, const QPoint &p)
 
572
{
 
573
    contextItem = static_cast<ClassTreeItem*>(item);
 
574
    
 
575
    KPopupMenu *popup = createPopup();
 
576
    popup->exec(p);
 
577
    delete popup;
 
578
}
 
579
 
 
580
void ClassTreeBase::slotGotoDeclaration()
 
581
{
 
582
    QString toFile;
 
583
    int toLine = -1;
 
584
    
 
585
    contextItem->getDeclaration(&toFile, &toLine);
 
586
    m_part->partController()->editDocument(toFile, toLine);
 
587
}
 
588
 
 
589
 
 
590
void ClassTreeBase::slotGotoImplementation()
 
591
{
 
592
    QString toFile;
 
593
    int toLine = -1;
 
594
    
 
595
    contextItem->getImplementation(&toFile, &toLine);
 
596
    m_part->partController()->editDocument(toFile, toLine);
 
597
}
 
598
 
 
599
 
 
600
void ClassTreeBase::slotAddMethod()
 
601
{
 
602
    if (m_part->languageSupport())
 
603
        m_part->languageSupport()->addMethod(contextItem->scopedText());
 
604
}
 
605
 
 
606
 
 
607
void ClassTreeBase::slotAddAttribute()
 
608
{
 
609
    if (m_part->languageSupport())
 
610
        m_part->languageSupport()->addAttribute(contextItem->scopedText());
 
611
}
 
612
 
 
613
 
 
614
void ClassTreeBase::slotClassBaseClasses()
 
615
{
 
616
    ClassToolDialog *dlg = new ClassToolDialog(m_part);
 
617
    dlg->setClassName(contextItem->scopedText());
 
618
    dlg->viewParents();
 
619
}
 
620
 
 
621
 
 
622
void ClassTreeBase::slotClassDerivedClasses()
 
623
{
 
624
    ClassToolDialog *dlg = new ClassToolDialog(m_part);
 
625
    dlg->setClassName(contextItem->scopedText());
 
626
    dlg->viewChildren();
 
627
}
 
628
 
 
629
 
 
630
void ClassTreeBase::slotClassTool()
 
631
{
 
632
    ClassToolDialog *dlg = new ClassToolDialog(m_part);
 
633
    dlg->setClassName(contextItem->scopedText());
 
634
    dlg->viewNone();
 
635
}
 
636
 
 
637
#include "classtreebase.moc"