Add category support to XTreeWidget with TREE_CATEGORY enum and sorting improvements
This commit is contained in:
parent
3e311e5aec
commit
af82d9a78a
@ -16,6 +16,7 @@ XTreeWidget::XTreeWidget(QWidget *parent)
|
||||
header()->hide();
|
||||
setMinimumWidth(350);
|
||||
setSortingEnabled(true);
|
||||
setIconSize(QSize(16, 16));
|
||||
|
||||
header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
|
||||
@ -38,42 +39,44 @@ XTreeWidget::~XTreeWidget() {
|
||||
|
||||
void XTreeWidget::AddFastFile(std::shared_ptr<FastFile> aFastFile) {
|
||||
XTreeWidgetItem *fastFileItem = new XTreeWidgetItem(this);
|
||||
fastFileItem->setText(0, aFastFile->GetStem() + ".ff");
|
||||
fastFileItem->setIcon(0, QIcon(":/icons/icons/Icon_FastFile.png"));
|
||||
fastFileItem->setText(0, aFastFile->GetStem());
|
||||
fastFileItem->setIcon(0, Utils::CreateAssetIcon("FF"));
|
||||
if (aFastFile->GetPlatform() == "PC") {
|
||||
fastFileItem->setIcon(1, QIcon(":/icons/icons/Icon_PC.png"));
|
||||
fastFileItem->setIcon(1, Utils::CreateAssetIcon("PC"));
|
||||
} else if (aFastFile->GetPlatform() == "360") {
|
||||
fastFileItem->setIcon(1, QIcon(":/icons/icons/Icon_Xbox.png"));
|
||||
fastFileItem->setIcon(1, Utils::CreateAssetIcon("360"));
|
||||
} else if (aFastFile->GetPlatform() == "PS3") {
|
||||
fastFileItem->setIcon(1, Utils::CreateAssetIcon("PS3"));
|
||||
} else if (aFastFile->GetPlatform() == "Wii") {
|
||||
fastFileItem->setIcon(1, QIcon(":/icons/icons/Icon_Wii.png"));
|
||||
fastFileItem->setIcon(1, Utils::CreateAssetIcon("WII"));
|
||||
} else if (aFastFile->GetPlatform() == "WiiU") {
|
||||
fastFileItem->setIcon(1, QIcon(":/icons/icons/Icon_WiiU.png"));
|
||||
fastFileItem->setIcon(1, Utils::CreateAssetIcon("WU"));
|
||||
}
|
||||
if (aFastFile->GetGame() == "COD2") {
|
||||
fastFileItem->setIcon(2, QIcon(":/icons/icons/Icon_COD2.png"));
|
||||
fastFileItem->setIcon(2, Utils::CreateGameIcon(2));
|
||||
} if (aFastFile->GetGame() == "COD4") {
|
||||
fastFileItem->setIcon(2, QIcon(":/icons/icons/Icon_COD4.png"));
|
||||
fastFileItem->setIcon(2, Utils::CreateGameIcon(4));
|
||||
} else if (aFastFile->GetGame() == "COD5") {
|
||||
fastFileItem->setIcon(2, QIcon(":/icons/icons/Icon_COD5.png"));
|
||||
fastFileItem->setIcon(2, Utils::CreateGameIcon(5));
|
||||
} else if (aFastFile->GetGame() == "COD6") {
|
||||
fastFileItem->setIcon(2, QIcon(":/icons/icons/Icon_COD6.png"));
|
||||
fastFileItem->setIcon(2, Utils::CreateGameIcon(6));
|
||||
} else if (aFastFile->GetGame() == "COD7") {
|
||||
fastFileItem->setIcon(2, QIcon(":/icons/icons/Icon_COD7.png"));
|
||||
fastFileItem->setIcon(2, Utils::CreateGameIcon(7));
|
||||
} else if (aFastFile->GetGame() == "COD8") {
|
||||
fastFileItem->setIcon(2, QIcon(":/icons/icons/Icon_COD8.png"));
|
||||
fastFileItem->setIcon(2, Utils::CreateGameIcon(8));
|
||||
} else if (aFastFile->GetGame() == "COD9") {
|
||||
fastFileItem->setIcon(2, QIcon(":/icons/icons/Icon_COD9.png"));
|
||||
fastFileItem->setIcon(2, Utils::CreateGameIcon(9));
|
||||
} else if (aFastFile->GetGame() == "COD10") {
|
||||
fastFileItem->setIcon(2, QIcon(":/icons/icons/Icon_COD10.png"));
|
||||
fastFileItem->setIcon(2, Utils::CreateGameIcon(10));
|
||||
} else if (aFastFile->GetGame() == "COD11") {
|
||||
fastFileItem->setIcon(2, QIcon(":/icons/icons/Icon_COD11.png"));
|
||||
fastFileItem->setIcon(2, Utils::CreateGameIcon(11));
|
||||
} else if (aFastFile->GetGame() == "COD12") {
|
||||
fastFileItem->setIcon(2, QIcon(":/icons/icons/Icon_COD12.png"));
|
||||
fastFileItem->setIcon(2, Utils::CreateGameIcon(12));
|
||||
}
|
||||
|
||||
AddZoneFile(aFastFile->GetZoneFile(), fastFileItem);
|
||||
|
||||
mFastFiles[aFastFile->GetStem().section(".", 0, 0)] = aFastFile;
|
||||
mFastFiles[aFastFile->GetStem()] = aFastFile;
|
||||
|
||||
resizeColumnToContents(1);
|
||||
setSortingEnabled(true);
|
||||
@ -87,42 +90,52 @@ void XTreeWidget::AddZoneFile(std::shared_ptr<ZoneFile> aZoneFile, XTreeWidgetIt
|
||||
} else {
|
||||
zoneItem = new XTreeWidgetItem(this);
|
||||
}
|
||||
zoneItem->setIcon(0, QIcon(":/icons/icons/Icon_ZoneFile.png"));
|
||||
zoneItem->setText(0, aZoneFile->GetStem() + ".zone");
|
||||
zoneItem->setIcon(0, ZoneFile::AssetTypeToIcon(ASSET_ZONE_FILE));
|
||||
zoneItem->setText(0, aZoneFile->GetBaseStem() + ".zone");
|
||||
|
||||
auto assetMap = aZoneFile->GetAssetMap();
|
||||
|
||||
if (!assetMap.localStrings.isEmpty()) {
|
||||
QIcon localStrIcon = ZoneFile::AssetTypeToIcon(ASSET_LOCAL_STRING);
|
||||
|
||||
XTreeWidgetItem *localStrRoot = new XTreeWidgetItem(zoneItem);
|
||||
localStrRoot->setText(0, "String Files");
|
||||
localStrRoot->setIcon(0, QIcon(":/icons/icons/Icon_StringFile.png"));
|
||||
localStrRoot->setIcon(0, localStrIcon);
|
||||
localStrRoot->SetCategory(CATEGORY_TYPE);
|
||||
|
||||
XTreeWidgetItem *localStrItem = new XTreeWidgetItem(localStrRoot);
|
||||
localStrItem->setText(0, aZoneFile->GetStem().section('.', 0, 0) + ".str");
|
||||
localStrItem->setIcon(0, QIcon(":/icons/icons/Icon_StringFile.png"));
|
||||
localStrItem->setIcon(0, localStrIcon);
|
||||
}
|
||||
|
||||
if (!assetMap.techSets.isEmpty()) {
|
||||
QIcon techSetIcon = ZoneFile::AssetTypeToIcon(ASSET_TECH_SET);
|
||||
|
||||
XTreeWidgetItem *techSetRoot = new XTreeWidgetItem(zoneItem);
|
||||
techSetRoot->setText(0, "Tech Sets");
|
||||
techSetRoot->setIcon(0, QIcon(":/icons/icons/Icon_TechSetFile.png"));
|
||||
techSetRoot->setIcon(0, techSetIcon);
|
||||
techSetRoot->SetCategory(CATEGORY_TYPE);
|
||||
|
||||
for (TechSet techSet : assetMap.techSets) {
|
||||
XTreeWidgetItem *techSetItem = new XTreeWidgetItem(techSetRoot);
|
||||
techSetItem->setText(0, techSet.name);
|
||||
techSetItem->setIcon(0, QIcon(":/icons/icons/Icon_TechSetFile.png"));
|
||||
techSetItem->setIcon(0, techSetIcon);
|
||||
}
|
||||
}
|
||||
|
||||
if (!assetMap.rawFiles.isEmpty()) {
|
||||
QIcon rawFileIcon = ZoneFile::AssetTypeToIcon(ASSET_RAW_FILE);
|
||||
|
||||
XTreeWidgetItem *rawFileRoot = new XTreeWidgetItem(zoneItem);
|
||||
rawFileRoot->setText(0, "Raw Files");
|
||||
rawFileRoot->setIcon(0, QIcon(":/icons/icons/Icon_GSCFile.png"));
|
||||
rawFileRoot->setIcon(0, rawFileIcon);
|
||||
rawFileRoot->SetCategory(CATEGORY_TYPE);
|
||||
for (RawFile rawFile : assetMap.rawFiles) {
|
||||
if (!rawFile.length) { continue; }
|
||||
|
||||
XTreeWidgetItem *tempItem = rawFileRoot;
|
||||
for (const QString &pathPart : rawFile.path.split('/')) {
|
||||
const QStringList pathParts = rawFile.path.split('/');
|
||||
for (const QString &pathPart : pathParts) {
|
||||
bool childFound = false;
|
||||
for (int i = 0; i < tempItem->childCount(); i++) {
|
||||
QTreeWidgetItem *rawChildItem = tempItem->child(i);
|
||||
@ -135,25 +148,30 @@ void XTreeWidget::AddZoneFile(std::shared_ptr<ZoneFile> aZoneFile, XTreeWidgetIt
|
||||
}
|
||||
}
|
||||
|
||||
if (pathPart.contains(".gsc")) {
|
||||
const QString rawFileStr = QString("%1 [%2-%3]").arg(pathPart).arg(rawFile.startPos).arg(rawFile.endPos);
|
||||
//rawFileStr = pathPart;
|
||||
if (pathPart == pathParts.last()) {
|
||||
XTreeWidgetItem *rawFileItem = new XTreeWidgetItem(tempItem);
|
||||
rawFileItem->setText(0, pathPart);
|
||||
rawFileItem->setText(0, rawFileStr);
|
||||
|
||||
tempItem = rawFileItem;
|
||||
} else if (!childFound) {
|
||||
tempItem = new XTreeWidgetItem(tempItem);
|
||||
tempItem->setText(0, pathPart);
|
||||
tempItem->setText(0, rawFileStr);
|
||||
}
|
||||
|
||||
}
|
||||
tempItem->setIcon(0, QIcon(":/icons/icons/Icon_GSCFile.png"));
|
||||
tempItem->setIcon(0, rawFileIcon);
|
||||
}
|
||||
}
|
||||
|
||||
if (!assetMap.menuFiles.isEmpty()) {
|
||||
QIcon menuFileIcon = ZoneFile::AssetTypeToIcon(ASSET_MENU);
|
||||
|
||||
XTreeWidgetItem *menuRoot = new XTreeWidgetItem(zoneItem);
|
||||
menuRoot->setText(0, "Menu Files");
|
||||
menuRoot->setIcon(0, QIcon(":/icons/icons/Icon_MenuFile.png"));
|
||||
menuRoot->setIcon(0, menuFileIcon);
|
||||
menuRoot->SetCategory(CATEGORY_TYPE);
|
||||
|
||||
int menuIndex = 1;
|
||||
for (MenuFile menuFile : assetMap.menuFiles) {
|
||||
@ -162,64 +180,79 @@ void XTreeWidget::AddZoneFile(std::shared_ptr<ZoneFile> aZoneFile, XTreeWidgetIt
|
||||
for (Menu menu : menuFile.menuDefs) {
|
||||
XTreeWidgetItem *menuItem = new XTreeWidgetItem(menuFileRoot);
|
||||
menuItem->setText(0, menu.filePath);
|
||||
menuItem->setIcon(0, QIcon(":/icons/icons/Icon_MenuFile.png"));
|
||||
menuItem->setIcon(0, menuFileIcon);
|
||||
}
|
||||
menuIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!assetMap.images.isEmpty()) {
|
||||
QIcon imageIcon = ZoneFile::AssetTypeToIcon(ASSET_IMAGE);
|
||||
|
||||
XTreeWidgetItem *imageRoot = new XTreeWidgetItem(zoneItem);
|
||||
imageRoot->setText(0, "Images");
|
||||
imageRoot->setIcon(0, QIcon(":/icons/icons/Icon_Image.png"));
|
||||
imageRoot->setIcon(0, imageIcon);
|
||||
imageRoot->SetCategory(CATEGORY_TYPE);
|
||||
|
||||
for (Image image : assetMap.images) {
|
||||
XTreeWidgetItem *imageItem = new XTreeWidgetItem(imageRoot);
|
||||
imageItem->setText(0, image.materialName);
|
||||
imageItem->setIcon(0, QIcon(":/icons/icons/Icon_Image.png"));
|
||||
imageItem->setIcon(0, imageIcon);
|
||||
}
|
||||
}
|
||||
|
||||
if (!assetMap.models.isEmpty()) {
|
||||
QIcon modelIcon = ZoneFile::AssetTypeToIcon(ASSET_MODEL);
|
||||
|
||||
XTreeWidgetItem *modelsRoot = new XTreeWidgetItem(zoneItem);
|
||||
modelsRoot->setText(0, "Models");
|
||||
modelsRoot->setIcon(0, QIcon(":/icons/icons/Icon_Model.png"));
|
||||
modelsRoot->setIcon(0, modelIcon);
|
||||
modelsRoot->SetCategory(CATEGORY_TYPE);
|
||||
|
||||
for (Model model: assetMap.models) {
|
||||
XTreeWidgetItem *modelItem = new XTreeWidgetItem(modelsRoot);
|
||||
modelItem->setText(0, model.modelName);
|
||||
modelItem->setIcon(0, QIcon(":/icons/icons/Icon_Model.png"));
|
||||
modelItem->setIcon(0, modelIcon);
|
||||
}
|
||||
}
|
||||
|
||||
if (!assetMap.materials.isEmpty()) {
|
||||
QIcon materialIcon = ZoneFile::AssetTypeToIcon(ASSET_MATERIAL);
|
||||
|
||||
XTreeWidgetItem *materialsRoot = new XTreeWidgetItem(zoneItem);
|
||||
materialsRoot->setText(0, "Materials");
|
||||
materialsRoot->setIcon(0, QIcon(":/icons/icons/Icon_Material.png"));
|
||||
materialsRoot->setIcon(0, materialIcon);
|
||||
materialsRoot->SetCategory(CATEGORY_TYPE);
|
||||
|
||||
for (Material material: assetMap.materials) {
|
||||
XTreeWidgetItem *materialItem = new XTreeWidgetItem(materialsRoot);
|
||||
materialItem->setText(0, material.name);
|
||||
materialItem->setIcon(0, QIcon(":/icons/icons/Icon_Material.png"));
|
||||
materialItem->setIcon(0, materialIcon);
|
||||
}
|
||||
}
|
||||
|
||||
if (!assetMap.stringTables.isEmpty()) {
|
||||
QIcon stringTableIcon = ZoneFile::AssetTypeToIcon(ASSET_STRING_TABLE);
|
||||
|
||||
XTreeWidgetItem *strTableRoot = new XTreeWidgetItem(zoneItem);
|
||||
strTableRoot->setText(0, "String Tables");
|
||||
strTableRoot->setIcon(0, QIcon(":/icons/icons/Icon_StringTable.png"));
|
||||
strTableRoot->setIcon(0, stringTableIcon);
|
||||
strTableRoot->SetCategory(CATEGORY_TYPE);
|
||||
|
||||
for (StringTable strTable: assetMap.stringTables) {
|
||||
XTreeWidgetItem *modelItem = new XTreeWidgetItem(strTableRoot);
|
||||
modelItem->setText(0, strTable.name);
|
||||
modelItem->setIcon(0, QIcon(":/icons/icons/Icon_StringTable.png"));
|
||||
modelItem->setIcon(0, stringTableIcon);
|
||||
}
|
||||
}
|
||||
|
||||
if (!assetMap.sounds.isEmpty()) {
|
||||
QIcon soundIcon = ZoneFile::AssetTypeToIcon(ASSET_SOUND);
|
||||
|
||||
XTreeWidgetItem *soundsRoot = new XTreeWidgetItem(zoneItem);
|
||||
soundsRoot->setText(0, "Sounds");
|
||||
soundsRoot->setIcon(0, QIcon(":/icons/icons/Icon_Sound.png"));
|
||||
soundsRoot->setIcon(0, soundIcon);
|
||||
soundsRoot->SetCategory(CATEGORY_TYPE);
|
||||
for (SoundAsset soundAsset : assetMap.sounds) {
|
||||
for (Sound sound : soundAsset.sounds) {
|
||||
XTreeWidgetItem *tempItem = soundsRoot;
|
||||
@ -251,16 +284,16 @@ void XTreeWidget::AddZoneFile(std::shared_ptr<ZoneFile> aZoneFile, XTreeWidgetIt
|
||||
}
|
||||
|
||||
}
|
||||
tempItem->setIcon(0, QIcon(":/icons/icons/Icon_Sound.png"));
|
||||
tempItem->setIcon(0, soundIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mZoneFiles[aZoneFile->GetStem().section(".", 0, 0)] = aZoneFile;
|
||||
mZoneFiles[aZoneFile->GetBaseStem() + ".zone"] = aZoneFile;
|
||||
}
|
||||
|
||||
void XTreeWidget::CloseFastFile(const QString aFFName) {
|
||||
const QString fileStem = aFFName.section(".", 0, 0);
|
||||
const QString fileStem = aFFName;
|
||||
emit ItemClosed(fileStem);
|
||||
}
|
||||
|
||||
@ -361,7 +394,7 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
|
||||
iwiFile->SaveJPG();
|
||||
});
|
||||
} else if (activeText.contains(".ff")) {
|
||||
const QString fileStem = activeText.replace(".zone", "");
|
||||
const QString fileStem = activeText;
|
||||
|
||||
QMenu *closeMultipleAction = new QMenu("Close Multiple Tabs");
|
||||
|
||||
@ -385,7 +418,7 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
|
||||
auto childItem = invisibleRootItem()->child(i);
|
||||
if (childItem == activeItem) { continue; }
|
||||
|
||||
const QString fileStem = childItem->text(0).replace(".ff", "");
|
||||
const QString fileStem = childItem->text(0);
|
||||
if (!mFastFiles.contains(fileStem)) {
|
||||
qDebug() << "Error: Could not find " << fileStem << " in Fast File map!";
|
||||
return;
|
||||
@ -407,7 +440,7 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
|
||||
auto childItem = invisibleRootItem()->child(i);
|
||||
if (childItem == activeItem) { return; }
|
||||
|
||||
const QString fileStem = childItem->text(0).replace(".ff", "");
|
||||
const QString fileStem = childItem->text(0);
|
||||
if (!mFastFiles.contains(fileStem)) {
|
||||
qDebug() << "Error: Could not find " << fileStem << " in Fast File map!";
|
||||
return;
|
||||
@ -434,7 +467,7 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const QString fileStem = childItem->text(0).replace(".ff", "");
|
||||
const QString fileStem = childItem->text(0);
|
||||
if (!mFastFiles.contains(fileStem)) {
|
||||
qDebug() << "Error: Could not find " << fileStem << " in Fast File map!";
|
||||
return;
|
||||
@ -454,7 +487,7 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
|
||||
connect(closeAction, &QAction::triggered, this, [this, &activeItem, &activeText](bool checked) {
|
||||
Q_UNUSED(checked);
|
||||
|
||||
const QString fileStem = activeItem->text(0).replace(".ff", "");
|
||||
const QString fileStem = activeItem->text(0);
|
||||
|
||||
mFastFiles.remove(fileStem);
|
||||
CloseFastFile(activeText);
|
||||
@ -488,7 +521,7 @@ void XTreeWidget::PrepareContextMenu(const QPoint &pos) {
|
||||
fastFile->GetZoneFile()->SaveZoneFile(zoneFilePath);
|
||||
});
|
||||
} else if (activeText.contains(".zone")) {
|
||||
const QString fileStem = activeText.replace(".zone", "");
|
||||
const QString fileStem = activeText;
|
||||
if (!mZoneFiles.contains(fileStem)) {
|
||||
qDebug() << "Error: Could not find " << fileStem << " in Zone File map!";
|
||||
return;
|
||||
@ -618,63 +651,39 @@ void XTreeWidget::ItemSelectionChanged() {
|
||||
QString selectedText = selectedItem->text(0);
|
||||
emit ItemSelected(selectedText);
|
||||
|
||||
const QString fileStem = selectedText.section(".", 0, 0);
|
||||
|
||||
XTreeWidgetItem *parentItem = dynamic_cast<XTreeWidgetItem*>(selectedItem->parent());
|
||||
|
||||
if (selectedText.contains(".dds")) {
|
||||
if (!mDDSFiles.contains(fileStem)) {
|
||||
LogManager::instance().addError("Could not find " + fileStem + " in DDS map!");
|
||||
if (!mDDSFiles.contains(selectedText)) {
|
||||
LogManager::instance().addError("Could not find " + selectedText + " in DDS map!");
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<DDSFile> ddsFile = mDDSFiles[fileStem];
|
||||
emit DDSFileSelected(ddsFile, fileStem);
|
||||
std::shared_ptr<DDSFile> ddsFile = mDDSFiles[selectedText];
|
||||
emit DDSFileSelected(ddsFile, selectedText);
|
||||
} else if (selectedText.contains(".iwi")) {
|
||||
if (!mIWIFiles.contains(fileStem)) {
|
||||
LogManager::instance().addError("Could not find " + fileStem + " in IWI map!");
|
||||
if (!mIWIFiles.contains(selectedText)) {
|
||||
LogManager::instance().addError("Could not find " + selectedText + " in IWI map!");
|
||||
return;
|
||||
}
|
||||
emit IWIFileSelected(mIWIFiles[fileStem], fileStem);
|
||||
emit IWIFileSelected(mIWIFiles[selectedText], selectedText);
|
||||
} else if (selectedText.contains(".ff")) {
|
||||
if (!mFastFiles.contains(fileStem)) {
|
||||
LogManager::instance().addError("Could not find " + fileStem + " in Fast File map!");
|
||||
if (!mFastFiles.contains(selectedText)) {
|
||||
LogManager::instance().addError("Could not find " + selectedText + " in Fast File map!");
|
||||
return;
|
||||
}
|
||||
emit FastFileSelected(mFastFiles[fileStem], fileStem);
|
||||
emit FastFileSelected(mFastFiles[selectedText], selectedText);
|
||||
} else if (selectedText.contains(".zone")) {
|
||||
if (!mZoneFiles.contains(fileStem)) {
|
||||
LogManager::instance().addError("Could not find " + fileStem + " in Zone File map!");
|
||||
if (!mZoneFiles.contains(selectedText)) {
|
||||
LogManager::instance().addError("Could not find " + selectedText + " in Zone File map!");
|
||||
return;
|
||||
}
|
||||
emit ZoneFileSelected(mZoneFiles[fileStem], fileStem);
|
||||
emit ZoneFileSelected(mZoneFiles[selectedText], selectedText);
|
||||
} else if (selectedText.contains(".str")) {
|
||||
if (!mZoneFiles.contains(fileStem)) {
|
||||
LogManager::instance().addError("Could not find " + fileStem + " in Zone File map!");
|
||||
if (!mZoneFiles.contains(selectedText.replace(".str", ".zone"))) {
|
||||
LogManager::instance().addError("Could not find " + selectedText + " in Zone File map!");
|
||||
return;
|
||||
}
|
||||
emit LocalStringSelected(mZoneFiles[fileStem], fileStem);
|
||||
} else if (selectedText.contains(".gsc")) {
|
||||
XTreeWidgetItem *zoneRoot = selectedItem;
|
||||
if (!zoneRoot) { return; }
|
||||
|
||||
while (!zoneRoot->text(0).contains(".zone")) {
|
||||
zoneRoot = dynamic_cast<XTreeWidgetItem*>(zoneRoot->parent());
|
||||
if (!zoneRoot) { return; }
|
||||
}
|
||||
|
||||
const QString fileStem = zoneRoot->text(0).section('.', 0, 0);
|
||||
if (!mZoneFiles.contains(fileStem)) {
|
||||
LogManager::instance().addError("Could not find " + fileStem + " in Zone File map!");
|
||||
return;
|
||||
}
|
||||
|
||||
QVector<RawFile> rawFiles = mZoneFiles[fileStem]->GetAssetMap().rawFiles;
|
||||
for (RawFile rawFile : rawFiles) {
|
||||
if (rawFile.path.contains(selectedText)) {
|
||||
emit RawFileSelected(std::make_shared<RawFile>(rawFile), fileStem);
|
||||
return;
|
||||
}
|
||||
}
|
||||
emit LocalStringSelected(mZoneFiles[selectedText], selectedText);
|
||||
} else if (parentItem && (parentItem->text(0) == "Images")) {
|
||||
XTreeWidgetItem *grandpaItem = dynamic_cast<XTreeWidgetItem*>(parentItem->parent());
|
||||
if (grandpaItem && grandpaItem->text(0).contains(".zone")) {
|
||||
@ -744,6 +753,32 @@ void XTreeWidget::ItemSelectionChanged() {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (selectedItem->GetCategory() != CATEGORY_TYPE) {
|
||||
XTreeWidgetItem *zoneRoot = selectedItem;
|
||||
|
||||
bool zoneChild = false;
|
||||
while (zoneRoot) {
|
||||
zoneRoot = dynamic_cast<XTreeWidgetItem*>(zoneRoot->parent());
|
||||
if (zoneRoot->text(0).contains("Raw Files")) {
|
||||
zoneChild = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!zoneChild) { return; }
|
||||
const QString fileStem = zoneRoot->parent()->text(0);
|
||||
|
||||
if (!mZoneFiles.contains(fileStem)) {
|
||||
LogManager::instance().addError("Could not find " + fileStem + " in Zone File map!");
|
||||
return;
|
||||
}
|
||||
|
||||
QVector<RawFile> rawFiles = mZoneFiles[fileStem]->GetAssetMap().rawFiles;
|
||||
for (RawFile rawFile : rawFiles) {
|
||||
if (rawFile.path.split('/').last() == selectedText) {
|
||||
emit RawFileSelected(std::make_shared<RawFile>(rawFile), fileStem);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -784,7 +819,7 @@ void XTreeWidget::AddIWIFile(std::shared_ptr<IWIFile> aIWIFile) {
|
||||
}
|
||||
|
||||
XTreeWidgetItem *iwiItem = new XTreeWidgetItem(this);
|
||||
iwiItem->setIcon(0, QIcon(":/icons/icons/Icon_IWIFile.png"));
|
||||
iwiItem->setIcon(0, ZoneFile::AssetTypeToIcon(ASSET_IMAGE));
|
||||
iwiItem->setText(0, iwiFileName);
|
||||
mIWIFiles[aIWIFile->fileStem.section(".", 0, 0)] = aIWIFile;
|
||||
}
|
||||
@ -800,7 +835,7 @@ void XTreeWidget::AddDDSFile(std::shared_ptr<DDSFile> aDDSFile) {
|
||||
}
|
||||
|
||||
XTreeWidgetItem *ddsItem = new XTreeWidgetItem(this);
|
||||
ddsItem->setIcon(0, QIcon(":/icons/icons/Icon_DDSFile.png"));
|
||||
ddsItem->setIcon(0, ZoneFile::AssetTypeToIcon(ASSET_IMAGE));
|
||||
ddsItem->setText(0, ddsFileName);
|
||||
mDDSFiles[aDDSFile->fileStem.section(".", 0, 0)] = aDDSFile;
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "fastfile.h"
|
||||
#include "xtreewidgetitem.h"
|
||||
#include "zonefile.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QFileDialog>
|
||||
|
||||
@ -1,15 +1,29 @@
|
||||
#include "xtreewidgetitem.h"
|
||||
|
||||
XTreeWidgetItem::XTreeWidgetItem(QTreeWidget *parent, bool group)
|
||||
: QTreeWidgetItem(parent), isGroup(group) {
|
||||
: QTreeWidgetItem(parent)
|
||||
, isGroup(group)
|
||||
, mCategory(CATEGORY_NONE) {
|
||||
|
||||
}
|
||||
|
||||
XTreeWidgetItem::XTreeWidgetItem(QTreeWidgetItem *parent, bool group)
|
||||
: QTreeWidgetItem(parent), isGroup(group) {
|
||||
: QTreeWidgetItem(parent)
|
||||
, isGroup(group)
|
||||
, mCategory(CATEGORY_NONE) {
|
||||
|
||||
}
|
||||
|
||||
void XTreeWidgetItem::SetCategory(TREE_CATEGORY category)
|
||||
{
|
||||
mCategory = category;
|
||||
}
|
||||
|
||||
TREE_CATEGORY XTreeWidgetItem::GetCategory()
|
||||
{
|
||||
return mCategory;
|
||||
}
|
||||
|
||||
bool XTreeWidgetItem::operator<(const QTreeWidgetItem &other) const {
|
||||
// Attempt to cast the other item to our custom type.
|
||||
const XTreeWidgetItem* otherItem = dynamic_cast<const XTreeWidgetItem*>(&other);
|
||||
|
||||
@ -4,6 +4,12 @@
|
||||
#include <QTreeWidget>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
enum TREE_CATEGORY {
|
||||
CATEGORY_NONE = 0x00,
|
||||
CATEGORY_FILE = 0x01,
|
||||
CATEGORY_TYPE = 0x02
|
||||
};
|
||||
|
||||
// Custom item class
|
||||
class XTreeWidgetItem : public QTreeWidgetItem
|
||||
{
|
||||
@ -15,9 +21,15 @@ public:
|
||||
XTreeWidgetItem(QTreeWidget *parent, bool group = false);
|
||||
XTreeWidgetItem(QTreeWidgetItem *parent, bool group = false);
|
||||
|
||||
void SetCategory(TREE_CATEGORY category);
|
||||
TREE_CATEGORY GetCategory();
|
||||
|
||||
// Override the less-than operator to customize sorting.
|
||||
bool operator<(const QTreeWidgetItem &other) const override;
|
||||
XTreeWidgetItem &operator =(const XTreeWidgetItem &other);
|
||||
|
||||
private:
|
||||
TREE_CATEGORY mCategory;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user