void unpackAndroidAssets() { const QString DEST_PREFIX = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/"; QStringList filesToCopy = readAssetLines("cache_assets.txt"); QString dateStamp = filesToCopy.takeFirst(); QString dateStampFilename = DEST_PREFIX + dateStamp; qDebug() << "Checking date stamp" << dateStamp; if (QFileInfo(dateStampFilename).exists()) { return; } auto rootDir = QDir::root(); for (const auto& fileToCopy : filesToCopy) { auto destFileName = DEST_PREFIX + fileToCopy; auto destFolder = QFileInfo(destFileName).absoluteDir(); if (!destFolder.exists()) { qDebug() << "Creating folder" << destFolder.absolutePath(); if (!rootDir.mkpath(destFolder.absolutePath())) { throw std::runtime_error("Error creating output path"); } } if (QFile::exists(destFileName)) { qDebug() << "Removing old file" << destFileName; if (!QFile::remove(destFileName)) { throw std::runtime_error("Failed to remove existing file"); } } qDebug() << "Copying asset " << fileToCopy << "to" << destFileName; copyAsset(fileToCopy.toStdString().c_str(), destFileName); } { qDebug() << "Writing date stamp" << dateStamp; QFile file(dateStampFilename); if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate)) { throw std::runtime_error("Can't write date stamp"); } QTextStream(&file) << "touch" << endl; file.close(); } }
PartList::PartList(QWidget *parent) : QWidget(parent), ui(new Ui::PartList) { ui->setupUi(this); // mAssetListWidget = findChild<AssetListWidget*>("assetList"); // connect(mAssetListWidget, SIGNAL(assetDoubleClicked(AssetRef)), this, SIGNAL(assetDoubleClicked(AssetRef))); mAssetTreeWidget = findChild<AssetTreeWidget*>("assetTree"); connect(mAssetTreeWidget, SIGNAL(assetDoubleClicked(AssetRef)), this, SIGNAL(assetDoubleClicked(AssetRef))); connect(findChild<QToolButton*>("toolButtonNewPart"), SIGNAL(clicked()), this, SLOT(newPart())); connect(findChild<QToolButton*>("toolButtonNewComp"), SIGNAL(clicked()), this, SLOT(newComp())); connect(findChild<QToolButton*>("toolButtonNewFolder"), SIGNAL(clicked()), this, SLOT(newFolder())); connect(findChild<QToolButton*>("toolButtonRenameAsset"), SIGNAL(clicked()), this, SLOT(renameAsset())); connect(findChild<QToolButton*>("toolButtonCopyAsset"), SIGNAL(clicked()), this, SLOT(copyAsset())); connect(findChild<QToolButton*>("toolButtonDeleteAsset"), SIGNAL(clicked()), this, SLOT(deleteAsset())); updateList(); }