2014-02-01 18:06:41 +00:00
|
|
|
#ifndef TABLEMIMEDATA_H
|
|
|
|
#define TABLEMIMEDATA_H
|
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <string>
|
2014-02-04 17:30:47 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2023-01-14 23:58:09 +00:00
|
|
|
#include <QModelIndex>
|
2014-02-04 10:40:48 +00:00
|
|
|
#include <QStringList>
|
2022-09-22 18:26:05 +00:00
|
|
|
#include <QtCore/QMimeData>
|
2014-02-04 10:40:48 +00:00
|
|
|
|
2014-02-13 09:21:49 +00:00
|
|
|
#include "columnbase.hpp"
|
2022-09-22 18:26:05 +00:00
|
|
|
#include "universalid.hpp"
|
2014-02-04 10:40:48 +00:00
|
|
|
|
2014-02-15 11:40:07 +00:00
|
|
|
namespace CSMDoc
|
|
|
|
{
|
|
|
|
class Document;
|
|
|
|
}
|
2014-02-01 18:06:41 +00:00
|
|
|
|
2023-01-14 20:49:54 +00:00
|
|
|
namespace CSVWorld
|
|
|
|
{
|
|
|
|
class DragRecordTable;
|
|
|
|
}
|
|
|
|
|
2014-02-04 08:13:40 +00:00
|
|
|
namespace CSMWorld
|
2014-02-01 18:06:41 +00:00
|
|
|
{
|
2014-02-14 13:04:36 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
/// \brief Subclass of QmimeData, augmented to contain and transport UniversalIds.
|
|
|
|
///
|
|
|
|
/// This class provides way to construct mimedata object holding the universalid copy
|
|
|
|
/// Universalid is used in the majority of the tables to store type, id, argument types.
|
|
|
|
/// This way universalid grants a way to retrieve record from the concrete table.
|
|
|
|
/// Please note, that tablemimedata object can hold multiple universalIds in the vector.
|
2014-02-14 13:04:36 +00:00
|
|
|
|
2014-02-04 08:13:40 +00:00
|
|
|
class TableMimeData : public QMimeData
|
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
std::vector<UniversalId> mUniversalId;
|
|
|
|
QStringList mObjectsFormats;
|
|
|
|
const CSMDoc::Document& mDocument;
|
2023-01-17 00:55:03 +00:00
|
|
|
const CSVWorld::DragRecordTable* mTableOfDragStart;
|
2023-01-14 20:49:54 +00:00
|
|
|
QModelIndex mIndexAtDragStart;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
TableMimeData(UniversalId id, const CSMDoc::Document& document);
|
2014-02-15 11:40:07 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
TableMimeData(const std::vector<UniversalId>& id, const CSMDoc::Document& document);
|
2014-02-15 11:40:07 +00:00
|
|
|
|
2023-05-29 11:37:19 +00:00
|
|
|
~TableMimeData() override = default;
|
2014-02-15 11:40:07 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
QStringList formats() const override;
|
2014-02-15 11:40:07 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
std::string getIcon() const;
|
2014-02-15 11:40:07 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
std::vector<UniversalId> getData() const;
|
2014-02-15 11:40:07 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
bool holdsType(UniversalId::Type type) const;
|
2014-02-15 11:40:07 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
bool holdsType(CSMWorld::ColumnBase::Display type) const;
|
2014-02-15 11:40:07 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
bool fromDocument(const CSMDoc::Document& document) const;
|
2014-02-15 11:40:07 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
UniversalId returnMatching(UniversalId::Type type) const;
|
2014-02-15 11:40:07 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
const CSMDoc::Document* getDocumentPtr() const;
|
2014-03-13 15:50:04 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const;
|
2023-01-14 23:58:09 +00:00
|
|
|
|
2023-01-17 00:55:03 +00:00
|
|
|
void setIndexAtDragStart(const QModelIndex& index) { mIndexAtDragStart = index; }
|
2023-01-14 23:58:09 +00:00
|
|
|
|
2023-01-17 00:55:03 +00:00
|
|
|
void setTableOfDragStart(const CSVWorld::DragRecordTable* const table) { mTableOfDragStart = table; }
|
2023-01-14 23:58:09 +00:00
|
|
|
|
|
|
|
const QModelIndex getIndexAtDragStart() const { return mIndexAtDragStart; }
|
|
|
|
|
|
|
|
const CSVWorld::DragRecordTable* getTableOfDragStart() const { return mTableOfDragStart; }
|
2014-02-01 18:06:41 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
static CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type);
|
2014-05-01 10:34:54 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
static CSMWorld::ColumnBase::Display convertEnums(CSMWorld::UniversalId::Type type);
|
2014-02-19 10:22:47 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
static bool isReferencable(CSMWorld::UniversalId::Type type);
|
2014-02-15 12:23:51 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
private:
|
|
|
|
bool isReferencable(CSMWorld::ColumnBase::Display type) const;
|
2014-02-04 08:13:40 +00:00
|
|
|
};
|
|
|
|
}
|
2014-09-06 20:29:09 +00:00
|
|
|
#endif // TABLEMIMEDATA_H
|