[Kde-imaging] [Bug 136941] graphical picture ordering and renaming

Aurelien Gateau aurelien.gateau at free.fr
Thu Nov 16 08:25:58 CET 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=136941         




------- Additional Comments From aurelien.gateau free fr  2006-11-16 08:25 -------
SVN commit 605272 by gateau:

It's now possible to move files in the list.
CCBUG: 136941


 M  +102 -76   renameimagesbase.ui  
 M  +78 -19    renameimageswidget.cpp  
 M  +6 -0      renameimageswidget.h  


--- trunk/extragear/libs/kipi-plugins/batchprocessimages/renameimagesbase.ui #605271:605272
 @ -8,8 +8,8  @
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>530</width>
-            <height>659</height>
+            <width>570</width>
+            <height>690</height>
         </rect>
     </property>
     <property name="caption">
 @ -115,55 +115,6  @
         </widget>
         <widget class="QGroupBox">
             <property name="name">
-                <cstring>m_sortGroupBox</cstring>
-            </property>
-            <property name="title">
-                <string>File List Order</string>
-            </property>
-            <grid>
-                <property name="name">
-                    <cstring>unnamed</cstring>
-                </property>
-                <widget class="QComboBox" row="0" column="1">
-                    <item>
-                        <property name="text">
-                            <string>By File Name</string>
-                        </property>
-                    </item>
-                    <item>
-                        <property name="text">
-                            <string>By File Size</string>
-                        </property>
-                    </item>
-                    <item>
-                        <property name="text">
-                            <string>By File Date</string>
-                        </property>
-                    </item>
-                    <property name="name">
-                        <cstring>m_sortCombo</cstring>
-                    </property>
-                </widget>
-                <widget class="QLabel" row="0" column="0">
-                    <property name="name">
-                        <cstring>m_sortLabel</cstring>
-                    </property>
-                    <property name="text">
-                        <string>Sort Original List :</string>
-                    </property>
-                </widget>
-                <widget class="QCheckBox" row="1" column="0">
-                    <property name="name">
-                        <cstring>m_reverseSortCheck</cstring>
-                    </property>
-                    <property name="text">
-                        <string>Reverse Order</string>
-                    </property>
-                </widget>
-            </grid>
-        </widget>
-        <widget class="QGroupBox">
-            <property name="name">
                 <cstring>m_addRemoveBox</cstring>
             </property>
             <property name="title">
 @ -195,29 +146,7  @
                         <string>Remove</string>
                     </property>
                 </widget>
-                <widget class="QLabel" row="2" column="1">
-                    <property name="name">
-                        <cstring>m_pixLabel</cstring>
-                    </property>
-                    <property name="sizePolicy">
-                        <sizepolicy>
-                            <hsizetype>0</hsizetype>
-                            <vsizetype>0</vsizetype>
-                            <horstretch>0</horstretch>
-                            <verstretch>0</verstretch>
-                        </sizepolicy>
-                    </property>
-                    <property name="minimumSize">
-                        <size>
-                            <width>96</width>
-                            <height>96</height>
-                        </size>
-                    </property>
-                    <property name="text">
-                        <string></string>
-                    </property>
-                </widget>
-                <widget class="KListView" row="0" column="0" rowspan="4" colspan="1">
+                <widget class="KListView" row="0" column="0" rowspan="10" colspan="1">
                     <column>
                         <property name="text">
                             <string>Album</string>
 @ -271,11 +200,14  @
                     <property name="resizeMode">
                         <enum>LastColumn</enum>
                     </property>
+                    <property name="dragEnabled">
+                        <bool>true</bool>
+                    </property>
                     <property name="shadeSortColumn">
                         <bool>false</bool>
                     </property>
                 </widget>
-                <spacer row="3" column="1">
+                <spacer row="9" column="1">
                     <property name="name">
                         <cstring>spacer25</cstring>
                     </property>
 @ -288,10 +220,104  @
                     <property name="sizeHint">
                         <size>
                             <width>16</width>
-                            <height>165</height>
+                            <height>175</height>
                         </size>
                     </property>
                 </spacer>
+                <widget class="QPushButton" row="8" column="1">
+                    <property name="name">
+                        <cstring>m_reverseList</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Reverse List</string>
+                    </property>
+                </widget>
+                <spacer row="6" column="1">
+                    <property name="name">
+                        <cstring>spacer3</cstring>
+                    </property>
+                    <property name="orientation">
+                        <enum>Vertical</enum>
+                    </property>
+                    <property name="sizeType">
+                        <enum>Fixed</enum>
+                    </property>
+                    <property name="sizeHint">
+                        <size>
+                            <width>16</width>
+                            <height>19</height>
+                        </size>
+                    </property>
+                </spacer>
+                <widget class="QPushButton" row="7" column="1">
+                    <property name="name">
+                        <cstring>m_sortButton</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Sort List</string>
+                    </property>
+                </widget>
+                <widget class="QPushButton" row="5" column="1">
+                    <property name="name">
+                        <cstring>m_moveDown</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Move &amp;Down</string>
+                    </property>
+                    <property name="accel">
+                        <string>Alt+D</string>
+                    </property>
+                </widget>
+                <widget class="QPushButton" row="4" column="1">
+                    <property name="name">
+                        <cstring>m_moveUp</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Move &amp;Up</string>
+                    </property>
+                    <property name="accel">
+                        <string>Alt+U</string>
+                    </property>
+                </widget>
+                <widget class="QLabel" row="2" column="1">
+                    <property name="name">
+                        <cstring>m_pixLabel</cstring>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>0</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="minimumSize">
+                        <size>
+                            <width>96</width>
+                            <height>96</height>
+                        </size>
+                    </property>
+                    <property name="text">
+                        <string></string>
+                    </property>
+                </widget>
+                <spacer row="3" column="1">
+                    <property name="name">
+                        <cstring>spacer3_2</cstring>
+                    </property>
+                    <property name="orientation">
+                        <enum>Vertical</enum>
+                    </property>
+                    <property name="sizeType">
+                        <enum>Fixed</enum>
+                    </property>
+                    <property name="sizeHint">
+                        <size>
+                            <width>16</width>
+                            <height>19</height>
+                        </size>
+                    </property>
+                </spacer>
             </grid>
         </widget>
     </vbox>
--- trunk/extragear/libs/kipi-plugins/batchprocessimages/renameimageswidget.cpp #605271:605272
 @ -37,6 +37,7  @
 #include <qtimer.h>
 #include <qprogressdialog.h>
 #include <qgroupbox.h>
+#include <qpopupmenu.h>
 
 #include <libkipi/interface.h>
 #include <libkipi/imageinfo.h>
 @ -67,7 +68,13  @
     m_listView->setSorting(-1);
 
     readSettings();
-    
+
+	QPopupMenu* sortMenu = new QPopupMenu(this);
+	sortMenu->insertItem(i18n("Sort by Name"), BYNAME);
+	sortMenu->insertItem(i18n("Sort by Size"), BYSIZE);
+	sortMenu->insertItem(i18n("Sort by Date"), BYDATE);
+	m_sortButton->setPopup(sortMenu);
+
     connect(m_listView, SIGNAL(doubleClicked(QListViewItem*)),
             SLOT(slotListViewDoubleClicked(QListViewItem*)));
     connect(m_listView, SIGNAL(selectionChanged(QListViewItem*)),
 @ -86,16 +93,23  @
     connect(m_formatDateEdit, SIGNAL(textChanged(const QString&)),
             SLOT(slotOptionsChanged()));
 
-    connect(m_sortCombo, SIGNAL(activated(int)),
-            SLOT(slotOptionsChanged()));
-    connect(m_reverseSortCheck, SIGNAL(toggled(bool)),
-            SLOT(slotOptionsChanged()));
-
     connect(m_addButton, SIGNAL(clicked()),
             SLOT(slotAddImages()));
     connect(m_removeButton, SIGNAL(clicked()),
             SLOT(slotRemoveImage()));
+
+	connect(sortMenu, SIGNAL(activated(int)),
+			SLOT(sortList(int)) );
+	
+	connect(m_reverseList, SIGNAL(clicked()),
+			SLOT(reverseList()) );
+
+    connect(m_moveUp, SIGNAL(clicked()),
+            SLOT(moveCurrentItemUp()) );
     
+    connect(m_moveDown, SIGNAL(clicked()),
+            SLOT(moveCurrentItemDown()) );
+    
     m_timer = new QTimer(this);
     m_progress = new QProgressDialog(this, 0, true);
     connect(m_timer, SIGNAL(timeout()),
 @ -137,9 +151,6  @
     m_formatDateCheck->setChecked(config.readBoolEntry("FormatDate", false));
     m_formatDateEdit->setText(config.readEntry("FormatDateString", "%Y-%m-%d"));
 
-    m_sortCombo->setCurrentItem((enum SortOrder)(config.readNumEntry("SortMethod", 0))); 
-    m_reverseSortCheck->setChecked(config.readBoolEntry("ReverseOrder", false));
-
     slotOptionsChanged();
 }
 
 @ -156,8 +167,6  @
     config.writeEntry("FormatDate", m_formatDateCheck->isChecked());
     config.writeEntry("FormatDateString", m_formatDateEdit->text());
 
-    config.writeEntry("SortMethod", m_sortCombo->currentItem());
-    config.writeEntry("ReverseOrder", m_reverseSortCheck->isChecked());
     config.sync();
 }
 
 @ -194,34 +203,34  @
             SLOT(slotGotPreview(const KFileItem*, const QPixmap&)));
 }
 
-void RenameImagesWidget::updateListing()
+
+void RenameImagesWidget::sortList(int intSortOrder)
 {
+    SortOrder sortOrder = static_cast<SortOrder>(intSortOrder);
+
     for (QListViewItem* it = m_listView->firstChild(); it;
          it = it->nextSibling())
     {
         BatchProcessImagesItem* item = static_cast<BatchProcessImagesItem*>(it);
 
-        switch (m_sortCombo->currentItem())
+        switch (sortOrder)
         {
         case(BYNAME):
         {
-            item->setKey(item->text(1),
-                         m_reverseSortCheck->isChecked());
+            item->setKey(item->text(1), false);
             break;
         }
         case(BYSIZE):
         {
             QFileInfo fi(item->pathSrc());
-            item->setKey(QString::number(fi.size()),
-                         m_reverseSortCheck->isChecked());
+            item->setKey(QString::number(fi.size()), false);
             break;
         }
         case(BYDATE):
         {
             KURL url(item->pathSrc());
             KIPI::ImageInfo info = m_interface->info(url);
-            item->setKey(info.time().toString(Qt::ISODate),
-                         m_reverseSortCheck->isChecked());
+            item->setKey(info.time().toString(Qt::ISODate), false);
             break;
         }
         }
 @ -233,6 +242,56  @
     m_listView->sort();
     m_listView->setSorting(-1);
 
+    updateListing();
+}
+
+
+void RenameImagesWidget::reverseList()
+{
+    if (m_listView->childCount() < 2) return;
+
+    QListViewItem* lastItem = m_listView->lastItem();
+
+    while (m_listView->firstChild() != lastItem) {
+        m_listView->firstChild()->moveItem(lastItem);
+    }
+
+    updateListing();
+}
+
+
+void RenameImagesWidget::moveCurrentItemUp() {
+    QListViewItem* currentItem = m_listView->currentItem();
+    if (!currentItem) return;
+
+    for (QListViewItem* previousItem = m_listView->firstChild(); previousItem;
+         previousItem = previousItem->nextSibling()) 
+    {
+        if (previousItem->nextSibling() == currentItem) {
+            previousItem->moveItem(currentItem);
+            break;
+        }
+    }
+
+    updateListing();
+}
+
+
+void RenameImagesWidget::moveCurrentItemDown() {
+    QListViewItem* currentItem = m_listView->currentItem();
+    if (!currentItem) return;
+    
+    QListViewItem* nextItem = currentItem->nextSibling();
+    if (nextItem) {
+        currentItem->moveItem(nextItem);
+    }
+
+    updateListing();
+}
+
+
+void RenameImagesWidget::updateListing()
+{
     int pos = 0;
     for (QListViewItem* it = m_listView->firstChild(); it;
          it = it->nextSibling())
--- trunk/extragear/libs/kipi-plugins/batchprocessimages/renameimageswidget.h #605271:605272
 @ -88,6 +88,12  @
 
     void slotAddImages();
     void slotRemoveImage();
+
+	void sortList(int);
+	void reverseList();
+
+	void moveCurrentItemUp();
+	void moveCurrentItemDown();
 };
 
 }


More information about the Kde-imaging mailing list