diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 51856ce5cd1a179df7a39f44faf91d5a9a0af72f..b96cd69ddb99b25454bf5e605a111d0103830649 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 ) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 2a7ba7ed2bd5b411540ff43c4d1be022cb1a1c43..e368dee9aba0c84ca7e02be34c15cac574e9c207 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -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() diff --git a/src/gui/protein_list_view/protein_view.ui b/src/gui/protein_list_view/protein_view.ui index cf5992c5d6f26da3742adc8b7bc3eb1039b592ef..f33d5e7cc807231510d9d94f8d46387472605c13 100644 --- a/src/gui/protein_list_view/protein_view.ui +++ b/src/gui/protein_list_view/protein_view.ui @@ -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> diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index fe6af95c4ac4e35935a87ef0412716af2c8479c4..7c646b25cade7bd4639e7d3887ebb9b10705de31 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -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() diff --git a/src/gui/protein_list_view/proteintablemodel.cpp b/src/gui/protein_list_view/proteintablemodel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..24a87a25d8bad2e998268fabd31a668f4a6704ac --- /dev/null +++ b/src/gui/protein_list_view/proteintablemodel.cpp @@ -0,0 +1,75 @@ + +/******************************************************************************* +* 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(); +} diff --git a/src/gui/protein_list_view/proteintablemodel.h b/src/gui/protein_list_view/proteintablemodel.h new file mode 100644 index 0000000000000000000000000000000000000000..473e630f880775fbc605e3bff893d916ab2852e8 --- /dev/null +++ b/src/gui/protein_list_view/proteintablemodel.h @@ -0,0 +1,40 @@ + +/******************************************************************************* +* 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