mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Fixed filedialog new / edit content path issue
This commit is contained in:
parent
b48f066f33
commit
2ca7f24731
@ -126,12 +126,9 @@ void CS::Editor::openFiles()
|
|||||||
files.push_back(path.toStdString());
|
files.push_back(path.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const boost::filesystem::path fp, files)
|
boost::filesystem::path savePath = mFileDialog.filename().toStdString();
|
||||||
qDebug() << "loading files: " << fp.c_str();
|
|
||||||
|
|
||||||
/// \todo Get the save path from the file dialogue
|
CSMDoc::Document *document = mDocumentManager.addDocument (files, savePath, false);
|
||||||
|
|
||||||
CSMDoc::Document *document = mDocumentManager.addDocument (files, *files.rbegin(), false);
|
|
||||||
|
|
||||||
mViewManager.addView (document);
|
mViewManager.addView (document);
|
||||||
mFileDialog.hide();
|
mFileDialog.hide();
|
||||||
@ -147,9 +144,9 @@ void CS::Editor::createNewFile()
|
|||||||
|
|
||||||
files.push_back(mFileDialog.filename().toStdString());
|
files.push_back(mFileDialog.filename().toStdString());
|
||||||
|
|
||||||
/// \todo Get the save path from the file dialogue.
|
boost::filesystem::path savePath = mFileDialog.filename().toStdString();
|
||||||
|
|
||||||
CSMDoc::Document *document = mDocumentManager.addDocument (files, *files.rbegin(), true);
|
CSMDoc::Document *document = mDocumentManager.addDocument (files, savePath, true);
|
||||||
|
|
||||||
mViewManager.addView (document);
|
mViewManager.addView (document);
|
||||||
mFileDialog.hide();
|
mFileDialog.hide();
|
||||||
|
@ -120,7 +120,7 @@ QString CSVDoc::FileDialog::filename() const
|
|||||||
if (mDialogType == DialogType_New)
|
if (mDialogType == DialogType_New)
|
||||||
return mFileWidget->getName();
|
return mFileWidget->getName();
|
||||||
|
|
||||||
return QString ("");
|
return mSelector->currentFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::FileDialog::slotRejected()
|
void CSVDoc::FileDialog::slotRejected()
|
||||||
|
@ -503,7 +503,6 @@ bool ContentSelectorModel::ContentModel::isChecked(const QString& name) const
|
|||||||
|
|
||||||
void ContentSelectorModel::ContentModel::setCheckState(const QString &name, bool checkState)
|
void ContentSelectorModel::ContentModel::setCheckState(const QString &name, bool checkState)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -9,10 +9,9 @@
|
|||||||
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QModelIndex>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) :
|
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
@ -26,7 +25,6 @@ ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) :
|
|||||||
void ContentSelectorView::ContentSelector::buildContentModel()
|
void ContentSelectorView::ContentSelector::buildContentModel()
|
||||||
{
|
{
|
||||||
mContentModel = new ContentSelectorModel::ContentModel();
|
mContentModel = new ContentSelectorModel::ContentModel();
|
||||||
//connect(mContentModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::buildGameFileView()
|
void ContentSelectorView::ContentSelector::buildGameFileView()
|
||||||
@ -41,7 +39,7 @@ void ContentSelectorView::ContentSelector::buildGameFileView()
|
|||||||
ui.gameFileView->setPlaceholderText(QString("Select a game file..."));
|
ui.gameFileView->setPlaceholderText(QString("Select a game file..."));
|
||||||
ui.gameFileView->setModel(mGameFileProxyModel);
|
ui.gameFileView->setModel(mGameFileProxyModel);
|
||||||
|
|
||||||
connect (ui.gameFileView, SIGNAL(currentIndexChanged(int)),
|
connect (ui.gameFileView, SIGNAL (currentIndexChanged(int)),
|
||||||
this, SLOT (slotCurrentGameFileIndexChanged(int)));
|
this, SLOT (slotCurrentGameFileIndexChanged(int)));
|
||||||
|
|
||||||
connect (ui.gameFileView, SIGNAL (currentIndexChanged (int)),
|
connect (ui.gameFileView, SIGNAL (currentIndexChanged (int)),
|
||||||
@ -64,9 +62,6 @@ void ContentSelectorView::ContentSelector::buildAddonView()
|
|||||||
ui.addonView->setModel(mAddonProxyModel);
|
ui.addonView->setModel(mAddonProxyModel);
|
||||||
|
|
||||||
connect(ui.addonView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotAddonTableItemClicked(const QModelIndex &)));
|
connect(ui.addonView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotAddonTableItemClicked(const QModelIndex &)));
|
||||||
|
|
||||||
for (int i = 0; i < mAddonProxyModel->rowCount(); ++i)
|
|
||||||
qDebug() << mAddonProxyModel->data(mAddonProxyModel->index(i,0,QModelIndex()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::setGameFile(const QString &filename)
|
void ContentSelectorView::ContentSelector::setGameFile(const QString &filename)
|
||||||
@ -113,6 +108,19 @@ void ContentSelectorView::ContentSelector::addFiles(const QString &path)
|
|||||||
|
|
||||||
if (ui.gameFileView->currentIndex() != -1)
|
if (ui.gameFileView->currentIndex() != -1)
|
||||||
ui.gameFileView->setCurrentIndex(-1);
|
ui.gameFileView->setCurrentIndex(-1);
|
||||||
|
|
||||||
|
mContentModel->uncheckAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ContentSelectorView::ContentSelector::currentFile() const
|
||||||
|
{
|
||||||
|
QModelIndex currentIdx = ui.addonView->currentIndex();
|
||||||
|
|
||||||
|
if (!currentIdx.isValid())
|
||||||
|
return ui.gameFileView->currentText();
|
||||||
|
|
||||||
|
QModelIndex idx = mContentModel->index(mAddonProxyModel->mapToSource(currentIdx).row(), 0, QModelIndex());
|
||||||
|
return mContentModel->data(idx, Qt::DisplayRole).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int index)
|
void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int index)
|
||||||
@ -125,12 +133,15 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i
|
|||||||
if (proxy)
|
if (proxy)
|
||||||
proxy->setDynamicSortFilter(false);
|
proxy->setDynamicSortFilter(false);
|
||||||
|
|
||||||
if (oldIndex > -1)
|
if (index != oldIndex)
|
||||||
model->setData(model->index(oldIndex, 0), false, Qt::UserRole + 1);
|
{
|
||||||
|
if (oldIndex > -1)
|
||||||
|
model->setData(model->index(oldIndex, 0), false, Qt::UserRole + 1);
|
||||||
|
|
||||||
oldIndex = index;
|
oldIndex = index;
|
||||||
|
|
||||||
model->setData(model->index(index, 0), true, Qt::UserRole + 1);
|
model->setData(model->index(index, 0), true, Qt::UserRole + 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (proxy)
|
if (proxy)
|
||||||
proxy->setDynamicSortFilter(true);
|
proxy->setDynamicSortFilter(true);
|
||||||
@ -139,7 +150,6 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i
|
|||||||
void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index)
|
void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *const model = ui.addonView->model();
|
QAbstractItemModel *const model = ui.addonView->model();
|
||||||
//QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
|
|
||||||
|
|
||||||
if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked)
|
if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked)
|
||||||
model->setData(index, Qt::Checked, Qt::CheckStateRole);
|
model->setData(index, Qt::Checked, Qt::CheckStateRole);
|
||||||
|
@ -26,6 +26,8 @@ namespace ContentSelectorView
|
|||||||
|
|
||||||
explicit ContentSelector(QWidget *parent = 0);
|
explicit ContentSelector(QWidget *parent = 0);
|
||||||
|
|
||||||
|
QString currentFile() const;
|
||||||
|
|
||||||
void addFiles(const QString &path);
|
void addFiles(const QString &path);
|
||||||
|
|
||||||
void clearCheckStates();
|
void clearCheckStates();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user