SVN commit 828907 by blackie: This completes the ImportDialog refactoring. M +3 -0 ImageRow.h M +1 -2 Import.cpp M +1 -21 ImportDialog.cpp M +6 -6 ImportDialog.h M +5 -6 ImportHandler.cpp M +6 -6 ImportHandler.h M +10 -0 ImportMatcher.h M +10 -0 ImportSettings.cpp M +10 -1 ImportSettings.h --- trunk/extragear/graphics/kphotoalbum/ImportExport/ImageRow.h #828906:828907 @@ -10,6 +10,9 @@ class ImportDialog; class KimFileReader; +/** + * This class represent a single row on the ImageDialog's "select widgets to import" page. + */ class ImageRow :public QObject { Q_OBJECT --- trunk/extragear/graphics/kphotoalbum/ImportExport/Import.cpp #828906:828907 @@ -74,11 +74,10 @@ return; } - bool ok = dialog.exec( &kimFileReader, fileName, m_kimFileUrl ); if ( ok ) { - ImportHandler handler( &dialog ); + ImportHandler handler; handler.exec(dialog.settings(), &kimFileReader); } --- trunk/extragear/graphics/kphotoalbum/ImportExport/ImportDialog.cpp #828906:828907 @@ -22,40 +22,26 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include #include -#include -#include -#include #include #include #include #include "Settings/SettingsData.h" #include "ImportMatcher.h" #include -#include "Utilities/Util.h" -#include "DB/ImageDB.h" #include -#include "Browser/BrowserWidget.h" #include -#include -#include -#include -#include #include -#include "DB/CategoryCollection.h" #include "DB/ImageInfo.h" #include "MiniViewer.h" #include "XMLDB/Database.h" -#include #include #include #include @@ -77,13 +63,6 @@ _kimFile = kimFileURL; -#ifdef KDAB_TEMPORARILY_REMOVED - connect( this, SIGNAL( failedToCopy( QStringList ) ), &m_importHandler, SLOT( aCopyFailed( QStringList ) ) ); // JKP -#else // KDAB_TEMPORARILY_REMOVED - qWarning("Code commented out in ImportDialog::ImportDialog"); -#endif //KDAB_TEMPORARILY_REMOVED - - QByteArray indexXML = _kimFileReader->indexXML(); if ( indexXML.isNull() ) return false; @@ -426,6 +405,7 @@ settings.setExternalSource( _externalSource ); settings.setKimFile( _kimFile ); settings.setBaseURL( _baseUrl ); + settings.setImportMatchers( &_matchers ); return settings; } --- trunk/extragear/graphics/kphotoalbum/ImportExport/ImportDialog.h #828906:828907 @@ -23,11 +23,10 @@ #include "ImportHandler.h" #include #include -#include "Utilities/Util.h" // JKP #include -#include #include #include +#include "ImportMatcher.h" class KTemporaryFile; class KLineEdit; @@ -43,6 +42,9 @@ class ImageRow; class KimFileReader; +/** + * This is the wizard that configures the import process + */ class ImportDialog :public KAssistantDialog { Q_OBJECT @@ -51,8 +53,6 @@ bool exec( KimFileReader* kimFileReader, const QString& fileName, const KUrl& kimFilePath ); ImportSettings settings(); - friend class ImportHandler; // JKP - protected: friend class ImageRow; @@ -85,11 +85,11 @@ KPageWidgetItem* _categoryMatcherPage; KPageWidgetItem* _dummy; ImportMatcher* _categoryMatcher; - QList _matchers; + ImportMatchers _matchers; QList< ImageRow* > _imagesSelect; KTemporaryFile* _tmp; bool _externalSource; - KUrl _kimFile; //JKP + KUrl _kimFile; bool _hasFilled; QString _baseUrl; KimFileReader* _kimFileReader; --- trunk/extragear/graphics/kphotoalbum/ImportExport/ImportHandler.cpp #828906:828907 @@ -8,18 +8,16 @@ #include #include #include -#include "ImportDialog.h" #include #include #include "MainWindow/Window.h" #include #include "DB/ImageDB.h" -#include // JKP #include "ImportMatcher.h" #include "Browser/BrowserWidget.h" -ImportExport::ImportHandler::ImportHandler( ImportDialog* import ) - :m_import(import), m_finishedPressed(false), _progress(0), _reportUnreadableFiles( true ) +ImportExport::ImportHandler::ImportHandler() + : m_finishedPressed(false), _progress(0), _reportUnreadableFiles( true ) { } @@ -88,7 +86,7 @@ } if (!succeeded) - emit m_import->failedToCopy( tried ); + aCopyFailed( tried ); } bool ImportExport::ImportHandler::copyFilesFromZipFile() @@ -149,7 +147,8 @@ DB::ImageDB::instance()->addImages( list ); // Run though the categories - for( QList::Iterator grpIt = m_import->_matchers.begin(); grpIt != m_import->_matchers.end(); ++grpIt ) { + const ImportMatchers* matchers = m_settings.importMatchers(); + for( QList::ConstIterator grpIt = matchers->begin(); grpIt != matchers->end(); ++grpIt ) { QString otherGrp = (*grpIt)->_otherCategory; QString myGrp = (*grpIt)->_myCategory; --- trunk/extragear/graphics/kphotoalbum/ImportExport/ImportHandler.h #828906:828907 @@ -11,17 +11,18 @@ namespace ImportExport { class KimFileReader; -class ImportDialog; - +/** + * This class contains the business logic for the import process + */ class ImportHandler :public QObject { Q_OBJECT public: - ImportHandler( ImportDialog* import ); + ImportHandler(); bool exec( const ImportSettings& settings, KimFileReader* kimFileReader ); -public: // JKP +private: void copyFromExternal(); void copyNextFromExternal(); bool copyFilesFromZipFile(); @@ -32,8 +33,7 @@ void aCopyFailed( QStringList files ); void aCopyJobCompleted( KJob* ); -public: // JKP - ImportDialog* m_import; +private: Utilities::UniqNameMap m_nameMap; bool m_finishedPressed; DB::ImageInfoList _pendingCopies; --- trunk/extragear/graphics/kphotoalbum/ImportExport/ImportMatcher.h #828906:828907 @@ -29,6 +29,9 @@ namespace ImportExport { +/** + * This class encaptualte a single row in an ImportMatcher. + */ class CategoryMatch { public: CategoryMatch( bool allowNew, const QString& categort, QStringList items, QWidget* parent, QGridLayout* grid, int row ); @@ -38,6 +41,11 @@ }; +/** + * This class is the configuration page for chooseing the matching between + * the .kim file and the DB's items (e.g. .kim says People, DB say + * Persons). + */ class ImportMatcher :public QScrollArea { Q_OBJECT @@ -51,6 +59,8 @@ QList _matchers; }; +typedef QList ImportMatchers; + } #endif /* IMPORTMATCHER_H */ --- trunk/extragear/graphics/kphotoalbum/ImportExport/ImportSettings.cpp #828906:828907 @@ -49,3 +49,13 @@ { return m_baseURL; } + +void ImportExport::ImportSettings::setImportMatchers( const ImportMatchers* matchers ) +{ + m_importMatchers = matchers; +} + +const ImportExport::ImportMatchers* ImportExport::ImportSettings::importMatchers() const +{ + return m_importMatchers; +} --- trunk/extragear/graphics/kphotoalbum/ImportExport/ImportSettings.h #828906:828907 @@ -3,10 +3,15 @@ #include #include "DB/ImageInfoList.h" - +#include "ImportMatcher.h" namespace ImportExport { +/** + * The class contains all the data that is transported between the + * ImportDialog, and the ImportHandler. The purpose of this class is to + * decouple the above two. + */ class ImportSettings { public: @@ -25,12 +30,16 @@ void setBaseURL( const KUrl& url ); KUrl baseURL() const; + void setImportMatchers( const ImportMatchers* matchers ); + const ImportMatchers* importMatchers() const; + private: DB::ImageInfoList m_selectedImages; QString m_destination; bool m_externalSource; KUrl m_kimFile; KUrl m_baseURL; + const ImportMatchers* m_importMatchers; }; }