2012-11-29 19:09:06 +01:00
|
|
|
#ifndef CSV_WORLD_TABLE_H
|
|
|
|
#define CSV_WORLD_TABLE_H
|
|
|
|
|
2022-10-19 19:02:00 +02:00
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
2012-12-06 15:25:31 +01:00
|
|
|
#include <string>
|
2012-11-30 13:58:10 +01:00
|
|
|
#include <vector>
|
|
|
|
|
2014-02-19 16:15:51 +01:00
|
|
|
#include "../../model/world/columnbase.hpp"
|
2014-09-17 09:03:02 +06:00
|
|
|
#include "../../model/world/universalid.hpp"
|
2014-04-29 11:19:19 +02:00
|
|
|
#include "dragrecordtable.hpp"
|
2013-08-18 16:53:28 +02:00
|
|
|
|
2012-12-03 21:44:16 +01:00
|
|
|
class QAction;
|
2022-10-19 19:02:00 +02:00
|
|
|
class QContextMenuEvent;
|
|
|
|
class QDropEvent;
|
|
|
|
class QModelIndex;
|
|
|
|
class QMouseEvent;
|
|
|
|
class QObject;
|
|
|
|
|
|
|
|
namespace CSMFilter
|
|
|
|
{
|
|
|
|
class Node;
|
|
|
|
}
|
2012-11-29 19:09:06 +01:00
|
|
|
|
2014-03-06 13:51:21 +01:00
|
|
|
namespace CSMDoc
|
|
|
|
{
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
2012-11-29 19:09:06 +01:00
|
|
|
namespace CSMWorld
|
|
|
|
{
|
2012-12-03 21:44:16 +01:00
|
|
|
class IdTableProxyModel;
|
2014-07-04 13:24:35 +02:00
|
|
|
class IdTableBase;
|
2014-06-06 12:43:21 +02:00
|
|
|
class CommandDispatcher;
|
2012-11-29 19:09:06 +01:00
|
|
|
}
|
|
|
|
|
2015-12-12 14:49:16 +01:00
|
|
|
namespace CSMPrefs
|
|
|
|
{
|
|
|
|
class Setting;
|
|
|
|
}
|
|
|
|
|
2012-11-29 19:09:06 +01:00
|
|
|
namespace CSVWorld
|
|
|
|
{
|
2012-11-30 13:58:10 +01:00
|
|
|
class CommandDelegate;
|
2015-07-04 18:51:39 +03:00
|
|
|
class TableEditIdAction;
|
2012-11-30 13:58:10 +01:00
|
|
|
|
2012-11-29 19:09:06 +01:00
|
|
|
///< Table widget
|
2014-04-29 11:19:19 +02:00
|
|
|
class Table : public DragRecordTable
|
2012-11-29 19:09:06 +01:00
|
|
|
{
|
2012-12-06 14:56:04 +01:00
|
|
|
Q_OBJECT
|
2012-12-03 21:44:16 +01:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
enum DoubleClickAction
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2014-10-25 16:27:36 +02:00
|
|
|
Action_None,
|
|
|
|
Action_InPlaceEdit,
|
2020-10-16 22:18:54 +04:00
|
|
|
Action_EditRecord,
|
2014-10-25 16:27:36 +02:00
|
|
|
Action_View,
|
2020-10-16 22:18:54 +04:00
|
|
|
Action_Revert,
|
|
|
|
Action_Delete,
|
|
|
|
Action_EditRecordAndClose,
|
2014-10-25 16:27:36 +02:00
|
|
|
Action_ViewAndClose
|
2020-10-16 22:18:54 +04:00
|
|
|
};
|
2012-11-30 13:58:10 +01:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
std::vector<CommandDelegate*> mDelegates;
|
2013-07-21 17:53:39 +02:00
|
|
|
QAction* mEditAction;
|
2012-12-03 21:44:16 +01:00
|
|
|
QAction* mCreateAction;
|
2014-01-14 15:44:04 +01:00
|
|
|
QAction* mCloneAction;
|
2020-10-16 22:18:54 +04:00
|
|
|
QAction* mTouchAction;
|
|
|
|
QAction* mRevertAction;
|
2012-12-06 15:18:41 +01:00
|
|
|
QAction* mDeleteAction;
|
2020-10-16 22:18:54 +04:00
|
|
|
QAction* mMoveUpAction;
|
|
|
|
QAction* mMoveDownAction;
|
2014-03-02 22:43:44 +01:00
|
|
|
QAction* mViewAction;
|
2020-10-16 22:18:54 +04:00
|
|
|
QAction* mPreviewAction;
|
|
|
|
QAction* mExtendedDeleteAction;
|
|
|
|
QAction* mExtendedRevertAction;
|
2020-04-18 20:54:21 +00:00
|
|
|
QAction* mHelpAction;
|
2020-10-16 22:18:54 +04:00
|
|
|
TableEditIdAction* mEditIdAction;
|
2012-12-06 14:56:04 +01:00
|
|
|
CSMWorld::IdTableProxyModel* mProxyModel;
|
2020-10-16 22:18:54 +04:00
|
|
|
CSMWorld::IdTableBase* mModel;
|
|
|
|
int mRecordStatusDisplay;
|
2014-06-06 12:43:21 +02:00
|
|
|
CSMWorld::CommandDispatcher* mDispatcher;
|
2020-10-16 22:18:54 +04:00
|
|
|
std::map<Qt::KeyboardModifiers, DoubleClickAction> mDoubleClickActions;
|
2015-05-15 12:32:29 +10:00
|
|
|
bool mJumpToAddedRecord;
|
2020-10-16 22:18:54 +04:00
|
|
|
bool mUnselectAfterJump;
|
2021-07-24 20:00:25 +00:00
|
|
|
bool mAutoJump;
|
2014-02-04 11:40:48 +01:00
|
|
|
|
2014-10-23 11:28:58 +02:00
|
|
|
private:
|
|
|
|
void contextMenuEvent(QContextMenuEvent* event) override;
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void mouseMoveEvent(QMouseEvent* event) override;
|
2014-10-23 11:28:58 +02:00
|
|
|
|
2012-11-29 19:09:06 +01:00
|
|
|
protected:
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent* event) override;
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
public:
|
2014-03-06 13:51:21 +01:00
|
|
|
Table(const CSMWorld::UniversalId& id, bool createAndDelete, bool sorting, CSMDoc::Document& document);
|
2012-12-03 21:44:16 +01:00
|
|
|
///< \param createAndDelete Allow creation and deletion of records.
|
2013-10-31 13:40:14 +01:00
|
|
|
/// \param sorting Allow changing order of rows in the view via column headers.
|
2012-11-30 13:58:10 +01:00
|
|
|
|
2014-04-29 19:43:58 +02:00
|
|
|
virtual void setEditLock(bool locked);
|
2012-12-03 21:44:16 +01:00
|
|
|
|
2012-12-13 13:35:08 +01:00
|
|
|
CSMWorld::UniversalId getUniversalId(int row) const;
|
|
|
|
|
2014-02-19 16:15:51 +01:00
|
|
|
std::vector<std::string> getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const;
|
|
|
|
|
2015-07-02 20:44:59 +03:00
|
|
|
std::vector<std::string> getSelectedIds() const;
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
std::vector<CSMWorld::UniversalId> getDraggedRecords() const override;
|
2014-04-29 11:19:19 +02:00
|
|
|
|
2013-07-21 17:53:39 +02:00
|
|
|
signals:
|
|
|
|
|
2014-03-02 22:34:41 +01:00
|
|
|
void editRequest(const CSMWorld::UniversalId& id, const std::string& hint);
|
2013-07-21 17:53:39 +02:00
|
|
|
|
2013-07-25 14:29:56 +02:00
|
|
|
void selectionSizeChanged(int size);
|
|
|
|
|
|
|
|
void tableSizeChanged(int size, int deleted, int modified);
|
|
|
|
///< \param size Number of not deleted records
|
|
|
|
/// \param deleted Number of deleted records
|
|
|
|
/// \param modified Number of added and modified records
|
|
|
|
|
2013-07-26 18:22:31 +02:00
|
|
|
void createRequest();
|
2014-04-30 13:32:54 +02:00
|
|
|
|
2023-01-14 20:36:49 +02:00
|
|
|
void createRecordsDirectlyRequest(const std::string& id);
|
|
|
|
|
2014-01-21 08:27:29 +01:00
|
|
|
void cloneRequest(const CSMWorld::UniversalId&);
|
2013-07-26 18:22:31 +02:00
|
|
|
|
2017-09-03 16:41:54 -04:00
|
|
|
void touchRequest(const std::vector<CSMWorld::UniversalId>& ids);
|
|
|
|
|
2014-10-25 16:27:36 +02:00
|
|
|
void closeRequest();
|
|
|
|
|
2015-07-02 20:44:59 +03:00
|
|
|
void extendedDeleteConfigRequest(const std::vector<std::string>& selectedIds);
|
|
|
|
|
|
|
|
void extendedRevertConfigRequest(const std::vector<std::string>& selectedIds);
|
|
|
|
|
2012-12-03 21:44:16 +01:00
|
|
|
private slots:
|
|
|
|
|
2014-09-17 09:03:02 +06:00
|
|
|
void editCell();
|
2014-09-15 23:15:32 +06:00
|
|
|
|
2020-04-18 20:54:21 +00:00
|
|
|
static void openHelp();
|
|
|
|
|
2013-07-21 17:53:39 +02:00
|
|
|
void editRecord();
|
2013-07-25 14:29:56 +02:00
|
|
|
|
2014-01-14 15:44:04 +01:00
|
|
|
void cloneRecord();
|
|
|
|
|
2017-08-31 22:01:38 -04:00
|
|
|
void touchRecord();
|
|
|
|
|
2013-11-14 11:39:14 +01:00
|
|
|
void moveUpRecord();
|
|
|
|
|
|
|
|
void moveDownRecord();
|
|
|
|
|
2021-01-13 15:38:29 +02:00
|
|
|
void moveRecords(QDropEvent* event);
|
|
|
|
|
2014-03-02 22:43:44 +01:00
|
|
|
void viewRecord();
|
|
|
|
|
2014-03-10 12:44:34 +01:00
|
|
|
void previewRecord();
|
|
|
|
|
2015-07-02 20:44:59 +03:00
|
|
|
void executeExtendedDelete();
|
|
|
|
|
|
|
|
void executeExtendedRevert();
|
|
|
|
|
2013-07-25 14:29:56 +02:00
|
|
|
public slots:
|
|
|
|
|
2015-12-12 14:49:16 +01:00
|
|
|
void settingChanged(const CSMPrefs::Setting* setting);
|
|
|
|
|
2013-07-25 14:29:56 +02:00
|
|
|
void tableSizeUpdate();
|
|
|
|
|
|
|
|
void selectionSizeUpdate();
|
2013-07-26 18:22:31 +02:00
|
|
|
|
2013-07-29 15:00:41 +02:00
|
|
|
void requestFocus(const std::string& id);
|
|
|
|
|
2017-05-05 21:42:57 +02:00
|
|
|
void recordFilterChanged(std::shared_ptr<CSMFilter::Node> filter);
|
2014-04-24 12:50:10 -05:00
|
|
|
|
2015-07-26 20:09:31 +03:00
|
|
|
void rowAdded(const std::string& id);
|
2021-07-24 20:00:25 +00:00
|
|
|
|
|
|
|
void dataChangedEvent(const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
|
|
|
|
|
|
|
void jumpAfterModChanged(int state);
|
|
|
|
|
|
|
|
void queuedScrollTo(int state);
|
2012-11-29 19:09:06 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|