mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 12:09:43 +00:00
added specialised report table
This commit is contained in:
parent
ab693f1f64
commit
7c59ea6296
5 changed files with 108 additions and 50 deletions
|
@ -92,7 +92,7 @@ opencs_hdrs_noqt (view/render
|
|||
|
||||
|
||||
opencs_units (view/tools
|
||||
reportsubview
|
||||
reportsubview reporttable
|
||||
)
|
||||
|
||||
opencs_units_noqt (view/tools
|
||||
|
|
|
@ -1,31 +1,15 @@
|
|||
|
||||
#include "reportsubview.hpp"
|
||||
|
||||
#include <QTableView>
|
||||
#include <QHeaderView>
|
||||
|
||||
#include "../../model/tools/reportmodel.hpp"
|
||||
|
||||
#include "../../view/world/idtypedelegate.hpp"
|
||||
#include "reporttable.hpp"
|
||||
|
||||
CSVTools::ReportSubView::ReportSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||
: CSVDoc::SubView (id), mModel (document.getReport (id))
|
||||
: CSVDoc::SubView (id)
|
||||
{
|
||||
setWidget (mTable = new QTableView (this));
|
||||
mTable->setModel (mModel);
|
||||
setWidget (mTable = new ReportTable (document, id, this));
|
||||
|
||||
mTable->horizontalHeader()->setResizeMode (QHeaderView::Interactive);
|
||||
mTable->verticalHeader()->hide();
|
||||
mTable->setSortingEnabled (true);
|
||||
mTable->setSelectionBehavior (QAbstractItemView::SelectRows);
|
||||
mTable->setSelectionMode (QAbstractItemView::ExtendedSelection);
|
||||
|
||||
mIdTypeDelegate = CSVWorld::IdTypeDelegateFactory().makeDelegate (
|
||||
document, this);
|
||||
|
||||
mTable->setItemDelegateForColumn (0, mIdTypeDelegate);
|
||||
|
||||
connect (mTable, SIGNAL (doubleClicked (const QModelIndex&)), this, SLOT (show (const QModelIndex&)));
|
||||
connect (mTable, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)),
|
||||
SIGNAL (focusId (const CSMWorld::UniversalId&, const std::string&)));
|
||||
}
|
||||
|
||||
void CSVTools::ReportSubView::setEditLock (bool locked)
|
||||
|
@ -33,13 +17,7 @@ void CSVTools::ReportSubView::setEditLock (bool locked)
|
|||
// ignored. We don't change document state anyway.
|
||||
}
|
||||
|
||||
void CSVTools::ReportSubView::updateUserSetting
|
||||
(const QString &name, const QStringList &list)
|
||||
void CSVTools::ReportSubView::updateUserSetting (const QString &name, const QStringList &list)
|
||||
{
|
||||
mIdTypeDelegate->updateUserSetting (name, list);
|
||||
}
|
||||
|
||||
void CSVTools::ReportSubView::show (const QModelIndex& index)
|
||||
{
|
||||
focusId (mModel->getUniversalId (index.row()), "");
|
||||
mTable->updateUserSetting (name, list);
|
||||
}
|
||||
|
|
|
@ -11,27 +11,15 @@ namespace CSMDoc
|
|||
class Document;
|
||||
}
|
||||
|
||||
namespace CSMTools
|
||||
{
|
||||
class ReportModel;
|
||||
}
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class CommandDelegate;
|
||||
}
|
||||
|
||||
namespace CSVTools
|
||||
{
|
||||
class Table;
|
||||
class ReportTable;
|
||||
|
||||
class ReportSubView : public CSVDoc::SubView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
CSMTools::ReportModel *mModel;
|
||||
QTableView *mTable;
|
||||
CSVWorld::CommandDelegate *mIdTypeDelegate;
|
||||
ReportTable *mTable;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -39,12 +27,7 @@ namespace CSVTools
|
|||
|
||||
virtual void setEditLock (bool locked);
|
||||
|
||||
virtual void updateUserSetting
|
||||
(const QString &, const QStringList &);
|
||||
|
||||
private slots:
|
||||
|
||||
void show (const QModelIndex& index);
|
||||
virtual void updateUserSetting (const QString &, const QStringList &);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
53
apps/opencs/view/tools/reporttable.cpp
Normal file
53
apps/opencs/view/tools/reporttable.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
|
||||
#include "reporttable.hpp"
|
||||
|
||||
#include <QHeaderView>
|
||||
|
||||
#include "../../model/tools/reportmodel.hpp"
|
||||
|
||||
#include "../../view/world/idtypedelegate.hpp"
|
||||
|
||||
CSVTools::ReportTable::ReportTable (CSMDoc::Document& document,
|
||||
const CSMWorld::UniversalId& id, QWidget *parent)
|
||||
: CSVWorld::DragRecordTable (document, parent), mModel (document.getReport (id))
|
||||
{
|
||||
horizontalHeader()->setResizeMode (QHeaderView::Interactive);
|
||||
verticalHeader()->hide();
|
||||
setSortingEnabled (true);
|
||||
setSelectionBehavior (QAbstractItemView::SelectRows);
|
||||
setSelectionMode (QAbstractItemView::ExtendedSelection);
|
||||
|
||||
setModel (mModel);
|
||||
|
||||
mIdTypeDelegate = CSVWorld::IdTypeDelegateFactory().makeDelegate (
|
||||
document, this);
|
||||
|
||||
setItemDelegateForColumn (0, mIdTypeDelegate);
|
||||
|
||||
connect (this, SIGNAL (doubleClicked (const QModelIndex&)), this, SLOT (show (const QModelIndex&)));
|
||||
}
|
||||
|
||||
std::vector<CSMWorld::UniversalId> CSVTools::ReportTable::getDraggedRecords() const
|
||||
{
|
||||
std::vector<CSMWorld::UniversalId> ids;
|
||||
|
||||
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||
|
||||
for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end();
|
||||
++iter)
|
||||
{
|
||||
ids.push_back (mModel->getUniversalId (iter->row()));
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
void CSVTools::ReportTable::updateUserSetting (const QString& name, const QStringList& list)
|
||||
{
|
||||
mIdTypeDelegate->updateUserSetting (name, list);
|
||||
}
|
||||
|
||||
void CSVTools::ReportTable::show (const QModelIndex& index)
|
||||
{
|
||||
emit editRequest (mModel->getUniversalId (index.row()), "");
|
||||
}
|
44
apps/opencs/view/tools/reporttable.hpp
Normal file
44
apps/opencs/view/tools/reporttable.hpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#ifndef CSV_TOOLS_REPORTTABLE_H
|
||||
#define CSV_TOOLS_REPORTTABLE_H
|
||||
|
||||
#include "../world/dragrecordtable.hpp"
|
||||
|
||||
namespace CSMTools
|
||||
{
|
||||
class ReportModel;
|
||||
}
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class CommandDelegate;
|
||||
}
|
||||
|
||||
namespace CSVTools
|
||||
{
|
||||
class ReportTable : public CSVWorld::DragRecordTable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
CSMTools::ReportModel *mModel;
|
||||
CSVWorld::CommandDelegate *mIdTypeDelegate;
|
||||
|
||||
public:
|
||||
|
||||
ReportTable (CSMDoc::Document& document, const CSMWorld::UniversalId& id,
|
||||
QWidget *parent = 0);
|
||||
|
||||
virtual std::vector<CSMWorld::UniversalId> getDraggedRecords() const;
|
||||
|
||||
void updateUserSetting (const QString& name, const QStringList& list);
|
||||
|
||||
private slots:
|
||||
|
||||
void show (const QModelIndex& index);
|
||||
|
||||
signals:
|
||||
|
||||
void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue