#include "../core/objects.h" #include "../core/files.h" #include "../core/core.h" #include "../core/processors.h" #include "../core/script.h" #include "../core/lang.h" #include "models.h" #include "moc/moc_models.cc" #include "widgets.h" #include "property_editor.h" #include "message_dialog.h" static QIcon nodeIcon(NodeType type, bool is_disabled = false) { QString iconName; switch (type) { case NODE_FUNCTIONS: iconName = ":/images/star.png"; break; case NODE_LICENSES: iconName = ":/images/key.png"; break; case NODE_SCRIPT: iconName = ":/images/script.png"; break; case NODE_OPTIONS: iconName = ":/images/gear.png"; break; case NODE_FILES: case NODE_ASSEMBLIES: iconName = ":/images/box.png"; break; case NODE_ARCHITECTURE: iconName = ":/images/processor.png"; break; case NODE_LOAD_COMMANDS: iconName = ":/images/lightning.png"; break; case NODE_SEGMENTS: iconName = ":/images/code.png"; break; case NODE_EXPORTS: iconName = ":/images/export.png"; break; case NODE_IMPORTS: iconName = ":/images/import.png"; break; case NODE_RESOURCES: iconName = ":/images/database.png"; break; case NODE_CALC: iconName = ":/images/calc.png"; break; case NODE_DUMP: iconName = ":/images/dump.png"; break; case NODE_LICENSE: iconName = ":/images/item_key.png"; break; case NODE_FILE: iconName = ":/images/item_file.png"; break; case NODE_PROPERTY: iconName = ":/images/item_property.png"; break; case NODE_LOAD_COMMAND: iconName = ":/images/item_load_command.png"; break; case NODE_SEGMENT: case NODE_SECTION: iconName = ":/images/item_code.png"; break; case NODE_IMPORT_FUNCTION: iconName = ":/images/item_import.png"; break; case NODE_EXPORT: iconName = ":/images/item_export.png"; break; case NODE_RESOURCE: iconName = ":/images/item_resource.png"; break; case NODE_WATERMARK: case NODE_FUNCTION: iconName = ":/images/item.png"; break; case NODE_SCRIPT_BOOKMARK: iconName = ":/images/item_code.png"; break; case NODE_FOLDER: case NODE_RESOURCE_FOLDER: case NODE_MAP_FOLDER: case NODE_IMPORT_FOLDER: case NODE_EXPORT_FOLDER: case NODE_IMPORT: case NODE_FILE_FOLDER: if (is_disabled) { QIcon res; QPixmap firstImage(":/images/folder_close.png"); QPixmap secondImage(":/images/bullet_delete.png"); { QPainter painter(&firstImage); painter.drawPixmap(firstImage.width() - secondImage.width(), firstImage.height() - secondImage.height(), secondImage); } res.addPixmap(firstImage); firstImage = QPixmap(":/images/folder.png"); { QPainter painter(&firstImage); painter.drawPixmap(firstImage.width() - secondImage.width(), firstImage.height() - secondImage.height(), secondImage); } res.addPixmap(firstImage, QIcon::Normal, QIcon::On); return res; } else { QIcon res = QIcon(":/images/folder_close.png"); res.addPixmap(QPixmap(":/images/folder.png"), QIcon::Normal, QIcon::On); return res; } break; } if (is_disabled) { QPixmap firstImage(iconName); QPixmap secondImage(":/images/bullet_delete.png"); QPainter painter(&firstImage); painter.drawPixmap(firstImage.width() - secondImage.width(), firstImage.height() - secondImage.height(), secondImage); return QIcon(firstImage); } else { return QIcon(iconName); } } template static QIcon functionIcon(F *func) { if (!func || !func->need_compile()) return nodeIcon(NODE_FUNCTION, true); QString iconName; switch (func->compilation_type()) { case ctMutation: iconName = ":/images/item_m.png"; break; case ctUltra: iconName = ":/images/item_u.png"; break; default: iconName = ":/images/item_v.png"; break; } QString bullet_name; if (func->type() == otUnknown) bullet_name = ":/images/bullet_warning.png"; else if (func->compilation_type() != ctMutation && (func->compilation_options() & coLockToKey)) bullet_name = ":/images/bullet_key.png"; if (!bullet_name.isEmpty()) { QPixmap firstImage(iconName); QPixmap secondImage(bullet_name); QPainter painter(&firstImage); painter.drawPixmap(firstImage.width() - secondImage.width(), firstImage.height() - secondImage.height(), secondImage); QIcon res; res.addPixmap(firstImage); return res; } return QIcon(iconName); } /** * ProjectNode */ ProjectNode::ProjectNode(ProjectNode *parent, NodeType type, void *data) : parent_(NULL), data_(data), type_(type), properties_(NULL) { if (parent) parent->addChild(this); } void ProjectNode::clear() { for (int i = 0; i < children_.size(); i++) { ProjectNode *node = children_[i]; node->parent_ = NULL; delete node; } children_.clear(); if (properties_) { delete properties_; properties_ = NULL; } } ProjectNode::~ProjectNode() { clear(); if (parent_) parent_->removeChild(this); } QString functionProtection(const FunctionBundle *func) { return func ? QString::fromUtf8(func->display_protection().c_str()) : QString::fromUtf8(language[lsNone].c_str()); } bool ProjectNode::contains(const QRegExp &filter) const { for (int i = 0; i < 2; i++) { if (text(i).contains(filter)) return true; } return false; } QString ProjectNode::text(int column) const { if (column == 0) return text_; switch (type_) { case NODE_SCRIPT: case NODE_SCRIPT_BOOKMARK: { Script *object = static_cast