Results 1 to 4 of 4

Thread: Advanced settings handling, suggestions?

  1. #1
    Join Date
    Oct 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Advanced settings handling, suggestions?

    For my current project, I need a way to manage settings that goes beyond what QSettings provides.
    For that, I'd like to ask you for suggestions.

    One thing that I really need is to be able to define some properties of the individual settings, like range for integers, length for strings and so on. One idea to handle that is to make a base class for the settings items that stores the name and a pointer to the Settings class to which the setting belongs.
    Cpp Code:
    1. class BasicType : public QObject {
    2. Q_OBJECT
    3. public:
    4. BasicType( const QString &name, Settings *parent );
    5. virtual ~BasicType();
    6. virtual QVariant value() = 0;
    7. virtual void set( const QVariant &newVal ) throw( something ) = 0;
    8. };
    To copy to clipboard, switch view to plain text mode 
    Based on that class, there would be a set of specialized classes like IntegerType which would know some details about the allowed contents.
    The Settings class would then contain a member for each of the types it is responsible for together with a Q_PROPERTY and control access to each of the items (so that they are never visible to the outside). This would also probably be the point where access management would hook in to allow access only to items that have the USER property set to true in the Settings class or finer grained if there's a way to find out who wants access to the item.

    Another way that came to my mind was the usage of just a Settings class and a set of visitors that would walk through the Settings class once one of the settings items change or just inspect the specific one and throw an exception if the new value would violate, say, the integer range of the item.

    This Settings class could then provide a function to load and store its contents using QSettings.

    What do you think? Suggestions welcome.

    greetings,
    Vultapher

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Advanced settings handling, suggestions?

    An xml file.

    Or a data stream

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Advanced settings handling, suggestions?

    Or even, maybe a sql data file, then you can search with specific parameters (like user=x and accesslevel>y).

  4. #4
    Join Date
    Oct 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Advanced settings handling, suggestions?

    Well, that would be an option to store it and let an external system handle everything for me. The application will either define integer access levels or flags. What I'm interested in is a way to manage the config inside the program. I'd go with Q_PROPERTY's and some functions that would simply check for the USER property parameter to restrict access (using a function there that would ask an SQL db or LDAP dir), but that's insufficient as I couldn't really define limits for the settings. Basically, I'm not sure what the better approach is, but I've seen type-specific classes used to store one single setting, managed by a config class before and thought it's a nice and clear way to handle that. Do you think so too?

Similar Threads

  1. Advanced QFileSystemModel
    By alexivanov91 in forum Qt Programming
    Replies: 0
    Last Post: 23rd September 2010, 09:23
  2. Advanced PKG Options [S60]
    By ManuMies in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 30th November 2009, 11:52
  3. Advanced use of QUiLoader
    By doberkofler in forum Qt Programming
    Replies: 2
    Last Post: 28th October 2009, 15:47
  4. Advanced use of QUiLoader
    By doberkofler in forum Newbie
    Replies: 0
    Last Post: 27th October 2009, 21:02
  5. QWidget Settings advanced idea
    By MarkoSan in forum Qt Programming
    Replies: 9
    Last Post: 27th March 2008, 09:41

Tags for this Thread

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.