From b48f066f33e0d54b5369e13194175ea2736203c7 Mon Sep 17 00:00:00 2001 From: graffy76 Date: Wed, 23 Oct 2013 17:39:17 -0500 Subject: [PATCH] Reimplemented content selector for filedialog and datafilespage classes --- apps/opencs/editor.cpp | 4 +--- apps/opencs/view/doc/filedialog.cpp | 13 ++++++------- apps/opencs/view/doc/filedialog.hpp | 4 ++-- .../contentselector/view/contentselector.cpp | 18 ++++++++---------- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 284762812..1099226d2 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -121,7 +121,6 @@ void CS::Editor::loadDocument() void CS::Editor::openFiles() { std::vector files; - QStringList paths = mFileDialog.checkedItemsPaths(); foreach (const QString &path, mFileDialog.selectedFilePaths()) { files.push_back(path.toStdString()); @@ -141,13 +140,12 @@ void CS::Editor::openFiles() void CS::Editor::createNewFile() { std::vector files; - QStringList paths = mFileDialog.checkedItemsPaths(); foreach (const QString &path, mFileDialog.selectedFilePaths()) { 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. diff --git a/apps/opencs/view/doc/filedialog.cpp b/apps/opencs/view/doc/filedialog.cpp index 5438effff..1ac476cb2 100644 --- a/apps/opencs/view/doc/filedialog.cpp +++ b/apps/opencs/view/doc/filedialog.cpp @@ -88,7 +88,6 @@ void CSVDoc::FileDialog::buildNewFileView() this, SLOT (slotUpdateCreateButton (int))); connect (ui.projectButtonBox, SIGNAL (accepted()), this, SIGNAL (createNewFile())); - connect (ui.projectButtonBox, SIGNAL (rejected()), this, SLOT (slotRejected())); } @@ -98,12 +97,7 @@ void CSVDoc::FileDialog::buildOpenFileView() ui.projectGroupBox->setTitle (QString("")); connect (ui.projectButtonBox, SIGNAL (accepted()), this, SIGNAL (openFiles())); - connect (ui.projectButtonBox, SIGNAL (rejected()), this , SIGNAL (rejected())); -} - -void CSVDoc::FileDialog::slotGameFileSelected(int value) -{ - emit signalUpdateCreateButton(value > -1, 1); + connect (ui.projectButtonBox, SIGNAL (rejected()), this, SLOT (slotRejected())); } void CSVDoc::FileDialog::slotUpdateCreateButton (int) @@ -129,3 +123,8 @@ QString CSVDoc::FileDialog::filename() const return QString (""); } +void CSVDoc::FileDialog::slotRejected() +{ + emit rejected(); + close(); +} diff --git a/apps/opencs/view/doc/filedialog.hpp b/apps/opencs/view/doc/filedialog.hpp index 85582e95f..3b93f42a8 100644 --- a/apps/opencs/view/doc/filedialog.hpp +++ b/apps/opencs/view/doc/filedialog.hpp @@ -53,18 +53,18 @@ namespace CSVDoc void buildOpenFileView(); signals: + void openFiles(); void createNewFile(); void signalUpdateCreateButton (bool, int); void signalUpdateCreateButtonFlags(int); - public slots: - private slots: void slotUpdateCreateButton (int); void slotUpdateCreateButton (const QString &, bool); + void slotRejected(); }; } #endif // FILEDIALOG_HPP diff --git a/components/contentselector/view/contentselector.cpp b/components/contentselector/view/contentselector.cpp index cb405f092..3d615906d 100644 --- a/components/contentselector/view/contentselector.cpp +++ b/components/contentselector/view/contentselector.cpp @@ -21,14 +21,12 @@ ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) : buildContentModel(); buildGameFileView(); buildAddonView(); - - updateViews(); } void ContentSelectorView::ContentSelector::buildContentModel() { mContentModel = new ContentSelectorModel::ContentModel(); - connect(mContentModel, SIGNAL(layoutChanged()), this, SLOT(updateViews())); + //connect(mContentModel, SIGNAL(layoutChanged()), this, SLOT(updateViews())); } void ContentSelectorView::ContentSelector::buildGameFileView() @@ -40,8 +38,8 @@ void ContentSelectorView::ContentSelector::buildGameFileView() mGameFileProxyModel->setFilterRole (Qt::UserRole); mGameFileProxyModel->setSourceModel (mContentModel); - gameFileView->setPlaceholderText(QString("Select a game file...")); - gameFileView->setModel(mGameFileProxyModel); + ui.gameFileView->setPlaceholderText(QString("Select a game file...")); + ui.gameFileView->setModel(mGameFileProxyModel); connect (ui.gameFileView, SIGNAL(currentIndexChanged(int)), this, SLOT (slotCurrentGameFileIndexChanged(int))); @@ -49,8 +47,8 @@ void ContentSelectorView::ContentSelector::buildGameFileView() connect (ui.gameFileView, SIGNAL (currentIndexChanged (int)), this, SIGNAL (signalCurrentGamefileIndexChanged (int))); - gameFileView->setCurrentIndex(-1); - gameFileView->setCurrentIndex(0); + ui.gameFileView->setCurrentIndex(-1); + ui.gameFileView->setCurrentIndex(0); } void ContentSelectorView::ContentSelector::buildAddonView() @@ -63,7 +61,7 @@ void ContentSelectorView::ContentSelector::buildAddonView() mAddonProxyModel->setDynamicSortFilter (true); mAddonProxyModel->setSourceModel (mContentModel); - addonView->setModel(mAddonProxyModel); + ui.addonView->setModel(mAddonProxyModel); 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; - QAbstractItemModel *const model = gameFileView->model(); + QAbstractItemModel *const model = ui.gameFileView->model(); QSortFilterProxyModel *proxy = dynamic_cast(model); if (proxy) @@ -140,7 +138,7 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index) { - QAbstractItemModel *const model = addonView->model(); + QAbstractItemModel *const model = ui.addonView->model(); //QSortFilterProxyModel *proxy = dynamic_cast(model); if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked)