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

List:       kde-commits
Subject:    playground/base/plasmagik
From:       Joseph Burns <jburns05.phate () gmail ! com>
Date:       2008-08-31 21:38:02
Message-ID: 1220218682.923859.26318.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 855479 by josebur:

Continuing to implement the new delegate...not quite working yet

 M  +3 -0      createpackage.ui  
 M  +24 -3     structuredelegate.cpp  
 M  +4 -0      structuredelegate.h  
 M  +5 -5      structuremodel.cpp  


--- trunk/playground/base/plasmagik/createpackage.ui #855478:855479
@@ -93,6 +93,9 @@
      <property name="allColumnsShowFocus" >
       <bool>true</bool>
      </property>
+     <property name="headerHidden" >
+      <bool>true</bool>
+     </property>
     </widget>
    </item>
   </layout>
--- trunk/playground/base/plasmagik/structuredelegate.cpp #855478:855479
@@ -5,6 +5,7 @@
 #include <QPixmap>
 #include <QColor>
 #include <QLinearGradient>
+#include <QPushButton>
 
 #include <KIcon>
 #include <KFileDialog>
@@ -37,11 +38,22 @@
 
 void StructureDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, \
const QModelIndex &index) const  {
+    if (index.column() == 0) {
+        paintMainColumn(painter, option, index);
+    } else if (index.column() == 1) {
+        paintWidgetColumn(painter, option, index);
+    } else {
+        kDebug() << "Unexpected column number";
+    }
+}
+
+void StructureDelegate::paintMainColumn(QPainter *painter, const \
QStyleOptionViewItem &option, const QModelIndex &index) const +{
     const int left = option.rect.left();
     const int top = option.rect.top();
     const int width = option.rect.width();
     const int height = calcItemHeight(option);
-    
+
     bool leftToRight = (painter->layoutDirection() == Qt::LeftToRight);
 
     QIcon::Mode iconMode = QIcon::Normal;
@@ -79,7 +91,7 @@
                Qt::AlignTop | Qt::AlignLeft, userPath);
 
     // Main icon
-    
+
 //     index.icon(index).paint(&p,
 //             leftToRight ? left + UNIVERSAL_PADDING : left + width - \
UNIVERSAL_PADDING - MAIN_ICON_SIZE,  //             top + UNIVERSAL_PADDING,
@@ -101,13 +113,22 @@
     QRect paintRect = option.rect;
     p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
     p.fillRect(paintRect, gradient);
+    p.end();
 
     painter->drawPixmap(option.rect.topLeft(), pixmap);
 }
 
+void StructureDelegate::paintWidgetColumn(QPainter *painter, const \
QStyleOptionViewItem &option, const QModelIndex &index) const +{
+    QPushButton *fileButton = new QPushButton();
+    fileButton->setIcon(KIcon("document-open"));
+    fileButton->show();
+}
+
 QSize StructureDelegate::sizeHint(const QStyleOptionViewItem &option, const \
QModelIndex &index) const  {
-    return QSize(0, calcItemHeight(option));
+    int width = (index.column() == 0) ? 0 : 90;
+    return QSize(width, calcItemHeight(option));
 }
 
 void StructureDelegate::getFileData()
--- trunk/playground/base/plasmagik/structuredelegate.h #855478:855479
@@ -19,6 +19,10 @@
     private slots:
         void getFileData();
         void getDirectoryData();
+
+    private:
+        void paintMainColumn(QPainter *painter, const QStyleOptionViewItem &option, \
const QModelIndex &index) const; +        void paintWidgetColumn(QPainter *painter, \
const QStyleOptionViewItem &option, const QModelIndex &index) const;  };
 
 #endif
--- trunk/playground/base/plasmagik/structuremodel.cpp #855478:855479
@@ -79,7 +79,7 @@
 
 int StructureModel::columnCount(const QModelIndex &/*parent*/) const
 {
-    return 1;
+    return 2;
 }
 
 QVariant StructureModel::data(const QModelIndex &index, int role) const
@@ -122,7 +122,7 @@
         if (section == 0) {
             return i18n("Package");
         } else if (section == 1) {
-            return i18n("Your Data");
+            return i18n("Widget");
         }
     }
     return QVariant();
@@ -131,9 +131,9 @@
 Qt::ItemFlags StructureModel::flags(const QModelIndex &index) const
 {
     Qt::ItemFlags flags = QAbstractItemModel::flags(index);
-    if (index.column() == 1) {
-        flags |= Qt::ItemIsEditable;
-    }
+//     if (index.column() == 1) {
+//         flags |= Qt::ItemIsEditable;
+//     }
 
     return flags;
 }


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

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