[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/krita
From:       Lukáš Tvrdý <lukast.dev () gmail ! com>
Date:       2010-10-01 9:43:07
Message-ID: 20101001094307.2AADDAC891 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1181524 by lukast:

Add priority to the paintops, so that they are sorted in the ui according them.

This aims to be consistent with tools.

 M  +12 -1     image/brushengine/kis_paintop_factory.cpp  
 M  +11 -0     image/brushengine/kis_paintop_factory.h  
 M  +2 -2      plugins/paintops/defaultpaintops/defaultpaintops_plugin.cc  
 M  +1 -0      plugins/paintops/defaultpaintops/duplicate/kis_duplicateop_factory.cpp  
 M  +2 -1      plugins/paintops/libpaintop/kis_simple_paintop_factory.h  
 M  +3 -8      ui/kis_paint_ops_model.cpp  
 M  +13 -3     ui/kis_paint_ops_model.h  


--- trunk/koffice/krita/image/brushengine/kis_paintop_factory.cpp #1181523:1181524
@@ -21,7 +21,7 @@
 #include <KoColorSpace.h>
 
 KisPaintOpFactory::KisPaintOpFactory(const QStringList & whiteListedCompositeOps)
-    : m_whiteListedCompositeOps(whiteListedCompositeOps)
+    : m_whiteListedCompositeOps(whiteListedCompositeOps), m_priority(100)
 {
 }
 
@@ -50,6 +50,17 @@
     return i18n("Stable");
 }
 
+void KisPaintOpFactory::setPriority(int newPriority)
+{
+    m_priority = newPriority;
+}
 
+
+int KisPaintOpFactory::priority() const
+{
+    return m_priority;
+}
+
+
 #include "kis_paintop_factory.moc"
 
--- trunk/koffice/krita/image/brushengine/kis_paintop_factory.h #1181523:1181524
@@ -86,8 +86,19 @@
      * create a widget that can display paintop settings
      */
     virtual KisPaintOpSettingsWidget* createSettingsWidget(QWidget* parent) = 0;
+
+    /**
+     * Set the priority of this paintop, as it is shown in the UI; lower number means
+     * it will be show more to the front of the list.
+     * @param newPriority the priority
+     */
+    void setPriority(int newPriority);
+    
+    int priority() const;
+    
 private:
     QStringList m_whiteListedCompositeOps;
+    int m_priority;
 };
 
 #endif
--- trunk/koffice/krita/plugins/paintops/defaultpaintops/defaultpaintops_plugin.cc #1181523:1181524
@@ -48,11 +48,11 @@
     //setComponentData(DefaultPaintOpsPluginFactory::componentData());
 
     KisPaintOpRegistry *r = KisPaintOpRegistry::instance();
-    r->add(new KisSimplePaintOpFactory<KisBrushOp, KisBrushBasedPaintOpSettings, \
KisBrushOpSettingsWidget>("paintbrush", i18n("Pixel Brush"), \
KisPaintOpFactory::categoryStable(),"krita-paintbrush.png")); +    r->add(new \
KisSimplePaintOpFactory<KisBrushOp, KisBrushBasedPaintOpSettings, KisBrushOpSettingsWidget>("paintbrush", \
i18n("Pixel Brush"), \
KisPaintOpFactory::categoryStable(),"krita-paintbrush.png",QString(),QStringList(),1));  r->add(new \
KisDuplicateOpFactory);  QStringList whiteList;
     whiteList << COMPOSITE_COPY;
-    r->add(new KisSimplePaintOpFactory<KisSmudgeOp, KisBrushBasedPaintOpSettings, \
KisSmudgeOpSettingsWidget>("smudge", i18n("Smudge Brush"), \
KisPaintOpFactory::categoryStable(),"krita-smudgebrush.png","smudge-finger", whiteList)); +    r->add(new \
KisSimplePaintOpFactory<KisSmudgeOp, KisBrushBasedPaintOpSettings, KisSmudgeOpSettingsWidget>("smudge", \
i18n("Smudge Brush"), KisPaintOpFactory::categoryStable(),"krita-smudgebrush.png","smudge-finger", \
whiteList,2));  }
 
 DefaultPaintOpsPlugin::~DefaultPaintOpsPlugin()
--- trunk/koffice/krita/plugins/paintops/defaultpaintops/duplicate/kis_duplicateop_factory.cpp \
#1181523:1181524 @@ -36,6 +36,7 @@
 KisDuplicateOpFactory::KisDuplicateOpFactory()
     : KisPaintOpFactory(QStringList(COMPOSITE_COPY))
 {
+    setPriority(3);
 }
 
 
--- trunk/koffice/krita/plugins/paintops/libpaintop/kis_simple_paintop_factory.h #1181523:1181524
@@ -31,7 +31,7 @@
 public:
     KisSimplePaintOpFactory(const QString& id, const QString& name, const QString& category,
                             const QString& pixmap, const QString& model = QString(),
-                            const QStringList& whiteListedCompositeOps = QStringList())
+                            const QStringList& whiteListedCompositeOps = QStringList(), int priority = \
100)  : KisPaintOpFactory(whiteListedCompositeOps)
         , m_id(id)
         , m_name(name)
@@ -39,6 +39,7 @@
         , m_pixmap(pixmap)
         , m_model(model)
         {
+            setPriority(priority);
         }
 
     virtual ~KisSimplePaintOpFactory()
--- trunk/koffice/krita/ui/kis_paint_ops_model.cpp #1181523:1181524
@@ -39,13 +39,10 @@
             pixmap = QPixmap(22,22);
             pixmap.fill();
         }
-        m_list.push_back(PaintOpInfo(op->id(), op->name(), op->category(), pixmap));
+        m_list.push_back(PaintOpInfo(op->id(), op->name(), op->category(), pixmap, op->priority()));
     }
 
-    foreach(const PaintOpInfo & info, m_list){
-            m_opsInOrder << info.id;
-    }
-    qSort(m_opsInOrder);
+    qSort(m_list);
     
     if (categories.isEmpty()){
         categories << KisPaintOpFactory::categoryStable() << KisPaintOpFactory::categoryExperimental();
@@ -74,9 +71,7 @@
         }
 
         case PaintOpSortRole: {
-            int idx = m_opsInOrder.indexOf(m_list[index.row()].id);
-            if (idx == -1) return m_opsInOrder.count();
-            return idx;
+            return index.row();
         }
         case KCategorizedSortFilterProxyModel::CategoryDisplayRole:
             return m_list[index.row()].category;
--- trunk/koffice/krita/ui/kis_paint_ops_model.h #1181523:1181524
@@ -54,20 +54,30 @@
     
 private:
     struct PaintOpInfo {
-        PaintOpInfo(QString _id, QString _name, QString _category, QPixmap _icon) : id(_id), \
name(_name), category(_category), icon(_icon) {} +        PaintOpInfo(QString _id, QString _name, QString \
_category, QPixmap _icon, int _priority) : id(_id), name(_name), category(_category), icon(_icon), \
priority(_priority) {}  QString id;
         QString name;
         QString category;
         QPixmap icon;
+        int priority;
 
         bool operator==(const PaintOpInfo info) const
         {
-            return ((info.id == id) && (info.name == name) && (info.category == category));
+            return ((info.id == id) && (info.name == name) && (info.category == category) && \
(info.priority == priority));  }
 
+        bool operator<( const PaintOpInfo & other ) const{
+            if (priority < other.priority) {
+                return true;
+            } else
+            if ((priority == other.priority) && (name < other.name)) {
+                return true;
+            }
+            return false;
+        }
     };
+    
     QList< PaintOpInfo > m_list;
-    QStringList m_opsInOrder;
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic