📄 ktablistbox.h
字号:
* argument is considered to be respectively less than, equal to, * or greater than the second. */ virtual void reorderRows(); /** Set column caption, width, type,order-type and order-mode */ virtual void setColumn (int col, const char* caption, int width=0, ColumnType type=TextColumn, OrderType ordt=NoOrder, OrderMode omode=Descending, bool verticalLine=false, int (*compar)(const char *, const char *)=0L); /** Set column width. */ virtual void setColumnWidth (int col, int width=0); /** Get column width. */ int columnWidth (int col) { return lbox.cellWidth(col); } /** Set default width of all columns. */ virtual void setDefaultColumnWidth(int width0, ...); /** change the Ascending/Descending mode of column col.*/ void changeMode(int col); /** Clear all number-check-buttons (ComplexOrder only) */ void clearAllNum(); /** Set separator character, e.g. '\t'. */ virtual void setSeparator (char sep) { sepChar = sep; } /** Return separator character. */ virtual char separator (void) const { return sepChar; } /** For convenient access to the dictionary of pictures that this listbox understands. */ KTabListBoxDict& dict (void) { return pixDict; } void repaint (void); /** Indicates that a drag has started with given item. Returns TRUE if we are dragging, FALSE if drag-start failed. */ bool startDrag(int col, int row, const QPoint& mousePos); QPixmap& dndPixmap(void) { return dndDefaultPixmap; } /** Read the config file entries in the group with the name of the listbox and set the default column widths and those. */ virtual void readConfig(void); /** Write the config file entries in the group with the name of the listbox*/ virtual void writeConfig(void); /** Return the actual position of the colum in the table.*/ int colPosList(int num); /** Return the actual positon of the row number num.*/ int itemPosList(int num); /** Get/set font of the table. font() and setFont() apply to the caption only. */ const QFont& tableFont(void) const { return lbox.font(); } void setTableFont(const QFont& fnt) { lbox.setFont(fnt); } signals: /** emited when the current item changes (either via setCurrentItem() or via mouse single-click). */ void highlighted (int Index, int column); /** emitted when the user double-clicks into a line. */ void selected (int Index, int column); /** emitted when the user presses the right mouse button over a line. */ void popupMenu (int Index, int column); /** emitted when the user presses the middle mouse button over a line. */ void midClick (int Index, int column); /** emitted when the user clicks on a column header. */ void headerClicked (int column);protected slots: void horSbValue(int val); void horSbSlidingDone();protected: /** Used to create new column objects. Overwrite this method * in a subclass to have your own column objects (e.g. with custom * data in it). You will then also need customData()/setCustomData() * methods in here that access the elememts in itemList[]. */ virtual KTabListBoxColumn* newKTabListBoxColumn(void); bool itemVisible (int idx) { return lbox.rowIsVisible(idx); } void updateItem (int idx, bool clear = TRUE); bool needsUpdate (int id); /// Internal method called by keyPressEvent. void setCItem (int idx); /// Adjust the number in the number check boxes. void adjustNumber(int num); // This should really go into kdecore and should be used by all // apps that have long scrollable widgets. void flushKeys(); /// For internal use. bool recursiveSort(int level,int n,KTabListBoxColumn **c,int *iCol); KTabListBoxItem* getItem (int idx); const KTabListBoxItem* getItem (int idx) const; virtual void keyPressEvent(QKeyEvent*); virtual void resizeEvent (QResizeEvent*); virtual void paintEvent (QPaintEvent*); virtual void mouseMoveEvent(QMouseEvent*); virtual void mousePressEvent(QMouseEvent*); virtual void mouseReleaseEvent(QMouseEvent*); /** Resize item array. Per default enlarge it to double size. */ virtual void resizeList (int newNumItems=-1); /** Called to set drag data, size, and type. If this method returns FALSE then no drag occurs. */ virtual bool prepareForDrag (int col, int row, char** data, int* size, int* type); /** Internal method that handles resizing of columns with the mouse. */ virtual void doMouseResizeCol(QMouseEvent*); /** Internal method that handles moving of columns with the mouse. */ virtual void doMouseMoveCol(QMouseEvent*); // This array contain the list of columns as they are inserted. KTabListBoxColumn** colList; // This array contain the column numbers as they are shown. int *colShowList; // This array contain the row numbers as they are shown. int *itemShowList; KTabListBoxItem** itemList; int maxItems, numColumns; int current; char sepChar; KTabListBoxDict pixDict; KTabListBoxTable lbox; int labelHeight; QPixmap dndDefaultPixmap; QPixmap upPix,downPix; QPixmap disabledUpPix,disabledDownPix; int columnPadding; QColor highlightColor; int tabPixels; bool mResizeCol; bool stopOrdering; bool needsSort; /// contain the number of the last column where the user clicked on checkbutton. int lastSelectedColumn; int nMarked; //number of marked rows. int mSortCol; // selected column for sorting order or -1 int mMouseCol; // column where the mouse action started // (resize, click, reorder) int mMouseColLeft; // left offset of mouse column int mLastX; // Used for drawing the XORed rect in column-drag. int mMouseColWidth; // width of mouse column QPoint mMouseStart; bool mMouseAction; bool mMouseDragColumn; // true when dragging the header of a column.private: // Disabled copy constructor and operator= KTabListBox (const KTabListBox &) {} KTabListBox& operator= (const KTabListBox&) { return *this; }};//--------------------------------------------------class KTabListBoxItem{public: KTabListBoxItem(int numColumns=1); virtual ~KTabListBoxItem(); virtual const QString& text(int column) const { return txt[column]; } void setText (int column, const char *text) { txt[column] = text; } virtual void setForeground (const QColor& fg ) { fgColor = fg; } const QColor& foreground (void) { return fgColor; } KTabListBoxItem& operator= (const KTabListBoxItem&); int marked (void) const { return mark; } bool isMarked (void) const { return (mark >= -1); } virtual void setMarked (int m) { mark = m; } private: QString* txt; int columns; QColor fgColor; int mark; friend class KTabListBox;};typedef KTabListBoxItem* KTabListBoxItemPtr;//--------------------------------------------------class KTabListBoxColumn: public QObject{ Q_OBJECTpublic: KTabListBoxColumn (KTabListBox* parent, int w=0); virtual ~KTabListBoxColumn(); int width (void) const { return iwidth; } virtual void setWidth (int w) { iwidth = w; } int defaultWidth (void) const { return idefwidth; } virtual void setDefaultWidth (int w) { idefwidth = w; } virtual void setType (KTabListBox::ColumnType lbt) { colType = lbt; } KTabListBox::ColumnType type (void) const { return colType; } /// @return true if need repaint. virtual bool changeMode (void); virtual void setNumber(int num); int number (void) const { return inumber;} void hideCheckButton(void) { if(mbut) mbut->hide(); } virtual void setOrder (KTabListBox::OrderType type, KTabListBox::OrderMode mode); KTabListBox::OrderType orderType (void) const {return ordtype;} KTabListBox::OrderMode orderMode (void) const {return ordmode;} virtual void paintCell (QPainter*, int row, const QString& string, bool marked); virtual void paint (QPainter*);protected slots: virtual void setButton(); virtual void resetButton(); virtual void clearAll(bool leftbutton); protected: int iwidth, idefwidth, inumber; KTabListBox::OrderMode ordmode; KTabListBox::OrderType ordtype; KTabListBox::ColumnType colType; KTabListBox* parent; KNumCheckButton *mbut;public: int (*columnSort)(const char *, const char *); bool vline; // if true print a vertical line to the end of column.};typedef KTabListBoxColumn* KTabListBoxColumnPtr;inline KTabListBoxItem* KTabListBox :: getItem (int idx){ return ((idx>=0 && idx<maxItems) ? itemList[idx] : (KTabListBoxItem*)0L);}inline const KTabListBoxItem* KTabListBox :: getItem (int idx) const{ return ((idx>=0 && idx<maxItems) ? itemList[idx] : (KTabListBoxItem*)0L);}#endif /*KTabListBox_h*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -