You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
144 lines
3.9 KiB
144 lines
3.9 KiB
//
|
|
// C++ Interface: treeview
|
|
//
|
|
// Description:
|
|
//
|
|
//
|
|
// Author: Paulo Moura Guedes <moura@kdewebdev.org>, (C) 2004
|
|
//
|
|
// Copyright: See COPYING file that comes with this distribution
|
|
//
|
|
//
|
|
#ifndef TREEVIEW_H
|
|
#define TREEVIEW_H
|
|
|
|
#include <tdelistview.h>
|
|
|
|
#include "resultview.h"
|
|
class TreeViewItem;
|
|
class TreeColumnViewItem;
|
|
class LinkMatcher;
|
|
|
|
/**
|
|
@author Paulo Moura Guedes
|
|
TreeView and TreeViewItem and currently a little messes up in its API
|
|
because of ResultView. ResultView class was to be the base interface to
|
|
a TQTable and a TQListView, but the APIs are a little diferent... then I realize
|
|
that a TQTable view isn't needed at all so some day I will clean this up.
|
|
*/
|
|
class TreeView : public TDEListView, public ResultView
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
TreeView(TQWidget *parent = 0, const char *name = 0);
|
|
~TreeView();
|
|
|
|
virtual void setColumns(TQStringList const& columns);
|
|
virtual void clear();
|
|
void removeColunas();
|
|
virtual void show(ResultView::Status const& status);
|
|
void show(LinkMatcher link_matcher);
|
|
virtual void showAll();
|
|
|
|
void setTreeDisplay(bool tree_display);
|
|
|
|
/**
|
|
If tree_display is false the view scrolls to follow the last link inserted,
|
|
except if the user scrolls the view up (like Konsole).
|
|
If tree_view, it follows always the last link inserted.
|
|
*/
|
|
void ensureRowVisible(const TQListViewItem * i, bool tree_display);
|
|
virtual bool isEmpty() const;
|
|
|
|
TreeViewItem* myItem(TQListViewItem* item) const;
|
|
|
|
protected:
|
|
virtual void resizeEvent(TQResizeEvent *e);
|
|
|
|
private slots:
|
|
|
|
void slotPopupContextMenu(TQListViewItem *, const TQPoint &, int);
|
|
virtual void slotCopyUrlToClipboard() const;
|
|
virtual void slotCopyParentUrlToClipboard() const;
|
|
virtual void slotCopyCellTextToClipboard() const;
|
|
virtual void slotEditReferrersWithQuanta();
|
|
virtual void slotEditReferrerWithQuanta(int id);
|
|
virtual void slotEditReferrerWithQuanta(KURL const& url);
|
|
virtual void slotViewUrlInBrowser();
|
|
virtual void slotViewParentUrlInBrowser();
|
|
virtual void loadContextTableMenu(TQValueVector<KURL> const& referrers, bool is_root = false);
|
|
|
|
private:
|
|
void resetColumns();
|
|
double columnsWidth() const;
|
|
|
|
private:
|
|
int current_column_; // apparently it's impossible to know what is the current column
|
|
bool tree_display_;
|
|
};
|
|
|
|
inline void TreeView::setTreeDisplay(bool tree_display) {
|
|
tree_display_ = tree_display;
|
|
setRootIsDecorated(tree_display_);
|
|
}
|
|
|
|
|
|
/* ******************************* TreeViewItem ******************************* */
|
|
|
|
class TreeViewItem: public TDEListViewItem
|
|
{
|
|
public:
|
|
|
|
TreeViewItem(TreeView* parent, TQListViewItem* after,
|
|
LinkStatus const* linkstatus);
|
|
TreeViewItem(TreeView* root, TQListViewItem* parent_item, TQListViewItem* after,
|
|
LinkStatus const* linkstatus);
|
|
virtual ~TreeViewItem();
|
|
|
|
void setLastChild(TQListViewItem* last_child);
|
|
TQListViewItem* lastChild() const;
|
|
|
|
TQString key(int column, bool) const;
|
|
LinkStatus const* linkStatus() const;
|
|
|
|
protected:
|
|
virtual void paintCell(TQPainter * p, const TQColorGroup & cg, int column, int width, int align);
|
|
|
|
private:
|
|
void init(LinkStatus const* linkstatus);
|
|
|
|
private:
|
|
TQValueVector<TreeColumnViewItem> column_items_;
|
|
TQListViewItem* last_child_;
|
|
TreeView* root_;
|
|
};
|
|
|
|
|
|
/* ******************************* TreeColumnViewItem ******************************* */
|
|
|
|
class TreeColumnViewItem
|
|
{
|
|
public:
|
|
TreeColumnViewItem()
|
|
{}
|
|
;
|
|
TreeColumnViewItem(TreeView* root, LinkStatus const* linkstatus, int column_index);
|
|
~TreeColumnViewItem();
|
|
|
|
//void setColumnIndex(int i);
|
|
int columnIndex() const;
|
|
LinkStatus const* linkStatus() const;
|
|
TQColor const& textStatusColor() const;
|
|
TQString text(int column) const;
|
|
TQPixmap pixmap(int column) const;
|
|
|
|
private:
|
|
TreeView* root_;
|
|
LinkStatus const* ls_;
|
|
int column_index_;
|
|
};
|
|
|
|
#endif
|