mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 12:26:39 +00:00 
			
		
		
		
	implemented basic headerData (still work in progress)
This commit is contained in:
		
							parent
							
								
									b63f2f4cd5
								
							
						
					
					
						commit
						873cfcf447
					
				
					 3 changed files with 48 additions and 3 deletions
				
			
		| 
						 | 
					@ -9,8 +9,12 @@ CSMWorld::NestedTableModel::NestedTableModel(const QModelIndex& parent,
 | 
				
			||||||
    : mParentColumn(parent.column())
 | 
					    : mParentColumn(parent.column())
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    const int parentRow = parent.row();
 | 
					    const int parentRow = parent.row();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mId = std::string(parentModel->index(parentRow, 0).data().toString().toUtf8());
 | 
					    mId = std::string(parentModel->index(parentRow, 0).data().toString().toUtf8());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QAbstractProxyModel::setSourceModel(parentModel);
 | 
					    QAbstractProxyModel::setSourceModel(parentModel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    setupHeaderVectors(columnId);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QModelIndex CSMWorld::NestedTableModel::mapFromSource(const QModelIndex& sourceIndex) const
 | 
					QModelIndex CSMWorld::NestedTableModel::mapFromSource(const QModelIndex& sourceIndex) const
 | 
				
			||||||
| 
						 | 
					@ -58,8 +62,8 @@ QModelIndex CSMWorld::NestedTableModel::index(int row, int column, const QModelI
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    CSMWorld::IdTable* table = dynamic_cast<CSMWorld::IdTable*>(sourceModel());
 | 
					    CSMWorld::IdTable* table = dynamic_cast<CSMWorld::IdTable*>(sourceModel());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    unsigned rows = table->rowCount(parent);
 | 
					    int rows = table->rowCount(parent);
 | 
				
			||||||
    usigned columns = table->columnCount(parent);
 | 
					    int columns = table->columnCount(parent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (row < 0 ||
 | 
					    if (row < 0 ||
 | 
				
			||||||
        row >= rows ||
 | 
					        row >= rows ||
 | 
				
			||||||
| 
						 | 
					@ -76,3 +80,39 @@ QModelIndex CSMWorld::NestedTableModel::parent(const QModelIndex& index) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return QModelIndex();
 | 
					    return QModelIndex();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QVariant CSMWorld::NestedTableModel::headerData(int section,
 | 
				
			||||||
 | 
					                                                Qt::Orientation orientation,
 | 
				
			||||||
 | 
					                                                int role) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (orientation==Qt::Vertical)
 | 
				
			||||||
 | 
					        return QVariant();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (role==Qt::DisplayRole)
 | 
				
			||||||
 | 
					        return tr (mHeaderTitle[section].c_str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (role==ColumnBase::Role_Flags)
 | 
				
			||||||
 | 
					        return QVariant(); //TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (role==ColumnBase::Role_Display)
 | 
				
			||||||
 | 
					        return mHeaderDisplay[section];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return QVariant();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void CSMWorld::NestedTableModel::setupHeaderVectors(ColumnBase::Display columnId)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    switch(columnId)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        case ColumnBase::Display_NestedItemList:
 | 
				
			||||||
 | 
					            mHeaderTitle.push_back("test1");
 | 
				
			||||||
 | 
					            mHeaderTitle.push_back("test2");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            mHeaderDisplay.push_back(ColumnBase::Display_String);
 | 
				
			||||||
 | 
					            mHeaderDisplay.push_back(ColumnBase::Display_Integer);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            assert(false);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,6 +43,11 @@ namespace CSMWorld
 | 
				
			||||||
        virtual QModelIndex index(int row, int column, const QModelIndex& parent) const;
 | 
					        virtual QModelIndex index(int row, int column, const QModelIndex& parent) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        virtual QModelIndex parent(const QModelIndex& index) const;
 | 
					        virtual QModelIndex parent(const QModelIndex& index) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        virtual QVariant headerData ( int section, Qt::Orientation orientation, int role ) const;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
 | 
					        void setupHeaderVectors(ColumnBase::Display columnId);
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -393,7 +393,7 @@ void CSVWorld::EditWidget::remake(int row)
 | 
				
			||||||
    int locked = 0;
 | 
					    int locked = 0;
 | 
				
			||||||
    const int columns = mTable->columnCount();
 | 
					    const int columns = mTable->columnCount();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (unsigned i=0; i<columns; ++i)
 | 
					    for (int i=0; i<columns; ++i)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        int flags = mTable->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt();
 | 
					        int flags = mTable->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue