[kde-doc-english] KDE/kdebase/workspace/plasma/wallpapers/image

Davide Bettio davide.bettio at kdemail.net
Sat Aug 29 19:31:20 CEST 2009


SVN commit 1017086 by bettio:

GUI: Replaced the wallpaper combobox with a QListView.


 M  +5 -5      backgroundlistmodel.cpp  
 M  +1 -1      backgroundlistmodel.h  
 M  +15 -15    image.cpp  
 M  +1 -1      image.h  
 M  +127 -144  imageconfig.ui  


--- trunk/KDE/kdebase/workspace/plasma/wallpapers/image/backgroundlistmodel.cpp #1017085:1017086
@@ -44,7 +44,7 @@
 void BackgroundListModel::removeBackground(const QString &path)
 {
     int index;
-    while ((index = indexOf(path)) != -1) {
+    while ((index = indexOf(path).row()) != -1) {
         beginRemoveRows(QModelIndex(), index, index);
         Plasma::Package *package = m_packages.at(index);
         m_packages.removeAt(index);
@@ -116,7 +116,7 @@
     }
 }
 
-int BackgroundListModel::indexOf(const QString &path) const
+QModelIndex BackgroundListModel::indexOf(const QString &path) const
 {
     for (int i = 0; i < m_packages.size(); i++) {
         // packages will end with a '/', but the path passed in may not
@@ -130,16 +130,16 @@
             // package->path does not contain the actual file name
             if ((!m_packages[i]->structure()->contentsPrefix().isEmpty()) ||
                 (path == m_packages[i]->filePath("preferred"))) {
-                return i;
+                return index(i, 0);
             }
         }
     }
-    return -1;
+    return index(-1, 0);
 }
 
 bool BackgroundListModel::contains(const QString &path) const
 {
-    return indexOf(path) != -1;
+    return indexOf(path).row() != -1;
 }
 
 int BackgroundListModel::rowCount(const QModelIndex &) const
--- trunk/KDE/kdebase/workspace/plasma/wallpapers/image/backgroundlistmodel.h #1017085:1017086
@@ -41,7 +41,7 @@
     void reload();
     void reload(const QStringList &selected);
     void addBackground(const QString &path);
-    int indexOf(const QString &path) const;
+    QModelIndex indexOf(const QString &path) const;
     virtual bool contains(const QString &bg) const;
 
     static QStringList findAllBackgrounds(Plasma::Wallpaper *structureParent,
--- trunk/KDE/kdebase/workspace/plasma/wallpapers/image/image.cpp #1017085:1017086
@@ -112,19 +112,19 @@
         m_model->setWallpaperSize(m_size);
         m_model->reload(m_usersWallpapers);
         m_uiImage.m_view->setModel(m_model);
-        m_uiImage.m_view->setItemDelegate(new BackgroundDelegate(m_uiImage.m_view->view(),
+        m_uiImage.m_view->setItemDelegate(new BackgroundDelegate(m_uiImage.m_view,
                                                                  ratio, m_configWidget));
-        m_uiImage.m_view->view()->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
-        int index = m_model->indexOf(m_wallpaper);
+        m_uiImage.m_view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
+        QModelIndex index = m_model->indexOf(m_wallpaper);
         kDebug() << m_wallpaper << index;
-        if (index != -1) {
+        ///if (index != -1) {
             m_uiImage.m_view->setCurrentIndex(index);
-            Plasma::Package *b = m_model->package(index);
+            Plasma::Package *b = m_model->package(index.row());
             if (b) {
                 fillMetaInfo(b);
             }
-        }
-        connect(m_uiImage.m_view, SIGNAL(currentIndexChanged(int)), this, SLOT(pictureChanged(int)));
+        ///}
+        connect(m_uiImage.m_view, SIGNAL(activated(const QModelIndex &)), this, SLOT(pictureChanged(const QModelIndex &)));
 
         m_uiImage.m_pictureUrlButton->setIcon(KIcon("document-open"));
         connect(m_uiImage.m_pictureUrlButton, SIGNAL(clicked()), this, SLOT(showFileDialog()));
@@ -153,7 +153,7 @@
 
         connect(m_uiImage.m_color, SIGNAL(changed(const QColor&)), this, SLOT(modified()));
         connect(m_uiImage.m_resizeMethod, SIGNAL(currentIndexChanged(int)), this, SLOT(modified()));
-        connect(m_uiImage.m_view, SIGNAL(currentIndexChanged(int)), this, SLOT(modified()));
+        connect(m_uiImage.m_view, SIGNAL(activated(const QModelIndex &)), this, SLOT(modified()));
 
     } else {
         m_uiSlideshow.setupUi(m_configWidget);
@@ -379,13 +379,13 @@
     setSingleImage();
 }
 
-void Image::pictureChanged(int index)
+void Image::pictureChanged(const QModelIndex &index)
 {
-    if (index == -1 || !m_model) {
+    if (index.row() == -1 || !m_model) {
         return;
     }
 
-    Plasma::Package *b = m_model->package(index);
+    Plasma::Package *b = m_model->package(index.row());
     if (!b) {
         return;
     }
@@ -504,10 +504,10 @@
     m_model->addBackground(wallpaper);
 
     // select it
-    int index = m_model->indexOf(wallpaper);
-    if (index != -1) {
+    QModelIndex index = m_model->indexOf(wallpaper);
+    ///if (index != -1) {
         m_uiImage.m_view->setCurrentIndex(index);
-    }
+    ///}
 
     // save it
     m_usersWallpapers << wallpaper;
@@ -609,7 +609,7 @@
 
 void Image::updateScreenshot(QPersistentModelIndex index)
 {
-    m_uiImage.m_view->view()->update(index);
+    m_uiImage.m_view->update(index);
 }
 
 void Image::updateFadedImage(qreal frame)
--- trunk/KDE/kdebase/workspace/plasma/wallpapers/image/image.h #1017085:1017086
@@ -46,7 +46,7 @@
         void slotRemoveDir();
         void getNewWallpaper();
         void colorChanged(const QColor& color);
-        void pictureChanged(int index);
+        void pictureChanged(const QModelIndex &);
         void wallpaperBrowseCompleted();
         void nextSlide();
         void updateBackground(const QImage &img);
--- trunk/KDE/kdebase/workspace/plasma/wallpapers/image/imageconfig.ui #1017085:1017086
@@ -6,174 +6,94 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>605</width>
-    <height>230</height>
+    <width>512</width>
+    <height>295</height>
    </rect>
   </property>
   <layout class="QGridLayout" name="gridLayout_2">
-   <item row="0" column="0">
-    <widget class="QLabel" name="label">
+   <item row="0" column="0" colspan="3">
+    <widget class="QListView" name="m_view">
+     <property name="minimumSize">
+      <size>
+       <width>504</width>
+       <height>116</height>
+      </size>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0">
+    <widget class="QLabel" name="m_authorLabel">
      <property name="text">
-      <string>&amp;Picture:</string>
+      <string>Author:</string>
      </property>
      <property name="alignment">
       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
      </property>
-     <property name="buddy">
-      <cstring>m_view</cstring>
-     </property>
     </widget>
    </item>
-   <item row="0" column="1">
-    <widget class="QComboBox" name="m_view">
+   <item row="2" column="1">
+    <widget class="QLabel" name="m_authorLine">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
        <horstretch>1</horstretch>
-       <verstretch>1</verstretch>
+       <verstretch>0</verstretch>
       </sizepolicy>
      </property>
+     <property name="text">
+      <string/>
+     </property>
     </widget>
    </item>
-   <item row="0" column="2">
-    <widget class="QToolButton" name="m_pictureUrlButton">
-     <property name="toolTip">
-      <string>Browse</string>
+   <item row="8" column="2">
+    <spacer name="verticalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
      </property>
-     <property name="text">
-      <string>...</string>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>13</width>
+       <height>5</height>
+      </size>
      </property>
-    </widget>
+    </spacer>
    </item>
-   <item row="1" column="1" colspan="2">
-    <layout class="QGridLayout" name="gridLayout">
-     <item row="0" column="0">
-      <widget class="QLabel" name="m_authorLabel">
-       <property name="text">
-        <string>Author:</string>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-       </property>
-      </widget>
-     </item>
-     <item row="0" column="1">
-      <widget class="QLabel" name="m_authorLine">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-         <horstretch>1</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="text">
-        <string/>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="0">
-      <widget class="QLabel" name="m_emailLabel">
-       <property name="text">
-        <string>Email:</string>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="1">
-      <widget class="QLabel" name="m_emailLine">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="text">
-        <string/>
-       </property>
-      </widget>
-     </item>
-     <item row="2" column="0">
-      <widget class="QLabel" name="m_licenseLabel">
-       <property name="text">
-        <string>License:</string>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
-       </property>
-      </widget>
-     </item>
-     <item row="2" column="1">
-      <widget class="QLabel" name="m_licenseLine">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-         <horstretch>1</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="text">
-        <string/>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item row="2" column="0">
-    <widget class="QLabel" name="label_4">
+   <item row="3" column="0">
+    <widget class="QLabel" name="m_emailLabel">
      <property name="text">
-      <string>P&amp;ositioning:</string>
+      <string>Email:</string>
      </property>
      <property name="alignment">
       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
      </property>
-     <property name="buddy">
-      <cstring>m_resizeMethod</cstring>
-     </property>
     </widget>
    </item>
-   <item row="2" column="1" colspan="2">
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
-      <widget class="QComboBox" name="m_resizeMethod">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer name="spacer_2">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>187</width>
-         <height>17</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
-   </item>
-   <item row="3" column="0">
-    <widget class="QLabel" name="label_5">
+   <item row="4" column="0">
+    <widget class="QLabel" name="m_licenseLabel">
      <property name="text">
-      <string>&amp;Color:</string>
+      <string>License:</string>
      </property>
      <property name="alignment">
-      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      <set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
      </property>
-     <property name="buddy">
-      <cstring>m_color</cstring>
+    </widget>
+   </item>
+   <item row="4" column="1">
+    <widget class="QLabel" name="m_licenseLine">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+       <horstretch>1</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
      </property>
+     <property name="text">
+      <string/>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+     </property>
     </widget>
    </item>
-   <item row="3" column="1" colspan="2">
+   <item row="6" column="1">
     <layout class="QHBoxLayout" name="horizontalLayout_2">
      <item>
       <widget class="KColorButton" name="m_color">
@@ -214,9 +134,32 @@
      </item>
     </layout>
    </item>
-   <item row="4" column="1" colspan="2">
+   <item row="3" column="1">
+    <widget class="QLabel" name="m_emailLine">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item row="7" column="1">
     <layout class="QHBoxLayout" name="horizontalLayout_3">
      <item>
+      <widget class="QToolButton" name="m_pictureUrlButton">
+       <property name="toolTip">
+        <string>Browse</string>
+       </property>
+       <property name="text">
+        <string>...</string>
+       </property>
+      </widget>
+     </item>
+     <item>
       <spacer name="horizontalSpacer">
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
@@ -242,18 +185,58 @@
     </layout>
    </item>
    <item row="5" column="1">
-    <spacer name="verticalSpacer_2">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QComboBox" name="m_resizeMethod">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="spacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>187</width>
+         <height>17</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item row="6" column="0">
+    <widget class="QLabel" name="m_colorLabel">
+     <property name="text">
+      <string>&amp;Color:</string>
      </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>13</width>
-       <height>5</height>
-      </size>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
      </property>
-    </spacer>
+     <property name="buddy">
+      <cstring>m_color</cstring>
+     </property>
+    </widget>
    </item>
+   <item row="5" column="0">
+    <widget class="QLabel" name="m_positioningLabel">
+     <property name="text">
+      <string>P&amp;ositioning:</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+     <property name="buddy">
+      <cstring>m_resizeMethod</cstring>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <customwidgets>



More information about the kde-doc-english mailing list