void OverwriteInfoDialog::setModInfo(ModInfo::Ptr modInfo)
{
  m_ModInfo = modInfo;
  if (QDir(modInfo->absolutePath()).exists()) {
    m_FileSystemModel->setRootPath(modInfo->absolutePath());
  } else {
    throw MyException(tr("%1 not found").arg(modInfo->absolutePath()));
  }
}
Пример #2
0
std::vector<std::tuple<QString, QString, int> > Profile::getActiveMods()
{
  std::vector<std::tuple<QString, QString, int> > result;
  for (std::vector<unsigned int>::const_iterator iter = m_ModIndexByPriority.begin();
       iter != m_ModIndexByPriority.end(); ++iter) {
    if ((*iter != UINT_MAX) && m_ModStatus[*iter].m_Enabled) {
      ModInfo::Ptr modInfo = ModInfo::getByIndex(*iter);
      result.push_back(std::make_tuple(modInfo->internalName(), modInfo->absolutePath(), m_ModStatus[*iter].m_Priority));
    }
  }

  unsigned int overwriteIndex = ModInfo::findMod([](ModInfo::Ptr mod) -> bool {
    std::vector<ModInfo::EFlag> flags = mod->getFlags();
    return std::find(flags.begin(), flags.end(), ModInfo::FLAG_OVERWRITE) != flags.end(); });

  if (overwriteIndex != UINT_MAX) {
    ModInfo::Ptr overwriteInfo = ModInfo::getByIndex(overwriteIndex);
    result.push_back(std::make_tuple(overwriteInfo->name(), overwriteInfo->absolutePath(), UINT_MAX));
  } else {
    reportError(tr("Overwrite directory couldn't be parsed"));
  }
  return result;
}
OverwriteInfoDialog::OverwriteInfoDialog(ModInfo::Ptr modInfo, QWidget *parent)
  : QDialog(parent), ui(new Ui::OverwriteInfoDialog), m_FileSystemModel(nullptr),
    m_DeleteAction(nullptr), m_RenameAction(nullptr), m_OpenAction(nullptr)
{
  ui->setupUi(this);

  this->setWindowModality(Qt::NonModal);

  m_FileSystemModel = new MyFileSystemModel(this);
  m_FileSystemModel->setReadOnly(false);
  setModInfo(modInfo);
  ui->filesView->setModel(m_FileSystemModel);
  ui->filesView->setRootIndex(m_FileSystemModel->index(modInfo->absolutePath()));
  ui->filesView->setColumnWidth(0, 250);

  m_DeleteAction = new QAction(tr("&Delete"), ui->filesView);
  m_RenameAction = new QAction(tr("&Rename"), ui->filesView);
  m_OpenAction = new QAction(tr("&Open"), ui->filesView);
  m_NewFolderAction = new QAction(tr("&New Folder"), ui->filesView);
  QObject::connect(m_DeleteAction, SIGNAL(triggered()), this, SLOT(deleteTriggered()));
  QObject::connect(m_RenameAction, SIGNAL(triggered()), this, SLOT(renameTriggered()));
  QObject::connect(m_OpenAction, SIGNAL(triggered()), this, SLOT(openTriggered()));
  QObject::connect(m_NewFolderAction, SIGNAL(triggered()), this, SLOT(createDirectoryTriggered()));
}