예제 #1
0
ObjectItem *CObjectModel::getObject(const QModelIndex &index)
{
	if ( !index.isValid() ) { return NULL ; }
	ObjectItem *p = static_cast<ObjectItem *>(index.internalPointer()) ;
	while ( p->parent() != m_pRoot ) {
		p = p->parent() ;
	}
	return p ;
}
예제 #2
0
bool CObjectModel::isLayer(const QModelIndex &index) const
{
	if ( !index.isValid() ) { return false ; }
	ObjectItem *p = getItemFromIndex(index) ;
	return p->parent() == m_pRoot ? false : true ;
//	return index.parent().internalPointer() != m_pRoot ? true : false ;
}
예제 #3
0
bool CObjectModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
	if ( action == Qt::IgnoreAction ) { return true ; }
	if ( !data->hasFormat("AnimationCreator/object.item.list") ) { return false ; }
	if ( column > 0 ) { return false ; }

	qDebug() << "dropMimeData row:" << row << " col:" << column ;
	qDebug() << " parent:" << parent << " action:" << action ;

	QByteArray encodeData = data->data("AnimationCreator/object.item.list") ;
	QDataStream stream(&encodeData, QIODevice::ReadOnly) ;

	while ( !stream.atEnd() ) {
		quint64 val ;
		ObjectItem *p ;
		stream >> val ;
		p = reinterpret_cast<ObjectItem *>(val) ;

		if ( p->parent() == m_pRoot ) {	// オブジェクト
			if ( !parent.isValid() ) {
				emit sig_copyIndex(row, p, parent, action) ;
			}
		}
		else {							// レイヤ
			if ( parent.isValid() ) {
				emit sig_copyIndex(row, p, parent, action) ;
			}
		}
	}

	return true ;
}
예제 #4
0
QModelIndex CObjectModel::parent(const QModelIndex &child) const
{
	if ( !child.isValid() ) { return QModelIndex() ; }
	ObjectItem *c = static_cast<ObjectItem *>(child.internalPointer()) ;
	ObjectItem *p = c->parent() ;
	if ( p == m_pRoot || c == m_pRoot ) { return QModelIndex() ; }
	return createIndex(p->row(), 0, p) ;
}
예제 #5
0
QString ObjectListView::GeneratePath(QTreeWidgetItem *item)
{
	ObjectItem *objitem = (ObjectItem*)item;
	char buf[50];
	QString res = QString();
	
	while (objitem->parent() != 0)
	{
		objitem->GetAttrib().toString(buf, 50);
		res.prepend(QString().sprintf(" %s ", buf));
		objitem = (ObjectItem*)objitem->parent();
	}

	objitem->GetValue().toString(buf, 50);
	res.prepend(buf);

	return res;
}