diff --git a/Configuration.cpp b/Configuration.cpp
index 83531fdd6..76be13ffe 100644
--- a/Configuration.cpp
+++ b/Configuration.cpp
@@ -148,6 +148,23 @@ private:
QLineEdit description_;
};
+class RearrangableMacrosModel
+ : public QStringListModel
+{
+public:
+ Qt::ItemFlags flags (QModelIndex const& index) const override
+ {
+ auto flags = QStringListModel::flags (index);
+ if (index.isValid ())
+ {
+ // disallow drop onto existing items
+ flags &= ~Qt::ItemIsDropEnabled;
+ }
+ return flags;
+ }
+};
+
+
// Fields that are transceiver related.
//
// These are aggregated in a structure to enable a non-equivalence to
@@ -268,6 +285,7 @@ private:
Q_SLOT void on_add_macro_line_edit_editingFinished ();
Q_SLOT void delete_macro ();
+ void delete_selected_macros (QModelIndexList);
Q_SLOT void on_save_path_select_push_button_clicked (bool);
@@ -318,7 +336,7 @@ private:
float jt9w_max_dt_;
QStringListModel macros_;
- QStringListModel next_macros_;
+ RearrangableMacrosModel next_macros_;
QAction * macro_delete_action_;
Bands bands_;
@@ -1222,6 +1240,9 @@ bool Configuration::impl::validate ()
int Configuration::impl::exec ()
{
+ // macros can be modified in the main window
+ next_macros_.setStringList (macros_.stringList ());
+
ptt_state_ = false;
have_rig_ = rig_active_; // record that we started with a rig open
@@ -1596,17 +1617,44 @@ void Configuration::impl::on_add_macro_line_edit_editingFinished ()
void Configuration::impl::on_delete_macro_push_button_clicked (bool /* checked */)
{
- auto index = ui_->macros_list_view->selectionModel ()->currentIndex ();
- if (index.isValid ())
+ auto selection_model = ui_->macros_list_view->selectionModel ();
+ if (selection_model->hasSelection ())
{
- next_macros_.removeRow (index.row ());
+ // delete all selected items
+ delete_selected_macros (selection_model->selectedRows ());
}
}
void Configuration::impl::delete_macro ()
{
- auto index = ui_->macros_list_view->currentIndex ();
- if (index.isValid ())
+ auto selection_model = ui_->macros_list_view->selectionModel ();
+ if (!selection_model->hasSelection ())
+ {
+ // delete item under cursor if any
+ auto index = selection_model->currentIndex ();
+ if (index.isValid ())
+ {
+ next_macros_.removeRow (index.row ());
+ }
+ }
+ else
+ {
+ // delete the whole selection
+ delete_selected_macros (selection_model->selectedRows ());
+ }
+}
+
+void Configuration::impl::delete_selected_macros (QModelIndexList selected_rows)
+{
+ // sort in reverse row order so that we can delete without changing
+ // indices underneath us
+ qSort (selected_rows.begin (), selected_rows.end (), [] (QModelIndex const& lhs, QModelIndex const& rhs)
+ {
+ return rhs.row () < lhs.row (); // reverse row ordering
+ });
+
+ // now delete them
+ Q_FOREACH (auto index, selected_rows)
{
next_macros_.removeRow (index.row ());
}
diff --git a/Configuration.ui b/Configuration.ui
index 5c3883a13..6b315acf1 100644
--- a/Configuration.ui
+++ b/Configuration.ui
@@ -6,8 +6,8 @@
0
0
- 508
- 471
+ 586
+ 550
@@ -1390,6 +1390,11 @@ both here.
Qt::ActionsContextMenu
+
+ Drag and drop items to rearrange order
+Right click for item specific actions
+Click, SHIFT+Click and, CRTL+Click to select items
+
QListView {
show-decoration-selected: 1; /* make the selection span the entire width of the view */
@@ -1418,8 +1423,17 @@ QListView::item:hover {
stop: 0 #FAFBFE, stop: 1 #DCDEF1);
}
+
+ QAbstractItemView::InternalMove
+
+
+ Qt::MoveAction
+
+
+ true
+
- QAbstractItemView::SingleSelection
+ QAbstractItemView::ExtendedSelection
true
@@ -1801,12 +1815,12 @@ soundcard changes
+
+
+
-
-
-
diff --git a/mainwindow.ui b/mainwindow.ui
index 87cc35fe0..9a216ad6d 100644
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -591,6 +591,46 @@ p, li { white-space: pre-wrap; }
-
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 113
+ 0
+
+
+
+
+ 105
+ 16777215
+
+
+
+ Audio Tx frequency
+
+
+ Hz
+
+
+ Tx
+
+
+ 200
+
+
+ 5000
+
+
+ 1500
+
+
+
-
@@ -876,46 +916,6 @@ p, li { white-space: pre-wrap; }
- -
-
-
-
- 0
- 0
-
-
-
-
- 113
- 0
-
-
-
-
- 105
- 16777215
-
-
-
- Audio Tx frequency
-
-
- Hz
-
-
- Tx
-
-
- 200
-
-
- 5000
-
-
- 1500
-
-
-
-
@@ -985,6 +985,28 @@ p, li { white-space: pre-wrap; }
+ -
+
+
+
+ 105
+ 23
+
+
+
+
+ 105
+ 16777215
+
+
+
+ Check to Tx in even minutes, uncheck for odd minutes
+
+
+ Tx even
+
+
+
-
@@ -1077,74 +1099,6 @@ p, li { white-space: pre-wrap; }
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 160
-
-
-
-
- 20
- 160
-
-
-
- Digital gain for audio input
-
-
- -50
-
-
- 50
-
-
- 20
-
-
- Qt::Vertical
-
-
- false
-
-
- false
-
-
- QSlider::TicksBelow
-
-
-
- -
-
-
-
- 105
- 23
-
-
-
-
- 105
- 16777215
-
-
-
- Check to Tx in even minutes, uncheck for odd minutes
-
-
- Tx even
-
-
-
-
@@ -1158,6 +1112,16 @@ p, li { white-space: pre-wrap; }
+ -
+
+
+ Add 2 kHz to requested dial frequency
+
+
+ +2 kHz
+
+
+
-
@@ -1203,13 +1167,19 @@ p, li { white-space: pre-wrap; }
- -
-
+
-
+
+
+
+ 15
+ 15
+
+
- Add 2 kHz to requested dial frequency
+ <html><head/><body><p>If orange, click to read dial frequency</p></body></html>
- +2 kHz
+
@@ -1273,7 +1243,7 @@ p, li { white-space: pre-wrap; }
QTabWidget::Triangular
- 0
+ 1
@@ -1778,11 +1748,17 @@ p, li { white-space: pre-wrap; }
16777215
+
+ Enter a free text message (maximum 13 characters)
+or select a predefined macro from the dropdown list.
+Press ENTER to add the current text to the predefined
+list. The list can be maintained in Settings (F2).
+
true
- QComboBox::NoInsert
+ QComboBox::InsertAtBottom
@@ -1990,11 +1966,17 @@ p, li { white-space: pre-wrap; }
0
+
+ Enter a free text message (maximum 13 characters)
+or select a predefined macro from the dropdown list.
+Press ENTER to add the current text to the predefined
+list. The list can be maintained in Settings (F2).
+
true
- QComboBox::NoInsert
+ QComboBox::InsertAtBottom
@@ -2031,19 +2013,10 @@ p, li { white-space: pre-wrap; }
- -
-
-
-
- 15
- 15
-
-
-
- <html><head/><body><p>If orange, click to read dial frequency</p></body></html>
-
+
-
+
-
+ Pwr
@@ -2063,6 +2036,34 @@ p, li { white-space: pre-wrap; }
+ -
+
+
+ Adjust Tx audio level
+
+
+ 300
+
+
+ 0
+
+
+ Qt::Vertical
+
+
+ true
+
+
+ true
+
+
+ QSlider::TicksBelow
+
+
+ 10
+
+
+
-
@@ -2094,41 +2095,6 @@ p, li { white-space: pre-wrap; }
- -
-
-
- Pwr
-
-
-
- -
-
-
- Adjust Tx audio level
-
-
- 300
-
-
- 0
-
-
- Qt::Vertical
-
-
- true
-
-
- true
-
-
- QSlider::TicksBelow
-
-
- 10
-
-
-
-
@@ -2237,6 +2203,52 @@ p, li { white-space: pre-wrap; }
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 160
+
+
+
+
+ 20
+ 160
+
+
+
+ Digital gain for audio input
+
+
+ -50
+
+
+ 50
+
+
+ 20
+
+
+ Qt::Vertical
+
+
+ false
+
+
+ false
+
+
+ QSlider::TicksBelow
+
+
+
@@ -2247,7 +2259,7 @@ p, li { white-space: pre-wrap; }
0
0
780
- 21
+ 20