Fixed filter issue (all addons for a gamefile are enabled for checking).

Note:  Other dependencies are not yet automatically selected when an
addon is checked.
actorid
graffy76 11 years ago
parent 513f0c4b3e
commit d7cff6361e

@ -25,7 +25,6 @@ namespace CSVDoc
void setLocalData (const boost::filesystem::path& localData);
QString getText() const;
bool isValid() const;
boost::filesystem::path getPath() const;

@ -67,7 +67,6 @@ void CSVDoc::FileDialog::slotEnableCreateButton(bool enable, int widgetNumber)
if (widgetNumber == 2)
mEnable_2 = enable;
qDebug() << "update enabled" << mEnable_1 << mEnable_2 << enable;
projectCreateButton->setEnabled(mEnable_1 && mEnable_2);
}
@ -113,5 +112,5 @@ void CSVDoc::FileDialog::slotAdjusterChanged(bool value)
void CSVDoc::FileDialog::slotGameFileSelected(int value)
{
emit signalUpdateCreateButton(value > -1, 1);
emit signalUpdateCreateButton(value > -1, 1);
}

@ -65,7 +65,7 @@ ContentSelectorModel::EsmFile *ContentSelectorModel::ContentModel::item(int row)
return 0;
}
const ContentSelectorModel::EsmFile *ContentSelectorModel::ContentModel::findItem(const QString &name) const
const ContentSelectorModel::EsmFile *ContentSelectorModel::ContentModel::item(const QString &name) const
{
foreach (const EsmFile *file, mFiles)
{
@ -99,7 +99,7 @@ Qt::ItemFlags ContentSelectorModel::ContentModel::flags(const QModelIndex &index
if (canBeChecked(file))
return Qt::ItemIsEnabled | mDragDropFlags | mDefaultFlags;
return mDefaultFlags;
return Qt::NoItemFlags;
}
QVariant ContentSelectorModel::ContentModel::data(const QModelIndex &index, int role) const
@ -167,7 +167,7 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex &index, int
if (file->isGameFile())
return ContentType_GameFile;
else
if (flags(index) & Qt::ItemIsEnabled)
if (flags(index) & mDefaultFlags)
return ContentType_Addon;
break;
@ -373,12 +373,26 @@ bool ContentSelectorModel::ContentModel::dropMimeData(const QMimeData *data, Qt:
bool ContentSelectorModel::ContentModel::canBeChecked(const EsmFile *file) const
{
//element can be checked if all its dependencies are
foreach (const QString &gamefile, file->gameFiles())
if (!isChecked(gamefile))
return false;
//game files can always be checked
if (file->isGameFile())
return true;
return true;
//addon can be checked if its gamefile is
foreach (const QString &fileName, file->gameFiles())
{
const EsmFile *dependency = item(fileName);
if (!dependency)
continue;
if (dependency->isGameFile())
{
if (isChecked(fileName))
return true;
}
}
return false;
}
void ContentSelectorModel::ContentModel::addFile(EsmFile *file)
@ -422,7 +436,7 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path)
// Put the file in the table
if (findItem(path) == 0)
if (item(path) == 0)
addFile(file);
} catch(std::runtime_error &e) {

@ -42,7 +42,7 @@ namespace ContentSelectorModel
void addFiles(const QString &path);
QModelIndex indexFromItem(const EsmFile *item) const;
const EsmFile *findItem(const QString &name) const;
const EsmFile *item(const QString &name) const;
bool isChecked(const QString &name) const;
void setCheckState(const QString &name, bool isChecked);
@ -54,6 +54,7 @@ namespace ContentSelectorModel
void addFile(EsmFile *file);
const EsmFile *item(int row) const;
EsmFile *item(int row);
bool canBeChecked(const EsmFile *file) const;
ContentFileList mFiles;

Loading…
Cancel
Save