/*
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#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("Full path to the compiled file"));
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("Name of 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);
}