Fixes to accommodate master/plugin loading

actorid
graffy76 12 years ago
parent e614ec3353
commit b52645bf2a

@ -29,16 +29,11 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
, mLauncherSettings(launcherSettings) , mLauncherSettings(launcherSettings)
, ContentSelector(parent) , ContentSelector(parent)
{ {
pluginView->hideColumn(2);
// Create a dialog for the new profile name input // Create a dialog for the new profile name input
mNewProfileDialog = new TextInputDialog(tr("New Profile"), tr("Profile name:"), this); mNewProfileDialog = new TextInputDialog(tr("New Profile"), tr("Profile name:"), this);
connect(mNewProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(updateOkButton(QString))); connect(mNewProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(updateOkButton(QString)));
//connect(pluginView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
//connect(masterView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
createActions(); createActions();
setupDataFiles(); setupDataFiles();
} }
@ -49,11 +44,6 @@ void DataFilesPage::createActions()
// Add the actions to the toolbuttons // Add the actions to the toolbuttons
newProfileButton->setDefaultAction(newProfileAction); newProfileButton->setDefaultAction(newProfileAction);
deleteProfileButton->setDefaultAction(deleteProfileAction); deleteProfileButton->setDefaultAction(deleteProfileAction);
// Context menu actions
mContextMenu = new QMenu(this);
mContextMenu->addAction(checkAction);
mContextMenu->addAction(uncheckAction);
} }
void DataFilesPage::setupDataFiles() void DataFilesPage::setupDataFiles()
@ -150,17 +140,17 @@ void DataFilesPage::saveSettings()
mGameSettings.remove(QString("master")); mGameSettings.remove(QString("master"));
mGameSettings.remove(QString("plugin")); mGameSettings.remove(QString("plugin"));
QStringList items = mDataFilesModel->checkedItems(); EsxModel::EsmFileList items = mDataFilesModel->checkedItems();
foreach(const QString &item, items) { foreach(const EsxModel::EsmFile *item, items) {
if (item.endsWith(QString(".esm"), Qt::CaseInsensitive)) { if (item->masters().size() == 0) {
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/master"), item); mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/master"), item->fileName());
mGameSettings.setMultiValue(QString("master"), item); mGameSettings.setMultiValue(QString("master"), item->fileName());
} else if (item.endsWith(QString(".esp"), Qt::CaseInsensitive)) { } else {
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/plugin"), item); mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/plugin"), item->fileName());
mGameSettings.setMultiValue(QString("plugin"), item); mGameSettings.setMultiValue(QString("plugin"), item->fileName());
} }
} }
@ -296,73 +286,3 @@ void DataFilesPage::profileRenamed(const QString &previous, const QString &curre
loadSettings(); loadSettings();
} }
/*
void DataFilesPage::showContextMenu(const QPoint &point)
{
QObject *object = QObject::sender();
// Not a signal-slot call
if (!object)
return;
if (object->objectName() == QLatin1String("PluginView")) {
if (!pluginView->selectionModel()->hasSelection())
return;
QPoint globalPos = pluginView->mapToGlobal(point);
QModelIndexList indexes = pluginView->selectionModel()->selectedIndexes();
// Show the check/uncheck actions depending on the state of the selected items
uncheckAction->setEnabled(false);
checkAction->setEnabled(false);
foreach (const QModelIndex &index, indexes)
{
if (!index.isValid())
return;
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(index);
if (!sourceIndex.isValid())
return;
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
? uncheckAction->setEnabled(true)
: checkAction->setEnabled(true);
}
// Show menu
mContextMenu->exec(globalPos);
}
if (object->objectName() == QLatin1String("MasterView")) {
if (!masterView->selectionModel()->hasSelection())
return;
QPoint globalPos = masterView->mapToGlobal(point);
QModelIndexList indexes = masterView->selectionModel()->selectedIndexes();
// Show the check/uncheck actions depending on the state of the selected items
uncheckAction->setEnabled(false);
checkAction->setEnabled(false);
foreach (const QModelIndex &index, indexes)
{
if (!index.isValid())
return;
QModelIndex sourceIndex = mMastersProxyModel->mapToSource(index);
if (!sourceIndex.isValid())
return;
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
? uncheckAction->setEnabled(true)
: checkAction->setEnabled(true);
}
mContextMenu->exec(globalPos);
}
}
*/

@ -23,6 +23,7 @@ CSVDoc::FileDialog::FileDialog(QWidget *parent) :
{ {
// Hide the profile elements // Hide the profile elements
profileGroupBox->hide(); profileGroupBox->hide();
pluginView->showColumn(2);
// Add some extra widgets // Add some extra widgets
QHBoxLayout *nameLayout = new QHBoxLayout(); QHBoxLayout *nameLayout = new QHBoxLayout();
@ -77,7 +78,7 @@ void CSVDoc::FileDialog::updateCreateButton(const QString &name)
QString CSVDoc::FileDialog::fileName() QString CSVDoc::FileDialog::fileName()
{ {
//return mNameLineEdit->text(); return mNameLineEdit->text();
} }
void CSVDoc::FileDialog::openFile() void CSVDoc::FileDialog::openFile()
@ -85,7 +86,7 @@ void CSVDoc::FileDialog::openFile()
setWindowTitle(tr("Open")); setWindowTitle(tr("Open"));
mNameLabel->hide(); mNameLabel->hide();
//mNameLineEdit->hide(); mNameLineEdit->hide();
mCreateButton->hide(); mCreateButton->hide();
mButtonBox->removeButton(mCreateButton); mButtonBox->removeButton(mCreateButton);
@ -103,8 +104,8 @@ void CSVDoc::FileDialog::newFile()
setWindowTitle(tr("New")); setWindowTitle(tr("New"));
mNameLabel->show(); mNameLabel->show();
//mNameLineEdit->clear(); mNameLineEdit->clear();
//mNameLineEdit->show(); mNameLineEdit->show();
mCreateButton->show(); mCreateButton->show();
mButtonBox->setStandardButtons(QDialogButtonBox::Cancel); mButtonBox->setStandardButtons(QDialogButtonBox::Cancel);

@ -365,23 +365,21 @@ EsxModel::EsmFile* EsxModel::DataFilesModel::item(int row) const
return 0; return 0;
} }
QStringList EsxModel::DataFilesModel::checkedItems() EsxModel::EsmFileList EsxModel::DataFilesModel::checkedItems()
{ {
QStringList list; EsmFileList list;
QList<EsmFile *>::ConstIterator it; EsmFileList::ConstIterator it;
QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd(); EsmFileList::ConstIterator itEnd = mFiles.constEnd();
int i = 0; int i = 0;
for (it = mFiles.constBegin(); it != itEnd; ++it) { for (it = mFiles.constBegin(); it != itEnd; ++it)
EsmFile *file = item(i); {
++i; EsmFile *file = *it;
QString name = file->fileName();
// Only add the items that are in the checked list and available // Only add the items that are in the checked list and available
if (mCheckStates[name] == Qt::Checked && canBeChecked(file)) if (mCheckStates[file->fileName()] == Qt::Checked && canBeChecked(file))
list << name; list << file;
} }
return list; return list;
@ -413,13 +411,13 @@ void EsxModel::DataFilesModel::uncheckAll()
emit layoutChanged(); emit layoutChanged();
} }
QStringList EsxModel::DataFilesModel::uncheckedItems() EsxModel::EsmFileList EsxModel::DataFilesModel::uncheckedItems()
{ {
QStringList list; EsmFileList list;
QStringList checked = checkedItems(); EsmFileList checked = checkedItems();
QList<EsmFile *>::ConstIterator it; EsmFileList::ConstIterator it;
QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd(); EsmFileList::ConstIterator itEnd = mFiles.constEnd();
int i = 0; int i = 0;
for (it = mFiles.constBegin(); it != itEnd; ++it) { for (it = mFiles.constBegin(); it != itEnd; ++it) {
@ -427,8 +425,8 @@ QStringList EsxModel::DataFilesModel::uncheckedItems()
++i; ++i;
// Add the items that are not in the checked list // Add the items that are not in the checked list
if (!checked.contains(file->fileName())) if (!checked.contains(file))
list << file->fileName(); list << file;
} }
return list; return list;

@ -10,6 +10,8 @@ namespace EsxModel
{ {
class EsmFile; class EsmFile;
typedef QList<EsmFile *> EsmFileList;
class DataFilesModel : public QAbstractTableModel class DataFilesModel : public QAbstractTableModel
{ {
Q_OBJECT Q_OBJECT
@ -39,8 +41,8 @@ namespace EsxModel
void uncheckAll(); void uncheckAll();
QStringList checkedItems(); EsmFileList checkedItems();
QStringList uncheckedItems(); EsmFileList uncheckedItems();
QStringList checkedItemsPaths(); QStringList checkedItemsPaths();
Qt::CheckState checkState(const QModelIndex &index); Qt::CheckState checkState(const QModelIndex &index);
@ -51,13 +53,13 @@ namespace EsxModel
EsmFile* item(int row) const; EsmFile* item(int row) const;
signals: signals:
void checkedItemsChanged(const QStringList &items); void checkedItemsChanged(const EsmFileList &items);
private: private:
bool canBeChecked(EsmFile *file) const; bool canBeChecked(EsmFile *file) const;
void addFile(EsmFile *file); void addFile(EsmFile *file);
QList<EsmFile *> mFiles; EsmFileList mFiles;
QHash<QString, Qt::CheckState> mCheckStates; QHash<QString, Qt::CheckState> mCheckStates;
QString mEncoding; QString mEncoding;

@ -77,6 +77,7 @@ void EsxView::ContentSelector::updateViews()
{ {
// Ensure the columns are hidden because sort() re-enables them // Ensure the columns are hidden because sort() re-enables them
pluginView->setColumnHidden(1, true); pluginView->setColumnHidden(1, true);
pluginView->setColumnHidden(2, true);
pluginView->setColumnHidden(3, true); pluginView->setColumnHidden(3, true);
pluginView->setColumnHidden(4, true); pluginView->setColumnHidden(4, true);
pluginView->setColumnHidden(5, true); pluginView->setColumnHidden(5, true);

@ -27,7 +27,7 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin"> <property name="leftMargin">
<number>9</number> <number>3</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>6</number> <number>6</number>
@ -115,7 +115,7 @@
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>9</number> <number>3</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>9</number> <number>9</number>

Loading…
Cancel
Save