libyui-qt
2.43.5
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YQTable.h 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef YQTable_h 00026 #define YQTable_h 00027 00028 #include <QFrame> 00029 #include "QY2ListView.h" 00030 #include <yui/YTable.h> 00031 00032 00033 class QY2ListView; 00034 class QTreeWidgetItem; 00035 class YQListViewItem; 00036 00037 class YQTable : public QFrame, public YTable 00038 { 00039 Q_OBJECT 00040 00041 public: 00042 00043 /** 00044 * Constructor. 00045 **/ 00046 YQTable( YWidget * parent, YTableHeader * header, bool multiSelection ); 00047 00048 /** 00049 * Destructor. 00050 **/ 00051 virtual ~YQTable(); 00052 00053 /** 00054 * Switch between sorting by item insertion order (keepSorting: true) or 00055 * allowing the user to sort by an arbitrary column (by clicking on the 00056 * column header). 00057 * 00058 * Reimplemented from YTable. 00059 **/ 00060 virtual void setKeepSorting( bool keepSorting ); 00061 00062 /** 00063 * Add an item. 00064 * 00065 * Reimplemented from YSelectionWidget. 00066 **/ 00067 virtual void addItem( YItem * item ); 00068 00069 /** 00070 * Add multiple items. 00071 * 00072 * Reimplemented for efficiency from YSelectionWidget. 00073 **/ 00074 virtual void addItems( const YItemCollection & itemCollection ); 00075 00076 /** 00077 * Select or deselect an item. 00078 * 00079 * Reimplemented from YSelectionWidget. 00080 **/ 00081 virtual void selectItem( YItem * item, bool selected = true ); 00082 00083 /** 00084 * Deselect all items. 00085 * 00086 * Reimplemented from YSelectionWidget. 00087 **/ 00088 virtual void deselectAllItems(); 00089 00090 /** 00091 * Delete all items. 00092 * 00093 * Reimplemented from YSelectionWidget. 00094 **/ 00095 virtual void deleteAllItems(); 00096 00097 /** 00098 * Notification that a cell (its text and/or its icon) was changed from the 00099 * outside. Applications are required to call this whenever a table cell is 00100 * changed after adding the corresponding table item (the row) to the table 00101 * widget. 00102 * 00103 * Reimplemented from YTable. 00104 **/ 00105 virtual void cellChanged( const YTableCell * cell ); 00106 00107 /** 00108 * Set enabled/disabled state. 00109 * 00110 * Reimplemented from YWidget. 00111 **/ 00112 virtual void setEnabled( bool enabled ); 00113 00114 /** 00115 * Preferred width of the widget. 00116 * 00117 * Reimplemented from YWidget. 00118 **/ 00119 virtual int preferredWidth(); 00120 00121 /** 00122 * Preferred height of the widget. 00123 * 00124 * Reimplemented from YWidget. 00125 **/ 00126 virtual int preferredHeight(); 00127 00128 /** 00129 * Set the new size of the widget. 00130 * 00131 * Reimplemented from YWidget. 00132 **/ 00133 virtual void setSize( int newWidth, int newHeight ); 00134 00135 /** 00136 * Accept the keyboard focus. 00137 * 00138 * Reimplemented from YWidget. 00139 **/ 00140 virtual bool setKeyboardFocus(); 00141 00142 00143 protected slots: 00144 00145 /** 00146 * Notification that an item is selected (single click or keyboard). 00147 **/ 00148 void slotSelected( QTreeWidgetItem * ); 00149 00150 /** 00151 * Notification that the item selection changed 00152 * (relevant for multiSelection mode). 00153 **/ 00154 void slotSelectionChanged(); 00155 00156 /** 00157 * Notification that an item is activated (double click or keyboard). 00158 **/ 00159 void slotActivated( QTreeWidgetItem * ); 00160 00161 /** 00162 * Propagate a context menu selection 00163 * 00164 * This will trigger an 'ContextMenuActivated' event if 'notifyContextMenu' is set. 00165 **/ 00166 void slotContextMenu ( const QPoint & pos ); 00167 00168 00169 00170 protected: 00171 00172 /** 00173 * Select the original item (the YTableItem) that corresponds to the 00174 * specified listViewItem. 00175 **/ 00176 void selectOrigItem( QTreeWidgetItem * listViewItem ); 00177 00178 /** 00179 * Internal addItem() method that will not do expensive operations in batch 00180 * mode. 00181 **/ 00182 void addItem( YItem * item, bool batchMode, bool resizeColumnsToContent ); 00183 00184 // 00185 // Data members 00186 // 00187 00188 QY2ListView * _qt_listView; 00189 }; 00190 00191 00192 00193 /** 00194 * Visual representation of a YTableItem. 00195 **/ 00196 class YQTableListViewItem: public QY2ListViewItem 00197 { 00198 public: 00199 00200 /** 00201 * Constructor. 00202 **/ 00203 YQTableListViewItem( YQTable * table, 00204 QY2ListView * parent, 00205 YTableItem * origItem ); 00206 00207 /** 00208 * Return the parent table widget. 00209 **/ 00210 YQTable * table() const { return _table; } 00211 00212 /** 00213 * Return the corresponding YTableItem. 00214 **/ 00215 YTableItem * origItem() const { return _origItem; } 00216 00217 /** 00218 * Update this item's display with the content of 'cell'. 00219 **/ 00220 void updateCell( const YTableCell * cell ); 00221 00222 protected: 00223 00224 YQTable * _table; 00225 YTableItem * _origItem; 00226 }; 00227 00228 00229 00230 #endif // YQLabel_h