Skip to content

Enhance editing#1218

Merged
SlySven merged 16 commits intoMudlet:developmentfrom
SlySven:Enhance_editing
Jul 23, 2017
Merged

Enhance editing#1218
SlySven merged 16 commits intoMudlet:developmentfrom
SlySven:Enhance_editing

Conversation

@SlySven
Copy link
Copy Markdown
Member

@SlySven SlySven commented Jul 11, 2017

This somewhat large PR enhances the Editor in several ways:

  • It makes the search have an option to be case-sensitive so that searching for "Needle" will ignore "needle" - which, as Lua is a case sensitive language can be a big help to find miss-capitalisations in identifiers.
  • It provides a means to clear the search result outlining in the edbee editor widget that result from a search operation (and clears the search results widget)
  • It allows the user to click on a search result item and the editor will switch to the selected item and position the cursor on the item in the editor that produced the result - and for ones where this is a multi-line widget and the result would otherwise be off-screen - scrolls so that the result is visible.† Not only are the lua code scripts, trigger patterns and item names searched but it has been extended to also search:
    • the "command" field(s) for those items that have it (or them for push-down buttons)
    • the "Css" (now renamed "Stylesheet") field for "Button/Menu/Toolbar" items
  • For "Lua code" and "Stylesheet" search areas where there can be multiple results on many different lines the "Where" field in the search results include a position indicator of the form {L: ## C: ##} to help in locating which result to click on - similarly "Pattern" results from triggers include a "{##}" addition to indicate which pattern provided the result. {Also the pattern numbers have been shifted up on screen in the GUI to be 1-50 instead of 0-49 and this is reflected in the search results and also fixes the bug from 2009 now recorded as Trigger pattern list GUI starts counting from 0 #608 ! 😀}
  • Tweaks the "xxxx_main_area" forms for most Mudlet item types so that item is identified uniformly by the term "Name:" and the term for the plain text that is sent straight to the MUD server is called "Command" - except for Push down buttons of course which have "Command {Down}" and "Command {Up}". To keep things simpler when I was making this PR I also renamed and relaid out some of the items in the above forms/files as there was quite a few oddly named widgets and it was confusing to keep track of which type I was working with - so the ones I have "adjusted" have all gained (if necessary) a camel case prefix of the widget type sans the initial "Q" followed by (in hindsight a somewhat redundant "Item" e.g. "trigger", "action", "key" etc.
  • Specifically for the Variables part of the editor I implemented a tweak that disables the user choosing invalid types for the "key" and "value" of an item selected in that view but allowing them to be set for "display" purposes - this ought to be checked by reviewers.

† - This feature is, I think, a major item to be trumpeted in the release announcement. 😤

vadi2 and others added 4 commits July 8, 2017 08:36
Following on from Mudlet#1096 I realised
that the search capability was still not case sensitive and given that Lua
is a case preserving language this struck me as a nuisance.  It is now
possible to configure this feature when searching with a button that
displays three line of letters "ABCD"/"AbCd"/"abcd" with all three lines
highlighted when searches are not case sensitive (i.e. a search for "A"
will also find "a") and only the middle line when the case does matter
(i.e. a search for "A" will not find the lower case one).

As we now have "boarder-outlines" around all the instances found in an
element in a lua script component, we ought to have a means to removed them
afterwards without having to click on another item and then return to the
current one being considered.  This commit also adds a clear button
to both clear the treeWidget_searchResults but also to remove those border
outlines.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Now clicking on a result in the search tree widget should put the focus
(and the cursor) on the first (or selected term depending on case) within
item.

Moved several methods in dlgTriggerEditor from being declared as SLOTs when
they are not so used:
* (void) recursiveSearchTriggers(TTrigger*, const QString&)
* (void) recursiveSearchAlias(TAlias*, const QString&)
* (void) recursiveSearchScripts(TScript*, const QString&)
* (void) recursiveSearchActions(TAction*, const QString&)
* (void) recursiveSearchTimers(TTimer*, const QString&)
* (void) recursiveSearchKeys(TKey*, const QString&)

In that class I also renamed:
* (void) recurseVariablesDown(TVar*, QList<TVar*>&, bool)
                   ==> recursiveSearchVariables(TVar*, QList<TVar*>&, bool)
because it had the same name as another function with a different signature
but it is used in the same manner as the previously mentioned no longer
SLOT methods.

Also renamed in the same class was:
* (void) slot_search_triggers(const QString)
                                 ==> slot_searchMudletItems(const QString&)
because it is now used to search all item types not just "Triggers" as it
may once have done!

I added a couple of enums to the same class, both for use with the search
functionality which this commit extends, the first is used to categorise
the data elements that are stored in the first item in each row of the
search results tree widget and the second (used as one type of the first)
to identify which part of a particular "item" the search result relates to
and thus how to process the stored data to goto the correct part of the
editor display when/if that result is selected by the user.

Elements were also renamed to try and be a bit more consistent across the
different Mudlet "item" types:

In "aliases" form/dialog:
* (QLineEdit *) pattern_textedit ==> lineEdit_alias_pattern
* (QComboBox *) comboBox ==> comboBox_alias_regex
* (QLineEdit *) substitution ==> lineEdit_alias_command

In "actions" (buttons/menus/toolbars) form/dialog:
* (QCheckBox *) checkBox_pushdownbutton
                                      ==> checkBox_action_button_isPushDown
* (QLineEdit *) lineEdit_command_down
                                    ==> lineEdit_action_button_command_down
* (QLineEdit *) lineEdit_command_up ==> lineEdit_action_button_command_up
* (QSpinBox *) buttonColumns ==> spinBox_action_bar_columns
* (QPlainTextEdit *) css ==> plainTextEdit_action_css
* (QComboBox *) comboBox_location ==> comboBox_action_bar_location
* (QComboBox *) comboBox_orientation ==> comboBox_action_bar_orientation
* (QComboBox *) buttonRotation ==> comboBox_action_button_rotation
* (QLabel *) label_command_down ==> label_action_button_command_down
* (QLabel *) label_command_up ==> label_action_button_command_up

In "keys" form/dialog:
* (QPushButton *) pushButton_grabKey ==> pushButton_key_grabKey
* (QLineEdit *) lineEdit_command ==> lineEdit_key_command
* (QLineEdit *) lineEdit_name ==> lineEdit_key_name
* (QLineEdit *) lineEdit_key ==> lineEdit_key_binding

In "scripts" form/dialog:
* (QLineEdit *) lineEdit ==> lineEdit_script_event_handler_entry
* (QListWidget *) listWidget_registered_event_handlers
                            ==> listWidget_script_registered_event_handlers
* (QToolButton *) toolButton_add ==> toolButton_script_add_event_handler
* (QToolButton *) toolButton_remove
                                  ==> toolButton_script_remove_even_handler

In "timer" form/dialog:
* (QLineEdit *) lineEdit_command ==> lineEdit_timer_command
* (QTimeEdit *) timeEdit_hours ==> timeEdit_timer_hours
* (QTimeEdit *) timeEdit_minutes ==> timeEdit_timer_minutes
* (QTimeEdit *) timeEdit_seconds ==> timeEdit_timer_seconds
* (QTimeEdit *) timeEdit_msecs ==> timeEdit_timer_msecs

In "trigger pattern" form/dialog:
* (QComboBox) patternType ==> comboBox_patternType
* (QPushButton) fgB ==> pushButton_fgColor
* (QPushButton) bgB ==> pushButton_bgColor
* (QLabel) number ==> label_patternNumber

In "variables" form/dialog:
* (QCheckBox *) hideVariable ==> checkBox_variable_hidden
* (QComboBox *) key_type ==> comboBox_variable_key_type
* (QComboBox *) var_type ==> comboBox_variable_value_type

Note that in the above SOME other elements that are not used in a
programmatic way (e.g. some label identifiers or layout or container
type widgets) have also been renamed in a similar way.

Also:
* The layout of the Timer editor has been "improved" and also now reports
the milli-seconds in "zzz" format rather than "z" so that it is more
obvious that the number is thousandths of a second and can range from "000"
to "999".
* The patterns in the trigger part of the editor are now numbered in a
more human-friendly 1 to 50 instead of the previous 0 to 49.
* When a different trigger is selected the pattern widget is scrolled so
that the highest used pattern number is in view.
* The search process now also searches: the "name" field for all items and
where relevant the "command" fields of "actions", "aliases", "keys",
"timers" and "triggers" {including the "command (up)}" for "buttons" and
the "Css"/"Stylesheet" field for "buttons"/"menus"/"buttons" and the
"Events handled" for "Scripts" and the "pattern" field for "aliases".
* Searching on fields that are multi-line (the Lua scripts for all but
"variables"; the "Css/Stylesheet" for "buttons"/"menus"/"buttons") or
multi-element ("trigger" patterns) indicate the line/column of the start
of the search term or pattern number respectively in the "What" column of
the search results.
* I have tweaked the tooltip for the case sensitive search a little to
better explain its two states - overall the icon is not the most perfect
for the role but I could not think of a better way to make it's image(s)
better match it's effects.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
…editor

Uses a means documented in https://stackoverflow.com/a/21376774/4805858
to replace the "standard" data model for the QComboBox with one from the
QListWidget which allows individual items to be flagged as disabled - which
the standard QComboBox does not.

This is designed to, in conjunction with a refactoring of code in
dlgTriggerEditor::slot_var_selected(...) to prevent invalid choices to be
made by the user (so types that they cannot enter through the Editor widget
but which are included in the type QComboBox s for display purposes:
functions for both and tables for one are disabled).

I would like to hide the editor widget when functions and tables are
selected in the tree widget - but that has proven to mess up the spacing
and layout for the remaining visible widgets and will have to be left until
I can bring: PR 436 "(release 30)bug fix get splitter working properly on
editor right side" into a usable state:
Mudlet#436

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven SlySven added this to the 3.4 milestone Jul 11, 2017
@SlySven SlySven requested a review from a team July 11, 2017 01:13
* Some not-used (or rather rejected) icons

* A typo of toolButton_script_remove_even_handler
when it should have been toolButton_script_remove_event_handler

* reordered all QGridLayout constructs in the "touched" dialog/forms in
strict ascending column & row (columns first) order - as Qt Form designer
does not currently enforce this but it increases Git noise in them.

* edited tooltip for hidden variable to match new form of hidden variables
control.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

void clearDocument(edbee::TextEditorWidget* ew, const QString& initialText=QLatin1Literal(""));

void setAllSearchData(QTreeWidgetItem* pItem, const int& type, const QString& name, const int& id, const SearchDataResultType& what, const int& pos = 0, const int& instance = 0, const int& subInstance = 0) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to document this and the next in the PR / Commit comment but (hopefully) in-line-able methods to fill out the QTreeWidgetItem::data construct in one swell foop...!

pItem->setData(0, IndexRole, subInstance);
}

void setAllSearchData(QTreeWidgetItem* pItem, const QString& name, const QStringList& id, const SearchDataResultType& what, const int& pos = 0, const int& subInstance = 0) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has a different signature and is only for Variables...

QTreeWidgetItem* mpCurrentAliasItem;
QTreeWidgetItem* mpCurrentVarItem;
QLineEdit* mpCursorPositionIndicator;
// Not used: QLineEdit* mpCursorPositionIndicator;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Candidate for next de-crufting...! 😀

#include <QFileDialog>
#include <QMessageBox>
#include <QScrollBar>
#include <QTableWidget>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found this was needed after removing it from dlgTriggerEditor class which does not contain any QTableWidgets (any more)

</property>
<property name="text">
<string>Number of columns/rows (depending on orientation)::</string>
<string>Number of columns/rows (depending on orientation):</string>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spotted this typo whilst doing other things...

mpTriggersMainArea->pushButtonFgColor->setStyleSheet(FgColorStyleSheet);
mpTriggersMainArea->pushButtonBgColor->setStyleSheet(BgColorStyleSheet);
mpTriggersMainArea->pushButtonFgColor->setPalette(FgColorPalette);
mpTriggersMainArea->pushButtonBgColor->setPalette(BgColorPalette);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this is, apparently naughty - see previous comment about mixing palettes and styles. ☹️

}
} else {
mpSourceEditorEdbee->setEnabled(true);
switch (keyType) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought a switch to a switch(...) was a better/clearer way to do this. 🤓

mpCurrentScriptItem = 0;
mpCurrentTimerItem = 0;
mpCurrentVarItem = 0;
mpCurrentTriggerItem = nullptr;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is C++11 as well as C++14 isn't it? 😁

{
if( trigger->isTemporary() ) { continue; }
std::list<TTrigger *> baseNodeList = mpHost->getTriggerUnit()->getTriggerRootNodeList();
for (auto trigger : baseNodeList) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems some stuff slipped past the "clang-formatter"?

QStringList sL;
sL << "Triggers";
mpTriggerBaseItem = new QTreeWidgetItem(static_cast<QTreeWidgetItem*>(0), sL);
mpTriggerBaseItem = new QTreeWidgetItem(static_cast<QTreeWidgetItem*>(0), QStringList(tr("Triggers")));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three lines down to one - and less named local variables.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 18, 2017

I like how's there's 20 comments already and not a single review yet 😉

Awesome work, thanks for doing this! I have started getting through this slowly.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 19, 2017

selection_126

The case sensitivity icon is really, really difficult to see (and very aliased). We need to think on a better icon for this.

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Jul 19, 2017

The case sensitivity icon is really, really difficult to see (and very aliased). We need to think on a better icon for this.

Yeah it was hard to come up with a suitable pair of icons to indicate whether the search is case sensitive or not. It might work better with a "bitmap" font rather than using GIMP to add a normal text in form of "ABCD"/"AbCd"/"abcd" - anti-aliasing does NOT work well on small font sizes. Off the top of my head I cannot actually think of an icon form that would intrinsically suggest in one state that only an exact match in case will be found whereas in the other any combination would work. I did not find anything like a standard Oxygen icon for this - which surprised me...!

On the choice of colours I originally used green/red but given that is the most common colour blindness form I changed the red to blue - which would have a higher lighteness contrast as well IIRC - I guess the grey/black form for the "un-hovered" state would look similarly better with bitmap text characters...

@itsTheFae
Copy link
Copy Markdown
Contributor

Would something like this work for the case sensitivity icon?
textcaseicons

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 20, 2017

I'm not a fan of that proposal either. I think this is a hard problem to solve and if we think ahead - we can skip solving it entirely. Given the option of case-insensitivity, people will also want to be able to search for regex and other ways, and we can't fill up that whole line with colourful buttons.

How about we adopt what Qt Creator did here. To select an option:

selection_127

With an option selected:

selection_128

, mpCurrentTriggerItem(0)
, mpCurrentAliasItem(0)
, mpCurrentVarItem(0)
: mpAliasBaseItem(nullptr)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 20, 2017

I've done an improvement on the clear button yesterday:

peek 2017-07-19 21-41

It now takes up less space and uses Qt's standard clearItem mechanism for a QLineEdit. I'll also work on adding the search & replace option from Qt Creator tonight in my PR to this PR.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 20, 2017

  • When a different trigger is selected the pattern widget is scrolled so
    that the highest used pattern number is in view.

How is this supposed to work? I'm not seeing any scrolling happening.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 20, 2017

I'm especially a fan of the improved Timers and Variables view. Great work! Looks so much neater 💯

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Jul 20, 2017

@ vadi2 wrote:

How is this supposed to work? I'm not seeing any scrolling happening.

If a trigger contains more patterns than will fit on screen in the scroll area of the trigger_main_area.ui form then when that item is selected from the treeWidget_triggers widget the scroll area should move so that the last filled pattern is visible without any further user action.

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Jul 20, 2017

@ vadi2 wrote:

I've done an improvement on the clear button yesterday:...

Does the same slot code get executed so that the boundary highlighting of the search terms in the current lua code content of the edbee editor widget gets cleared - I am guessing it is but it is not visible in the peek... 😀

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Jul 20, 2017

@ vadi2 wrote:

... I'm not a fan of that proposal either. I think this is a hard problem to solve and if we think ahead - we can skip solving it entirely...

It is hard to unambiguously show case sensitivity in an icon - it is not apparent whether screenshot_20170720_150059 means case sensitivity is on or off - on the other hand inserting status display widgets at the start of the search term widget might be interesting (for some Chinese values of "interesting" 😆 ) as that is a QComboBox with readOnly mode turned off - OTOH IIRC QComboBox do support an icon for each entry as standard whereas it would have to be added to a QLineEdit - we would just have to track the settings for each entry stored in it - and arrange for a (drop down) context menu to allow for the options to be set for each and then build and insert a suitable icon containing the set options as part of the the context menu handler... 🤔

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 20, 2017

Does the same slot code get executed

Yep!

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 20, 2017

It is more apparent in use - when the option is disabled, nothing is shown. When it is enabled, it adds an icon. I mean, try it in Qt Creator yourself! I think it's a good design we could adopt.

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Jul 20, 2017

Yeah, I am aware of it, hell, I use it and should we get whole word/regexp searches coded in I think that could be way to go - but it does need more code that I do not currently have to hand. In the short term I'd prefer to try to redraw the icons for case sensitivity using a graphics editor that allows a bitmap font (or one without anti-aliasing) to be used - or to draw the characters/glyphs manually...

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 20, 2017

OK, my bad, I didn't mean that you should do it now and I wasn't clear on that. Could try using a better icon - I'll think of something too.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 20, 2017

Err meant to submit a PR but pushed code instead to the original branch. Let me know if you disagree with any of the changes I did @SlySven!

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Jul 20, 2017

From the file names it looks as though you have replaced the grey/green show/hide results icons of 16x16 pixel size - assuming that the same icon engine is used for icons set via setStyleSheet(...) as if set directly why go for such a low resolution - the engine can scale down icons but will not scale them up?

It took a while to deduce what you were doing with the new code on the search term QComboBox but I eventually worked out you retrieved the QLineEditor component and then obtained all the members that it had and then iterated through them looking for the one corresponding to a QAction and then connect that to the dlgTriggerEditor::slot_clearSearchResults() slot. Does the use of that form connect(...) work for Qt 5.6 or whatever the earliest supported Qt version? I thought we had some problems with that sort of thing recently. Also is there only the clear() action that can be located with the given code? It does look as though more QActions can be inserted into a QLineEdit on its own or as part of a QComboBox - maybe that is how we can insert extra icons in to indicate search settings as previously talked about.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 21, 2017

The engine did a terrible job of scaling down the icons so I had to manually scale them in GIMP.

That form of connect(...) works since Qt 5.0... we never had problems with that sort of things and it's in use in the IRC code quite fine.

Yep, we could use that QActions thing to add more icons!

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 21, 2017

How about a variation of @itsTheFae's proposal, but with Aa as the letters, and with highlighting when it's on / monotone when it's off?

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Jul 21, 2017

Well, for the current icon can we fit a reasonable size "AA/Aa/aa" for case sensitive off and "AA/Aa/aa" for case sensitive on into it - the trouble with just a single pair of letters is that it is not intuitive and you need at least two to show how only the specific combination will match...

I guess if we have already moved the clear icon into the QComboBox we could allow an icon for this to be non-square (i.e. a landscape format) so the glyphs can be larger and less prone to aliasing issues. This would be a temporary measure until we can move this option into the QComboBox's context menu (when we have other options to go alongside it)...

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 21, 2017 via email

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 22, 2017

@SlySven by the way, a now shows when using clang to build: https://travis-ci.org/Mudlet/Mudlet/jobs/255923230#L1309

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 22, 2017

Here is the tweak I came up with!

peek 2017-07-22 14-42

I don't like how there's too much space on the sides, but unfortunately I couldn't find a way to reduce it - reducing the icon size just made Qt stretch the icon back to 16x16.

Also, search is kinda slow, people do complain about it. A topic for another day.

The mechanism now behaves very like the Qt Creator's own search options
which are presented as a clickable menu at the start of the search term
QLineEdit part of the editable QComboBox.

At present only Case Sensitivity is supported but it will be possible to
add additional search options - the most likely being whole word and
regular expression type searches. As the QtCreator inspiration does
different icons are shown depending on the options enabled on the menu
that is displayed is clicked (and encoded into the new enum/QFlags
"SearchOptions" which is stored in dlgTriggerEditor::mSearchOptions). As
new options are coded extra icons that support all the combinations will
be needed (although if a combination is not provided with an icon) the
grey binoculars icon that is used when no option is set is replaced with
a red one to indicate something is enabled and modifying the search
behaviour.

At present the options chosen are NOT stored against the search terms that
get stored into the search term QComboBox - it might be wanted to store
the search options chosen as part of each search term (use a item::data for
that) so they can be restore if an existing term is reused...

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Jul 22, 2017

@vadi2 give it a try now - I have implemented the same methodology that Qt use for the find in QtCreator...

It only does Case Sensitive right now but extending the option list is straightforward. 😇

Also, search is kinda slow, people do complain about it. A topic for another day.

That is probably the variable searching - that does really bog things down but does find the search terms in both names and values anywhere in the lua data - which does have some use - perhaps an Ignore "Variable" values (and possibly names) option might be helpful for coders who do not want to bother looking into the run-time data but just their code (unfortunately if my concerns are valid skipping just the "value" won't speed things up to much as we still need to check the "name" and that requires walking the global "_G" table)!

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Jul 22, 2017

The binocular icons are derived but modified from the Oxygen icon set and the two letter one is a non alias but full hinted "Sans" 24 point by me (all GPLed). The 64x64 icons may scale down OK - they look Ok to me.

Copy link
Copy Markdown
Member

@vadi2 vadi2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 awesome stuff! It's great that it searches event handlers now and a lot of other things.

Just need to fix the introduced warning at https://travis-ci.org/Mudlet/Mudlet/jobs/255923230#L1309 and it's good to go!


mpAction_searchCaseSensitive = new QAction(tr("Case sensitive"), this);
mpAction_searchCaseSensitive->setObjectName(QLatin1String("mpAction_searchCaseSensitive"));
mpAction_searchCaseSensitive->setObjectName(QStringLiteral("mpAction_searchCaseSensitive"));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch - BTW how does QLatin11String compare to QLatin1Literal I have seen a few uses of the latter used in our code-base and I suspect that is the QtCreator IDE helpfully auto-completing it when the other one is really wanted... 😮

Was producing a: "warning: comparison of constant -1 with boolean
expression is always true [-Wtautological-constant-out-of-range-compare]"
issue on Travis CI - which is just as well because the code in that one
case had not previous been correct. I think I must have been doing a
repetitive edit to code that I had copy and pasted and then revised and
messed up one instance.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Jul 23, 2017

Will squash and merge once latest CI completes. Note that I have spotted some other compilation CI warnings related to bit-ops on char type in TBuffer that I did for the UTF-8 stuff but I'll do that as a separate PR (close by other places that used the same code but with test values that didn't trip those warnings will also be addressed)...

@SlySven SlySven merged commit d004dab into Mudlet:development Jul 23, 2017
@SlySven SlySven deleted the Enhance_editing branch July 23, 2017 17:48
vadi2 pushed a commit that referenced this pull request Aug 6, 2017
…1218)

* Enhance: make editor search have optional case-sensitivity and clear

Following on from #1096 I realised
that the search capability was still not case sensitive and given that Lua
is a case preserving language this struck me as a nuisance.  It is now
possible to configure this feature when searching.

As we now have "boarder-outlines" around all the instances found in an
element in a lua script component, we ought to have a means to removed them
afterwards without having to click on another item and then return to the
current one being considered.  This commit also adds the built in clear
button in the QLineEdit of the QComboBox that the search term is entered
into which also clears the treeWidget_searchResults and also remove
those border outlines.

Clicking on a result in the search tree widget should put the focus (and
the cursor) on the first (or selected term depending on case) within item.

Moved several methods in dlgTriggerEditor from being declared as SLOTs when
they are not so used:
* (void) recursiveSearchTriggers(TTrigger*, const QString&)
* (void) recursiveSearchAlias(TAlias*, const QString&)
* (void) recursiveSearchScripts(TScript*, const QString&)
* (void) recursiveSearchActions(TAction*, const QString&)
* (void) recursiveSearchTimers(TTimer*, const QString&)
* (void) recursiveSearchKeys(TKey*, const QString&)

In that class I also renamed:
* (void) recurseVariablesDown(TVar*, QList<TVar*>&, bool)
                   ==> recursiveSearchVariables(TVar*, QList<TVar*>&, bool)
because it had the same name as another function with a different signature
but it is used in the same manner as the previously mentioned no longer
SLOT methods.

Also renamed in the same class was:
* (void) slot_search_triggers(const QString)
                                 ==> slot_searchMudletItems(const QString&)
because it is now used to search all item types not just "Triggers" as it
may once have done!

I added a couple of enums to the same class, both for use with the search
functionality which this commit extends, the first is used to categorise
the data elements that are stored in the first item in each row of the
search results tree widget and the second (used as one type of the first)
to identify which part of a particular "item" the search result relates to
and thus how to process the stored data to goto the correct part of the
editor display when/if that result is selected by the user.

Elements were also renamed to try and be a bit more consistent across the
different Mudlet "item" types:

In "aliases" form/dialog:
* (QLineEdit *) pattern_textedit ==> lineEdit_alias_pattern
* (QComboBox *) comboBox ==> comboBox_alias_regex
* (QLineEdit *) substitution ==> lineEdit_alias_command

In "actions" (buttons/menus/toolbars) form/dialog:
* (QCheckBox *) checkBox_pushdownbutton
                                      ==> checkBox_action_button_isPushDown
* (QLineEdit *) lineEdit_command_down
                                    ==> lineEdit_action_button_command_down
* (QLineEdit *) lineEdit_command_up ==> lineEdit_action_button_command_up
* (QSpinBox *) buttonColumns ==> spinBox_action_bar_columns
* (QPlainTextEdit *) css ==> plainTextEdit_action_css
* (QComboBox *) comboBox_location ==> comboBox_action_bar_location
* (QComboBox *) comboBox_orientation ==> comboBox_action_bar_orientation
* (QComboBox *) buttonRotation ==> comboBox_action_button_rotation
* (QLabel *) label_command_down ==> label_action_button_command_down
* (QLabel *) label_command_up ==> label_action_button_command_up

In "keys" form/dialog:
* (QPushButton *) pushButton_grabKey ==> pushButton_key_grabKey
* (QLineEdit *) lineEdit_command ==> lineEdit_key_command
* (QLineEdit *) lineEdit_name ==> lineEdit_key_name
* (QLineEdit *) lineEdit_key ==> lineEdit_key_binding

In "scripts" form/dialog:
* (QLineEdit *) lineEdit ==> lineEdit_script_event_handler_entry
* (QListWidget *) listWidget_registered_event_handlers
                            ==> listWidget_script_registered_event_handlers
* (QToolButton *) toolButton_add ==> toolButton_script_add_event_handler
* (QToolButton *) toolButton_remove
                                  ==> toolButton_script_remove_even_handler

In "timer" form/dialog:
* (QLineEdit *) lineEdit_command ==> lineEdit_timer_command
* (QTimeEdit *) timeEdit_hours ==> timeEdit_timer_hours
* (QTimeEdit *) timeEdit_minutes ==> timeEdit_timer_minutes
* (QTimeEdit *) timeEdit_seconds ==> timeEdit_timer_seconds
* (QTimeEdit *) timeEdit_msecs ==> timeEdit_timer_msecs

In "trigger pattern" form/dialog:
* (QComboBox) patternType ==> comboBox_patternType
* (QPushButton) fgB ==> pushButton_fgColor
* (QPushButton) bgB ==> pushButton_bgColor
* (QLabel) number ==> label_patternNumber

In "variables" form/dialog:
* (QCheckBox *) hideVariable ==> checkBox_variable_hidden
* (QComboBox *) key_type ==> comboBox_variable_key_type
* (QComboBox *) var_type ==> comboBox_variable_value_type

Note that in the above SOME other elements that are not used in a
programmatic way (e.g. some label identifiers or layout or container
type widgets) have also been renamed in a similar way.

Also:
* The layout of the Timer editor has been "improved" and also now reports
the milli-seconds in "zzz" format rather than "z" so that it is more
obvious that the number is thousandths of a second and can range from "000"
to "999".
* The patterns in the trigger part of the editor are now numbered in a
more human-friendly 1 to 50 instead of the previous 0 to 49.
* When a different trigger is selected the pattern widget is scrolled so
that the highest used pattern number is in view.
* The search process now also searches: the "name" field for all items and
where relevant the "command" fields of "actions", "aliases", "keys",
"timers" and "triggers" {including the "command (up)}" for "buttons" and
the "Css"/"Stylesheet" field for "buttons"/"menus"/"buttons" and the
"Events handled" for "Scripts" and the "pattern" field for "aliases".
* Searching on fields that are multi-line (the Lua scripts for all but
"variables"; the "Css/Stylesheet" for "buttons"/"menus"/"buttons") or
multi-element ("trigger" patterns) indicate the line/column of the start
of the search term or pattern number respectively in the "What" column of
the search results.

A tweak has been included that disables some items on the key and value
QComboBoxs in the "Variable" part of the editor, this uses a means
documented in https://stackoverflow.com/a/21376774/4805858
to replace the "standard" data model for the QComboBox with one from the
QListWidget which allows individual items to be flagged as disabled - which
the standard QComboBox does not.

This is designed to, in conjunction with a refactoring of code in
dlgTriggerEditor::slot_var_selected(...) to prevent invalid choices to be
made by the user (so types that they cannot enter through the Editor widget
but which are included in the type QComboBox s for display purposes:
functions for both and tables for one are disabled).

I would like to hide the editor widget when functions and tables are
selected in the tree widget - but that has proven to mess up the spacing
and layout for the remaining visible widgets and will have to be left until
I can bring: PR 436 "(release 30)bug fix get splitter working properly on
editor right side" into a usable state: #436

I have reordered all QGridLayout constructs in the "touched" dialog/forms in
strict ascending column & row (columns first) order - as Qt Form designer
does not currently enforce this but it increases Git noise in them.

Also have edited tooltip for hidden variable to match new form of hidden
variables control.

Part way through the evolution of this (squashed down to a single)
commit it was decided to revised the search to be an options menu
with space for additional options.

The mechanism now behaves very like the Qt Creator's own search options
which are presented as a clickable menu at the start of the search term
QLineEdit part of the editable QComboBox.

At present only Case Sensitivity is supported but it will be possible to
add additional search options - the most likely being whole word and
regular expression type searches. As the QtCreator inspiration does
different icons are shown depending on the options enabled on the menu
that is displayed is clicked (and encoded into the new enum/QFlags
"SearchOptions" which is stored in dlgTriggerEditor::mSearchOptions). As
new options are coded extra icons that support all the combinations will
be needed (although if a combination is not provided with an icon) the
grey binoculars icon that is used when no option is set is replaced with
a red one to indicate something is enabled and modifying the search
behaviour.

Also currently the options chosen are NOT stored against the search terms
that get stored into the search term QComboBox - it might be wanted to store
the search options chosen as part of each search term (use a item::data for
that) so they can be restore if an existing term is reused...

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
mpconley added a commit to mpconley/Mudlet that referenced this pull request Mar 9, 2026
Fix pre-existing copy-paste bug (from Mudlet#1218) where clicking Keys search
results for name/command incorrectly focused Triggers fields instead of
Keys fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants