From cddece4f9e84de70e7861c24373c62a37d4356ad Mon Sep 17 00:00:00 2001 From: graffy76 Date: Fri, 1 Nov 2013 21:47:26 -0500 Subject: [PATCH] Another stab at fixing the pathing problem... --- apps/opencs/view/doc/adjusterwidget.cpp | 6 ++++- apps/opencs/view/doc/filedialog.cpp | 9 ++++--- .../contentselector/model/contentmodel.cpp | 27 ++++++++++++------- components/contentselector/model/esmfile.cpp | 6 ++--- components/contentselector/model/esmfile.hpp | 6 ++--- .../contentselector/view/contentselector.cpp | 5 ++-- 6 files changed, 37 insertions(+), 22 deletions(-) diff --git a/apps/opencs/view/doc/adjusterwidget.cpp b/apps/opencs/view/doc/adjusterwidget.cpp index 09e58690f..5ebfacd03 100644 --- a/apps/opencs/view/doc/adjusterwidget.cpp +++ b/apps/opencs/view/doc/adjusterwidget.cpp @@ -10,6 +10,9 @@ #include #include +#include + + CSVDoc::AdjusterWidget::AdjusterWidget (QWidget *parent) : QWidget (parent), mValid (false), mAction (ContentAction_Undefined) { @@ -76,7 +79,8 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon) path.extension() == ".esp"); bool isFilePathChanged = (path.parent_path().string() != mLocalData.string()); - + qDebug() << "current path: " << path.parent_path().c_str(); + qDebug() << "data-local: " << mLocalData.c_str(); if (isLegacyPath) path.replace_extension (addon ? ".omwaddon" : ".omwgame"); diff --git a/apps/opencs/view/doc/filedialog.cpp b/apps/opencs/view/doc/filedialog.cpp index c0cda26dc..ce7d7dfb0 100644 --- a/apps/opencs/view/doc/filedialog.cpp +++ b/apps/opencs/view/doc/filedialog.cpp @@ -17,6 +17,8 @@ #include "filewidget.hpp" #include "adjusterwidget.hpp" +#include + CSVDoc::FileDialog::FileDialog(QWidget *parent) : QDialog(parent), mSelector (0), mFileWidget (0), mAdjusterWidget (0) { @@ -38,7 +40,7 @@ QStringList CSVDoc::FileDialog::selectedFilePaths() QStringList filePaths; foreach (ContentSelectorModel::EsmFile *file, mSelector->selectedFiles() ) - filePaths.append(file->path()); + filePaths.append(file->filePath()); return filePaths; } @@ -139,7 +141,8 @@ void CSVDoc::FileDialog::slotUpdateAcceptButton(const QString &name, bool) else { ContentSelectorModel::EsmFile *file = mSelector->selectedFiles().back();; - mAdjusterWidget->setName (file->fileName(), !file->isGameFile()); + mAdjusterWidget->setName (file->filePath(), !file->isGameFile()); + qDebug() << "setting filepath " << file->filePath(); } ui.projectButtonBox->button (QDialogButtonBox::Ok)->setEnabled (success); @@ -168,7 +171,7 @@ void CSVDoc::FileDialog::slotOpenFile() { ContentSelectorModel::EsmFile *file = mSelector->selectedFiles().back(); - mAdjusterWidget->setName (file->fileName(), !file->isGameFile()); + mAdjusterWidget->setName (file->filePath(), !file->isGameFile()); emit signalOpenFiles (mAdjusterWidget->getPath()); } diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index 0674642ee..ea389c2bf 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -69,7 +69,7 @@ const ContentSelectorModel::EsmFile *ContentSelectorModel::ContentModel::item(co { foreach (const EsmFile *file, mFiles) { - if (name == file->fileName()) + if (name == file->filePath()) return file; } return 0; @@ -158,7 +158,7 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex &index, int case Qt::CheckStateRole: { if (!file->isGameFile()) - return isChecked(file->fileName()); + return isChecked(file->filePath()); break; } @@ -174,7 +174,7 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex &index, int } case Qt::UserRole + 1: - return isChecked(file->fileName()); + return isChecked(file->filePath()); break; } return QVariant(); @@ -186,7 +186,7 @@ bool ContentSelectorModel::ContentModel::setData(const QModelIndex &index, const return false; EsmFile *file = item(index.row()); - QString fileName = file->fileName(); + QString fileName = file->filePath(); bool success = false; switch(role) @@ -396,6 +396,7 @@ bool ContentSelectorModel::ContentModel::canBeChecked(const EsmFile *file) const void ContentSelectorModel::ContentModel::addFile(EsmFile *file) { + qDebug() << "adding file: " << file->filePath(); beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count()); mFiles.append(file); endInsertRows(); @@ -417,6 +418,8 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path) // Create a decoder for non-latin characters in esx metadata QTextDecoder *decoder = codec->makeDecoder(); + qDebug() << "searching path: " << path << " files found: " << dir.entryList().size(); + foreach (const QString &path, dir.entryList()) { QFileInfo info(dir.absoluteFilePath(path)); @@ -430,18 +433,24 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path) fileReader.open(dir.absoluteFilePath(path).toStdString()); foreach (const ESM::Header::MasterData &item, fileReader.getGameFiles()) + { + qDebug() << "adding gamefile: " << item.name.c_str(); file->addGameFile(QString::fromStdString(item.name)); + } file->setAuthor (decoder->toUnicode(fileReader.getAuthor().c_str())); file->setDate (info.lastModified()); file->setFormat (fileReader.getFormat()); - file->setPath (info.absoluteFilePath()); + file->setFilePath (info.absoluteFilePath()); file->setDescription(decoder->toUnicode(fileReader.getDesc().c_str())); // Put the file in the table - if (item(path) == 0) + if (item(file->filePath()) == 0) + { + qDebug () << "adding file " << file->filePath(); addFile(file); + } } catch(std::runtime_error &e) { // An error occurred while reading the .esp @@ -543,8 +552,8 @@ void ContentSelectorModel::ContentModel::setCheckState(const QString &name, bool { if (downstreamFile->gameFiles().contains(name)) { - if (mCheckStates.contains(downstreamFile->fileName())) - mCheckStates[downstreamFile->fileName()] = Qt::Unchecked; + if (mCheckStates.contains(downstreamFile->filePath())) + mCheckStates[downstreamFile->filePath()] = Qt::Unchecked; emit dataChanged(indexFromItem(downstreamFile), indexFromItem(downstreamFile)); } @@ -558,7 +567,7 @@ ContentSelectorModel::ContentFileList ContentSelectorModel::ContentModel::checke foreach (EsmFile *file, mFiles) { - if (isChecked(file->fileName())) + if (isChecked(file->filePath())) list << file; } diff --git a/components/contentselector/model/esmfile.cpp b/components/contentselector/model/esmfile.cpp index 9dfe49eba..35f78386c 100644 --- a/components/contentselector/model/esmfile.cpp +++ b/components/contentselector/model/esmfile.cpp @@ -34,7 +34,7 @@ void ContentSelectorModel::EsmFile::setFormat(int format) mFormat = format; } -void ContentSelectorModel::EsmFile::setPath(const QString &path) +void ContentSelectorModel::EsmFile::setFilePath(const QString &path) { mPath = path; } @@ -81,7 +81,7 @@ QVariant ContentSelectorModel::EsmFile::fileProperty(const FileProperty prop) co return mModified.toString(Qt::ISODate); break; - case FileProperty_Path: + case FileProperty_FilePath: return mPath; break; @@ -118,7 +118,7 @@ void ContentSelectorModel::EsmFile::setFileProperty (const FileProperty prop, co mModified = QDateTime::fromString(value); break; - case FileProperty_Path: + case FileProperty_FilePath: mPath = value; break; diff --git a/components/contentselector/model/esmfile.hpp b/components/contentselector/model/esmfile.hpp index 743b1c5a6..fc0cca8a2 100644 --- a/components/contentselector/model/esmfile.hpp +++ b/components/contentselector/model/esmfile.hpp @@ -23,7 +23,7 @@ namespace ContentSelectorModel FileProperty_Author = 1, FileProperty_Format = 2, FileProperty_DateModified = 3, - FileProperty_Path = 4, + FileProperty_FilePath = 4, FileProperty_Description = 5, FileProperty_GameFile = 6 }; @@ -41,7 +41,7 @@ namespace ContentSelectorModel void setSize(const int size); void setDate(const QDateTime &modified); void setFormat(const int format); - void setPath(const QString &path); + void setFilePath(const QString &path); void setGameFiles(const QStringList &gameFiles); void setDescription(const QString &description); @@ -52,7 +52,7 @@ namespace ContentSelectorModel inline QString author() const { return mAuthor; } inline QDateTime modified() const { return mModified; } inline float format() const { return mFormat; } - inline QString path() const { return mPath; } + inline QString filePath() const { return mPath; } inline const QStringList &gameFiles() const { return mGameFiles; } inline QString description() const { return mDescription; } inline QString toolTip() const { return sToolTip.arg(mAuthor) diff --git a/components/contentselector/view/contentselector.cpp b/components/contentselector/view/contentselector.cpp index b9e518931..d12c8cb24 100644 --- a/components/contentselector/view/contentselector.cpp +++ b/components/contentselector/view/contentselector.cpp @@ -42,9 +42,6 @@ void ContentSelectorView::ContentSelector::buildGameFileView() connect (ui.gameFileView, SIGNAL (currentIndexChanged(int)), this, SLOT (slotCurrentGameFileIndexChanged(int))); - connect (ui.gameFileView, SIGNAL (currentIndexChanged (int)), - this, SIGNAL (signalCurrentGamefileIndexChanged (int))); - ui.gameFileView->setCurrentIndex(-1); ui.gameFileView->setCurrentIndex(0); } @@ -145,6 +142,8 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i if (proxy) proxy->setDynamicSortFilter(true); + + emit signalCurrentGamefileIndexChanged (index); } void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index)