File indexing completed on 2024-04-21 04:58:00

0001 /* This file is part of KCachegrind.
0002     SPDX-FileCopyrightText: 2002-2009 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only
0005 */
0006 
0007 /**
0008  * A Widget for visualizing hierarchical metrics as areas.
0009  * The API is similar to QListView.
0010  *
0011  * This file defines the following classes:
0012  *  DrawParams, RectDrawing, TreeMapItem, TreeMapWidget
0013  *
0014  * DrawParams/RectDrawing allows reusing of TreeMap drawing
0015  * functions in other widgets.
0016  */
0017 
0018 #ifndef TREEMAP_H
0019 #define TREEMAP_H
0020 
0021 #include <QString>
0022 #include <QWidget>
0023 #include <QPixmap>
0024 #include <QColor>
0025 #include <QStringList>
0026 #include <QPaintEvent>
0027 #include <QKeyEvent>
0028 #include <QContextMenuEvent>
0029 #include <QMenu>
0030 #include <QMouseEvent>
0031 #include <kconfiggroup.h>
0032 
0033 class TreeMapWidget;
0034 class TreeMapItem;
0035 class TreeMapItemList;
0036 
0037 /**
0038  * Drawing parameters for an object.
0039  * A Helper Interface for RectDrawing.
0040  */
0041 class DrawParams
0042 {
0043 public:
0044     /**
0045      * Positions for drawing into a rectangle.
0046      *
0047      * The specified position assumes no rotation.
0048      * If there is more than one text for one position, it is put
0049      * nearer to the center of the item.
0050      *
0051      * Drawing at top positions cuts free space from top,
0052      * drawing at bottom positions cuts from bottom.
0053      * Default usually gives positions clockwise according to field number.
0054      */
0055     enum Position { TopLeft, TopCenter, TopRight,
0056                     BottomLeft, BottomCenter, BottomRight,
0057                     Default, Unknown
0058                   };
0059 
0060     // no constructor as this is an abstract class
0061     virtual ~DrawParams() {}
0062 
0063     virtual QString  text(int) const = 0;
0064     virtual QPixmap  pixmap(int) const = 0;
0065     virtual Position position(int) const = 0;
0066     // 0: no limit, negative: leave at least -maxLines() free
0067     virtual int      maxLines(int) const
0068     {
0069         return 0;
0070     }
0071     virtual int      fieldCount() const
0072     {
0073         return 0;
0074     }
0075 
0076     virtual QColor   backColor() const
0077     {
0078         return Qt::white;
0079     }
0080     virtual const QFont &font() const = 0;
0081 
0082     virtual bool selected() const
0083     {
0084         return false;
0085     }
0086     virtual bool current() const
0087     {
0088         return false;
0089     }
0090     virtual bool shaded() const
0091     {
0092         return true;
0093     }
0094     virtual bool rotated() const
0095     {
0096         return false;
0097     }
0098     virtual bool drawFrame() const
0099     {
0100         return true;
0101     }
0102 };
0103 
0104 /*
0105  * DrawParam with attributes stored
0106  */
0107 class StoredDrawParams: public DrawParams
0108 {
0109 public:
0110     StoredDrawParams();
0111     explicit StoredDrawParams(const QColor &c,
0112                               bool selected = false, bool current = false);
0113 
0114     // getters
0115     QString  text(int) const override;
0116     QPixmap  pixmap(int) const override;
0117     Position position(int) const override;
0118     int      maxLines(int) const override;
0119     int      fieldCount() const override
0120     {
0121         return _field.size();
0122     }
0123 
0124     QColor   backColor() const override
0125     {
0126         return _backColor;
0127     }
0128     bool selected() const override
0129     {
0130         return _selected;
0131     }
0132     bool current() const override
0133     {
0134         return _current;
0135     }
0136     bool shaded() const override
0137     {
0138         return _shaded;
0139     }
0140     bool rotated() const override
0141     {
0142         return _rotated;
0143     }
0144     bool drawFrame() const override
0145     {
0146         return _drawFrame;
0147     }
0148 
0149     const QFont &font() const override;
0150 
0151     // attribute setters
0152     void setField(int f, const QString &t, const QPixmap &pm = QPixmap(),
0153                   Position p = Default, int maxLines = 0);
0154     void setText(int f, const QString &);
0155     void setPixmap(int f, const QPixmap &);
0156     void setPosition(int f, Position);
0157     void setMaxLines(int f, int);
0158     void setBackColor(const QColor &c)
0159     {
0160         _backColor = c;
0161     }
0162     void setSelected(bool b)
0163     {
0164         _selected = b;
0165     }
0166     void setCurrent(bool b)
0167     {
0168         _current = b;
0169     }
0170     void setShaded(bool b)
0171     {
0172         _shaded = b;
0173     }
0174     void setRotated(bool b)
0175     {
0176         _rotated = b;
0177     }
0178     void drawFrame(bool b)
0179     {
0180         _drawFrame = b;
0181     }
0182 
0183 protected:
0184     QColor _backColor;
0185     bool _selected : 1;
0186     bool _current : 1;
0187     bool _shaded : 1;
0188     bool _rotated : 1;
0189     bool _drawFrame : 1;
0190 
0191 private:
0192     // resize field array if needed to allow to access field <f>
0193     void ensureField(int f);
0194 
0195     struct Field {
0196         QString text;
0197         QPixmap pix;
0198         Position pos;
0199         int maxLines;
0200     };
0201 
0202     QVector<Field> _field;
0203 };
0204 
0205 /* State for drawing on a rectangle.
0206  *
0207  * Following drawing functions are provided:
0208  * - background drawing with shading and 3D frame
0209  * - successive pixmap/text drawing at various positions with wrap-around
0210  *   optimized for minimal space usage (e.g. if a text is drawn at top right
0211  *   after text on top left, the same line is used if space allows)
0212  *
0213  */
0214 class RectDrawing
0215 {
0216 public:
0217     RectDrawing(const QRect &);
0218     ~RectDrawing();
0219 
0220     // The default DrawParams object used.
0221     DrawParams *drawParams();
0222     // we take control over the given object (i.e. delete at destruction)
0223     void setDrawParams(DrawParams *);
0224 
0225     // draw on a given QPainter, use this class as info provider per default
0226     void drawBack(QPainter *, DrawParams *dp = nullptr);
0227     /* Draw field at position() from pixmap()/text() with maxLines().
0228      * Returns true if something was drawn
0229      */
0230     bool drawField(QPainter *, int f, DrawParams *dp = nullptr);
0231 
0232     // resets rectangle for free space
0233     void setRect(const QRect &);
0234 
0235     // Returns the rectangle area still free of text/pixmaps after
0236     // a number of drawText() calls.
0237     QRect remainingRect(DrawParams *dp = nullptr);
0238 
0239 private:
0240     int _usedTopLeft, _usedTopCenter, _usedTopRight;
0241     int _usedBottomLeft, _usedBottomCenter, _usedBottomRight;
0242     QRect _rect;
0243 
0244     // temporary
0245     int _fontHeight;
0246     QFontMetrics *_fm;
0247     DrawParams *_dp;
0248 };
0249 
0250 class TreeMapItemList: public QList<TreeMapItem *>
0251 {
0252 public:
0253     TreeMapItem *commonParent();
0254 };
0255 
0256 /**
0257  * Base class of items in TreeMap.
0258  *
0259  * This class supports an arbitrary number of text() strings
0260  * positioned counterclock-wise starting at TopLeft. Each item
0261  * has its own static value(), sum() and sorting(). The
0262  * splitMode() and borderWidth() is taken from a TreeMapWidget.
0263  *
0264  * If you want more flexibility, reimplement TreeMapItem and
0265  * override the corresponding methods. For dynamic creation of child
0266  * items on demand, reimplement children().
0267  */
0268 class TreeMapItem: public StoredDrawParams
0269 {
0270 public:
0271 
0272     /**
0273      * Split direction for nested areas:
0274      *  AlwaysBest: Choose split direction for every subitem according to
0275      *              longest side of rectangle left for drawing
0276      *  Best:       Choose split direction for all subitems of an area
0277      *              depending on longest side
0278      *  HAlternate: Horizontal at top;  alternate direction on depth step
0279      *  VAlternate: Vertical at top; alternate direction on depth step
0280      *  Horizontal: Always horizontal split direction
0281      *  Vertical:   Always vertical split direction
0282      */
0283     enum SplitMode { Bisection, Columns, Rows,
0284                      AlwaysBest, Best,
0285                      HAlternate, VAlternate,
0286                      Horizontal, Vertical
0287                    };
0288 
0289     explicit TreeMapItem(TreeMapItem *parent = nullptr, double value = 1.0);
0290     TreeMapItem(TreeMapItem *parent, double value,
0291                 const QString &text1, const QString &text2 = QString(),
0292                 const QString &text3 = QString(), const QString &text4 = QString());
0293     ~TreeMapItem() override;
0294 
0295     bool isChildOf(TreeMapItem *);
0296 
0297     TreeMapItem *commonParent(TreeMapItem *item);
0298 
0299     // force a redraw of this item
0300     void redraw();
0301 
0302     // delete all children
0303     void clear();
0304 
0305     // force new child generation & refresh
0306     void refresh();
0307 
0308     // call in a reimplemented items() method to check if already called
0309     // after a clear(), this will return false
0310     bool initialized();
0311 
0312     /**
0313      * Adds an item to a parent.
0314      * When no sorting is used, the item is appended (drawn at bottom).
0315      * This is only needed if the parent was not already specified in the
0316      * construction of the item.
0317      */
0318     void addItem(TreeMapItem *);
0319 
0320     /**
0321      * Returns a list of text strings of specified text number,
0322      * from root up to this item.
0323      */
0324     QStringList path(int) const;
0325 
0326     /**
0327      * Depth of this item. This is the distance to root.
0328      */
0329     int depth() const;
0330 
0331     /**
0332      * Parent Item
0333      */
0334     TreeMapItem *parent() const
0335     {
0336         return _parent;
0337     }
0338 
0339     /**
0340      * Temporary rectangle used for drawing this item the last time.
0341      * This is internally used to map from a point to an item.
0342      */
0343     void setItemRect(const QRect &r)
0344     {
0345         _rect = r;
0346     }
0347     void clearItemRect();
0348     const QRect &itemRect() const
0349     {
0350         return _rect;
0351     }
0352     int width() const
0353     {
0354         return _rect.width();
0355     }
0356     int height() const
0357     {
0358         return _rect.height();
0359     }
0360 
0361     /**
0362      * Temporary rectangle list of free space of this item.
0363      * Used internally to enable tooltip.
0364      */
0365     void clearFreeRects();
0366     const QList<QRect> &freeRects() const
0367     {
0368         return _freeRects;
0369     }
0370     void addFreeRect(const QRect &r);
0371 
0372     /**
0373      * Temporary child item index of the child that was current() recently.
0374      */
0375     int index() const
0376     {
0377         return _index;
0378     }
0379     void setIndex(int i)
0380     {
0381         _index = i;
0382     }
0383 
0384     /**
0385      * TreeMap widget this item is put in.
0386      */
0387     TreeMapWidget *widget() const
0388     {
0389         return _widget;
0390     }
0391 
0392     void setParent(TreeMapItem *p);
0393     void setWidget(TreeMapWidget *w)
0394     {
0395         _widget = w;
0396     }
0397     void setSum(double s)
0398     {
0399         _sum = s;
0400     }
0401     void setValue(double s)
0402     {
0403         _value = s;
0404     }
0405 
0406     virtual double sum() const;
0407     virtual double value() const;
0408     // replace "Default" position with setting from TreeMapWidget
0409     Position position(int) const override;
0410     const QFont &font() const override;
0411     virtual bool isMarked(int) const;
0412 
0413     virtual int borderWidth() const;
0414 
0415     /**
0416      * Returns the text number after that sorting is done or
0417      * -1 for no sorting, -2 for value() sorting (default).
0418      * If ascending != 0, a bool value is written at that location
0419      * to indicate if sorting should be ascending.
0420      */
0421     virtual int sorting(bool *ascending) const;
0422 
0423     /**
0424      * Set the sorting for child drawing.
0425      *
0426      * Default is no sorting: <textNo> = -1
0427      * For value() sorting, use <textNo> = -2
0428      *
0429      * For fast sorting, set this to -1 before child insertions and call
0430      * again after inserting all children.
0431      */
0432     void setSorting(int textNo, bool ascending = true);
0433 
0434     /**
0435      * Resort according to the already set sorting.
0436      *
0437      * This has to be done if the sorting base changes (e.g. text or values
0438      * change). If this is only true for the children of this item, you can
0439      * set the recursive parameter to false.
0440      */
0441     void resort(bool recursive = true);
0442 
0443     virtual SplitMode splitMode() const;
0444     virtual int rtti() const;
0445     // not const as this can create children on demand
0446     virtual TreeMapItemList *children();
0447 
0448 protected:
0449     TreeMapItemList *_children;
0450     double _sum, _value;
0451 
0452 private:
0453     TreeMapWidget *_widget;
0454     TreeMapItem *_parent;
0455 
0456     int _sortTextNo;
0457     bool _sortAscending;
0458 
0459     // temporary layout
0460     QRect _rect;
0461     QList<QRect> _freeRects;
0462     int _depth;
0463 
0464     // temporary self value (when using level skipping)
0465     double _unused_self;
0466 
0467     // index of last active subitem
0468     int _index;
0469 };
0470 
0471 /**
0472  * Class for visualization of a metric of hierarchically
0473  * nested items as 2D areas.
0474  */
0475 class TreeMapWidget: public QWidget
0476 {
0477     Q_OBJECT
0478 
0479 public:
0480 
0481     /**
0482      * Same as in QListBox/QListView
0483      */
0484     enum SelectionMode { Single, Multi, Extended, NoSelection };
0485 
0486     /* The widget gets owner of the base item */
0487     explicit TreeMapWidget(TreeMapItem *base, QWidget *parent = nullptr);
0488     ~TreeMapWidget() override;
0489 
0490     /**
0491      * Returns the TreeMapItem filling out the widget space
0492      */
0493     TreeMapItem *base() const
0494     {
0495         return _base;
0496     }
0497 
0498     /**
0499      * Returns a reference to the current widget font.
0500      */
0501     const QFont &currentFont() const;
0502 
0503     /**
0504      * Returns the area item at position x/y, independent from any
0505      * maxSelectDepth setting.
0506      */
0507     TreeMapItem *item(int x, int y) const;
0508 
0509     /**
0510      * Returns the nearest item with a visible area; this
0511      * can be the given item itself.
0512      */
0513     TreeMapItem *visibleItem(TreeMapItem *) const;
0514 
0515     /**
0516      * Returns the item possible for selection. this returns the
0517      * given item itself or a parent thereof,
0518      * depending on setting of maxSelectDepth().
0519      */
0520     TreeMapItem *possibleSelection(TreeMapItem *) const;
0521 
0522     /**
0523      * Selects or unselects an item.
0524      * In multiselection mode, the constrain that a selected item
0525      * has no selected children or parents stays true.
0526      */
0527     void setSelected(TreeMapItem *, bool selected = true);
0528 
0529     /**
0530      * Switches on the marking <markNo>. Marking 0 switches off marking.
0531      * This is mutually exclusive to selection, and is automatically
0532      * switched off when selection is changed (also by the user).
0533      * Marking is visually the same as selection, and is based on
0534      * TreeMapItem::isMarked(<markNo>).
0535      * This enables to programmatically show multiple selected items
0536      * at once even in single selection mode.
0537      */
0538     void setMarked(int markNo = 1, bool redraw = true);
0539 
0540     /**
0541      * Clear selection of all selected items which are children of
0542      * parent. When parent == 0, clears whole selection
0543      * Returns true if selection changed.
0544      */
0545     bool clearSelection(TreeMapItem *parent = nullptr);
0546 
0547     /**
0548      * Selects or unselects items in a range.
0549      * This is needed internally for Shift-Click in Extended mode.
0550      * Range means for a hierarchical widget:
0551      * - select/unselect i1 and i2 according selected
0552      * - search common parent of i1 and i2, and select/unselect the
0553      *   range of direct children between but excluding the child
0554      *   leading to i1 and the child leading to i2.
0555      */
0556     void setRangeSelection(TreeMapItem *i1,
0557                            TreeMapItem *i2, bool selected);
0558 
0559     /**
0560      * Sets the current item.
0561      * The current item is mainly used for keyboard navigation.
0562      */
0563     void setCurrent(TreeMapItem *, bool kbd = false);
0564 
0565     /**
0566      * Set the maximal depth a selected item can have.
0567      * If you try to select a item with higher depth, the ancestor holding
0568      * this condition is used.
0569      *
0570      * See also possibleSelection().
0571      */
0572     void setMaxSelectDepth(int d)
0573     {
0574         _maxSelectDepth = d;
0575     }
0576 
0577     void setSelectionMode(SelectionMode m)
0578     {
0579         _selectionMode = m;
0580     }
0581 
0582     /**
0583      * for setting/getting global split direction
0584      */
0585     void setSplitMode(TreeMapItem::SplitMode m);
0586     TreeMapItem::SplitMode splitMode() const;
0587     // returns true if string was recognized
0588     bool setSplitMode(const QString &);
0589     QString splitModeString() const;
0590 
0591     /*
0592      * Shading of rectangles enabled ?
0593      */
0594     void setShadingEnabled(bool s);
0595     bool isShadingEnabled() const
0596     {
0597         return _shading;
0598     }
0599 
0600     /* Setting for a whole depth level: draw 3D frame (default) or solid */
0601     void drawFrame(int d, bool b);
0602     bool drawFrame(int d) const
0603     {
0604         return (d < 4) ? _drawFrame[d] : true;
0605     }
0606 
0607     /* Setting for a whole depth level: draw items (default) or transparent */
0608     void setTransparent(int d, bool b);
0609     bool isTransparent(int d) const
0610     {
0611         return (d < 4) ? _transparent[d] : false;
0612     }
0613 
0614     /**
0615      * Items usually have a size proportional to their value().
0616      * With <width>, you can give the minimum width
0617      * of the resulting rectangle to still be drawn.
0618      * For space not used because of to small items, you can specify
0619      * with <reuseSpace> if the background should shine through or
0620      * the space will be used to enlarge the next item to be drawn
0621      * at this level.
0622      */
0623     void setVisibleWidth(int width, bool reuseSpace = false);
0624 
0625     /**
0626      * If a children value() is almost the parents sum(),
0627      * it can happen that the border to be drawn for visibilty of
0628      * nesting relations takes to much space, and the
0629      * parent/child size relation can not be mapped to a correct
0630      * area size relation.
0631      *
0632      * Either
0633      * (1) Ignore the incorrect drawing, or
0634      * (2) Skip drawing of the parent level alltogether.
0635      */
0636     void setSkipIncorrectBorder(bool enable = true);
0637     bool skipIncorrectBorder() const
0638     {
0639         return _skipIncorrectBorder;
0640     }
0641 
0642     /**
0643      * Maximal nesting depth
0644      */
0645     void setMaxDrawingDepth(int d);
0646     int maxDrawingDepth() const
0647     {
0648         return _maxDrawingDepth;
0649     }
0650 
0651     /**
0652      * Minimal area for rectangles to draw
0653      */
0654     void setMinimalArea(int area);
0655     int minimalArea() const
0656     {
0657         return _minimalArea;
0658     }
0659 
0660     /* defaults for text attributes */
0661     QString defaultFieldType(int) const;
0662     QString defaultFieldStop(int) const;
0663     bool    defaultFieldVisible(int) const;
0664     bool    defaultFieldForced(int) const;
0665     DrawParams::Position defaultFieldPosition(int) const;
0666 
0667     /**
0668      * Set the type name of a field.
0669      * This is important for the visualization menu generated
0670      * with visualizationMenu()
0671      */
0672     void setFieldType(int, const QString &);
0673     QString fieldType(int) const;
0674 
0675     /**
0676      * Stop drawing at item with name
0677      */
0678     void setFieldStop(int, const QString &);
0679     QString fieldStop(int) const;
0680 
0681     /**
0682      * Should the text with number textNo be visible?
0683      * This is only done if remaining space is enough to allow for
0684      * proportional size constrains.
0685      */
0686     void setFieldVisible(int, bool);
0687     bool fieldVisible(int) const;
0688 
0689     /**
0690      * Should the drawing of the name into the rectangle be forced?
0691      * This enables drawing of the name before drawing subitems, and
0692      * thus destroys proportional constrains.
0693      */
0694     void setFieldForced(int, bool);
0695     bool fieldForced(int) const;
0696 
0697     /**
0698      * Set the field position in the area. See TreeMapItem::Position
0699      */
0700     void setFieldPosition(int, DrawParams::Position);
0701     DrawParams::Position fieldPosition(int) const;
0702     void setFieldPosition(int, const QString &);
0703     QString fieldPositionString(int) const;
0704 
0705     /**
0706      * Do we allow the texts to be rotated by 90 degrees for better fitting?
0707      */
0708     void setAllowRotation(bool);
0709     bool allowRotation() const
0710     {
0711         return _allowRotation;
0712     }
0713 
0714     void setBorderWidth(int w);
0715     int borderWidth() const
0716     {
0717         return _borderWidth;
0718     }
0719 
0720     /**
0721      * Save/restore options.
0722      */
0723     void saveOptions(KConfigGroup *, const QString &prefix = QString());
0724     void restoreOptions(KConfigGroup *, const QString &prefix = QString());
0725 
0726     /**
0727      * These functions populate given popup menus.
0728      * The added items are already connected to handlers.
0729      *
0730      * The int is the menu id where to start for the items (100 IDs reserved).
0731      */
0732     void addSplitDirectionItems(QMenu *, int);
0733     void addSelectionItems(QMenu *, int, TreeMapItem *);
0734     void addFieldStopItems(QMenu *, int, TreeMapItem *);
0735     void addAreaStopItems(QMenu *, int, TreeMapItem *);
0736     void addDepthStopItems(QMenu *, int, TreeMapItem *);
0737     void addVisualizationItems(QMenu *, int);
0738 
0739     TreeMapWidget *widget()
0740     {
0741         return this;
0742     }
0743     TreeMapItem *current() const
0744     {
0745         return _current;
0746     }
0747     TreeMapItemList selection() const
0748     {
0749         return _selection;
0750     }
0751     bool isSelected(TreeMapItem *i) const;
0752     int maxSelectDepth() const
0753     {
0754         return _maxSelectDepth;
0755     }
0756     SelectionMode selectionMode() const
0757     {
0758         return _selectionMode;
0759     }
0760 
0761     /**
0762      * Return tooltip string to show for a item (can be rich text)
0763      * Default implementation gives lines with "text0 (text1)" going to root.
0764      */
0765     virtual QString tipString(TreeMapItem *i) const;
0766 
0767     /**
0768      * Redraws an item with all children.
0769      * This takes changed values(), sums(), colors() and text() into account.
0770      */
0771     void redraw(TreeMapItem *);
0772     void redraw()
0773     {
0774         redraw(_base);
0775     }
0776 
0777     /**
0778      * Resort all TreeMapItems. See TreeMapItem::resort().
0779      */
0780     void resort()
0781     {
0782         _base->resort(true);
0783     }
0784 
0785     // internal
0786     void drawTreeMap();
0787 
0788     // used internally when items are destroyed
0789     void deletingItem(TreeMapItem *);
0790 
0791 protected slots:
0792     void splitActivated(QAction *);
0793     void selectionActivated(QAction *);
0794     void fieldStopActivated(QAction *);
0795     void areaStopActivated(QAction *);
0796     void depthStopActivated(QAction *);
0797     void visualizationActivated(QAction *a);
0798 
0799 signals:
0800     void selectionChanged();
0801     void selectionChanged(TreeMapItem *);
0802 
0803     /**
0804      * This signal is emitted if the current item changes.
0805      * If the change is done because of keyboard navigation,
0806      * the <kbd> is set to true
0807      */
0808     void currentChanged(TreeMapItem *, bool keyboard);
0809     void clicked(TreeMapItem *);
0810     void returnPressed(TreeMapItem *);
0811     void doubleClicked(TreeMapItem *);
0812     void rightButtonPressed(TreeMapItem *, const QPoint &);
0813     void contextMenuRequested(TreeMapItem *, const QPoint &);
0814 
0815 protected:
0816     void mousePressEvent(QMouseEvent *) override;
0817     void contextMenuEvent(QContextMenuEvent *) override;
0818     void mouseReleaseEvent(QMouseEvent *) override;
0819     void mouseMoveEvent(QMouseEvent *) override;
0820     void mouseDoubleClickEvent(QMouseEvent *) override;
0821     void keyPressEvent(QKeyEvent *) override;
0822     void paintEvent(QPaintEvent *) override;
0823     void fontChange(const QFont &);
0824     bool event(QEvent *event) override;
0825     // For "Esc deselects all" functionality implemented in FSView.
0826     TreeMapItem *_pressed;
0827     // add a checkable popup item
0828     void addPopupItem(QMenu *popup, const QString &text,
0829                       bool bChecked, int id, bool bEnabled = true);
0830 private:
0831     TreeMapItemList diff(TreeMapItemList &, TreeMapItemList &);
0832     // returns true if selection changed
0833     TreeMapItem *setTmpSelected(TreeMapItem *, bool selected = true);
0834     TreeMapItem *setTmpRangeSelection(TreeMapItem *i1,
0835                                       TreeMapItem *i2, bool selected);
0836     bool isTmpSelected(TreeMapItem *i);
0837 
0838     void drawItem(QPainter *p, TreeMapItem *);
0839     void drawItems(QPainter *p, TreeMapItem *);
0840     bool horizontal(TreeMapItem *i, const QRect &r);
0841     void drawFill(TreeMapItem *, QPainter *p, const QRect &r);
0842     void drawFill(TreeMapItem *, QPainter *p, const QRect &r,
0843                   TreeMapItemList *list, int idx, int len, bool goBack);
0844     bool drawItemArray(QPainter *p, TreeMapItem *, const QRect &r, double,
0845                        TreeMapItemList *list, int idx, int len, bool);
0846     bool resizeAttr(int);
0847 
0848     TreeMapItem *_base;
0849     TreeMapItem *_current, *_lastOver, *_oldCurrent;
0850     int _maxSelectDepth, _maxDrawingDepth;
0851 
0852     // attributes for field, per textNo
0853     struct FieldAttr {
0854         QString type, stop;
0855         bool visible, forced;
0856         DrawParams::Position pos;
0857     };
0858     QVector<FieldAttr> _attr;
0859 
0860     SelectionMode _selectionMode;
0861     TreeMapItem::SplitMode _splitMode;
0862     int _visibleWidth, _stopArea, _minimalArea, _borderWidth;
0863     bool _reuseSpace, _skipIncorrectBorder, _drawSeparators, _shading;
0864     bool _allowRotation;
0865     bool _transparent[4], _drawFrame[4];
0866     TreeMapItem *_needsRefresh;
0867     TreeMapItemList _selection;
0868     int _markNo;
0869 
0870     // for the context menus: start IDs
0871     int _splitID, _selectionID, _visID;
0872     int _fieldStopID, _areaStopID, _depthStopID;
0873     TreeMapItem *_menuItem;
0874 
0875     // temporary selection while dragging, used for drawing
0876     // most of the time, _selection == _tmpSelection
0877     TreeMapItemList _tmpSelection;
0878     bool _inShiftDrag, _inControlDrag;
0879 
0880     // temporary widget font metrics while drawing
0881     QFont _font;
0882     int _fontHeight;
0883 
0884     // back buffer pixmap
0885     QPixmap _pixmap;
0886 };
0887 
0888 #endif