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();
|
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());
|
virtual bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex());
|
||||||
|
|
||||||
void add (const std::string& row);
|
void add (const std::string& row);
|
||||||
|
|
||||||
|
const CSMWorld::UniversalId& getUniversalId (int row) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
class UniversalId
|
class UniversalId
|
||||||
|
@ -87,4 +89,6 @@ namespace CSMWorld
|
||||||
std::ostream& operator< (std::ostream& stream, const UniversalId& universalId);
|
std::ostream& operator< (std::ostream& stream, const UniversalId& universalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE (CSMWorld::UniversalId)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,6 +35,10 @@ namespace CSVDoc
|
||||||
CSMWorld::UniversalId getUniversalId() const;
|
CSMWorld::UniversalId getUniversalId() const;
|
||||||
|
|
||||||
virtual void setEditLock (bool locked) = 0;
|
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);
|
SubView *view = mSubViewFactory.makeSubView (id, *mDocument);
|
||||||
addDockWidget (Qt::TopDockWidgetArea, view);
|
addDockWidget (Qt::TopDockWidgetArea, view);
|
||||||
|
|
||||||
|
connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&)), this,
|
||||||
|
SLOT (addSubView (const CSMWorld::UniversalId&)));
|
||||||
|
|
||||||
view->show();
|
view->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,12 +80,14 @@ namespace CSVDoc
|
||||||
|
|
||||||
void updateProgress (int current, int max, int type, int threads);
|
void updateProgress (int current, int max, int type, int threads);
|
||||||
|
|
||||||
void addSubView (const CSMWorld::UniversalId& id);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void newDocumentRequest();
|
void newDocumentRequest();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
void addSubView (const CSMWorld::UniversalId& id);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void newView();
|
void newView();
|
||||||
|
|
|
@ -7,19 +7,26 @@
|
||||||
#include "../../model/tools/reportmodel.hpp"
|
#include "../../model/tools/reportmodel.hpp"
|
||||||
|
|
||||||
CSVTools::ReportSubView::ReportSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
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));
|
setWidget (mTable = new QTableView (this));
|
||||||
mTable->setModel (document.getReport (id));
|
mTable->setModel (mModel);
|
||||||
|
|
||||||
mTable->horizontalHeader()->setResizeMode (QHeaderView::Interactive);
|
mTable->horizontalHeader()->setResizeMode (QHeaderView::Interactive);
|
||||||
mTable->verticalHeader()->hide();
|
mTable->verticalHeader()->hide();
|
||||||
mTable->setSortingEnabled (true);
|
mTable->setSortingEnabled (true);
|
||||||
mTable->setSelectionBehavior (QAbstractItemView::SelectRows);
|
mTable->setSelectionBehavior (QAbstractItemView::SelectRows);
|
||||||
mTable->setSelectionMode (QAbstractItemView::ExtendedSelection);
|
mTable->setSelectionMode (QAbstractItemView::ExtendedSelection);
|
||||||
|
|
||||||
|
connect (mTable, SIGNAL (doubleClicked (const QModelIndex&)), this, SLOT (show (const QModelIndex&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVTools::ReportSubView::setEditLock (bool locked)
|
void CSVTools::ReportSubView::setEditLock (bool locked)
|
||||||
{
|
{
|
||||||
// ignored. We don't change document state anyway.
|
// 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"
|
#include "../doc/subview.hpp"
|
||||||
|
|
||||||
class QTableView;
|
class QTableView;
|
||||||
|
class QModelIndex;
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
class Document;
|
class Document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace CSMTools
|
||||||
|
{
|
||||||
|
class ReportModel;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVTools
|
namespace CSVTools
|
||||||
{
|
{
|
||||||
class Table;
|
class Table;
|
||||||
|
|
||||||
class ReportSubView : public CSVDoc::SubView
|
class ReportSubView : public CSVDoc::SubView
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
CSMTools::ReportModel *mModel;
|
||||||
QTableView *mTable;
|
QTableView *mTable;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -23,6 +32,10 @@ namespace CSVTools
|
||||||
ReportSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
|
ReportSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
|
||||||
|
|
||||||
virtual void setEditLock (bool locked);
|
virtual void setEditLock (bool locked);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void show (const QModelIndex& index);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue