Esempio n. 1
0
Qt::ItemFlags ProjectDirModel::flags(const QModelIndex &index) const {
  Qt::ItemFlags flags = QAbstractItemModel::flags(index);
  if (index.isValid()) {
    DvDirModelNode *node = getNode(index);
    if (node && node->isRenameEnabled()) flags |= Qt::ItemIsEditable;
  }
  return flags;
}
Esempio n. 2
0
QModelIndex ProjectDirModel::parent(const QModelIndex &index) const {
  if (!index.isValid()) return QModelIndex();
  DvDirModelNode *node       = getNode(index);
  DvDirModelNode *parentNode = node->getParent();
  if (!parentNode || parentNode == m_root)
    return QModelIndex();
  else
    return createIndex(parentNode->getRow(), 0, parentNode);
}
Esempio n. 3
0
QModelIndex ProjectDirModel::index(int row, int column,
                                   const QModelIndex &parent) const {
  if (column != 0) return QModelIndex();
  DvDirModelNode *parentNode       = m_root;
  if (parent.isValid()) parentNode = getNode(parent);
  if (row < 0 || row >= parentNode->getChildCount()) return QModelIndex();
  DvDirModelNode *node = parentNode->getChild(row);
  return createIndex(row, column, node);
}
Esempio n. 4
0
void ProjectDirModel::refreshFolderChild(const QModelIndex &i) {
  DvDirModelNode *node = getNode(i);
  if (!node || !node->areChildrenValid()) return;

  if (node->isFolder() || dynamic_cast<DvDirModelMyComputerNode *>(node))
    refresh(i);
  int count = rowCount(i);
  int r;
  for (r = 0; r < count; r++) refreshFolderChild(index(r, 0, i));
}
Esempio n. 5
0
void ProjectDirModel::refresh(const QModelIndex &index) {
  if (!index.isValid()) return;
  DvDirModelNode *node = getNode(index);
  if (!node) return;
  emit layoutAboutToBeChanged();
  emit beginRemoveRows(index, 0, node->getChildCount());
  node->refreshChildren();
  emit endRemoveRows();
  emit layoutChanged();
}
Esempio n. 6
0
QModelIndex ProjectDirModel::childByName(const QModelIndex &parent,
                                         const std::wstring &name) const {
  if (!parent.isValid()) return QModelIndex();
  DvDirModelNode *parentNode = getNode(parent);
  if (!parentNode) return QModelIndex();
  int row = parentNode->rowByName(name);
  if (row < 0 || row >= parentNode->getChildCount()) return QModelIndex();
  DvDirModelNode *childNode = parentNode->getChild(row);
  return createIndex(row, 0, childNode);
}
Esempio n. 7
0
bool ProjectDirModel::setData(const QModelIndex &index, const QVariant &value,
                              int role) {
  if (!index.isValid()) return false;
  DvDirModelNode *node = getNode(index);
  if (!node || !node->isRenameEnabled()) return false;
  QString newName = value.toString();
  if (newName == "") return false;
  if (!node->setName(newName.toStdWString())) return false;
  emit dataChanged(index, index);
  return true;
}
Esempio n. 8
0
QVariant ProjectDirModel::data(const QModelIndex &index, int role) const {
  if (!index.isValid()) return QVariant();
  DvDirModelNode *node = getNode(index);
  if (role == Qt::DisplayRole || role == Qt::EditRole)
    return QString::fromStdWString(node->getName());
  else if (role == Qt::DecorationRole) {
    return QVariant();
  } else if (role == Qt::ForegroundRole) {
    if (!node || !node->isRenameEnabled())
      return QBrush(Qt::blue);
    else
      return QVariant();
  } else
    return QVariant();
}
void ExportSceneDvDirModel::refresh(const QModelIndex &index)
{
	DvDirModelNode *node;
	if (!index.isValid())
		node = m_root;
	else
		node = getNode(index);
	if (!node)
		return;
	emit layoutAboutToBeChanged();
	emit beginRemoveRows(index, 0, node->getChildCount());
	node->refreshChildren();
	emit endRemoveRows();
	emit layoutChanged();
}
void ExportSceneTreeViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	QRect rect = option.rect;
	DvDirModelNode *node = DvDirModel::instance()->getNode(index);
	if (!node)
		return;

	DvDirModelProjectNode *pnode = dynamic_cast<DvDirModelProjectNode *>(node);
	DvDirModelFileFolderNode *fnode = dynamic_cast<DvDirModelFileFolderNode *>(node);

	if (node == m_treeView->getCurrentNode())
		painter->fillRect(rect, option.palette.highlight());

	QPixmap px = node->getPixmap(m_treeView->isExpanded(index));
	if (!px.isNull()) {
		int x = rect.left();
		int y = rect.top() + (rect.height() - px.height()) / 2;
		painter->drawPixmap(QPoint(x, y), px);
	}
	rect.adjust(pnode ? 26 : 20, 0, 0, 0);
	QVariant d = index.data();
	QString name = QString::fromStdWString(node->getName());
	if (node == m_treeView->getCurrentNode() && option.state & QStyle::State_Active)
		painter->setPen(Qt::white);
	else if (fnode && fnode->isProjectFolder())
		painter->setPen(Qt::blue);
	else
		painter->setPen(Qt::black);
	QRect nameBox;
	painter->drawText(rect, Qt::AlignVCenter | Qt::AlignLeft, name, &nameBox);

	if (pnode) {
		painter->setPen(Qt::black);
		if (pnode->isCurrent())
			painter->setBrush(Qt::red);
		else
			painter->setBrush(Qt::NoBrush);
		int d = 4;
		int y = (rect.height() - d) / 2;
		painter->drawEllipse(rect.x() - d - 4, rect.y() + y, d, d);
	}
	painter->setPen(Qt::magenta);
	painter->setBrush(Qt::NoBrush);
}
Esempio n. 11
0
bool ProjectDirModel::hasChildren(const QModelIndex &parent) const {
  DvDirModelNode *node = getNode(parent);
  return node->hasChildren();
}
Esempio n. 12
0
int ProjectDirModel::rowCount(const QModelIndex &parent) const {
  DvDirModelNode *node = getNode(parent);
  int childCount       = node->getChildCount();
  return childCount;
}
bool ExportSceneDvDirModel::hasChildren(const QModelIndex &parent) const
{
	DvDirModelNode *node = getNode(parent);
	return node->hasChildren();
}
void ExportSceneDvDirModelRootNode::add(wstring name, const TFilePath &path)
{
	DvDirModelNode *child = new ExportSceneDvDirModelFileFolderNode(this, name, path);
	child->setRow((int)m_children.size());
	m_children.push_back(child);
}