From ba3589bc763383ac03a2ebfb9710b20b86d178c8 Mon Sep 17 00:00:00 2001 From: graffy76 Date: Tue, 22 Oct 2013 22:20:21 -0500 Subject: [PATCH] Revert "Implemented ContentSelector as a singleton "charm" modifier for" This reverts commit 24b167b7552ce8bf6e62933a535752a899c77473. Conflicts: apps/launcher/datafilespage.cpp apps/opencs/editor.cpp apps/opencs/view/doc/filedialog.cpp apps/opencs/view/doc/filedialog.hpp components/contentselector/view/contentselector.cpp components/contentselector/view/contentselector.hpp --- apps/launcher/datafilespage.cpp | 1 - apps/opencs/editor.cpp | 9 +++-- apps/opencs/view/doc/filedialog.cpp | 6 ++-- apps/opencs/view/doc/filedialog.hpp | 7 ++-- .../contentselector/view/contentselector.cpp | 33 +++++++------------ .../contentselector/view/contentselector.hpp | 1 - 6 files changed, 23 insertions(+), 34 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 2140caaf9..ca404c5d8 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -28,7 +28,6 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam , QWidget(parent) { ui.setupUi (this); - setObjectName ("DataFilesPage"); mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget); diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index e78357bc5..284762812 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -121,6 +121,7 @@ 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()); @@ -130,28 +131,30 @@ void CS::Editor::openFiles() qDebug() << "loading files: " << fp.c_str(); /// \todo Get the save path from the file dialogue + CSMDoc::Document *document = mDocumentManager.addDocument (files, *files.rbegin(), false); mViewManager.addView (document); - mFileDialog.close(); + mFileDialog.hide(); } 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. CSMDoc::Document *document = mDocumentManager.addDocument (files, *files.rbegin(), true); mViewManager.addView (document); - mFileDialog.close(); + mFileDialog.hide(); } void CS::Editor::createNewGame (const boost::filesystem::path& file) diff --git a/apps/opencs/view/doc/filedialog.cpp b/apps/opencs/view/doc/filedialog.cpp index 49e90ec81..5438effff 100644 --- a/apps/opencs/view/doc/filedialog.cpp +++ b/apps/opencs/view/doc/filedialog.cpp @@ -10,10 +10,10 @@ #include #include #include -#include #include "components/contentselector/model/esmfile.hpp" #include "components/contentselector/view/contentselector.hpp" + #include "filewidget.hpp" #include "adjusterwidget.hpp" @@ -101,9 +101,9 @@ void CSVDoc::FileDialog::buildOpenFileView() connect (ui.projectButtonBox, SIGNAL (rejected()), this , SIGNAL (rejected())); } -void CSVDoc::FileDialog::slotRejected() +void CSVDoc::FileDialog::slotGameFileSelected(int value) { - close(); + emit signalUpdateCreateButton(value > -1, 1); } void CSVDoc::FileDialog::slotUpdateCreateButton (int) diff --git a/apps/opencs/view/doc/filedialog.hpp b/apps/opencs/view/doc/filedialog.hpp index 78883791e..85582e95f 100644 --- a/apps/opencs/view/doc/filedialog.hpp +++ b/apps/opencs/view/doc/filedialog.hpp @@ -53,19 +53,18 @@ namespace CSVDoc void buildOpenFileView(); signals: - void openFiles(); void createNewFile(); - public slots: + void signalUpdateCreateButton (bool, int); + void signalUpdateCreateButtonFlags(int); - void slotRejected(); + public slots: private slots: void slotUpdateCreateButton (int); void slotUpdateCreateButton (const QString &, bool); - }; } #endif // FILEDIALOG_HPP diff --git a/components/contentselector/view/contentselector.cpp b/components/contentselector/view/contentselector.cpp index 7a7e1fd9d..cb405f092 100644 --- a/components/contentselector/view/contentselector.cpp +++ b/components/contentselector/view/contentselector.cpp @@ -6,6 +6,7 @@ #include #include + #include #include #include @@ -21,26 +22,13 @@ ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) : buildGameFileView(); buildAddonView(); - /* - //mContentModel->sort(3); // Sort by date accessed - -*/ + updateViews(); } void ContentSelectorView::ContentSelector::buildContentModel() { mContentModel = new ContentSelectorModel::ContentModel(); - - if (mFilePaths.size()>0) - { - foreach (const QString &path, mFilePaths) - mContentModel->addFiles(path); - - mFilePaths.clear(); - } - - ui.gameFileView->setCurrentIndex(-1); - mContentModel->uncheckAll(); + connect(mContentModel, SIGNAL(layoutChanged()), this, SLOT(updateViews())); } void ContentSelectorView::ContentSelector::buildGameFileView() @@ -52,8 +40,8 @@ void ContentSelectorView::ContentSelector::buildGameFileView() mGameFileProxyModel->setFilterRole (Qt::UserRole); mGameFileProxyModel->setSourceModel (mContentModel); - ui.gameFileView->setPlaceholderText(QString("Select a game file...")); - ui.gameFileView->setModel(mGameFileProxyModel); + gameFileView->setPlaceholderText(QString("Select a game file...")); + gameFileView->setModel(mGameFileProxyModel); connect (ui.gameFileView, SIGNAL(currentIndexChanged(int)), this, SLOT (slotCurrentGameFileIndexChanged(int))); @@ -61,7 +49,8 @@ void ContentSelectorView::ContentSelector::buildGameFileView() connect (ui.gameFileView, SIGNAL (currentIndexChanged (int)), this, SIGNAL (signalCurrentGamefileIndexChanged (int))); - ui.gameFileView->setCurrentIndex(-1); + gameFileView->setCurrentIndex(-1); + gameFileView->setCurrentIndex(0); } void ContentSelectorView::ContentSelector::buildAddonView() @@ -74,7 +63,7 @@ void ContentSelectorView::ContentSelector::buildAddonView() mAddonProxyModel->setDynamicSortFilter (true); mAddonProxyModel->setSourceModel (mContentModel); - ui.addonView->setModel(mAddonProxyModel); + addonView->setModel(mAddonProxyModel); connect(ui.addonView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotAddonTableItemClicked(const QModelIndex &))); @@ -120,7 +109,6 @@ ContentSelectorModel::ContentFileList return mContentModel->checkedItems(); } - void ContentSelectorView::ContentSelector::addFiles(const QString &path) { mContentModel->addFiles(path); @@ -133,7 +121,7 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i { static int oldIndex = -1; - QAbstractItemModel *const model = ui.gameFileView->model(); + QAbstractItemModel *const model = gameFileView->model(); QSortFilterProxyModel *proxy = dynamic_cast(model); if (proxy) @@ -152,7 +140,8 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index) { - QAbstractItemModel *const model = ui.addonView->model(); + QAbstractItemModel *const model = addonView->model(); + //QSortFilterProxyModel *proxy = dynamic_cast(model); if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked) model->setData(index, Qt::Checked, Qt::CheckStateRole); diff --git a/components/contentselector/view/contentselector.hpp b/components/contentselector/view/contentselector.hpp index 0882abfb7..163b19855 100644 --- a/components/contentselector/view/contentselector.hpp +++ b/components/contentselector/view/contentselector.hpp @@ -10,7 +10,6 @@ class QSortFilterProxyModel; namespace ContentSelectorView { - class ContentSelector : public QObject { Q_OBJECT