From 4237883004b3aac48100bfabf1e0955af4a4093f Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Thu, 14 Sep 2017 16:57:50 +0200 Subject: [PATCH] use QVariant to store fastafile pointer --- src/CMakeLists.txt | 3 ++- src/files/fastafile.cpp | 2 +- src/files/fastafile.h | 1 + src/gui/project_view/projectwindow.cpp | 12 +++++++++--- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 58c2c8fad..78a4382f3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,6 +31,7 @@ FIND_PACKAGE( Pappsomspp REQUIRED ) # SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") # SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") # SET (PAPPSOMSPP_INCLUDE_DIR "${PAPPSOMSPP_DIR}/src") +# SET (PAPPSOMSPP_QT5_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt5.so") # SET (PAPPSOMSPP_QT4_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt4.so") @@ -210,7 +211,7 @@ MESSAGE("XTPCPP_SRCS: ${XTPCPP_SRCS}") ADD_EXECUTABLE(xtpcpp main.cpp ${CPP_FILES} ${XTPCPP_SRCS} ${GUI_UI_HDRS} ${XTPCPP_MOC_SRCS} ${xtpcpp_RCC_SRCS}) target_include_directories (xtpcpp PUBLIC ${Pwiz_INCLUDE_DIR} ${PAPPSOMSPP_INCLUDE_DIR} ${ODSSTREAM_INCLUDE_DIR} -${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${QT_QTGUI_INCLUDE_DIR} +${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/gui/peptide_detail_view/spectrum_widget ${CMAKE_CURRENT_SOURCE_DIR}/gui/peptide_detail_view/spectrum_widget) target_compile_definitions(xtpcpp PUBLIC ${QT_DEFINITIONS}) diff --git a/src/files/fastafile.cpp b/src/files/fastafile.cpp index 4a61c6e5c..3ec99bbaf 100644 --- a/src/files/fastafile.cpp +++ b/src/files/fastafile.cpp @@ -32,7 +32,7 @@ public: }; void setSequence(const QString& description, const QString& sequence) override { - //qDebug() << "PeptideReader::setSequence " << description << " " <<sequence; + qDebug() << "PeptideReader::setSequence " << description << " " <<sequence; QStringList descr_split = description.simplified().split(" "); QString accession = descr_split.at(0); _protein_store.setContaminantAccession(accession); diff --git a/src/files/fastafile.h b/src/files/fastafile.h index 35a2868af..6d4885c99 100644 --- a/src/files/fastafile.h +++ b/src/files/fastafile.h @@ -55,4 +55,5 @@ private : }; +Q_DECLARE_METATYPE(FastaFile *) #endif // FASTAFILE_H diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index 90b11fee1..6ddb3933d 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -284,8 +284,13 @@ void ProjectWindow::doAutomaticFilterParametersChanged(AutomaticFilterParameters if (index_list.size() > 0) { _project_sp.get()->getProteinStore().clearContaminants(); for (QModelIndex index :index_list) { - FastaFile fasta_file (_p_fasta_str_li->itemFromIndex(index)->data(Qt::UserRole).toString()); - fasta_file.setContaminants(_project_sp.get()->getProteinStore()); + if (index.data(Qt::UserRole).canConvert<FastaFile *>()) { + FastaFile * p_fasta_file = index.data(Qt::UserRole).value<FastaFile *>(); + p_fasta_file->setContaminants(_project_sp.get()->getProteinStore()); + } + else { + throw pappso::PappsoException(QObject::tr("can not convert to FastaFile index.data().canConvert<FastaFile *>()")); + } } } else { @@ -471,8 +476,9 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) { QStandardItem *item; item = new QStandardItem(QString("%1").arg(fasta_file.get()->getFilename())); item->setEditable(false); + item->setData(QVariant::fromValue(fasta_file.get()), Qt::UserRole); _p_fasta_str_li->appendRow(item); - item->setData(QVariant(QString("%1").arg(fasta_file.get()->getAbsoluteFilePath())),Qt::UserRole); + //item->setData(QVariant(QString("%1").arg(fasta_file.get()->getAbsoluteFilePath())),Qt::UserRole); } for (auto && p_window :_ptm_island_list_window_collection) { -- GitLab