[Kde-imaging] extragear/graphics/kipi-plugins/slideshow
Valerio Fuoglio
valerio.fuoglio at gmail.com
Sun Sep 14 18:29:26 CEST 2008
SVN commit 860923 by vfuoglio:
Fixed bug : "Add" button doesn't work.
Dropped some KDE3 includes
CCMAIL: kde-imaging at kde.org
M +4 -8 listimageitems.cpp
M +7 -7 listimageitems.h
M +84 -107 maindialog.cpp
M +1 -1 maindialog.h
--- trunk/extragear/graphics/kipi-plugins/slideshow/listimageitems.cpp #860922:860923
@@ -21,7 +21,6 @@
* ============================================================ */
// QT includes
-
#include <qstring.h>
#include <qwidget.h>
#include <qevent.h>
@@ -29,28 +28,25 @@
#include <q3dragobject.h>
#include <qfileinfo.h>
#include <q3listbox.h>
-//Added by qt3to4:
#include <QDropEvent>
#include <QDragEnterEvent>
// KDE includes
-
-#include <k3listbox.h>
#include <kurl.h>
// Local includes
-
#include "listimageitems.h"
#include "listimageitems.moc"
namespace KIPISlideShowPlugin
{
-ListImageItems::ListImageItems(QWidget *parent, const char *name)
- : K3ListBox(parent, name)
+ListImageItems::ListImageItems(QWidget *parent)
+ : QListWidget(parent)
{
- setSelectionMode (Q3ListBox::Extended);
+ setSelectionMode(QAbstractItemView::SingleSelection);
setAcceptDrops(true);
+ setSortingEnabled(false);
}
void ListImageItems::dragEnterEvent(QDragEnterEvent *e)
--- trunk/extragear/graphics/kipi-plugins/slideshow/listimageitems.h #860922:860923
@@ -29,23 +29,23 @@
#include <QString>
#include <QDropEvent>
#include <QDragEnterEvent>
+#include <QListWidget>
+#include <QListWidgetItem>
// KDE includes
-
-#include <k3listbox.h>
#include <kurl.h>
namespace KIPISlideShowPlugin
{
-class ImageItem : public Q3ListBoxText
+class ImageItem : public QListWidgetItem
{
public:
- ImageItem(Q3ListBox * parent, QString const & name, QString const & comments, QString const & path,
+ ImageItem(QListWidget* parent, QString const & name, QString const & comments, QString const & path,
QString const & album)
- : Q3ListBoxText(parent), _name(name), _comments(comments), _path(path), _album(album)
+ : QListWidgetItem(parent), _name(name), _comments(comments), _path(path), _album(album)
{}
QString comments() { return _comments; }
@@ -62,13 +62,13 @@
QString _album;
};
-class ListImageItems : public K3ListBox
+class ListImageItems : public QListWidget
{
Q_OBJECT
public:
- ListImageItems(QWidget *parent=0, const char *name=0);
+ ListImageItems(QWidget *parent=0);
signals:
--- trunk/extragear/graphics/kipi-plugins/slideshow/maindialog.cpp #860922:860923
@@ -83,8 +83,8 @@
connect(m_delaySpinBox, SIGNAL(valueChanged(int)), this, SLOT(slotDelayChanged()));
connect(m_effectsComboBox, SIGNAL(activated(int)), this, SLOT(slotEffectChanged()));
- connect( m_ImagesFilesListBox, SIGNAL( currentChanged( Q3ListBoxItem * ) ),
- this, SLOT( slotImagesFilesSelected(Q3ListBoxItem *) ) );
+ connect( m_ImagesFilesListBox, SIGNAL( currentRowChanged( int ) ),
+ this, SLOT( slotImagesFilesSelected( int ) ) );
connect(m_ImagesFilesListBox, SIGNAL( addedDropItems(KUrl::List) ),
this, SLOT( slotAddDropItems(KUrl::List)));
connect( m_ImagesFilesButtonAdd, SIGNAL( clicked() ),
@@ -244,7 +244,7 @@
bool MainDialog::updateUrlList()
{
- for (uint i=0 ; i < m_ImagesFilesListBox->count() ; ++i)
+ for (int i=0 ; i < m_ImagesFilesListBox->count() ; ++i)
{
ImageItem *pitem = static_cast<ImageItem*>( m_ImagesFilesListBox->item(i) );
if (!QFile::exists(pitem->path()))
@@ -261,8 +261,9 @@
// --- Slots
-void MainDialog::slotImagesFilesSelected( Q3ListBoxItem *item )
+void MainDialog::slotImagesFilesSelected( int row )
{
+ QListWidgetItem* item = m_ImagesFilesListBox->item(row);
if ( !item || m_ImagesFilesListBox->count() == 0 )
{
@@ -287,40 +288,42 @@
connect(m_thumbJob, SIGNAL(failed(const KFileItem&)),
SLOT(slotFailedPreview(const KFileItem&)));
- int index = m_ImagesFilesListBox->index ( item );
+ int index = m_ImagesFilesListBox->row ( item );
m_label7->setText(i18n("Image no. %1",QString::number(index + 1)));
}
void MainDialog::addItems(const KUrl::List& fileList)
{
- if (fileList.isEmpty()) return;
- KUrl::List Files = fileList;
+ if (fileList.isEmpty()) kDebug()<<"IS EMPTY!"<<endl;
+ if (fileList.isEmpty()) return;
+ KUrl::List Files = fileList;
- for ( KUrl::List::Iterator it = Files.begin() ; it != Files.end() ; ++it )
- {
- KUrl currentFile = *it;
+ for ( KUrl::List::Iterator it = Files.begin() ; it != Files.end() ; ++it )
+ {
+ KUrl currentFile = *it;
- QFileInfo fi(currentFile.path());
- QString Temp = fi.path();
- QString albumName = Temp.section('/', -1);
+ QFileInfo fi(currentFile.path());
+ QString Temp = fi.path();
+ QString albumName = Temp.section('/', -1);
- KIPI::ImageInfo info = m_sharedData->interface->info(currentFile);
- QString comments = info.description();
+ KIPI::ImageInfo info = m_sharedData->interface->info(currentFile);
+ QString comments = info.description();
- ImageItem *item = new ImageItem( m_ImagesFilesListBox,
- currentFile.path().section('/', -1 ), // File name with extension.
- comments, // Image comments.
- currentFile.path().section('/', 0, -1), // Complete path with file name.
- albumName // Album name.
- );
+ ImageItem *item = new ImageItem( m_ImagesFilesListBox,
+ currentFile.path().section('/', -1 ), // File name with extension.
+ comments, // Image comments.
+ currentFile.path().section('/', 0, -1), // Complete path with file name.
+ albumName // Album name.
+ );
- item->setName( currentFile.path().section('/', -1) );
- }
+ item->setName( currentFile.path().section('/', -1) );
+ m_ImagesFilesListBox->insertItem(m_ImagesFilesListBox->count()-1, item);
+ }
- ShowNumberImages( m_ImagesFilesListBox->count() );
- m_ImagesFilesListBox->setCurrentItem( m_ImagesFilesListBox->count()-1) ;
- slotImagesFilesSelected(m_ImagesFilesListBox->item(m_ImagesFilesListBox->currentItem()));
- m_ImagesFilesListBox->centerCurrentItem();
+ ShowNumberImages( m_ImagesFilesListBox->count() );
+ m_ImagesFilesListBox->setCurrentItem(m_ImagesFilesListBox->item(m_ImagesFilesListBox->count()-1)) ;
+ slotImagesFilesSelected(m_ImagesFilesListBox->currentRow());
+ m_ImagesFilesListBox->scrollToItem(m_ImagesFilesListBox->currentItem());
}
@@ -331,12 +334,9 @@
void MainDialog::slotImagesFilesButtonAdd( void )
{
- KIPIPlugins::ImageDialog dlg(this, m_sharedData->interface, true, false);
+ KIPIPlugins::ImageDialog dlg(this, m_sharedData->interface,false);
KUrl::List urls = dlg.urls();
- kDebug()<<dlg.urls().isEmpty()<<endl;
- kDebug()<<urls.isEmpty()<<endl;
-
if (!urls.isEmpty())
{
addItems(urls);
@@ -346,114 +346,91 @@
void MainDialog::slotImagesFilesButtonDelete( void )
{
- for (uint i = 0 ; i < m_ImagesFilesListBox->count() ; ++i)
- {
- if (m_ImagesFilesListBox->isSelected(i))
- {
- m_ImagesFilesListBox->removeItem(i);
- m_ImagesFilesListBox->setCurrentItem(i);
- --i;
- }
- }
+ int Index = m_ImagesFilesListBox->currentRow();
+ ImageItem* pitem = static_cast<ImageItem*>(m_ImagesFilesListBox->takeItem(Index));
+ delete pitem;
- m_ImagesFilesListBox->setSelected(m_ImagesFilesListBox->item(m_ImagesFilesListBox->currentItem()), true);
- slotImagesFilesSelected(m_ImagesFilesListBox->item(m_ImagesFilesListBox->currentItem()));
- ShowNumberImages( m_ImagesFilesListBox->count() );
+ slotImagesFilesSelected(m_ImagesFilesListBox->currentRow());
+ ShowNumberImages( m_ImagesFilesListBox->count() );
}
void MainDialog::slotImagesFilesButtonUp( void )
{
- int Cpt = 0;
+ int Cpt = 0;
- for (uint i = 0 ; i < m_ImagesFilesListBox->count() ; ++i)
- if (m_ImagesFilesListBox->isSelected(i))
- ++Cpt;
+ for (int i = 0 ; i < m_ImagesFilesListBox->count() ; ++i)
+ if (m_ImagesFilesListBox->currentRow() == i)
+ ++Cpt;
- if (Cpt == 0)
- return;
+ if (Cpt == 0)
+ return;
- if (Cpt > 1)
- {
- KMessageBox::error(this, i18n("You can only move up one image file at once."));
- return;
- }
+ if (Cpt > 1)
+ {
+ KMessageBox::error(this, i18n("You can only move up one image file at once."));
+ return;
+ }
- unsigned int Index = m_ImagesFilesListBox->currentItem();
+ unsigned int Index = m_ImagesFilesListBox->currentRow();
- if (Index == 0)
- return;
+ if (Index == 0)
+ return;
- ImageItem *pitem = static_cast<ImageItem*>( m_ImagesFilesListBox->item(Index) );
- QString path(pitem->path());
- QString comment(pitem->comments());
- QString name(pitem->name());
- QString album(pitem->album());
- m_ImagesFilesListBox->removeItem(Index);
- ImageItem *item = new ImageItem( 0, name, comment, path, album );
- item->setName( name );
- m_ImagesFilesListBox->insertItem(item, Index-1);
- m_ImagesFilesListBox->setSelected(Index-1, true);
- m_ImagesFilesListBox->setCurrentItem(Index-1);
+ ImageItem* pitem = static_cast<ImageItem*>(m_ImagesFilesListBox->takeItem(Index));
+ m_ImagesFilesListBox->insertItem(Index-1, pitem);
+ m_ImagesFilesListBox->setCurrentItem(pitem);
}
void MainDialog::slotImagesFilesButtonDown( void )
{
- int Cpt = 0;
+ int Cpt = 0;
- for (uint i = 0 ; i < m_ImagesFilesListBox->count() ; ++i)
- if (m_ImagesFilesListBox->isSelected(i))
- ++Cpt;
+ for (int i = 0 ; i < m_ImagesFilesListBox->count() ; ++i)
+ if (m_ImagesFilesListBox->currentRow() == i)
+ ++Cpt;
- if (Cpt == 0)
- return;
+ if (Cpt == 0)
+ return;
- if (Cpt > 1)
- {
- KMessageBox::error(this, i18n("You can only move down one image file at once."));
- return;
- }
+ if (Cpt > 1)
+ {
+ KMessageBox::error(this, i18n("You can only move down one image file at once."));
+ return;
+ }
- unsigned int Index = m_ImagesFilesListBox->currentItem();
+ int Index = m_ImagesFilesListBox->currentRow();
- if (Index == m_ImagesFilesListBox->count())
- return;
+ if (Index == m_ImagesFilesListBox->count())
+ return;
- ImageItem *pitem = static_cast<ImageItem*>( m_ImagesFilesListBox->item(Index) );
- QString path(pitem->path());
- QString comment(pitem->comments());
- QString name(pitem->name());
- QString album(pitem->name());
- m_ImagesFilesListBox->removeItem(Index);
- ImageItem *item = new ImageItem( 0, name, comment, path, album );
- item->setName( name );
- m_ImagesFilesListBox->insertItem(item, Index+1);
- m_ImagesFilesListBox->setSelected(Index+1, true);
- m_ImagesFilesListBox->setCurrentItem(Index+1);
+ ImageItem* pitem = static_cast<ImageItem*>(m_ImagesFilesListBox->takeItem(Index));
+ m_ImagesFilesListBox->insertItem(Index+1, pitem);
+ m_ImagesFilesListBox->setCurrentItem(pitem);
}
void MainDialog::slotOpenGLToggled( void )
{
- if (m_openglCheckBox->isChecked()) {
- loadEffectNamesGL();
- }
- else {
- loadEffectNames();
- }
+ if (m_openglCheckBox->isChecked()) {
+ loadEffectNamesGL();
+ }
+ else {
+ loadEffectNames();
+ }
- ShowNumberImages( m_ImagesFilesListBox->count() );
+ ShowNumberImages( m_ImagesFilesListBox->count() );
- slotEffectChanged();
+ slotEffectChanged();
}
void MainDialog::slotEffectChanged( void )
{
- bool isKB = m_effectsComboBox->currentText() == i18n("Ken Burns");
+bool isKB = m_effectsComboBox->currentText() == i18n("Ken Burns");
- m_printNameCheckBox->setEnabled(!isKB);
- m_printProgressCheckBox->setEnabled(!isKB);
- m_printCommentsCheckBox->setEnabled(!isKB);
- m_sharedData->page_caption->setEnabled((!isKB) &&
- m_printCommentsCheckBox->isChecked());
+m_printNameCheckBox->setEnabled(!isKB);
+m_printProgressCheckBox->setEnabled(!isKB);
+m_printCommentsCheckBox->setEnabled(!isKB);
+m_sharedData->page_caption->setEnabled((!isKB) &&
+ m_printCommentsCheckBox->isChecked());
}
void MainDialog::slotDelayChanged( void )
--- trunk/extragear/graphics/kipi-plugins/slideshow/maindialog.h #860922:860923
@@ -57,7 +57,7 @@
void slotUseMillisecondsToggled( void );
void SlotPortfolioDurationChanged ( int );
- void slotImagesFilesSelected( Q3ListBoxItem *item );
+ void slotImagesFilesSelected( int );
void slotAddDropItems(KUrl::List filesUrl);
void slotImagesFilesButtonAdd( void );
void slotImagesFilesButtonDelete( void );
More information about the Kde-imaging
mailing list