Improving FET code

Started by Liviu Lalescu, September 10, 2011, 12:12:34 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Liviu Lalescu

1) I have some thoughts of simplifying the FET code for the interface. There are too many files (.cpp/.h/.ui and add/list/modify, so 9 files for each constraint type). Ideas?

2) I know how to create a FET executable for GUI and another executable for the command line version. But how to have them both without wasting space? Qt experienced guys to advice?

3) How to ensure that I am using only Qt 5 compatible functions in the code, or to ensure I am not using obsolete Qt code? Is there a macro?

4) I might be interested in obtaining a standalone FET command line version without Qt dependence. So, just get the necessary Qt code and include it in FET, like QList, QHash, QSet and a few other used functions/classes. How could I do that?

Zsolt Udvari

#1
Quote1) I have some thoughts of simplifying the FET code for the interface. There are too many files (.cpp/.h/.ui and add/list/modify, so 9 files for each constraint type). Ideas?

Maybe you can use any template (not C++ -template, GUI-template).
I don't know what templates are in market (or world :)), but IMHO it isn't hard to write a simple library.

I've made similar in PHP. How works?
1. You specify the items (e.g. "Name", "Groups",...) in a simple data-structure.
2. You write a simple "parser" what creates the Dialog from your items.

I think you can do this with Classes. You declare a "core" classes, which has "add", "modify" and similar methods (this displays a dialog). This CoreClass's childs have specified properties (e.g. Name, etc.).

I hope you understand what I want say :)

A simple (language-independent) example:

class DialogCore {
    array DataFields; // this will overwrite in children objects

    function add() {
         MyDialog = new Dialog;
         for Data in DataFields {
             if (Data.type=="textbox") {
                  MyDialog->PutATextboxField();
             } elseif (Data.type=="....") {
             }
             MyDialog->PutALabel(Data.Label);
         }
         MyDialog->show();
    }
     ....
}

class TeacherDialog extends DialogCore {
     DataFields = array(
          (Label = "Teacher's name", type = "textbox"),
          (any other fields)...
     )   
}


I don't know it is possible or not in C++/Qt and how difficult to create this, it was just an idea :)

Corfiot

find what UI elements are common and make them widgets or create the forms more programmatically.

e.g. you have one .ui for add_contraint, del_constraint, edit_constraint (one for all three) and add/remove required components/behaviours programmatically for each constraint.

effectively, make the forms more generic and make behaviours and special fields part of each constraint's code.

This is my first thought.

Corfiot

#3
Quote
I think you can do this with Classes. You declare a "core" classes, which has "add", "modify" and similar methods (this displays a dialog). This CoreClass's childs have specified properties (e.g. Name, etc.).
I agree that this is a good way to start: define an interface like this an implement it in the Contraint classes.

I don't think it's necessary to do all the work in your code (create the whole form programatically). I think using a UI with all the common items and layout, making it effectively a template, then instantiating it for each constraint programmatically is a better compromise. Especially considering that at the moment the whole thing is based on UI editing.

Liviu Lalescu

Thank you for your suggestions! I thought of something similar.

I wanted to begin such work, but it is a lot of work (maybe not so useful), and I might have problems with the existing translations.

For the moment, I began getting rid of Qt 3 support classes, maybe in a week I'll have the converted code. This is to ensure future Qt 5 compatibility and make FET better. I will need help to read my changes and test. I'll announce in the Snapshots section the test version.