mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 00:56:39 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			85 lines
		
	
	
	
		
			2.3 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			85 lines
		
	
	
	
		
			2.3 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable file
		
	
	
	
	
#ifndef DATADISPLAYDELEGATE_HPP
 | 
						|
#define DATADISPLAYDELEGATE_HPP
 | 
						|
 | 
						|
#include <QTextOption>
 | 
						|
#include "enumdelegate.hpp"
 | 
						|
 | 
						|
namespace CSVWorld
 | 
						|
{
 | 
						|
 | 
						|
 | 
						|
    class DataDisplayDelegate : public EnumDelegate
 | 
						|
    {
 | 
						|
    public:
 | 
						|
 | 
						|
        typedef std::vector < std::pair < int, QIcon > > IconList;
 | 
						|
        typedef std::vector<std::pair<int, QString> > ValueList;
 | 
						|
 | 
						|
    protected:
 | 
						|
 | 
						|
        enum DisplayMode
 | 
						|
        {
 | 
						|
            Mode_TextOnly,
 | 
						|
            Mode_IconOnly,
 | 
						|
            Mode_IconAndText
 | 
						|
        };
 | 
						|
 | 
						|
        DisplayMode mDisplayMode;
 | 
						|
        IconList mIcons;
 | 
						|
 | 
						|
    private:
 | 
						|
 | 
						|
        std::vector <std::pair <int, QPixmap> > mPixmaps;
 | 
						|
        QTextOption mTextAlignment;
 | 
						|
        QSize mIconSize;
 | 
						|
        int mIconLeftOffset;
 | 
						|
        int mTextLeftOffset;
 | 
						|
 | 
						|
    public:
 | 
						|
        explicit DataDisplayDelegate (const ValueList & values,
 | 
						|
                                      const IconList & icons,
 | 
						|
                                      QUndoStack& undoStack, QObject *parent);
 | 
						|
 | 
						|
        ~DataDisplayDelegate();
 | 
						|
 | 
						|
        virtual void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
 | 
						|
 | 
						|
        /// pass a QSize defining height / width of icon. Default is QSize (16,16).
 | 
						|
        void setIconSize (const QSize icon);
 | 
						|
 | 
						|
        /// offset the horizontal position of the icon from the left edge of the cell.  Default is 3 pixels.
 | 
						|
        void setIconLeftOffset (int offset);
 | 
						|
 | 
						|
        /// offset the horizontal position of the text from the right edge of the icon.  Default is 8 pixels.
 | 
						|
        void setTextLeftOffset (int offset);
 | 
						|
 | 
						|
    private:
 | 
						|
 | 
						|
        /// custom paint function for painting the icon.  Mode_IconAndText and Mode_Icon only.
 | 
						|
        void paintIcon (QPainter *painter, const QStyleOptionViewItem &option, int i) const;
 | 
						|
 | 
						|
        /// rebuild the list of pixmaps from the provided icons (called when icon size is changed)
 | 
						|
        void buildPixmaps();
 | 
						|
 | 
						|
    };
 | 
						|
 | 
						|
    class DataDisplayDelegateFactory : public EnumDelegateFactory
 | 
						|
    {
 | 
						|
    protected:
 | 
						|
 | 
						|
        DataDisplayDelegate::IconList mIcons;
 | 
						|
 | 
						|
    public:
 | 
						|
 | 
						|
        virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
 | 
						|
        ///< The ownership of the returned CommandDelegate is transferred to the caller.
 | 
						|
 | 
						|
    protected:
 | 
						|
 | 
						|
       void add (int enumValue,const  QString enumName, const QString iconFilename);
 | 
						|
 | 
						|
    };
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
#endif // DATADISPLAYDELEGATE_HPP
 |