Commit 63a0b97a authored by Renne Thomas's avatar Renne Thomas
Browse files

Add Search bar

parent fcd1a198
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>826</width>
<width>1084</width>
<height>404</height>
</rect>
</property>
......@@ -14,7 +14,7 @@
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="windowTitle">
<string>Protein list</string>
<string>Ms Identification List</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="contextMenuPolicy">
......@@ -28,6 +28,39 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="search_label">
<property name="text">
<string>Search</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="search_combobox">
<item>
<property name="text">
<string>ms identification</string>
</property>
</item>
<item>
<property name="text">
<string>Identification File</string>
</property>
</item>
<item>
<property name="text">
<string>peak-list file</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="identification_id_line_edit"/>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
......@@ -35,7 +68,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>826</width>
<width>1084</width>
<height>24</height>
</rect>
</property>
......@@ -53,30 +86,6 @@
<string>&amp;as ODS file</string>
</property>
</action>
<action name="actionValid_proteins">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;valid proteins</string>
</property>
</action>
<action name="actionChecked_proteins">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;checked proteins</string>
</property>
</action>
<action name="actionGrouped_proteins">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;grouped proteins</string>
</property>
</action>
</widget>
<resources/>
<connections>
......@@ -96,6 +105,38 @@
</hint>
</hints>
</connection>
<connection>
<sender>identification_id_line_edit</sender>
<signal>textChanged(QString)</signal>
<receiver>MsIdentificationView</receiver>
<slot>onMsIdentificationSearchEdit(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>846</x>
<y>356</y>
</hint>
<hint type="destinationlabel">
<x>1112</x>
<y>383</y>
</hint>
</hints>
</connection>
<connection>
<sender>search_combobox</sender>
<signal>activated(QString)</signal>
<receiver>MsIdentificationView</receiver>
<slot>doSearchOn(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>98</x>
<y>356</y>
</hint>
<hint type="destinationlabel">
<x>1108</x>
<y>299</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>doNotValidHide(bool)</slot>
......@@ -107,5 +148,6 @@
<slot>doScanNumberSearch(int)</slot>
<slot>doModificationSearch(QString)</slot>
<slot>doExportAsOdsFile()</slot>
<slot>onMsIdentificationSearchEdit(QString)</slot>
</slots>
</ui>
......@@ -36,7 +36,7 @@ MsIdentificationListQactionColumn::MsIdentificationListQactionColumn(
{
this->setText(MsIdentificationTableModel::getTitle(column));
this->setCheckable(true);
// this->setCheckable(true);
m_column = column;
m_msid_list_window = parent;
......@@ -89,44 +89,54 @@ MsIdentificationListWindow::MsIdentificationListWindow(ProjectWindow *parent)
ui->tableView->setSortingEnabled(true);
ui->tableView->setAlternatingRowColors(true);
connect(ui->centralwidget,
&QWidget::customContextMenuRequested,
connect(this,
&MsIdentificationListWindow::MsIdentificationDataChanged,
m_msid_table_model_p,
&MsIdentificationTableModel::onMsIdentificationDataChanged);
connect(m_msid_table_model_p,
&MsIdentificationTableModel::layoutChanged,
this,
&MsIdentificationListWindow::showContextMenu);
&MsIdentificationListWindow::updateStatusBar);
}
void
MsIdentificationListWindow::showContextMenu(const QPoint &pos)
MsIdentificationListWindow::resizeColumnsToContents()
{
if(_p_context_menu == nullptr)
{
_p_context_menu = new QMenu(tr("Context menu"), this);
MsIdentificationListQactionColumn *p_action;
for(unsigned int i = 0; i < m_msid_table_model_p->columnCount(); i++)
{
p_action = new MsIdentificationListQactionColumn(
this, MsIdentificationTableModel::getMsIdentificationListColumn(i));
_p_context_menu->addAction(p_action);
}
_p_context_menu->exec(mapToGlobal(pos));
}
_p_context_menu->move(mapToGlobal(pos));
_p_context_menu->show();
ui->tableView->resizeColumnsToContents();
}
void
MsIdentificationListWindow::resizeColumnsToContents()
MsIdentificationListWindow::doSearchOn(QString search_on)
{
ui->tableView->resizeColumnsToContents();
qDebug() << "ProteinTableProxyModel::doSearchOn begin " << search_on;
m_proxy_model->setSearchOn(search_on);
emit MsIdentificationDataChanged();
}
void
MsIdentificationListWindow::onMsIdentificationSearchEdit(
QString ms_id_search_string)
{
qDebug()
<< "MsIdentificationTableProxyModel::onMsIdentificationSearchEdit begin "
<< ms_id_search_string;
m_proxy_model->setMsIdentificationSearchString(ms_id_search_string);
emit MsIdentificationDataChanged();
}
MsIdentificationListWindow::~MsIdentificationListWindow()
{
}
void
MsIdentificationListWindow::updateStatusBar()
{
ui->statusbar->showMessage(
tr("Ms identification all:%1 displayed:%5")
.arg(m_msid_table_model_p->getIdentificationDataSourceSpList().size())
.arg(m_proxy_model->rowCount()));
}
void
MsIdentificationListWindow::setIdentificationDataSourceSpList(
std::vector<IdentificationDataSourceSp> &identificationDataSourceSpList)
......
......@@ -72,8 +72,13 @@ class MsIdentificationListWindow : public QMainWindow
bool toggled);
void resizeColumnsToContents();
signals:
void MsIdentificationDataChanged();
protected slots:
void showContextMenu(const QPoint &);
void doSearchOn(QString search_on);
void updateStatusBar();
void onMsIdentificationSearchEdit(QString protein_search_string);
private:
Ui::MsIdentificationView *ui;
......
......@@ -50,6 +50,11 @@ MsIdentificationTableModel::setIdentificationDataSourceSpList(
m_ms_id_list_window->resizeColumnsToContents();
}
std::vector<IdentificationDataSourceSp>
MsIdentificationTableModel::getIdentificationDataSourceSpList() const
{
return m_identificationDataSourceSpList;
}
int
MsIdentificationTableModel::rowCount(const QModelIndex &parent) const
......@@ -57,9 +62,6 @@ MsIdentificationTableModel::rowCount(const QModelIndex &parent) const
// qDebug() << "MsIdentificationTableModel::rowCount begin ";
if(m_identificationDataSourceSpList.size() != 0)
{
// qDebug() << "MsIdentificationTableModel::rowCount(const QModelIndex
// &parent ) "
// << _p_identification_group->getProteinMatchList().size();
return (int)m_identificationDataSourceSpList.size();
}
return 0;
......@@ -93,14 +95,14 @@ MsIdentificationTableModel::getTitle(std::int8_t column)
{
case(std::int8_t)msIdentificationListColumn::run_id:
return "Run ID";
return "Identification RunID";
break;
case(std::int8_t)msIdentificationListColumn::id_file:
return "File ID";
return "Identification File";
break;
case(std::int8_t)msIdentificationListColumn::mzML:
return "mzML";
return "Peak-list file";
break;
}
return "";
......@@ -115,14 +117,14 @@ MsIdentificationTableModel::getDescription(std::int8_t column)
{
case(std::int8_t)msIdentificationListColumn::run_id:
return "Run ID";
return "Identification of RunID";
break;
case(std::int8_t)msIdentificationListColumn::id_file:
return "File ID pathway";
return "Identification File pathway";
break;
case(std::int8_t)msIdentificationListColumn::mzML:
return "mzML file pathway";
return "peak-list data file pathway";
break;
}
return "";
......@@ -160,13 +162,13 @@ MsIdentificationTableModel::getColumnWidth(int column)
switch(column)
{
case(int)msIdentificationListColumn::run_id:
return 300;
return 200;
break;
case(int)msIdentificationListColumn::id_file:
return 500;
break;
case(int)msIdentificationListColumn::mzML:
return 300;
return 500;
break;
}
return 300;
......@@ -196,7 +198,7 @@ MsIdentificationTableModel::data(const QModelIndex &index, int role) const
{
case(std::int8_t)msIdentificationListColumn::run_id:
return QVariant(
m_identificationDataSourceSpList.at(row)->getSampleName());
m_identificationDataSourceSpList.at(row)->getXmlId());
}
if(col == (std::int8_t)msIdentificationListColumn::id_file)
{
......@@ -206,8 +208,10 @@ MsIdentificationTableModel::data(const QModelIndex &index, int role) const
if(col == (std::int8_t)msIdentificationListColumn::mzML)
{
return QVariant(
m_identificationDataSourceSpList.at(row)->getXmlId());
return QVariant(m_identificationDataSourceSpList.at(row)
->getMsRunSp()
.get()
->getFileName());
}
return QVariant();
}
......
......@@ -68,6 +68,9 @@ class MsIdentificationTableModel : public QAbstractTableModel
void setIdentificationDataSourceSpList(
std::vector<IdentificationDataSourceSp> &identificationDataSourceSpList);
std::vector<IdentificationDataSourceSp>
getIdentificationDataSourceSpList() const;
public slots:
void onMsIdentificationDataChanged();
......
......@@ -60,6 +60,79 @@ MsIdentificationTableProxyModel::~MsIdentificationTableProxyModel()
{
}
bool
MsIdentificationTableProxyModel::filterAcceptsColumn(
int source_column, const QModelIndex &source_parent) const
{
return m_column_display[source_column];
}
bool
MsIdentificationTableProxyModel::filterAcceptsRow(
int source_row, const QModelIndex &source_parent) const
{
try
{
if(!m_ms_id_search_string.isEmpty())
{
if(m_search_on == "Identification File")
{
if(!m_msid_table_model_p->getIdentificationDataSourceSpList()
.at(source_row)
->getResourceName()
.contains(m_ms_id_search_string))
{
return false;
}
}
else if(m_search_on == "ms identification")
{
if(!m_msid_table_model_p->getIdentificationDataSourceSpList()
.at(source_row)
->getXmlId()
.contains(m_ms_id_search_string))
{
return false;
}
}
else if(m_search_on == "peak-list file")
{
if(!m_msid_table_model_p->getIdentificationDataSourceSpList()
.at(source_row)
->getMsRunSp()
.get()
->getFileName()
.contains(m_ms_id_search_string))
{
return false;
}
}
}
}
catch(pappso::PappsoException exception_pappso)
{
// QMessageBox::warning(this,
// tr("Error in ProteinTableModel::acceptRow :"),
// exception_pappso.qwhat());
qDebug() << "Error in ProteinTableModel::acceptRow :"
<< exception_pappso.qwhat();
}
catch(std::exception exception_std)
{
// QMessageBox::warning(this,
// tr("Error in ProteinTableModel::acceptRow :"),
// exception_std.what());
qDebug() << "Error in ProteinTableModel::acceptRow :"
<< exception_std.what();
}
return true;
// return true;
}
bool
MsIdentificationTableProxyModel::lessThan(const QModelIndex &left,
const QModelIndex &right) const
......@@ -81,6 +154,19 @@ MsIdentificationTableProxyModel::lessThan(const QModelIndex &left,
return leftData.toString() < rightData.toString();
}
void
MsIdentificationTableProxyModel::setSearchOn(QString search_on)
{
m_search_on = search_on;
}
void
MsIdentificationTableProxyModel::setMsIdentificationSearchString(
QString ms_id_search_string)
{
m_ms_id_search_string = ms_id_search_string;
}
QVariant
MsIdentificationTableProxyModel::data(const QModelIndex &index, int role) const
{
......
......@@ -42,22 +42,28 @@ class MsIdentificationTableProxyModel : public QSortFilterProxyModel
MsIdentificationListWindow *m_msid_list_window,
MsIdentificationTableModel *m_msid_table_model_p);
virtual ~MsIdentificationTableProxyModel();
bool filterAcceptsRow(int source_row,
const QModelIndex &source_parent) const override;
bool filterAcceptsColumn(int source_column,
const QModelIndex &source_parent) const override;
QVariant
headerData(int section, Qt::Orientation orientation, int role) const override;
QVariant data(const QModelIndex &index,
int role = Qt::DisplayRole) const override;
bool lessThan(const QModelIndex &left,
const QModelIndex &right) const override;
void setSearchOn(QString search_on);
void setMsIdentificationSearchString(QString ms_id_search_string);
void setMsIdentificationListColumnDisplay(msIdentificationListColumn column,
bool toggled);
private:
std::vector<IdentificationDataSourceSp> m_identificationDataSourceSpList;
MsIdentificationTableModel *m_msid_table_model_p;
MsIdentificationListWindow *m_msid_list_window;
QString m_ms_id_search_string;
QString m_search_on = "ms identification";
std::vector<bool> m_column_display;
PercentItemDelegate *m_percent_delegate;
};
......@@ -192,9 +192,11 @@ void
ProjectWindow::connectNewMsRunListWindow()
{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
_p_current_ms_identification_list_window = new MsIdentificationListWindow(this);
_p_current_ms_identification_list_window =
new MsIdentificationListWindow(this);
_ms_identification_list_window_collection.push_back(_p_current_ms_identification_list_window);
_ms_identification_list_window_collection.push_back(
_p_current_ms_identification_list_window);
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
}
......@@ -668,7 +670,6 @@ ProjectWindow::doViewMsIdentificationList()
{
connectNewMsRunListWindow();
}
_p_current_ms_identification_list_window->setWindowTitle("Ms Identification List");
_p_current_ms_identification_list_window->show();
_p_current_ms_identification_list_window->raise();
_p_current_ms_identification_list_window->activateWindow();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment