Viewer Refactoring Working Group
From Rex community wiki
RexNetworkingModule
Motivation
To make a easily repurposable viewer, careful attention must be paid to hide implementation details and platform assumptions in replacable components. RexLogic was designed to implement the "policy" or "decision-making" portions of the viewer. It holds global knowledge of the components and their behavior, so that other modules can remain unaware.
However, since there are no clear standards for VW protocols, and realXtend is actively innovating at the networking layer, it is expected that realXtend's networking choices may become more tightly coupled with the "logic" than is desirable, and replacing our networking layer may require replacing the entire logic layer.
To make the coupling explicit, and to introduce the conditions and means whereby networking may be changed without changing the logic layer (as well as generally cleaning up the current ad-hoc situation), we introduce a "RexNetworkingModule", and introduce abstractions into the framework for handling basic network sessions and data streams.
This change should be seen only as an improvement on the current situation, not a "finished" design.
Pics
Inventory Module & Inventory View/Data Model Proposal
InventoryModule
Having a separate inventory module adds flexible support for different inventory models (WebDAV, OpenSim, some other 3rd party model). Since tree model is a common denominator among virtually every inventory model and Qt offers nice model/view architecture for programming it makes sense to make this architecture the central piece of our model.
InventoryModule instantiates and owns the InventoryWindow.
Inventory module has its own event handler (like every other module) which can handle inventory-related events (e.g. InventoryDescendents SLUDP packet arrives).
AbstractInventoryDataModel
AbstractInventoryDataModel is the base class for different inventory data models.
AbstractInventoryDataModel is a pure virtual class
class AbstractInventoryDataModel
{
public:
AbstractInventoryDataModel();
virtual ~AbstractInventoryDataModel();
virtual AddFolder(AbstractInventoryFolder newFolder, AbstractInventoryFolder *parent) = 0;
// other common functionalities
private:
AbstractInventoryFolder rootFolder_;
}
AbstractInventoryFolder is a base class for inventory items. There can exists also something like
AbstractInventoryAsset. These classes can be inherited from a common base class e.g.
AbstractInventoryItem.
OpenSimInventoryDataModel
OpenSimInventoryDataModel inherits from AbstractInventoryDataModel and implements the functions is
OS-spesific way.
class OpenSimInventoryDataModel : public AbstractInventoryDataModel
{
// ctor & dtor
AddFolder(OpenSimFolder newFolder, OpenSimFolder *parent);
//...
};
OpenSimFolder class is inherited from AbstractInventoryFolder
InventoryViewModel
The user's InventoryViewModel is inherited from QAbstractItemModel.
class InventoryViewModel : public QAbstractItemModel
{
InventoryViewModel(AbstractInventoryDataModel *dataModel);
virtual ~InventoryViewModel();
//Bunch of QAbstractItemModel overrides.
QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
bool insertRows(int position, int rows, const QModelIndex &parent);
// etc.
// You can add your own functions also.
private:
AbstractInventoryDataModel *dataModel_;
};
InventoryViewModel::InventoryViewModel(AbstractInventoryDataModel *dataModel)
{
SetupMyViewModelFromData(dataModel);
}
InventoryWindow
InventoryWindow class handles the UI logic. InventoryWindow owns the InventoryViewModel.
class InventoryWindow : public QObject
{
Q_OBJECT;
public:
// ctor & dtor
private slots:
void OpenWindow();
void CloseWindow();
void InsertChild();
void DeleteChild();
void RenameChild();
// etc.
private:
QTreeView *treeView_;
InventoryViewModel *viewModel_;
};
InventoryWindow::InitInventoryView
{
QTreeView *treeView_ = inventoryWidget_->findChild<QTreeView *>("treeViewOfYourUI");
OpenSimInventoryDataModel *dataModel = magicStuff->GetOpenSimInventoryDataModel();
viewModel_ = new InventoryViewModel(dataModel)
treeView->setModel(myDataModel_)
}
</div>
|