- Adds "rename" to the context menu for categories, it uses the same code path as the default dblClick handler for the base class. - Added a separator so the context menu looks more like the one for models - Some whitespace changes in mdichild.h, my editor truncates whitespace on blank lines.
This commit is contained in:
committed by
Bertrand Songis
parent
58971dffea
commit
c6026e8a0f
@@ -139,6 +139,8 @@ void MdiChild::showModelsListContextMenu(const QPoint & pos)
|
|||||||
else if (IS_HORUS(firmware->getBoard())) {
|
else if (IS_HORUS(firmware->getBoard())) {
|
||||||
if (modelsListModel->getCategoryIndex(modelIndex) >= 0) {
|
if (modelsListModel->getCategoryIndex(modelIndex) >= 0) {
|
||||||
contextMenu.addAction(CompanionIcon("add.png"), tr("&Add model"), this, SLOT(modelAdd()));
|
contextMenu.addAction(CompanionIcon("add.png"), tr("&Add model"), this, SLOT(modelAdd()));
|
||||||
|
contextMenu.addSeparator();
|
||||||
|
contextMenu.addAction(CompanionIcon("rename.png"), tr("&Rename category"), this, SLOT(categoryRename()));
|
||||||
contextMenu.addAction(CompanionIcon("delete.png"), tr("&Delete category"), this, SLOT(categoryDelete()));
|
contextMenu.addAction(CompanionIcon("delete.png"), tr("&Delete category"), this, SLOT(categoryDelete()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -370,6 +372,19 @@ void MdiChild::categoryAdd()
|
|||||||
setModified();
|
setModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MdiChild::categoryRename()
|
||||||
|
{
|
||||||
|
QModelIndex modelIndex = ui->modelsList->currentIndex();
|
||||||
|
int categoryIndex = modelsListModel->getCategoryIndex(modelIndex);
|
||||||
|
if (categoryIndex < 0 || categoryIndex >= (int)radioData.categories.size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not calling setModified() here because QAbstractItemView::edit will
|
||||||
|
// haandle it if the user actually makes a change
|
||||||
|
ui->modelsList->edit(modelIndex);
|
||||||
|
}
|
||||||
|
|
||||||
void MdiChild::categoryDelete()
|
void MdiChild::categoryDelete()
|
||||||
{
|
{
|
||||||
int categoryIndex = modelsListModel->getCategoryIndex(ui->modelsList->currentIndex());
|
int categoryIndex = modelsListModel->getCategoryIndex(ui->modelsList->currentIndex());
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class MdiChild : public QWidget
|
|||||||
int getCurrentRow() const;
|
int getCurrentRow() const;
|
||||||
void refresh(bool expand=false);
|
void refresh(bool expand=false);
|
||||||
void keyPressEvent(QKeyEvent * event);
|
void keyPressEvent(QKeyEvent * event);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void copyAvailable(bool val);
|
void copyAvailable(bool val);
|
||||||
|
|
||||||
@@ -69,12 +69,13 @@ class MdiChild : public QWidget
|
|||||||
void on_radioSettings_clicked();
|
void on_radioSettings_clicked();
|
||||||
void setDefault();
|
void setDefault();
|
||||||
void onFirmwareChanged();
|
void onFirmwareChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showModelsListContextMenu(const QPoint & pos);
|
void showModelsListContextMenu(const QPoint & pos);
|
||||||
void checkAndInitModel(int row);
|
void checkAndInitModel(int row);
|
||||||
void generalEdit();
|
void generalEdit();
|
||||||
void categoryAdd();
|
void categoryAdd();
|
||||||
|
void categoryRename();
|
||||||
void categoryDelete();
|
void categoryDelete();
|
||||||
void modelAdd();
|
void modelAdd();
|
||||||
void modelEdit();
|
void modelEdit();
|
||||||
@@ -84,7 +85,7 @@ class MdiChild : public QWidget
|
|||||||
void confirmDelete();
|
void confirmDelete();
|
||||||
void deleteSelectedModels();
|
void deleteSelectedModels();
|
||||||
void onDataChanged(const QModelIndex & index);
|
void onDataChanged(const QModelIndex & index);
|
||||||
|
|
||||||
void cut();
|
void cut();
|
||||||
void copy();
|
void copy();
|
||||||
void paste();
|
void paste();
|
||||||
@@ -101,11 +102,11 @@ class MdiChild : public QWidget
|
|||||||
void doCopy(QByteArray * gmData);
|
void doCopy(QByteArray * gmData);
|
||||||
void doPaste(QByteArray * gmData, int index);
|
void doPaste(QByteArray * gmData, int index);
|
||||||
void initModelsList();
|
void initModelsList();
|
||||||
|
|
||||||
MainWindow * parent;
|
MainWindow * parent;
|
||||||
Ui::MdiChild * ui;
|
Ui::MdiChild * ui;
|
||||||
TreeModel * modelsListModel;
|
TreeModel * modelsListModel;
|
||||||
|
|
||||||
QString curFile;
|
QString curFile;
|
||||||
|
|
||||||
Firmware * firmware;
|
Firmware * firmware;
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ ModelsListWidget::ModelsListWidget(QWidget * parent):
|
|||||||
{
|
{
|
||||||
setColumnWidth(0, 50);
|
setColumnWidth(0, 50);
|
||||||
setColumnWidth(2, 100);
|
setColumnWidth(2, 100);
|
||||||
|
|
||||||
active_highlight_color = palette().color(QPalette::Active, QPalette::Highlight);
|
active_highlight_color = palette().color(QPalette::Active, QPalette::Highlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +337,7 @@ void ModelsListWidget::mouseMoveEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
if (!(event->buttons() & Qt::LeftButton))
|
if (!(event->buttons() & Qt::LeftButton))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((event->pos() - dragStartPosition).manhattanLength() < QApplication::startDragDistance())
|
if ((event->pos() - dragStartPosition).manhattanLength() < QApplication::startDragDistance())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user