15 #include <QScriptValue>
73 QApplication::setOverrideCursor(Qt::WaitCursor);
74 setWindowTitle(model->
data(
root, Qt::DisplayRole).toString());
87 setAttribute(Qt::WA_DeleteOnClose);
89 QVBoxLayout*
layout =
new QVBoxLayout(
this);
92 QHBoxLayout* buttons =
new QHBoxLayout();
97 auto exportCsv =
new QPushButton(tr(
"Export as CSV"),
this);
98 buttons->addWidget(exportCsv);
102 exportCsv->setEnabled(
false);
103 exportCsv->setToolTip(tr(
"CSV export is not available for this type of ressources"));
107 exportCsv->setToolTip(tr(
"Export visible ressources to CSV file"));
110 layout->addLayout(buttons);
112 auto splitter =
new QSplitter(
this);
113 layout->addWidget(splitter);
115 myTree =
new QTreeView(
this);
118 splitter->addWidget(
myTree);
119 myTree->setIconSize(QSize(32, 32));
122 myTree->setSelectionMode(QAbstractItemView::SingleSelection);
123 myTree->setDragEnabled(
true);
124 myTree->setDropIndicatorShown(
true);
125 myTree->setDragDropMode(QAbstractItemView::DragDrop);
126 myTree->setContextMenuPolicy(Qt::CustomContextMenu);
129 connect(
myModel, &QAbstractItemModel::rowsInserted, [
this](
const QModelIndex &parent,
int ,
int ) {
133 QWidget* w =
new QWidget(splitter);
135 splitter->addWidget(w);
139 dummy->
addLabel(tr(
"No details available."),
nullptr);
170 splitter->setSizes({5000, 5000});
172 QApplication::restoreOverrideCursor();
199 newPanel->setAsset(
item);
209 panel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
217 if (dlg.exec() != QDialog::Accepted)
231 QAction* clear =
new QAction(tr(
"(none)"),
this);
240 QAction*
a =
new QAction(
filter->name(),
this);
248 QAction* quick =
new QAction(tr(
"Quick filter..."),
this);
251 QAction*
dialog =
new QAction(tr(
"Filters definition..."),
this);
267 if (dlg.exec() != QDialog::Accepted) {
282 if (
myTree->model() ==
nullptr) {
288 myTree->setModel(
nullptr);
296 assert(
root->canExportAsCsv());
298 auto destination = QFileDialog::getSaveFileName(
this, tr(
"Export as CSV..."), QString(), tr(
"CSV file (*.csv);;All files (*.*)"));
299 if (destination.isEmpty())
307 for (
int i = 0; i <
count; i++) {
309 if (!idx.isValid()) {
312 idx =
myModel->mapToSource(idx);
313 auto w =
static_cast<const AssetWrapper *
>(idx.internalPointer());
317 QFile
file(destination);
318 if (!
file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
319 QMessageBox::critical(
this, tr(
"Error writing CSV file %1").arg(destination), tr(
"Unable to write CSV file %1!").arg(destination));
324 QMessageBox::information(
this, tr(
"Export complete"), tr(
"Ressources correctly exported to CSV file %1.").arg(destination));
332 if (
index.isValid() &&
index.internalPointer()) {
335 item->fillMenu(&menu);
339 if (menu.actions().size() == 0)
341 menu.exec(
myTree->mapToGlobal(pos) + QPoint(5, 5));
346 auto name = QInputDialog::getText(
this,
"Create new quest",
"New quest code").toStdString();
351 QMessageBox::critical(
this,
"Quest already exists", tr(
"Quest %1 already exists!").arg(
name.data()));