Results 1 to 2 of 2

Thread: Best way of manage projects

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Best way of manage projects

    Hi people,
    I am doing a Qt app for desktop and I need, from my app, to manage projects, i.e. create a new of, delete an existing one and switching between projects.
    A project is nothing else than a group of files whose content I load in my workspace. When I need to delete a project, now I manually delete its files but I would have
    some managing system like, for example, visual studio does.

    Any suggestion?

    Thank you
    Franco Amato

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Best way of manage projects

    Make a "project" a file itself that contains the list of the other files in the project. When you delete the project, you delete each of the files listed in this file, then you delete the project file itself.

    I like to use XML for these kind of files - I use it a lot for files that contain parameters especially, and you can dump all kinds of information in them and use Qt's QDomDocument API to read and write it to or from C++ data structures. You can open it in a web page and see it pretty-printed or use Notepad++ or Visual Studio or some other text editor to edit it it if you want.

    I will typically have a file that looks something like this:

    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <Project version="1000">
    3. <ProjectFiles version="1000" count="3">
    4. <ProjectFile version="1000" name="File1" path="/path/to/file" description="The first file"/>
    5. <ProjectFile version="1000" name="File2" path="/path/to/file" description="The second file"/>
    6. <ProjectFile version="1000" name="File3" path="/path/to/file" description="The third file"/>
    7. <ProjectFiles/>
    8. <OtherStuff version="1002">
    9. <ThingUnderOtherStuff version="1001" name="Thing1" value="42"/>
    10. <OtherStuff/>
    11. <Project/>
    To copy to clipboard, switch view to plain text mode 

    A few important concepts here. First, every element (<SomeElement>) has a version number string. This is not a version number of whatever is inside the element, it is the format of the element itself. I always use an initial value of 1000, and each time I change the format of what is contained inside the element, I bump up the version number.

    So say for the <ProjectFile> element I decide to add a "fileVersion" attribute that keeps the current version number of the file itself. The first version of the <ProjectFile> element doesn't contain this, so if I am reading in an older project, I first look at the version number for each element, and that tells me what I can expect to see in that element. I know if it is a version 1000 file, I won't find a fileVersion attribute, but if it is 1001 or later I will.

    When my program saves the XML file, it is always saved with the current version of each element.

    The second concept is that it is human readable. You can look at the file and see whether you have forgotten to include something or misspelled an element or attribute name when reading or writing.

    Third, it is portable. You can read it on any OS. You can read it with any XML viewer, not just your program.

    Fourth, if you want to get fancy, you can write XSLT scripts to transform the XML into a flat ASCII format or into HTML for a pretty web page display.

    And fifth, you aren't limited to ASCII text content. If you have binary content you want to store, you can easily convert it to Base64-encoded text and save that and back on reading.

    If you use Visual Studio, open one of the .sln or .vcxproj files in a text editor. You'll see that they are both XML-based, and that the .sln files is a list of all of the projects in the solution, and the .vcxproj is a very detailed description of the files in the project and how to build whatever the target is.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    franco.amato (7th December 2020)

Similar Threads

  1. sofware to manage meetings
    By mickey in forum General Discussion
    Replies: 7
    Last Post: 18th January 2011, 19:28
  2. Replies: 2
    Last Post: 7th September 2010, 21:19
  3. best way to manage forms?
    By skuda in forum Qt Programming
    Replies: 4
    Last Post: 7th December 2009, 08:38
  4. What is the best way to manage memory across threads?
    By bughunter2 in forum Qt Programming
    Replies: 2
    Last Post: 4th January 2009, 23:53
  5. How to manage QPainter?
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2006, 13:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.