Menu

#9 Export the Panel

Next Minor Release
closed
nobody
5
2008-11-23
2008-11-03
No

I need to subclass QEditor for extend createMimeDataFromSelection, PaintEvent, and some event (as showEvent/hideEvent), and for this, i wrote an equivalent object of QCodeEdit. But for this i need access to QPanelLayout (with the macro QCE_EXPORT). Can you add it ?

Thanks for your help (and your editor).

Discussion

  • fullmetalcoder

    fullmetalcoder - 2008-11-03
    • milestone: --> Next Minor Release
     
  • fullmetalcoder

    fullmetalcoder - 2008-11-03

    Fixed in SVN.

    Are you sure you need to recreate QCodeEdit? Why couldn't you instead subclass it?
    I'm asking these questions because the answer could help me in improving the API
    to suit more complicated needs.

    regards

    fullmetalcoder

    p.s : I'm curious to learn about any project that uses QCodeEdit. Do you have a website? screenshots? or even a name and a brief description. I'd like to create a small "hall of fame" to gather informations about all projects using QCodeEdit.

     
  • Ulrich Van Den Hekke

    I must sub-class QEditor to modify createMimeDataFromSelection, add an highlight word functionality (in paint event, unless this feature is QCodeEdit). But I can't tell to QCodeEditor to use a subclass of QEditor instead of QEditor.

    Until now, I use QTextEdit, QSyntaxHighlighter, and QCompleter in my software, but now i search a more powerfull editor (better performance, code folding, ...).
    I don't use QCodeEdit but i think about use it and start to developpe some code to migrate my application from QTextEdit to QCodeEdit and keep old functionnality i have already developped.

    You can find my application in http://xinx.shadoware.org (ScreenShoot : http://xinx.shadoware.org/wiki/ScreenShoot\). It's a XSL editor application.

    You can find my test app : http://xinx.shadoware.org/browser/branches_dev/200821027%20-%20Changement%20de%20QCodeEdit/ext/xinxcodeedit

    Maybe i'm in the wrong way and there is a more easier solution

     
  • fullmetalcoder

    fullmetalcoder - 2008-11-03

    syntax highlighting is of course part of QCodeEdit. All you have to do to enable it is :
    1) to use the appropriate classes (have a look at the example program and ask questions if there is something you don't fully understand)
    2) create a syntax definition file (XML files with .qnfa extension in the qxs/ subdir) if none exist for the languages you want to support

    if you have any questions regarding the creation of syntax definition file that cannot be solved by having a look at the existing ones (C++, Doxygen, C#, Python, XML) please don't hesitate to ask it (though the task tracker probably isn't the best place for this).

    As far as I can see from the code in your repository you won't need to subclass any of QCodeEdit classes. Syntax highlighting, line numbers, code folding and other niceties are all handled directly by QCodeEdit provided you write a syntax file. Code completion requires more work but if you had started working on it already all you'll have to do is port your code to the new infrastructure which should not be complicated.

    Last but not least, why do you think you need to modify createMimeDataFromSelection() ? There may be another way to achieve what you want to do.
    Besides, even if you were forced to subclass QEditor you would not have to subclass anything else. You can always use qobject_cast to "convert"
    a QEditor* to your custom editor.

     
  • Nobody/Anonymous

    In fact, i think to highlight same word, but not syntax highlighting. By Example, my edit cursor is on "foo", and all Word "foo" in the text is show with a yellow background (on demand, or/and automatically).

    For createMimeDataFromSelection, i would like to export text in two format: text and html. In HTML format, the syntax highlighting will be process in HTML balise and a copy/paste in an editor like OpenOffice/MSOffice will be colored.

    > Besides, even if you were forced to subclass QEditor you would not have to
    > subclass anything else. You can always use qobject_cast to "convert"
    > a QEditor* to your custom editor.

    In QCodeEdit the QEditor is created in the constructor. So, i can't tell to QCodeEditor to create a XinxQEditor and not a QCodeEditor. So, i can't have member variable, or virtual method, because my XinxQEditor is never called. I don't saw how i can resolve this problem with qobject_cast.

     
  • fullmetalcoder

    fullmetalcoder - 2008-11-04

    you can highlight similar words using the overlay features of QDocumentLine (addOverlay, removeOverlay).
    and you can even automate the process of highlighting same words using QDocumentSearch and its highlightAll flag.
    the source code of the search/replace panel will help you understanding how to use QDocumentSearch (and you can ask questions if things are still unclear).

    As for the createMimeDataFromSelection() thing, I think it would make sense to add this in QCodeEdit instead of leaving it up to users. I'm too busy to implement this right now but if you can make a proper HTML export I'll be happy to apply your patch.

    Last but not least, you are not forced to rewrite QCodeEdit from scratch, you can just subclass it and provide methods working with your custom editor instead of QEditor (provided your custom editor is a subclass of QEditor). Then there may still be some places where implicit conversion will not work but then qobject_cast will be enough to solve these cases.

    Well actually it is not currently possible to do so but it will be after I add an extra ctor to QCodeEdit which will let you create a custom editor (and possibly even a custom panel).

     
  • Ulrich Van Den Hekke

    Oky thanks for your comments, I look on QDocumentSearch and i have some remarks :

    - QCE_EXPORT is not use on QDocumentSearch, can you add it ?
    - Can you add the feature of change the background color of a word (to highlight the word with a yellow background when finded ?)
    - When i use QDocumentSearch with QDocumentSearch::Silent and QDocumentSearch::HighlightAll options, the first word is selected in the editor. How can i use QDocumentSearch for only search word in a non visible cursor (the user cursor don't move). cursor.setSilent( true ) don't work too in this case.

     
  • fullmetalcoder

    fullmetalcoder - 2008-11-13

    ok both issues fixed.

    as for advanced use of QDocumentSearch, you should have a look at the cursor() and next() methods which allow you to navigate through matches (if the highlightAll flag is used first search will be longer but subsequent navigation will be faster, beware though, matches may be offsetted if some text is typed after the initial search).

     
  • Ulrich Van Den Hekke

    • status: open --> closed
     

Log in to post a comment.