diff options
Diffstat (limited to 'kdat/ktreeview.cpp')
-rw-r--r-- | kdat/ktreeview.cpp | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/kdat/ktreeview.cpp b/kdat/ktreeview.cpp index 334a834..90d445e 100644 --- a/kdat/ktreeview.cpp +++ b/kdat/ktreeview.cpp @@ -24,11 +24,11 @@ #include <ktreeview.h> #include "ktreeview.moc" -#include <qapplication.h> /* used for QApplication::closingDown() */ -#include <qkeycode.h> /* used for keyboard interface */ -#include <qpainter.h> /* used to paint items */ -#include <qscrollbar.h> -#include <qstyle.h> +#include <tqapplication.h> /* used for TQApplication::closingDown() */ +#include <tqkeycode.h> /* used for keyboard interface */ +#include <tqpainter.h> /* used to paint items */ +#include <tqscrollbar.h> +#include <tqstyle.h> #include <assert.h> /* @@ -40,7 +40,7 @@ */ // constructor -KTreeViewItem::KTreeViewItem(const QString& theText) : +KTreeViewItem::KTreeViewItem(const TQString& theText) : owner(0), numChildren(0), doExpandButton(true), @@ -57,8 +57,8 @@ KTreeViewItem::KTreeViewItem(const QString& theText) : } // constructor that takes a pixmap -KTreeViewItem::KTreeViewItem(const QString& theText, - const QPixmap& thePixmap) : +KTreeViewItem::KTreeViewItem(const TQString& theText, + const TQPixmap& thePixmap) : owner(0), numChildren(0), doExpandButton(true), @@ -110,14 +110,14 @@ void KTreeViewItem::appendChild(KTreeViewItem* newChild) // returns the bounding rectangle of the item content (not including indent // and branches) for hit testing -QRect KTreeViewItem::boundingRect(int indent) const +TQRect KTreeViewItem::boundingRect(int indent) const { - const QFontMetrics& fm = owner->fontMetrics(); + const TQFontMetrics& fm = owner->fontMetrics(); int rectX = indent; int rectY = 1; int rectW = width(indent, fm) - rectX; int rectH = height(fm) - 2; - return QRect(rectX, rectY, rectW, rectH); + return TQRect(rectX, rectY, rectW, rectH); } // returns the child item at the specified index @@ -153,12 +153,12 @@ int KTreeViewItem::childIndex(KTreeViewItem* searched) const } // indicates whether mouse press is in expand button -inline bool KTreeViewItem::expandButtonClicked(const QPoint& coord) const +inline bool KTreeViewItem::expandButtonClicked(const TQPoint& coord) const { return expandButton.contains(coord); } -bool KTreeViewItem::mousePressEvent( const QPoint& ) +bool KTreeViewItem::mousePressEvent( const TQPoint& ) { return FALSE; } @@ -176,7 +176,7 @@ KTreeViewItem* KTreeViewItem::getParent() const } // returns reference to the item pixmap -const QPixmap& KTreeViewItem::getPixmap() const +const TQPixmap& KTreeViewItem::getPixmap() const { return pixmap; } @@ -188,7 +188,7 @@ KTreeViewItem* KTreeViewItem::getSibling() const } // returns a pointer to the item text -const QString& KTreeViewItem::getText() const +const TQString& KTreeViewItem::getText() const { return text; } @@ -219,7 +219,7 @@ int KTreeViewItem::height() const // returns the maximum height of text and pixmap including margins // or -1 if item is empty -- SHOULD NEVER BE -1! -int KTreeViewItem::height(const QFontMetrics& fm) const +int KTreeViewItem::height(const TQFontMetrics& fm) const { int maxHeight = pixmap.height(); int textHeight = fm.ascent() + fm.leading(); @@ -277,7 +277,7 @@ bool KTreeViewItem::isVisible() const } // paint this item, including tree branches and expand button -void KTreeViewItem::paint(QPainter* p, int indent, const QColorGroup& cg, +void KTreeViewItem::paint(TQPainter* p, int indent, const TQColorGroup& cg, bool highlighted) const { assert(getParent() != 0); /* can't paint root item */ @@ -312,7 +312,7 @@ void KTreeViewItem::paint(QPainter* p, int indent, const QColorGroup& cg, p->restore(); } -void KTreeViewItem::paintExpandButton(QPainter* p, int indent, int cellHeight) const +void KTreeViewItem::paintExpandButton(TQPainter* p, int indent, int cellHeight) const { int parentLeaderX = indent - (22 / 2); int cellCenterY = cellHeight / 2; @@ -333,22 +333,22 @@ void KTreeViewItem::paintExpandButton(QPainter* p, int indent, int cellHeight) c } // paint the highlight -void KTreeViewItem::paintHighlight(QPainter* p, int indent, const QColorGroup& colorGroup, +void KTreeViewItem::paintHighlight(TQPainter* p, int indent, const TQColorGroup& colorGroup, bool hasFocus, Qt::GUIStyle style) const { - QColor fc; + TQColor fc; if (style == Qt::WindowsStyle) fc = Qt::darkBlue; /* hardcoded in Qt */ else fc = colorGroup.text(); - QRect textRect = textBoundingRect(indent); + TQRect textRect = textBoundingRect(indent); int t,l,b,r; textRect.coords(&l, &t, &r, &b); p->fillRect(textRect, fc); /* draw highlight background */ if (hasFocus) { if(style == Qt::WindowsStyle) { /* draw Windows style highlight */ textRect.setCoords(l - 1, t - 1, r + 1, b + 1); - p->setPen(QPen(Qt::yellow, 0, Qt::DotLine)); + p->setPen(TQPen(Qt::yellow, 0, Qt::DotLine)); p->setBackgroundColor(fc); p->setBackgroundMode(Qt::OpaqueMode); p->drawRect(textRect); @@ -364,15 +364,15 @@ void KTreeViewItem::paintHighlight(QPainter* p, int indent, const QColorGroup& c } // draw the text, highlighted if requested -void KTreeViewItem::paintText(QPainter* p, int indent, int cellHeight, - const QColorGroup& cg, bool highlighted) const +void KTreeViewItem::paintText(TQPainter* p, int indent, int cellHeight, + const TQColorGroup& cg, bool highlighted) const { int textX = indent + pixmap.width() + 4; int textY = cellHeight - ((cellHeight - p->fontMetrics().ascent() - p->fontMetrics().leading()) / 2); if (highlighted) { paintHighlight(p, indent, cg, owner->hasFocus(), - (Qt::GUIStyle)owner->style().styleHint(QStyle::SH_GUIStyle)); // Qt3 doesn't make this easy ;) + (Qt::GUIStyle)owner->style().styleHint(TQStyle::SH_GUIStyle)); // Qt3 doesn't make this easy ;) p->setPen(cg.base()); p->setBackgroundColor(cg.text()); } @@ -384,7 +384,7 @@ void KTreeViewItem::paintText(QPainter* p, int indent, int cellHeight, } // paint the tree structure -void KTreeViewItem::paintTree(QPainter* p, int indent, int cellHeight) const +void KTreeViewItem::paintTree(TQPainter* p, int indent, int cellHeight) const { int parentLeaderX = indent - (22 / 2); int cellCenterY = cellHeight / 2; @@ -504,7 +504,7 @@ void KTreeViewItem::setExpanded(bool is) } // sets the item pixmap to the given pixmap -void KTreeViewItem::setPixmap(const QPixmap& pm) +void KTreeViewItem::setPixmap(const TQPixmap& pm) { pixmap = pm; if ( owner ) { @@ -514,7 +514,7 @@ void KTreeViewItem::setPixmap(const QPixmap& pm) } // sets the item text to the given string -void KTreeViewItem::setText(const QString& t) +void KTreeViewItem::setText(const TQString& t) { text = t; if ( owner ) { @@ -536,17 +536,17 @@ void KTreeViewItem::synchNumChildren() /* * returns the bounding rect of the item text in cell coordinates couldn't - * get QFontMetrics::boundingRect() to work right so I made my own + * get TQFontMetrics::boundingRect() to work right so I made my own */ -QRect KTreeViewItem::textBoundingRect(int indent) const +TQRect KTreeViewItem::textBoundingRect(int indent) const { - const QFontMetrics& fm = owner->fontMetrics(); + const TQFontMetrics& fm = owner->fontMetrics(); int cellHeight = height(fm); int rectX = indent + pixmap.width() + 3; int rectY = (cellHeight - fm.ascent() - fm.leading()) / 2 + 2; int rectW = fm.width(text) + 1; int rectH = fm.ascent() + fm.leading(); - return QRect(rectX, rectY, rectW, rectH); + return TQRect(rectX, rectY, rectW, rectH); } // returns the total width of text and pixmap, including margins, spacing @@ -556,7 +556,7 @@ int KTreeViewItem::width(int indent) const return width(indent, owner->fontMetrics()); } -int KTreeViewItem::width(int indent, const QFontMetrics& fm) const +int KTreeViewItem::width(int indent, const TQFontMetrics& fm) const { int maxWidth = pixmap.width(); maxWidth += (4 + fm.width(text)); @@ -573,10 +573,10 @@ int KTreeViewItem::width(int indent, const QFontMetrics& fm) const */ // constructor -KTreeView::KTreeView(QWidget *parent, +KTreeView::KTreeView(TQWidget *parent, const char *name, WFlags f) : - QGridView(parent, name, f), + TQGridView(parent, name, f), clearing(false), current(-1), drawExpandButton(true), @@ -598,11 +598,11 @@ KTreeView::KTreeView(QWidget *parent, //switch(style().guiStyle()) { //case WindowsStyle: //case MotifStyle: - setFrameStyle(QFrame::WinPanel | QFrame::Sunken); + setFrameStyle(TQFrame::WinPanel | TQFrame::Sunken); setBackgroundColor(colorGroup().base()); //break; /*default: - setFrameStyle(QFrame::Panel | QFrame::Plain); + setFrameStyle(TQFrame::Panel | TQFrame::Plain); setLineWidth(1); }*/ // setAcceptFocus(true); @@ -628,7 +628,7 @@ KTreeView::~KTreeView() // appends a child to the item at the given index with the given text // and pixmap -void KTreeView::appendChildItem(const QString & theText, const QPixmap& thePixmap, +void KTreeView::appendChildItem(const TQString & theText, const TQPixmap& thePixmap, int index) { KTreeViewItem* item = new KTreeViewItem(theText, thePixmap); @@ -638,7 +638,7 @@ void KTreeView::appendChildItem(const QString & theText, const QPixmap& thePixma // appends a child to the item at the end of the given path with // the given text and pixmap -void KTreeView::appendChildItem(const QString & theText, const QPixmap& thePixmap, +void KTreeView::appendChildItem(const TQString & theText, const TQPixmap& thePixmap, const KPath& thePath) { KTreeViewItem* item = new KTreeViewItem(theText, thePixmap); @@ -692,8 +692,8 @@ bool KTreeView::bottomScrollBar() const } // find item at specified index and change pixmap and/or text -void KTreeView::changeItem(const QString & newText, - const QPixmap *newPixmap, +void KTreeView::changeItem(const TQString & newText, + const TQPixmap *newPixmap, int index) { KTreeViewItem *item = itemAt(index); @@ -702,8 +702,8 @@ void KTreeView::changeItem(const QString & newText, } // find item at end of specified path, and change pixmap and/or text -void KTreeView::changeItem(const QString & newText, - const QPixmap* newPixmap, +void KTreeView::changeItem(const TQString & newText, + const TQPixmap* newPixmap, const KPath& thePath) { KTreeViewItem* item = itemAt(thePath); @@ -723,7 +723,7 @@ void KTreeView::clear() bool autoU = autoUpdate(); setAutoUpdate(FALSE); - QPtrStack<KTreeViewItem> stack; + TQPtrStack<KTreeViewItem> stack; stack.push(treeRoot); while(!stack.isEmpty()) { KTreeViewItem *item = stack.pop(); @@ -741,7 +741,7 @@ void KTreeView::clear() } } clearing = FALSE; - if(goingDown || QApplication::closingDown()) + if(goingDown || TQApplication::closingDown()) return; if(autoU && isVisible()) repaint(); @@ -875,7 +875,7 @@ int KTreeView::indentSpacing() // or after the item at the given index, depending on the value // of prefix // if index is negative, appends item to tree at root level -bool KTreeView::insertItem(const QString & theText, const QPixmap& thePixmap, +bool KTreeView::insertItem(const TQString & theText, const TQPixmap& thePixmap, int row, bool prefix) { KTreeViewItem* refItem = itemAt(row); @@ -892,7 +892,7 @@ bool KTreeView::insertItem(const QString & theText, const QPixmap& thePixmap, // inserts a new item with the specified text and pixmap before // or after the item at the end of the given path, depending on the value // of prefix -bool KTreeView::insertItem(const QString & theText, const QPixmap& thePixmap, +bool KTreeView::insertItem(const TQString & theText, const TQPixmap& thePixmap, const KPath& path, bool prefix) { KTreeViewItem* refItem = itemAt(path); @@ -1269,7 +1269,7 @@ void KTreeView::appendChildItem(KTreeViewItem* theParent, // changes the given item with the new text and/or pixmap void KTreeView::changeItem(KTreeViewItem* toChange, int itemRow, - const QString & newText, const QPixmap* newPixmap) + const TQString & newText, const TQPixmap* newPixmap) { int indent = indentation(toChange); int oldWidth = toChange->width(indent); @@ -1388,10 +1388,10 @@ void KTreeView::fixChildren(KTreeViewItem *parentItem) } } -// handles QFocusEvent processing by setting current item to top +// handles TQFocusEvent processing by setting current item to top // row if there is no current item, and updates cell to add or // delete the focus rectangle on the highlight bar -void KTreeView::focusInEvent(QFocusEvent *) +void KTreeView::focusInEvent(TQFocusEvent *) { if(current < 0 && numRows() > 0) setCurrentItem(rowAt(contentsY())); @@ -1406,7 +1406,7 @@ void KTreeView::forEveryItem(KForEveryM func, void *user) { KTreeViewItem *item = treeRoot->getChild(); - QPtrStack<KTreeViewItem> stack; + TQPtrStack<KTreeViewItem> stack; while(item) { stack.push(item); while(!stack.isEmpty()) { @@ -1432,7 +1432,7 @@ void KTreeView::forEveryItem(KForEveryM func, void KTreeView::forEveryVisibleItem(KForEveryM func, void *user) { - QPtrStack<KTreeViewItem> stack; + TQPtrStack<KTreeViewItem> stack; KTreeViewItem *item = treeRoot->getChild(); do { while(item) { @@ -1528,7 +1528,7 @@ void KTreeView::itemPath(KTreeViewItem* item, KPath& path) const assert(item->owner == this); if (item != treeRoot) { itemPath(item->getParent(), path); - path.push(new QString(item->getText())); + path.push(new TQString(item->getText())); } } @@ -1551,7 +1551,7 @@ void KTreeView::join(KTreeViewItem *item) } // handles keyboard interface to tree list -void KTreeView::keyPressEvent(QKeyEvent *e) +void KTreeView::keyPressEvent(TQKeyEvent *e) { if(numRows() == 0) @@ -1658,11 +1658,11 @@ void KTreeView::lowerItem(KTreeViewItem *item) // handle mouse double click events by selecting the clicked item // and emitting the signal -void KTreeView::mouseDoubleClickEvent(QMouseEvent *e) +void KTreeView::mouseDoubleClickEvent(TQMouseEvent *e) { // find out which row has been clicked - QPoint mouseCoord = viewportToContents(e->pos()); + TQPoint mouseCoord = viewportToContents(e->pos()); int itemClicked = rowAt(mouseCoord.y()); // if a valid row was not clicked, do nothing @@ -1677,7 +1677,7 @@ void KTreeView::mouseDoubleClickEvent(QMouseEvent *e) int cellY = cellHeight()*itemClicked; int cellX = 0; - QPoint cellCoord(mouseCoord.x() - cellX, mouseCoord.y() - cellY); + TQPoint cellCoord(mouseCoord.x() - cellX, mouseCoord.y() - cellY); // hit test item int indent = indentation(item); @@ -1686,7 +1686,7 @@ void KTreeView::mouseDoubleClickEvent(QMouseEvent *e) } // handle mouse movement events -void KTreeView::mouseMoveEvent(QMouseEvent *e) +void KTreeView::mouseMoveEvent(TQMouseEvent *e) { // in rubberband_mode we actually scroll the window now if (rubberband_mode) @@ -1697,7 +1697,7 @@ void KTreeView::mouseMoveEvent(QMouseEvent *e) // handle single mouse presses -void KTreeView::mousePressEvent(QMouseEvent *e) +void KTreeView::mousePressEvent(TQMouseEvent *e) { // first: check which button was pressed @@ -1720,7 +1720,7 @@ void KTreeView::mousePressEvent(QMouseEvent *e) } // find out which row has been clicked - QPoint mouseCoord = viewportToContents(e->pos()); + TQPoint mouseCoord = viewportToContents(e->pos()); int itemClicked = rowAt(mouseCoord.y()); // nothing to do if not on valid row @@ -1734,7 +1734,7 @@ void KTreeView::mousePressEvent(QMouseEvent *e) // translate mouse coord to cell coord int cellX = 0; int cellY = cellHeight()*itemClicked; - QPoint cellCoord(mouseCoord.x() - cellX, mouseCoord.y() - cellY); + TQPoint cellCoord(mouseCoord.x() - cellX, mouseCoord.y() - cellY); /* hit expand button (doesn't set currentItem) */ if(item->expandButtonClicked(cellCoord)) { @@ -1752,13 +1752,13 @@ void KTreeView::mousePressEvent(QMouseEvent *e) else if (item->boundingRect(indentation(item)).contains(cellCoord)) { setCurrentItem(itemClicked); // highlight item if ( e->button() == RightButton ) { - emit popupMenu( itemClicked, mapToGlobal( QPoint( e->pos().x(), e->pos().y() ) ) ); + emit popupMenu( itemClicked, mapToGlobal( TQPoint( e->pos().x(), e->pos().y() ) ) ); } } } // handle mouse release events -void KTreeView::mouseReleaseEvent(QMouseEvent *e) +void KTreeView::mouseReleaseEvent(TQMouseEvent *e) { /* if it's the MMB end rubberbanding */ if (rubberband_mode && e->button()==MidButton) @@ -1779,7 +1779,7 @@ void KTreeView::draw_rubberband() */ if (!rubberband_mode) return; - QPainter paint(this); + TQPainter paint(this); paint.setPen(white); paint.setRasterOp(XorROP); paint.drawRect(xOffset()*viewWidth()/totalWidth(), @@ -1790,7 +1790,7 @@ void KTreeView::draw_rubberband() } // rubberband move: start move -void KTreeView::start_rubberband(const QPoint& where) +void KTreeView::start_rubberband(const TQPoint& where) { #if 0 if (rubberband_mode) { // Oops! @@ -1826,13 +1826,13 @@ void KTreeView::end_rubberband() } // rubberband move: handle mouse moves -void KTreeView::move_rubberband(const QPoint& where) +void KTreeView::move_rubberband(const TQPoint& where) { #if 0 if (!rubberband_mode) return; // look how much the mouse moved and calc the new scroll position - QPoint delta = where - rubber_startMouse; + TQPoint delta = where - rubber_startMouse; int nx = rubber_startX + delta.x() * totalWidth() / viewWidth(); int ny = rubber_startY + delta.y() * totalHeight() / viewHeight(); @@ -1852,14 +1852,14 @@ void KTreeView::move_rubberband(const QPoint& where) // paints the cell at the specified row and col // col is ignored for now since there is only one -void KTreeView::paintCell(QPainter* p, int row, int) +void KTreeView::paintCell(TQPainter* p, int row, int) { KTreeViewItem* item = itemAt(row); if (item == 0) return; - p->setClipRect(cellRect(), QPainter::CoordPainter ); - QColorGroup cg = colorGroup(); + p->setClipRect(cellRect(), TQPainter::CoordPainter ); + TQColorGroup cg = colorGroup(); int indent = indentation(item); item->paint(p, indent, cg, current == row); /* highlighted */ @@ -1889,7 +1889,7 @@ KTreeViewItem* KTreeView::recursiveFind(KPath& path) return treeRoot; // get the next key - QString* searchString = path.pop(); + TQString* searchString = path.pop(); // find the parent item KTreeViewItem* parent = recursiveFind(path); |