Improved free text macro functionality.

The macro edit  page in the settings dialog  now allows multiple items
to be selected in an extended selection.

The macro items can be rearranged  by drag and drop of single items or
whole selections.

The  delete button  and  context menu  item  will now  delete all  the
selected items.

The  free text  macro drop  down combo  boxes on  the main  screen now
automatically insert new  macros into the macros list  (at the end) if
the ENTER key is pressed while the combobox has focus.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4038 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2014-04-16 23:10:45 +00:00
parent ed2de0ed08
commit 2e8c4c4ec0
3 changed files with 249 additions and 175 deletions

View File

@ -148,6 +148,23 @@ private:
QLineEdit description_; 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. // Fields that are transceiver related.
// //
// These are aggregated in a structure to enable a non-equivalence to // 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 on_add_macro_line_edit_editingFinished ();
Q_SLOT void delete_macro (); Q_SLOT void delete_macro ();
void delete_selected_macros (QModelIndexList);
Q_SLOT void on_save_path_select_push_button_clicked (bool); Q_SLOT void on_save_path_select_push_button_clicked (bool);
@ -318,7 +336,7 @@ private:
float jt9w_max_dt_; float jt9w_max_dt_;
QStringListModel macros_; QStringListModel macros_;
QStringListModel next_macros_; RearrangableMacrosModel next_macros_;
QAction * macro_delete_action_; QAction * macro_delete_action_;
Bands bands_; Bands bands_;
@ -1222,6 +1240,9 @@ bool Configuration::impl::validate ()
int Configuration::impl::exec () int Configuration::impl::exec ()
{ {
// macros can be modified in the main window
next_macros_.setStringList (macros_.stringList ());
ptt_state_ = false; ptt_state_ = false;
have_rig_ = rig_active_; // record that we started with a rig open have_rig_ = rig_active_; // record that we started with a rig open
@ -1596,20 +1617,47 @@ void Configuration::impl::on_add_macro_line_edit_editingFinished ()
void Configuration::impl::on_delete_macro_push_button_clicked (bool /* checked */) void Configuration::impl::on_delete_macro_push_button_clicked (bool /* checked */)
{ {
auto index = ui_->macros_list_view->selectionModel ()->currentIndex (); auto selection_model = ui_->macros_list_view->selectionModel ();
if (index.isValid ()) if (selection_model->hasSelection ())
{ {
next_macros_.removeRow (index.row ()); // delete all selected items
delete_selected_macros (selection_model->selectedRows ());
} }
} }
void Configuration::impl::delete_macro () void Configuration::impl::delete_macro ()
{ {
auto index = ui_->macros_list_view->currentIndex (); 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 ()) if (index.isValid ())
{ {
next_macros_.removeRow (index.row ()); 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 ());
}
} }
void Configuration::impl::on_add_macro_push_button_clicked (bool /* checked */) void Configuration::impl::on_add_macro_push_button_clicked (bool /* checked */)

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>508</width> <width>586</width>
<height>471</height> <height>550</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -1390,6 +1390,11 @@ both here.</string>
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::ActionsContextMenu</enum> <enum>Qt::ActionsContextMenu</enum>
</property> </property>
<property name="toolTip">
<string>Drag and drop items to rearrange order
Right click for item specific actions
Click, SHIFT+Click and, CRTL+Click to select items</string>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QListView { <string notr="true">QListView {
show-decoration-selected: 1; /* make the selection span the entire width of the view */ 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); stop: 0 #FAFBFE, stop: 1 #DCDEF1);
}</string> }</string>
</property> </property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::MoveAction</enum>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode"> <property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum> <enum>QAbstractItemView::ExtendedSelection</enum>
</property> </property>
<property name="uniformItemSizes"> <property name="uniformItemSizes">
<bool>true</bool> <bool>true</bool>
@ -1801,12 +1815,12 @@ soundcard changes</string>
</connection> </connection>
</connections> </connections>
<buttongroups> <buttongroups>
<buttongroup name="TX_audio_source_button_group"/>
<buttongroup name="TX_mode_button_group"/> <buttongroup name="TX_mode_button_group"/>
<buttongroup name="split_mode_button_group"/>
<buttongroup name="CAT_stop_bits_button_group"/> <buttongroup name="CAT_stop_bits_button_group"/>
<buttongroup name="PTT_method_button_group"/>
<buttongroup name="CAT_data_bits_button_group"/> <buttongroup name="CAT_data_bits_button_group"/>
<buttongroup name="CAT_handshake_button_group"/> <buttongroup name="CAT_handshake_button_group"/>
<buttongroup name="TX_audio_source_button_group"/>
<buttongroup name="split_mode_button_group"/>
<buttongroup name="PTT_method_button_group"/>
</buttongroups> </buttongroups>
</ui> </ui>

View File

@ -591,6 +591,46 @@ p, li { white-space: pre-wrap; }
</item> </item>
<item> <item>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="6">
<widget class="QSpinBox" name="TxFreqSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>113</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>105</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Audio Tx frequency</string>
</property>
<property name="suffix">
<string> Hz</string>
</property>
<property name="prefix">
<string>Tx </string>
</property>
<property name="minimum">
<number>200</number>
</property>
<property name="maximum">
<number>5000</number>
</property>
<property name="value">
<number>1500</number>
</property>
</widget>
</item>
<item row="3" column="3"> <item row="3" column="3">
<widget class="QLabel" name="labAz"> <widget class="QLabel" name="labAz">
<property name="sizePolicy"> <property name="sizePolicy">
@ -876,46 +916,6 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="6">
<widget class="QSpinBox" name="TxFreqSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>113</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>105</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Audio Tx frequency</string>
</property>
<property name="suffix">
<string> Hz</string>
</property>
<property name="prefix">
<string>Tx </string>
</property>
<property name="minimum">
<number>200</number>
</property>
<property name="maximum">
<number>5000</number>
</property>
<property name="value">
<number>1500</number>
</property>
</widget>
</item>
<item row="0" column="3" colspan="2"> <item row="0" column="3" colspan="2">
<widget class="QLabel" name="labDialFreq"> <widget class="QLabel" name="labDialFreq">
<property name="sizePolicy"> <property name="sizePolicy">
@ -985,6 +985,28 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="6">
<widget class="QCheckBox" name="txFirstCheckBox">
<property name="minimumSize">
<size>
<width>105</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>105</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Check to Tx in even minutes, uncheck for odd minutes</string>
</property>
<property name="text">
<string>Tx even</string>
</property>
</widget>
</item>
<item row="1" column="3"> <item row="1" column="3">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="sizePolicy"> <property name="sizePolicy">
@ -1077,74 +1099,6 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" rowspan="5">
<widget class="QSlider" name="inGain">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>160</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>160</height>
</size>
</property>
<property name="toolTip">
<string>Digital gain for audio input</string>
</property>
<property name="minimum">
<number>-50</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="value">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QCheckBox" name="txFirstCheckBox">
<property name="minimumSize">
<size>
<width>105</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>105</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Check to Tx in even minutes, uncheck for odd minutes</string>
</property>
<property name="text">
<string>Tx even</string>
</property>
</widget>
</item>
<item row="1" column="6"> <item row="1" column="6">
<widget class="QPushButton" name="pbTxMode"> <widget class="QPushButton" name="pbTxMode">
<property name="enabled"> <property name="enabled">
@ -1158,6 +1112,16 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="cbPlus2kHz">
<property name="toolTip">
<string>Add 2 kHz to requested dial frequency</string>
</property>
<property name="text">
<string>+2 kHz</string>
</property>
</widget>
</item>
<item row="5" column="3" rowspan="2" colspan="2"> <item row="5" column="3" rowspan="2" colspan="2">
<widget class="QLabel" name="labUTC"> <widget class="QLabel" name="labUTC">
<property name="sizePolicy"> <property name="sizePolicy">
@ -1203,13 +1167,19 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="1" column="2">
<widget class="QCheckBox" name="cbPlus2kHz"> <widget class="QPushButton" name="readFreq">
<property name="maximumSize">
<size>
<width>15</width>
<height>15</height>
</size>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Add 2 kHz to requested dial frequency</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If orange, click to read dial frequency&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>+2 kHz</string> <string/>
</property> </property>
</widget> </widget>
</item> </item>
@ -1273,7 +1243,7 @@ p, li { white-space: pre-wrap; }
<enum>QTabWidget::Triangular</enum> <enum>QTabWidget::Triangular</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@ -1778,11 +1748,17 @@ p, li { white-space: pre-wrap; }
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="toolTip">
<string>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).</string>
</property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="insertPolicy"> <property name="insertPolicy">
<enum>QComboBox::NoInsert</enum> <enum>QComboBox::InsertAtBottom</enum>
</property> </property>
</widget> </widget>
</item> </item>
@ -1990,11 +1966,17 @@ p, li { white-space: pre-wrap; }
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="toolTip">
<string>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).</string>
</property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="insertPolicy"> <property name="insertPolicy">
<enum>QComboBox::NoInsert</enum> <enum>QComboBox::InsertAtBottom</enum>
</property> </property>
</widget> </widget>
</item> </item>
@ -2031,19 +2013,10 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="0" column="9">
<widget class="QPushButton" name="readFreq"> <widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>15</width>
<height>15</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If orange, click to read dial frequency&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string/> <string>Pwr</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -2063,6 +2036,34 @@ p, li { white-space: pre-wrap; }
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="9" rowspan="6">
<widget class="QSlider" name="outAttenuation">
<property name="toolTip">
<string>Adjust Tx audio level</string>
</property>
<property name="maximum">
<number>300</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="invertedAppearance">
<bool>true</bool>
</property>
<property name="invertedControls">
<bool>true</bool>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3"> <item row="0" column="0" colspan="3">
<widget class="QComboBox" name="bandComboBox"> <widget class="QComboBox" name="bandComboBox">
<property name="sizePolicy"> <property name="sizePolicy">
@ -2094,41 +2095,6 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="9">
<widget class="QLabel" name="label">
<property name="text">
<string>Pwr</string>
</property>
</widget>
</item>
<item row="1" column="9" rowspan="6">
<widget class="QSlider" name="outAttenuation">
<property name="toolTip">
<string>Adjust Tx audio level</string>
</property>
<property name="maximum">
<number>300</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="invertedAppearance">
<bool>true</bool>
</property>
<property name="invertedControls">
<bool>true</bool>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item row="3" column="7"> <item row="3" column="7">
<widget class="QPushButton" name="pbT2R"> <widget class="QPushButton" name="pbT2R">
<property name="sizePolicy"> <property name="sizePolicy">
@ -2237,6 +2203,52 @@ p, li { white-space: pre-wrap; }
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="1" rowspan="5">
<widget class="QSlider" name="inGain">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>160</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>160</height>
</size>
</property>
<property name="toolTip">
<string>Digital gain for audio input</string>
</property>
<property name="minimum">
<number>-50</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="value">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -2247,7 +2259,7 @@ p, li { white-space: pre-wrap; }
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>780</width> <width>780</width>
<height>21</height> <height>20</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">