#11 QFormatFactory

Next Minor Release
closed
nobody
5
2008-12-06
2008-12-01
No

Is it possible to divide QFormatFactory in a class and an abstract class :
class QCE_EXPORT QAbstractFormatFactory : public QObject
{
Q_OBJECT

public:
QAbstractFormatFactory (QObject *p = 0);
virtual ~ QAbstractFormatFactory ();

virtual int formatCount() const = 0;
virtual QStringList formats() const = 0;

virtual QString id(int ifid) const = 0;
virtual int id(const QString& sfid) const = 0;

virtual QFormat format(int ifid) const = 0;
virtual QFormat format(const QString& sfid) const = 0;

public slots:
virtual void setFormat(const QString& fid, const QFormat& fmt) = 0;
};

class QCE_EXPORT QFormatFactory : public QAbstractFormatFactory
{
Q_OBJECT

public:
QFormatFactory(const QString& f, QObject *p = 0);
virtual ~QFormatFactory();

int formatCount() const;
QStringList formats() const;

virtual QString id(int ifid) const;
virtual int id(const QString& sfid) const;

virtual QFormat format(int ifid) const;
virtual QFormat format(const QString& sfid) const;

public slots:
virtual void setFormat(const QString& fid, const QFormat& fmt);

private:
QString m_settings;

QVector<QString> m_formatKeys;
QVector<QFormat> m_formatValues;
};

The goal will be to use QAbstractFormatFactory in all QCodeEdit, but use QFormatFactory at the creation (for use in the application as now).
This permit to use a different storage of format settings (I have already my own storage, in a QSettings and method of QFormatFactory will be redirect in my configuration object).
It’s possible to subclass QFormatFactory with a empty string for the filename, but I don’t love this method.

Discussion

  • fullmetalcoder
    fullmetalcoder
    2008-12-01

    Good point.

    However, im my opinion, moving loading/saving of formats settings to two virtual methods make more sense than creating yet another abstract class (besides, virtualizing this class would decrease performances as it is often queried during document drawing, probably not very noticeably but I do not want to lose speed without very good reasons).

     
  • Oky.

    I think that this can be another good solution.
    Thanks

     
  • fullmetalcoder
    fullmetalcoder
    2008-12-04

    • milestone: --> Next Minor Release
     
  • fullmetalcoder
    fullmetalcoder
    2008-12-04

    Done in SVN (r755)

    Simply reimp the load() and save() method to benefit from it.

     
    • status: open --> closed
     
    • status: closed --> open
     
  • Thanks

     
    • status: open --> closed