mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Reimplemented content selector for filedialog and datafilespage classes
This commit is contained in:
parent
ba3589bc76
commit
b48f066f33
4 changed files with 17 additions and 22 deletions
|
@ -121,7 +121,6 @@ void CS::Editor::loadDocument()
|
||||||
void CS::Editor::openFiles()
|
void CS::Editor::openFiles()
|
||||||
{
|
{
|
||||||
std::vector<boost::filesystem::path> files;
|
std::vector<boost::filesystem::path> files;
|
||||||
QStringList paths = mFileDialog.checkedItemsPaths();
|
|
||||||
|
|
||||||
foreach (const QString &path, mFileDialog.selectedFilePaths()) {
|
foreach (const QString &path, mFileDialog.selectedFilePaths()) {
|
||||||
files.push_back(path.toStdString());
|
files.push_back(path.toStdString());
|
||||||
|
@ -141,13 +140,12 @@ void CS::Editor::openFiles()
|
||||||
void CS::Editor::createNewFile()
|
void CS::Editor::createNewFile()
|
||||||
{
|
{
|
||||||
std::vector<boost::filesystem::path> files;
|
std::vector<boost::filesystem::path> files;
|
||||||
QStringList paths = mFileDialog.checkedItemsPaths();
|
|
||||||
|
|
||||||
foreach (const QString &path, mFileDialog.selectedFilePaths()) {
|
foreach (const QString &path, mFileDialog.selectedFilePaths()) {
|
||||||
files.push_back(path.toStdString());
|
files.push_back(path.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
files.push_back(mFileDialog.fileName().toStdString());
|
files.push_back(mFileDialog.filename().toStdString());
|
||||||
|
|
||||||
/// \todo Get the save path from the file dialogue.
|
/// \todo Get the save path from the file dialogue.
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,6 @@ void CSVDoc::FileDialog::buildNewFileView()
|
||||||
this, SLOT (slotUpdateCreateButton (int)));
|
this, SLOT (slotUpdateCreateButton (int)));
|
||||||
|
|
||||||
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SIGNAL (createNewFile()));
|
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SIGNAL (createNewFile()));
|
||||||
|
|
||||||
connect (ui.projectButtonBox, SIGNAL (rejected()), this, SLOT (slotRejected()));
|
connect (ui.projectButtonBox, SIGNAL (rejected()), this, SLOT (slotRejected()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,12 +97,7 @@ void CSVDoc::FileDialog::buildOpenFileView()
|
||||||
ui.projectGroupBox->setTitle (QString(""));
|
ui.projectGroupBox->setTitle (QString(""));
|
||||||
|
|
||||||
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SIGNAL (openFiles()));
|
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SIGNAL (openFiles()));
|
||||||
connect (ui.projectButtonBox, SIGNAL (rejected()), this , SIGNAL (rejected()));
|
connect (ui.projectButtonBox, SIGNAL (rejected()), this, SLOT (slotRejected()));
|
||||||
}
|
|
||||||
|
|
||||||
void CSVDoc::FileDialog::slotGameFileSelected(int value)
|
|
||||||
{
|
|
||||||
emit signalUpdateCreateButton(value > -1, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::FileDialog::slotUpdateCreateButton (int)
|
void CSVDoc::FileDialog::slotUpdateCreateButton (int)
|
||||||
|
@ -129,3 +123,8 @@ QString CSVDoc::FileDialog::filename() const
|
||||||
return QString ("");
|
return QString ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::FileDialog::slotRejected()
|
||||||
|
{
|
||||||
|
emit rejected();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
|
@ -53,18 +53,18 @@ namespace CSVDoc
|
||||||
void buildOpenFileView();
|
void buildOpenFileView();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void openFiles();
|
void openFiles();
|
||||||
void createNewFile();
|
void createNewFile();
|
||||||
|
|
||||||
void signalUpdateCreateButton (bool, int);
|
void signalUpdateCreateButton (bool, int);
|
||||||
void signalUpdateCreateButtonFlags(int);
|
void signalUpdateCreateButtonFlags(int);
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void slotUpdateCreateButton (int);
|
void slotUpdateCreateButton (int);
|
||||||
void slotUpdateCreateButton (const QString &, bool);
|
void slotUpdateCreateButton (const QString &, bool);
|
||||||
|
void slotRejected();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // FILEDIALOG_HPP
|
#endif // FILEDIALOG_HPP
|
||||||
|
|
|
@ -21,14 +21,12 @@ ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) :
|
||||||
buildContentModel();
|
buildContentModel();
|
||||||
buildGameFileView();
|
buildGameFileView();
|
||||||
buildAddonView();
|
buildAddonView();
|
||||||
|
|
||||||
updateViews();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::buildContentModel()
|
void ContentSelectorView::ContentSelector::buildContentModel()
|
||||||
{
|
{
|
||||||
mContentModel = new ContentSelectorModel::ContentModel();
|
mContentModel = new ContentSelectorModel::ContentModel();
|
||||||
connect(mContentModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
//connect(mContentModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::buildGameFileView()
|
void ContentSelectorView::ContentSelector::buildGameFileView()
|
||||||
|
@ -40,8 +38,8 @@ void ContentSelectorView::ContentSelector::buildGameFileView()
|
||||||
mGameFileProxyModel->setFilterRole (Qt::UserRole);
|
mGameFileProxyModel->setFilterRole (Qt::UserRole);
|
||||||
mGameFileProxyModel->setSourceModel (mContentModel);
|
mGameFileProxyModel->setSourceModel (mContentModel);
|
||||||
|
|
||||||
gameFileView->setPlaceholderText(QString("Select a game file..."));
|
ui.gameFileView->setPlaceholderText(QString("Select a game file..."));
|
||||||
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)));
|
||||||
|
@ -49,8 +47,8 @@ void ContentSelectorView::ContentSelector::buildGameFileView()
|
||||||
connect (ui.gameFileView, SIGNAL (currentIndexChanged (int)),
|
connect (ui.gameFileView, SIGNAL (currentIndexChanged (int)),
|
||||||
this, SIGNAL (signalCurrentGamefileIndexChanged (int)));
|
this, SIGNAL (signalCurrentGamefileIndexChanged (int)));
|
||||||
|
|
||||||
gameFileView->setCurrentIndex(-1);
|
ui.gameFileView->setCurrentIndex(-1);
|
||||||
gameFileView->setCurrentIndex(0);
|
ui.gameFileView->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::buildAddonView()
|
void ContentSelectorView::ContentSelector::buildAddonView()
|
||||||
|
@ -63,7 +61,7 @@ void ContentSelectorView::ContentSelector::buildAddonView()
|
||||||
mAddonProxyModel->setDynamicSortFilter (true);
|
mAddonProxyModel->setDynamicSortFilter (true);
|
||||||
mAddonProxyModel->setSourceModel (mContentModel);
|
mAddonProxyModel->setSourceModel (mContentModel);
|
||||||
|
|
||||||
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 &)));
|
||||||
|
|
||||||
|
@ -121,7 +119,7 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i
|
||||||
{
|
{
|
||||||
static int oldIndex = -1;
|
static int oldIndex = -1;
|
||||||
|
|
||||||
QAbstractItemModel *const model = gameFileView->model();
|
QAbstractItemModel *const model = ui.gameFileView->model();
|
||||||
QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
|
QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
|
||||||
|
|
||||||
if (proxy)
|
if (proxy)
|
||||||
|
@ -140,7 +138,7 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index)
|
void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *const model = addonView->model();
|
QAbstractItemModel *const model = ui.addonView->model();
|
||||||
//QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(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)
|
||||||
|
|
Loading…
Reference in a new issue