Skip to content
Snippets Groups Projects
Commit 87d37f9b authored by Olivier Langella's avatar Olivier Langella
Browse files

first table model to populate the protein list

parent aa86ca06
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} )
SET(XTPCPP_SRCS
./gui/mainwindow.cpp
./gui/protein_list_view/proteinlistwindow.cpp
./gui/protein_list_view/proteintablemodel.cpp
)
SET (GUI_UIS
......@@ -75,6 +76,7 @@ SET(XTPCPP_MOC_HDRS
./gui/mainwindow.h
./gui/protein_list_view/proteinlistwindow.h
./gui/protein_list_view/proteintablemodel.h
)
......
......@@ -21,6 +21,7 @@
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation
******************************************************************************/
#include <QDockWidget>
#include "mainwindow.h"
#include "ui_main.h"
......@@ -53,8 +54,11 @@ MainWindow::MainWindow(QWidget *parent):
*/
workerThread.start();
QDockWidget *dock = new QDockWidget(tr("Protein List"), this);
_protein_list_window = new ProteinListWindow(this);
_protein_list_window->show();
//_protein_list_window->show();
dock->setWidget(_protein_list_window);
addDockWidget(Qt::RightDockWidgetArea, dock);
}
MainWindow::~MainWindow()
......
......@@ -11,33 +11,12 @@
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
<string>Protein list</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableWidget" name="tableWidget">
<column>
<property name="text">
<string>group</string>
</property>
</column>
<column>
<property name="text">
<string>subgroup</string>
</property>
</column>
<column>
<property name="text">
<string>accession</string>
</property>
</column>
<column>
<property name="text">
<string>description</string>
</property>
</column>
</widget>
<widget class="QTableView" name="tableView"/>
</item>
</layout>
</widget>
......@@ -47,7 +26,7 @@
<x>0</x>
<y>0</y>
<width>826</width>
<height>22</height>
<height>19</height>
</rect>
</property>
</widget>
......
......@@ -24,6 +24,7 @@
#include "proteinlistwindow.h"
#include "ui_protein_view.h"
#include "proteintablemodel.h"
ProteinListWindow::ProteinListWindow(QWidget *parent):
......@@ -50,7 +51,8 @@ ProteinListWindow::ProteinListWindow(QWidget *parent):
/*
*/
ProteinTableModel * p_myModel = new ProteinTableModel(0);
ui->tableView->setModel( p_myModel );
}
ProteinListWindow::~ProteinListWindow()
......
/*******************************************************************************
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation
******************************************************************************/
#include "proteintablemodel.h"
#include <QDebug>
ProteinTableModel::ProteinTableModel(QObject *parent)
:QAbstractTableModel(parent)
{
//ui->tableView->show();
// QModelIndex topLeft = createIndex(0,0);
//emit a signal to make the view reread identified data
//emit dataChanged(topLeft, topLeft);
}
int ProteinTableModel::rowCount(const QModelIndex &parent ) const {
return 2;
}
int ProteinTableModel::columnCount(const QModelIndex &parent ) const {
return 3;
}
QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role == Qt::DisplayRole)
{
if (orientation == Qt::Horizontal) {
switch (section)
{
case 0:
return QString("first");
case 1:
return QString("second");
case 2:
return QString("third");
}
}
}
return QVariant();
}
QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const {
// generate a log message when this method gets called
int row = index.row();
int col = index.column();
qDebug() << QString("row %1, col%2, role %3")
.arg(row).arg(col).arg(role);
if (role == Qt::DisplayRole)
{
return QString("Row%1, Column%2")
.arg(index.row() + 1)
.arg(index.column() +1);
}
return QVariant();
}
/*******************************************************************************
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation
******************************************************************************/
#ifndef PROTEINTABLEMODEL_H
#define PROTEINTABLEMODEL_H
#include <QAbstractTableModel>
class ProteinTableModel: public QAbstractTableModel
{
Q_OBJECT
public:
ProteinTableModel(QObject *parent=0);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
};
#endif // PROTEINTABLEMODEL_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment