class QSocketDataSet : public QAbstractItemModel{ Q_OBJECT QSocketDataSet( QObject * parent = 0 ); ~QSocketDataSet();private:public: QList<Columns*> m_vColumns;};class Columns {public: Columns(int width, bool visibility, Qt::Orientation orientation, int columnIndex); ~Columns(); int width() { return m_iWidth; } bool hidden() { return m_bHidden; } QString title() { return m_sTitle; } Qt::Orientation orientation() { return m_Orientation; }protected:private: QString m_sTitle; int m_iWidth; Qt::Orientation m_Orientation; bool m_bHidden; int m_iColumnIndex; };
QSocketDataSet::QSocketDataSet( QObject * parent): QAbstractItemModel(parent){ Columns* section1 = new Columns( 100, false, Qt::Horizontal, 0); m_vColumns.push_back( section1 );}Columns::Columns(int width, bool visibility, Qt::Orientation orientation, int columnIndex){ m_iWidth = width; m_bHidden = visibility; m_pOrientation = orientation; m_sTitle = "parent column|child column1|child column2"; m_iColumnIndex = columnIndex;}
cds->Fields->Columns[i]->...
cds->Columns[i]->
QField *fld = cds->Fields->Columns[ logicalIndex ];
Сolumns *fld = cds->Columns[ logicalIndex ];
v_list.insert(0, cds->Fields->Columns[ Section ]->fieldName());
QVariantList v_list; if(orientation == Qt::Horizontal) // Если горизонтальный { // Вытащить инфу о хидере для Section, которая строится по title getTreeItems(headerModel->invisibleRootItem(), &v_list, Section, &tmp_rows); if(v_list.count() == 0) // Если инфы о хидере по title нет, значит title забыли задать, либо НЕ посчитали нужным // Впихнуть туда SQL имя поля из БД v_list.insert(0, cds->Fields->Columns[ Section ]->fieldName()); return v_list; }
class QField{ ... QString p_title; int p_width; int p_displayScale; Qt::Orientation p_orientation; QString p_typeFormat; char p_format; bool p_hidden; bool p_readOnly; bool p_checkBox; QString p_trueValue; QString p_falseValue; QStringList p_pickList; QColor p_color; int p_columnIndex; ...}class QFields {... QList<QField*> Fields; QList<QField*> Columns;...}class QDataSet: public QAbstractTableModel{... QFields *Fields;...}class QSocketDataSet: public QDataSet{... // Порт, IP Сервера и т.д....}
void QDataHeaderView::slotCountChanged ( int oldCount, int newCount ){ QSocketDataSet *cds = qobject_cast<QSocketDataSet*>(model()); if(cds == NULL) return;...}
class QSocketDataSet : public QAbstractItemModel{ Q_OBJECT QSocketDataSet( QObject * parent = 0 ); ~QSocketDataSet();private: QList<Field*> Columns;};
QDataHeaderView::slotCountChanged ( int oldCount, int newCount )