#include "macroinfomodel.h" MacroInfoModel::MacroInfoModel(QObject *parent) : QAbstractListModel(parent) { addMacroInfo("", tr("The default directory")); addMacroInfo("", tr("Path to the Red Panda C++'s executable file.")); addMacroInfo("", tr("Version of the Red Panda C++")); addMacroInfo("", tr("PATH to the Red Panda C++'s installation folder.")); addMacroInfo("", tr("Current date")); addMacroInfo("", tr("Current date and time")); addMacroInfo("", tr("The first include directory of the working compiler set.")); addMacroInfo("", tr("The first lib directory of the working compiler set.")); addMacroInfo("", tr("The compiled filename")); addMacroInfo("", tr("Filename of the current source file")); addMacroInfo("", tr("Full path to the current source file")); addMacroInfo("", tr("Path to the current source file's parent folder")); addMacroInfo("", tr("Word at the cursor in the active editor")); addMacroInfo("", tr("Name of the current project")); addMacroInfo("", tr("Full path to the current project file")); addMacroInfo("", tr("Path to the current project's folder")); } int MacroInfoModel::rowCount(const QModelIndex &parent) const { return mMacroInfos.count(); } QVariant MacroInfoModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); if (role == Qt::DisplayRole) { PMacroInfo info = mMacroInfos[index.row()]; return info->description; } else if (role == Qt::UserRole) { PMacroInfo info = mMacroInfos[index.row()]; return info->macro; } return QVariant(); } PMacroInfo MacroInfoModel::getInfo(const QModelIndex &index) const { if (!index.isValid()) return PMacroInfo(); return mMacroInfos[index.row()]; } void MacroInfoModel::addMacroInfo(const QString& macro, const QString& description) { PMacroInfo info = std::make_shared(); info->macro = macro; info->description = description; mMacroInfos.append(info); }