mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Layer list cosmetic changes
This commit is contained in:
@@ -69,6 +69,9 @@ public:
|
||||
static const int ZOOM_TOOLBAR_ICON_SIZE = 16;
|
||||
static const int ZOOM_TOOLBAR_BUTTON_SIZE = 20;
|
||||
static const int MAPPING_LIST_ICON_SIZE = 16;
|
||||
static const int MAPPING_LIST_HIDE_COLUMN = 24;
|
||||
static const int MAPPING_LIST_NAME_COLUMN = 135;
|
||||
static const int MAPPING_LIST_BUTTONS_COLUMN = 128;
|
||||
|
||||
// OSC
|
||||
static const int DEFAULT_OSC_PORT = 12345;
|
||||
|
||||
+15
-7
@@ -182,6 +182,7 @@ void MainWindow::handleMappingItemSelectionChanged(const QModelIndex &index)
|
||||
|
||||
// Update canvases.
|
||||
updateCanvases();
|
||||
updateMappingListColumnWidth();
|
||||
}
|
||||
|
||||
void MainWindow::handleMappingItemChanged(const QModelIndex &index)
|
||||
@@ -1516,13 +1517,14 @@ void MainWindow::createLayout()
|
||||
mappingList->setModel(mappingListModel);
|
||||
mappingList->setItemDelegate(mappingItemDelegate);
|
||||
// Pimp Mapping table widget
|
||||
mappingList->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
mappingList->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
mappingList->horizontalHeader()->setStretchLastSection(true);
|
||||
//mappingList->setShowGrid(false);
|
||||
mappingList->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
mappingList->setShowGrid(false);
|
||||
mappingList->horizontalHeader()->hide();
|
||||
mappingList->verticalHeader()->hide();
|
||||
mappingList->setMouseTracking(true);// Important
|
||||
mappingList->setColumnWidth(0, MM::MAPPING_LIST_HIDE_COLUMN);
|
||||
mappingList->setColumnWidth(1, MM::MAPPING_LIST_NAME_COLUMN);
|
||||
mappingList->setColumnWidth(2, MM::MAPPING_LIST_BUTTONS_COLUMN);
|
||||
|
||||
// Create property panel.
|
||||
mappingPropertyPanel = new QStackedWidget;
|
||||
@@ -1546,7 +1548,7 @@ void MainWindow::createLayout()
|
||||
sourceLayout->addWidget(sourceCanvasToolbar, 0, Qt::AlignRight);
|
||||
sourcePanel->setLayout(sourceLayout);
|
||||
|
||||
destinationCanvas = new MapperGLCanvas(this, true, 0, (QGLWidget*)sourceCanvas->viewport());
|
||||
destinationCanvas = new MapperGLCanvas(this, true, nullptr, static_cast<QGLWidget*>(sourceCanvas->viewport()));
|
||||
destinationCanvas->setFocusPolicy(Qt::ClickFocus);
|
||||
destinationCanvas->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
destinationCanvas->setMinimumSize(CANVAS_MINIMUM_WIDTH, CANVAS_MINIMUM_HEIGHT);
|
||||
@@ -1608,6 +1610,7 @@ void MainWindow::createLayout()
|
||||
mainSplitter = new QSplitter(Qt::Horizontal);
|
||||
mainSplitter->addWidget(canvasSplitter);
|
||||
mainSplitter->addWidget(contentTab);
|
||||
connect(mainSplitter, SIGNAL(splitterMoved(int, int)), this, SLOT(updateMappingListColumnWidth()));
|
||||
|
||||
// Initialize size to 9:1 proportions.
|
||||
QSize sz = mainSplitter->size();
|
||||
@@ -3299,7 +3302,7 @@ void MainWindow::showMappingContextMenu(const QPoint &point)
|
||||
mappingHideAction->setChecked(!mapping->isVisible());
|
||||
mappingSoloAction->setChecked(mapping->isSolo());
|
||||
|
||||
if (objectSender != NULL) {
|
||||
if (objectSender != nullptr) {
|
||||
if (sender() == mappingItemDelegate) // XXX: The item delegate is not a widget
|
||||
mappingContextMenu->exec(mappingList->mapToGlobal(point));
|
||||
else
|
||||
@@ -3311,7 +3314,7 @@ void MainWindow::showPaintContextMenu(const QPoint &point)
|
||||
{
|
||||
QWidget *objectSender = dynamic_cast<QWidget*>(sender());
|
||||
|
||||
if (objectSender != NULL && paintList->count() > 0)
|
||||
if (objectSender != nullptr && paintList->count() > 0)
|
||||
paintContextMenu->exec(objectSender->mapToGlobal(point));
|
||||
}
|
||||
|
||||
@@ -3599,6 +3602,11 @@ void MainWindow::updateSettings()
|
||||
stickyVerticesAction->setChecked(settings.value("stickyVertices").toBool());
|
||||
}
|
||||
|
||||
void MainWindow::updateMappingListColumnWidth()
|
||||
{
|
||||
mappingList->setColumnWidth(1, mappingList->horizontalHeader()->width() - (MM::MAPPING_LIST_HIDE_COLUMN + MM::MAPPING_LIST_BUTTONS_COLUMN));
|
||||
}
|
||||
|
||||
// void MainWindow::applyOscCommand(const QVariantList& command)
|
||||
// {
|
||||
// bool VERBOSE = true;
|
||||
|
||||
@@ -166,6 +166,8 @@ private slots:
|
||||
|
||||
void updateSettings();
|
||||
|
||||
void updateMappingListColumnWidth();
|
||||
|
||||
public slots:
|
||||
|
||||
// CRUD.
|
||||
|
||||
@@ -184,7 +184,7 @@ QWidget *MappingItemDelegate::createEditor(QWidget *parent,
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ void MappingItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *mode
|
||||
void MappingItemDelegate::updateEditorGeometry(QWidget *editor,
|
||||
const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(index)
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,17 +39,17 @@ class MappingItemDelegate : public QStyledItemDelegate
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MappingItemDelegate(QObject *parent = 0);
|
||||
MappingItemDelegate(QObject *parent = nullptr);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const Q_DECL_OVERRIDE;
|
||||
const QModelIndex &index) const override;
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const Q_DECL_OVERRIDE;
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE;
|
||||
const QModelIndex &index) const override;
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const Q_DECL_OVERRIDE;
|
||||
const QModelIndex &index) const override;
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const Q_DECL_OVERRIDE;
|
||||
const QModelIndex &index) const override;
|
||||
|
||||
signals:
|
||||
void itemContextMenuRequested(const QPoint &pos);
|
||||
@@ -58,7 +58,7 @@ signals:
|
||||
|
||||
protected:
|
||||
bool editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||
const QStyleOptionViewItem &option, const QModelIndex &index) Q_DECL_OVERRIDE;
|
||||
const QStyleOptionViewItem &option, const QModelIndex &index) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ int MappingListModel::rowCount(const QModelIndex &parent) const
|
||||
|
||||
int MappingListModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
Q_UNUSED(parent)
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -43,39 +43,38 @@ QVariant MappingListModel::data(const QModelIndex &index, int role) const
|
||||
switch (role) {
|
||||
case Qt::CheckStateRole:
|
||||
return mappingList.at(index.row()).isVisible ? Qt::Checked : Qt::Unchecked;
|
||||
break;
|
||||
|
||||
case Qt::SizeHintRole:
|
||||
if (index.column() == MM::HideColumn)
|
||||
return QSize(24, 40);
|
||||
// if (index.column() == MM::IconAndNameColum)
|
||||
// return QSize(135, 40);
|
||||
else if (index.column() == MM::GroupButtonColum)
|
||||
return QSize(128, 40);
|
||||
break;
|
||||
return QSize(MM::MAPPING_LIST_HIDE_COLUMN, 40);
|
||||
if (index.column() == MM::IconAndNameColum)
|
||||
return QSize(MM::MAPPING_LIST_NAME_COLUMN, 40);
|
||||
if (index.column() == MM::GroupButtonColum)
|
||||
return QSize(MM::MAPPING_LIST_BUTTONS_COLUMN, 40);
|
||||
break;
|
||||
case Qt::CheckStateRole + 1:
|
||||
return mappingList.at(index.row()).isSolo ? Qt::Checked : Qt::Unchecked;
|
||||
break;
|
||||
|
||||
case Qt::CheckStateRole + 2:
|
||||
return mappingList.at(index.row()).isLocked ? Qt::Checked : Qt::Unchecked;
|
||||
break;
|
||||
|
||||
case Qt::UserRole:
|
||||
return QVariant(mappingList.at(index.row()).id);
|
||||
break;
|
||||
|
||||
case Qt::EditRole:
|
||||
return QVariant(mappingList.at(index.row()).label);
|
||||
break;
|
||||
|
||||
case Qt::DisplayRole:
|
||||
return QVariant(mappingList.at(index.row()).label);
|
||||
break;
|
||||
|
||||
case Qt::DecorationRole:
|
||||
return mappingList.at(index.row()).icon;
|
||||
break;
|
||||
|
||||
case Qt::ToolTipRole:
|
||||
return QString("ID: %1").arg(mappingList.at(index.row()).id);
|
||||
break;
|
||||
|
||||
default:
|
||||
return QVariant();
|
||||
break;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
@@ -84,7 +83,7 @@ QVariant MappingListModel::data(const QModelIndex &index, int role) const
|
||||
Qt::ItemFlags MappingListModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
return Qt::NoItemFlags;
|
||||
|
||||
if (index.column() == MM::IconAndNameColum)
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
|
||||
+11
-11
@@ -38,22 +38,22 @@ class MappingListModel : public QAbstractTableModel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MappingListModel(QObject *parent = 0);
|
||||
~MappingListModel() {}
|
||||
MappingListModel(QObject *parent = nullptr);
|
||||
~MappingListModel() override {}
|
||||
|
||||
int rowCount(const QModelIndex & parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||
int columnCount(const QModelIndex & parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
|
||||
int rowCount(const QModelIndex & parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex & parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
|
||||
Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
|
||||
QStringList mimeTypes() const Q_DECL_OVERRIDE;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const Q_DECL_OVERRIDE;
|
||||
QStringList mimeTypes() const override;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE;
|
||||
int row, int column, const QModelIndex &parent) override;
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) Q_DECL_OVERRIDE;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
void removeItem(int index);
|
||||
void addItem(Mapping::ptr mapping, const QIcon &icon, const QString &label);
|
||||
|
||||
Reference in New Issue
Block a user