forked from teamnwah/openmw-tes3coop
open sub view on double click in report view
This commit is contained in:
parent
c75563c184
commit
cc18b30e17
8 changed files with 45 additions and 4 deletions
|
@ -64,3 +64,8 @@ void CSMTools::ReportModel::add (const std::string& row)
|
|||
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
const CSMWorld::UniversalId& CSMTools::ReportModel::getUniversalId (int row) const
|
||||
{
|
||||
return mRows.at (row).first;
|
||||
}
|
|
@ -29,6 +29,8 @@ namespace CSMTools
|
|||
virtual bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex());
|
||||
|
||||
void add (const std::string& row);
|
||||
|
||||
const CSMWorld::UniversalId& getUniversalId (int row) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <string>
|
||||
#include <iosfwd>
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
class UniversalId
|
||||
|
@ -87,4 +89,6 @@ namespace CSMWorld
|
|||
std::ostream& operator< (std::ostream& stream, const UniversalId& universalId);
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE (CSMWorld::UniversalId)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,10 @@ namespace CSVDoc
|
|||
CSMWorld::UniversalId getUniversalId() const;
|
||||
|
||||
virtual void setEditLock (bool locked) = 0;
|
||||
|
||||
signals:
|
||||
|
||||
void focusId (const CSMWorld::UniversalId& universalId);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -188,6 +188,10 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id)
|
|||
|
||||
SubView *view = mSubViewFactory.makeSubView (id, *mDocument);
|
||||
addDockWidget (Qt::TopDockWidgetArea, view);
|
||||
|
||||
connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&)), this,
|
||||
SLOT (addSubView (const CSMWorld::UniversalId&)));
|
||||
|
||||
view->show();
|
||||
}
|
||||
|
||||
|
|
|
@ -80,12 +80,14 @@ namespace CSVDoc
|
|||
|
||||
void updateProgress (int current, int max, int type, int threads);
|
||||
|
||||
void addSubView (const CSMWorld::UniversalId& id);
|
||||
|
||||
signals:
|
||||
|
||||
void newDocumentRequest();
|
||||
|
||||
public slots:
|
||||
|
||||
void addSubView (const CSMWorld::UniversalId& id);
|
||||
|
||||
private slots:
|
||||
|
||||
void newView();
|
||||
|
|
|
@ -7,19 +7,26 @@
|
|||
#include "../../model/tools/reportmodel.hpp"
|
||||
|
||||
CSVTools::ReportSubView::ReportSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||
: CSVDoc::SubView (id)
|
||||
: CSVDoc::SubView (id), mModel (document.getReport (id))
|
||||
{
|
||||
setWidget (mTable = new QTableView (this));
|
||||
mTable->setModel (document.getReport (id));
|
||||
mTable->setModel (mModel);
|
||||
|
||||
mTable->horizontalHeader()->setResizeMode (QHeaderView::Interactive);
|
||||
mTable->verticalHeader()->hide();
|
||||
mTable->setSortingEnabled (true);
|
||||
mTable->setSelectionBehavior (QAbstractItemView::SelectRows);
|
||||
mTable->setSelectionMode (QAbstractItemView::ExtendedSelection);
|
||||
|
||||
connect (mTable, SIGNAL (doubleClicked (const QModelIndex&)), this, SLOT (show (const QModelIndex&)));
|
||||
}
|
||||
|
||||
void CSVTools::ReportSubView::setEditLock (bool locked)
|
||||
{
|
||||
// ignored. We don't change document state anyway.
|
||||
}
|
||||
|
||||
void CSVTools::ReportSubView::show (const QModelIndex& index)
|
||||
{
|
||||
focusId (mModel->getUniversalId (index.row()));
|
||||
}
|
|
@ -4,18 +4,27 @@
|
|||
#include "../doc/subview.hpp"
|
||||
|
||||
class QTableView;
|
||||
class QModelIndex;
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
class Document;
|
||||
}
|
||||
|
||||
namespace CSMTools
|
||||
{
|
||||
class ReportModel;
|
||||
}
|
||||
|
||||
namespace CSVTools
|
||||
{
|
||||
class Table;
|
||||
|
||||
class ReportSubView : public CSVDoc::SubView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
CSMTools::ReportModel *mModel;
|
||||
QTableView *mTable;
|
||||
|
||||
public:
|
||||
|
@ -23,6 +32,10 @@ namespace CSVTools
|
|||
ReportSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
|
||||
|
||||
virtual void setEditLock (bool locked);
|
||||
|
||||
private slots:
|
||||
|
||||
void show (const QModelIndex& index);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue