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)
, ContentSelector(parent)
{
pluginView->hideColumn(2);
// Create a dialog for the new profile name input
mNewProfileDialog = new TextInputDialog(tr("New Profile"), tr("Profile name:"), this);
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();
setupDataFiles();
}
@ -49,11 +44,6 @@ void DataFilesPage::createActions()
// Add the actions to the toolbuttons
newProfileButton->setDefaultAction(newProfileAction);
deleteProfileButton->setDefaultAction(deleteProfileAction);
// Context menu actions
mContextMenu = new QMenu(this);
mContextMenu->addAction(checkAction);
mContextMenu->addAction(uncheckAction);
}
void DataFilesPage::setupDataFiles()
@ -150,17 +140,17 @@ void DataFilesPage::saveSettings()
mGameSettings.remove(QString("master"));
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)) {
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/master"), item);
mGameSettings.setMultiValue(QString("master"), item);
if (item->masters().size() == 0) {
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/master"), item->fileName());
mGameSettings.setMultiValue(QString("master"), item->fileName());
} else if (item.endsWith(QString(".esp"), Qt::CaseInsensitive)) {
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/plugin"), item);
mGameSettings.setMultiValue(QString("plugin"), item);
} else {
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/plugin"), item->fileName());
mGameSettings.setMultiValue(QString("plugin"), item->fileName());
}
}
@ -296,73 +286,3 @@ void DataFilesPage::profileRenamed(const QString &previous, const QString &curre
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
profileGroupBox->hide();
pluginView->showColumn(2);
// Add some extra widgets
QHBoxLayout *nameLayout = new QHBoxLayout();
@ -77,7 +78,7 @@ void CSVDoc::FileDialog::updateCreateButton(const QString &name)
QString CSVDoc::FileDialog::fileName()
{
//return mNameLineEdit->text();
return mNameLineEdit->text();
}
void CSVDoc::FileDialog::openFile()
@ -85,7 +86,7 @@ void CSVDoc::FileDialog::openFile()
setWindowTitle(tr("Open"));
mNameLabel->hide();
//mNameLineEdit->hide();
mNameLineEdit->hide();
mCreateButton->hide();
mButtonBox->removeButton(mCreateButton);
@ -103,8 +104,8 @@ void CSVDoc::FileDialog::newFile()
setWindowTitle(tr("New"));
mNameLabel->show();
//mNameLineEdit->clear();
//mNameLineEdit->show();
mNameLineEdit->clear();
mNameLineEdit->show();
mCreateButton->show();
mButtonBox->setStandardButtons(QDialogButtonBox::Cancel);

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

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

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

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

Loading…
Cancel
Save