2 * This file is part of LineMan.
4 * Copyright 2006 Igor Khanin
6 * LiteMan is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * LiteMan is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with LiteMan; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <QVBoxLayout>
27 #include "dataviewer.h"
29 DataViewer::DataViewer(QWidget
* parent
) : QWidget(parent
)
31 newRowAct
= removeRowAct
= 0;
33 tableView
= new QTableView();
34 statusText
= new QTextEdit();
35 buttonBar
= new QToolBar();
38 statusText
->setReadOnly(true);
41 QVBoxLayout
* mainLayout
= new QVBoxLayout();
42 mainLayout
->setMargin(0);
43 mainLayout
->addWidget(tableView
, 1);
44 mainLayout
->addWidget(statusText
);
45 mainLayout
->addWidget(buttonBar
);
47 setLayout(mainLayout
);
50 DataViewer::~DataViewer()
54 QAbstractItemModel
* DataViewer::tableModel()
56 return tableView
->model();
59 void DataViewer::setTableModel(QAbstractItemModel
* model
)
61 tableView
->setModel(model
);
64 int DataViewer::currentTableRow()
66 return tableView
->currentIndex().row();
69 void DataViewer::setActions(QAction
* newRowAction
, QAction
* removeRowAction
)
71 newRowAct
= newRowAction
;
72 removeRowAct
= removeRowAction
;
75 foreach(QAction
* act
, buttonBar
->actions())
76 buttonBar
->removeAction(act
);
78 buttonBar
->addAction(newRowAction
);
79 buttonBar
->addAction(removeRowAction
);
82 void DataViewer::setStatusText(const QString
& text
)
84 statusText
->setPlainText(text
);
87 void DataViewer::showStatusText(bool show
)
89 (show
) ? statusText
->show() : statusText
->hide();
92 void DataViewer::showButtons(bool show
)
94 buttonBar
->setEnabled(show
);