21 #ifndef _STOREDVIEWDIALOG_P_HPP_
22 #define _STOREDVIEWDIALOG_P_HPP_
24 #include "SceneInfo.hpp"
28 #include <QAbstractListModel>
35 CustomTextEdit(QWidget* parent = NULL) : QTextEdit(parent), textChanged(
false), trackChange(
false)
37 connect(
this,&QTextEdit::textChanged,
this,&CustomTextEdit::handleTextChange);
40 void focusInEvent(QFocusEvent* e)
44 QTextEdit::focusInEvent(e);
47 void focusOutEvent(QFocusEvent *e)
49 QTextEdit::focusOutEvent(e);
62 void handleTextChange()
69 bool textChanged, trackChange;
79 int rowCount(
const QModelIndex &parent)
const
83 return global.size() + user.size();
86 QVariant data(
const QModelIndex &index,
int role)
const
88 if(role == Qt::DisplayRole || role == Qt::EditRole)
90 return getViewAtIdx(index.row()).label;
92 if(role == Qt::DecorationRole)
94 if(getViewAtIdx(index.row()).isGlobal)
97 return QIcon(
":/graphicGui/folder.png");
105 if(idx >= global.size())
107 return user[idx-global.size()];
117 if(idx >= global.size())
119 return user[idx-global.size()];
130 int idx = global.size() + user.size();
131 beginInsertRows(QModelIndex(),idx,idx);
138 void deleteView(
int idx)
143 int useridx = idx - global.size();
145 beginRemoveRows(QModelIndex(),idx,idx);
146 user.removeAt(useridx);
153 qWarning()<<
"[StoredViewDialog] Cannot delete global view";
157 void persistUserViews()
159 qDebug()<<
"[StoredViewDialog] Persisting user views...";
163 void updatedAtIdx(
int idx)
165 QModelIndex mIdx = index(idx);
167 emit dataChanged(mIdx,mIdx);
170 SceneInfo getScene() {
return currentScene; }
175 qDebug()<<
"[StoredViewDialog] Loading stored views for"<<scene.
name;
176 this->currentScene = scene;
178 qDebug()<<
"[StoredViewDialog]"<<rowCount(QModelIndex())<<
"entries loaded";
182 void resetData(
const StoredViewList& global,
const StoredViewList& user)
184 this->beginResetModel();
185 this->global = global;
187 this->endResetModel();
191 StoredViewList global, user;
Contains all the metadata necessary for a Scenery3d scene, and can be loaded from special ...
QString name
Name of the scene.
static StoredViewList getGlobalViewsForScene(const SceneInfo &scene)
Returns a list of all global views of a scene.
bool isGlobal
True if this is a position stored next to the scene definition (viewpoints.ini). If false...
static StoredViewList getUserViewsForScene(const SceneInfo &scene)
Returns a list of all user-generated views of a scene.
A structure which stores a specific view position, view direction and FOV, together with a textual de...
void editingFinished()
Emitted when focus lost and text was changed.
A custom QTextEdit subclass that has an editingFinished() signal like QLineEdit.
static void saveUserViews(const SceneInfo &scene, const StoredViewList &list)
Saves the given user views to userviews.ini, replacing all views existing for this scene The scene MU...