~ubuntu-branches/ubuntu/precise/gwenview/precise-proposed

« back to all changes in this revision

Viewing changes to app/kipiinterface.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:54 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20111215141754-z043hyx69dulbggf
Tags: upstream-4.7.90
ImportĀ upstreamĀ versionĀ 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// vim: set tabstop=4 shiftwidth=4 noexpandtab:
 
1
// vim: set tabstop=4 shiftwidth=4 expandtab:
2
2
/*
3
3
Gwenview: an image viewer
4
4
Copyright 2000-2008 AurĆ©lien GĆ¢teau <agateau@kde.org>
50
50
#include <lib/mimetypeutils.h>
51
51
#include <lib/semanticinfo/sorteddirmodel.h>
52
52
 
53
 
namespace Gwenview {
 
53
namespace Gwenview
 
54
{
54
55
#undef ENABLE_LOG
55
56
#undef LOG
56
57
 
61
62
#define LOG(x) ;
62
63
#endif
63
64
 
64
 
 
65
 
class KIPIImageInfo : public KIPI::ImageInfoShared {
66
 
        static const QRegExp sExtensionRE;
 
65
class KIPIImageInfo : public KIPI::ImageInfoShared
 
66
{
 
67
    static const QRegExp sExtensionRE;
67
68
public:
68
 
        KIPIImageInfo(KIPI::Interface* interface, const KUrl& url) : KIPI::ImageInfoShared(interface, url) {}
69
 
 
70
 
        QString title() {
71
 
                QString txt=_url.fileName();
72
 
                txt.replace('_', ' ');
73
 
                txt.remove(sExtensionRE);
74
 
                return txt;
75
 
        }
76
 
 
77
 
        QString description() {
78
 
                if (!_url.isLocalFile()) return QString();
79
 
 
80
 
                JpegContent content;
81
 
                bool ok=content.load(_url.toLocalFile());
82
 
                if (!ok) return QString();
83
 
 
84
 
                return content.comment();
85
 
        }
86
 
 
87
 
        void setDescription(const QString&) {}
88
 
 
89
 
        int angle() {
90
 
                loadMetaInfo();
91
 
 
92
 
                if (!mMetaInfo.isValid()) {
93
 
                        return 0;
94
 
                }
95
 
 
96
 
                const KFileMetaInfoItem& mii = mMetaInfo.item("http://freedesktop.org/standards/xesam/1.0/core#orientation");
97
 
                bool ok = false;
98
 
                const Orientation orientation = (Orientation)mii.value().toInt(&ok);
99
 
                if (!ok) {
100
 
                        return 0;
101
 
                }
102
 
 
103
 
                switch(orientation) {
104
 
                case NOT_AVAILABLE:
105
 
                case NORMAL:
106
 
                        return 0;
107
 
 
108
 
                case ROT_90:
109
 
                        return 90;
110
 
 
111
 
                case ROT_180:
112
 
                        return 180;
113
 
 
114
 
                case ROT_270:
115
 
                        return 270;
116
 
 
117
 
                case HFLIP:
118
 
                case VFLIP:
119
 
                case TRANSPOSE:
120
 
                case TRANSVERSE:
121
 
                        kWarning() << "Can't represent an orientation value of" << orientation << "as an angle (" << _url << ')';
122
 
                        return 0;
123
 
                }
124
 
 
125
 
                kWarning() << "Don't know how to handle an orientation value of" << orientation << '(' << _url << ')';
126
 
                return 0;
127
 
        }
128
 
 
129
 
        QMap<QString,QVariant> attributes() {
130
 
                return QMap<QString,QVariant>();
131
 
        }
132
 
 
133
 
        void delAttributes( const QStringList& ) {}
134
 
 
135
 
        void clearAttributes() {}
136
 
 
137
 
        void addAttributes(const QMap<QString, QVariant>&) {}
 
69
    KIPIImageInfo(KIPI::Interface* interface, const KUrl& url) : KIPI::ImageInfoShared(interface, url) {}
 
70
 
 
71
    QString title()
 
72
    {
 
73
        QString txt = _url.fileName();
 
74
        txt.replace('_', ' ');
 
75
        txt.remove(sExtensionRE);
 
76
        return txt;
 
77
    }
 
78
 
 
79
    QString description()
 
80
    {
 
81
        if (!_url.isLocalFile()) return QString();
 
82
 
 
83
        JpegContent content;
 
84
        bool ok = content.load(_url.toLocalFile());
 
85
        if (!ok) return QString();
 
86
 
 
87
        return content.comment();
 
88
    }
 
89
 
 
90
    void setDescription(const QString&)
 
91
    {}
 
92
 
 
93
    int angle()
 
94
    {
 
95
        loadMetaInfo();
 
96
 
 
97
        if (!mMetaInfo.isValid()) {
 
98
            return 0;
 
99
        }
 
100
 
 
101
        const KFileMetaInfoItem& mii = mMetaInfo.item("http://freedesktop.org/standards/xesam/1.0/core#orientation");
 
102
        bool ok = false;
 
103
        const Orientation orientation = (Orientation)mii.value().toInt(&ok);
 
104
        if (!ok) {
 
105
            return 0;
 
106
        }
 
107
 
 
108
        switch (orientation) {
 
109
        case NOT_AVAILABLE:
 
110
        case NORMAL:
 
111
            return 0;
 
112
 
 
113
        case ROT_90:
 
114
            return 90;
 
115
 
 
116
        case ROT_180:
 
117
            return 180;
 
118
 
 
119
        case ROT_270:
 
120
            return 270;
 
121
 
 
122
        case HFLIP:
 
123
        case VFLIP:
 
124
        case TRANSPOSE:
 
125
        case TRANSVERSE:
 
126
            kWarning() << "Can't represent an orientation value of" << orientation << "as an angle (" << _url << ')';
 
127
            return 0;
 
128
        }
 
129
 
 
130
        kWarning() << "Don't know how to handle an orientation value of" << orientation << '(' << _url << ')';
 
131
        return 0;
 
132
    }
 
133
 
 
134
    QMap<QString, QVariant> attributes() {
 
135
        return QMap<QString, QVariant>();
 
136
    }
 
137
 
 
138
    void delAttributes(const QStringList&)
 
139
    {}
 
140
 
 
141
    void clearAttributes()
 
142
    {}
 
143
 
 
144
    void addAttributes(const QMap<QString, QVariant>&)
 
145
    {}
138
146
 
139
147
private:
140
 
        KFileMetaInfo mMetaInfo;
 
148
    KFileMetaInfo mMetaInfo;
141
149
 
142
 
        void loadMetaInfo() {
143
 
                if (!mMetaInfo.isValid()) {
144
 
                        mMetaInfo = KFileMetaInfo(_url);
145
 
                }
146
 
        }
 
150
    void loadMetaInfo()
 
151
    {
 
152
        if (!mMetaInfo.isValid()) {
 
153
            mMetaInfo = KFileMetaInfo(_url);
 
154
        }
 
155
    }
147
156
};
148
157
 
149
 
const QRegExp KIPIImageInfo::sExtensionRE("\\.[a-z0-9]+$", Qt::CaseInsensitive );
150
 
 
 
158
const QRegExp KIPIImageInfo::sExtensionRE("\\.[a-z0-9]+$", Qt::CaseInsensitive);
151
159
 
152
160
struct MenuInfo {
153
 
        QString mName;
154
 
        QList<QAction*> mActions;
155
 
        MenuInfo() {}
156
 
        MenuInfo(const QString& name) : mName(name) {}
 
161
    QString mName;
 
162
    QList<QAction*> mActions;
 
163
    MenuInfo() {}
 
164
    MenuInfo(const QString& name) : mName(name) {}
157
165
};
158
166
typedef QMap<KIPI::Category, MenuInfo> MenuInfoMap;
159
167
 
160
 
 
161
168
struct KIPIInterfacePrivate {
162
 
        KIPIInterface* that;
163
 
        MainWindow* mMainWindow;
164
 
        QMenu* mPluginMenu;
165
 
        KIPI::PluginLoader* mPluginLoader;
166
 
        KIPI::PluginLoader::PluginList mPluginQueue;
167
 
        MenuInfoMap mMenuInfoMap;
168
 
 
169
 
        void setupPluginsMenu() {
170
 
                mPluginMenu = static_cast<QMenu*>(
171
 
                        mMainWindow->factory()->container("plugins", mMainWindow));
172
 
                QObject::connect(mPluginMenu, SIGNAL(aboutToShow()),
173
 
                        that, SLOT(loadPlugins()) );
174
 
        }
175
 
 
176
 
        void createDummyPluginAction(const QString& text) {
177
 
                KAction* action = mMainWindow->actionCollection()->add<KAction>("dummy_plugin");
178
 
                action->setText(text);
179
 
                action->setShortcutConfigurable(false);
180
 
                action->setEnabled(false);
181
 
                mPluginMenu->addAction(action);
182
 
        }
 
169
    KIPIInterface* q;
 
170
    MainWindow* mMainWindow;
 
171
    QMenu* mPluginMenu;
 
172
    KIPI::PluginLoader* mPluginLoader;
 
173
    KIPI::PluginLoader::PluginList mPluginQueue;
 
174
    MenuInfoMap mMenuInfoMap;
 
175
 
 
176
    void setupPluginsMenu()
 
177
    {
 
178
        mPluginMenu = static_cast<QMenu*>(
 
179
                          mMainWindow->factory()->container("plugins", mMainWindow));
 
180
        QObject::connect(mPluginMenu, SIGNAL(aboutToShow()),
 
181
                         q, SLOT(loadPlugins()));
 
182
    }
 
183
 
 
184
    void createDummyPluginAction(const QString& text)
 
185
    {
 
186
        KAction* action = mMainWindow->actionCollection()->add<KAction>("dummy_plugin");
 
187
        action->setText(text);
 
188
        action->setShortcutConfigurable(false);
 
189
        action->setEnabled(false);
 
190
        mPluginMenu->addAction(action);
 
191
    }
183
192
};
184
193
 
185
194
KIPIInterface::KIPIInterface(MainWindow* mainWindow)
186
 
:KIPI::Interface(mainWindow)
187
 
, d(new KIPIInterfacePrivate) {
188
 
        d->that = this;
189
 
        d->mMainWindow = mainWindow;
190
 
        d->mPluginLoader = 0;
 
195
: KIPI::Interface(mainWindow)
 
196
, d(new KIPIInterfacePrivate)
 
197
{
 
198
    d->q = this;
 
199
    d->mMainWindow = mainWindow;
 
200
    d->mPluginLoader = 0;
191
201
 
192
 
        d->setupPluginsMenu();
193
 
        QObject::connect(d->mMainWindow->contextManager(), SIGNAL(selectionChanged()),
194
 
                this, SLOT(slotSelectionChanged()) );
195
 
        QObject::connect(d->mMainWindow->contextManager(), SIGNAL(currentDirUrlChanged()),
196
 
                this, SLOT(slotDirectoryChanged()) );
 
202
    d->setupPluginsMenu();
 
203
    QObject::connect(d->mMainWindow->contextManager(), SIGNAL(selectionChanged()),
 
204
                     this, SLOT(slotSelectionChanged()));
 
205
    QObject::connect(d->mMainWindow->contextManager(), SIGNAL(currentDirUrlChanged()),
 
206
                     this, SLOT(slotDirectoryChanged()));
197
207
#if 0
198
208
//TODO instead of delaying can we load them all at start-up to use actions somewhere else?
199
209
// delay a bit, so that it's called after loadPlugins()
200
 
        QTimer::singleShot( 0, this, SLOT( init()));
 
210
    QTimer::singleShot(0, this, SLOT(init()));
201
211
#endif
202
212
}
203
213
 
204
 
 
205
 
KIPIInterface::~KIPIInterface() {
206
 
        delete d;
207
 
}
208
 
 
209
 
 
210
 
static bool actionLessThan(QAction* a1, QAction* a2) {
211
 
        QString a1Text = a1->text().replace("&", "");
212
 
        QString a2Text = a2->text().replace("&", "");
213
 
        return QString::compare(a1Text, a2Text, Qt::CaseInsensitive) < 0;
214
 
}
215
 
 
216
 
 
217
 
void KIPIInterface::loadPlugins() {
218
 
        // Already done
219
 
        if (d->mPluginLoader) {
220
 
                return;
221
 
        }
222
 
 
223
 
        d->mMenuInfoMap[KIPI::ImagesPlugin]      = MenuInfo(i18nc("@title:menu", "Images"));
224
 
        d->mMenuInfoMap[KIPI::EffectsPlugin]     = MenuInfo(i18nc("@title:menu", "Effects"));
225
 
        d->mMenuInfoMap[KIPI::ToolsPlugin]       = MenuInfo(i18nc("@title:menu", "Tools"));
226
 
        d->mMenuInfoMap[KIPI::ImportPlugin]      = MenuInfo(i18nc("@title:menu", "Import"));
227
 
        d->mMenuInfoMap[KIPI::ExportPlugin]      = MenuInfo(i18nc("@title:menu", "Export"));
228
 
        d->mMenuInfoMap[KIPI::BatchPlugin]       = MenuInfo(i18nc("@title:menu", "Batch Processing"));
229
 
        d->mMenuInfoMap[KIPI::CollectionsPlugin] = MenuInfo(i18nc("@title:menu", "Collections"));
230
 
 
231
 
        d->mPluginLoader = new KIPI::PluginLoader(QStringList(), this);
232
 
        d->mPluginQueue = d->mPluginLoader->pluginList();
233
 
        d->createDummyPluginAction(i18n("Loading..."));
234
 
        loadOnePlugin();
235
 
}
236
 
 
237
 
void KIPIInterface::loadOnePlugin() {
238
 
        while (!d->mPluginQueue.isEmpty()) {
239
 
                KIPI::PluginLoader::Info* pluginInfo = d->mPluginQueue.takeFirst();
240
 
                if (!pluginInfo->shouldLoad()) {
241
 
                        continue;
242
 
                }
243
 
 
244
 
                KIPI::Plugin* plugin = pluginInfo->plugin();
245
 
                if (!plugin) {
246
 
                        kWarning() << "Plugin from library" << pluginInfo->library() << "failed to load";
247
 
                        continue;
248
 
                }
249
 
 
250
 
                plugin->setup(d->mMainWindow);
251
 
                QList<KAction*> actions = plugin->actions();
252
 
                Q_FOREACH(KAction* action, actions) {
253
 
                        KIPI::Category category = plugin->category(action);
254
 
 
255
 
                        if (!d->mMenuInfoMap.contains(category)) {
256
 
                                kWarning() << "Unknown category '" << category;
257
 
                                continue;
258
 
                        }
259
 
 
260
 
                        d->mMenuInfoMap[category].mActions << action;
261
 
                }
262
 
                // FIXME: Port
263
 
                //plugin->actionCollection()->readShortcutSettings();
264
 
 
265
 
                // If we reach this point, we just loaded one plugin. Go back to the
266
 
                // event loop. We will come back to load the remaining plugins or create
267
 
                // the menu later
268
 
                QMetaObject::invokeMethod(this, "loadOnePlugin", Qt::QueuedConnection);
269
 
                return;
270
 
        }
271
 
 
272
 
        // If we reach this point, all plugins have been loaded. We can fill the
273
 
        // menu
274
 
        bool atLeastOnePluginLoaded = false;
275
 
        MenuInfoMap::Iterator
276
 
                it = d->mMenuInfoMap.begin(),
277
 
                end = d->mMenuInfoMap.end();
278
 
        for (; it != end; ++it) {
279
 
                MenuInfo& info = it.value();
280
 
                if (!info.mActions.isEmpty()) {
281
 
                        QMenu* menu = d->mPluginMenu->addMenu(info.mName);
282
 
                        qSort(info.mActions.begin(), info.mActions.end(), actionLessThan);
283
 
                        Q_FOREACH(QAction* action, info.mActions) {
284
 
                                atLeastOnePluginLoaded = true;
285
 
                                menu->addAction(action);
286
 
                        }
287
 
                }
288
 
        }
289
 
 
290
 
        delete d->mMainWindow->actionCollection()->action("dummy_plugin");
291
 
        if (!atLeastOnePluginLoaded) {
292
 
                d->createDummyPluginAction(i18n("No Plugin Found"));
293
 
        }
294
 
}
295
 
 
296
 
 
297
 
QList<QAction*> KIPIInterface::pluginActions(KIPI::Category category) const {
298
 
        const_cast<KIPIInterface*>(this)->loadPlugins();
299
 
        return d->mMenuInfoMap.value(category).mActions;
300
 
}
301
 
 
302
 
 
303
 
void KIPIInterface::init() {
304
 
        slotDirectoryChanged();
305
 
        slotSelectionChanged();
306
 
}
307
 
 
308
 
KIPI::ImageCollection KIPIInterface::currentAlbum() {
309
 
        LOG("");
310
 
        const ContextManager* contextManager = d->mMainWindow->contextManager();
311
 
        const KUrl url = contextManager->currentDirUrl();
312
 
        const SortedDirModel* model = contextManager->dirModel();
313
 
 
314
 
        KUrl::List list;
315
 
        const int count = model->rowCount();
316
 
        for (int row = 0; row < count; ++row) {
317
 
                const QModelIndex& index = model->index(row, 0);
318
 
                const KFileItem item = model->itemForIndex(index);
319
 
                if (MimeTypeUtils::fileItemKind(item) == MimeTypeUtils::KIND_RASTER_IMAGE) {
320
 
                        list << item.targetUrl();
321
 
                }
322
 
        }
323
 
 
324
 
        return KIPI::ImageCollection(new ImageCollection(url, url.fileName(), list));
325
 
}
326
 
 
327
 
 
328
 
KIPI::ImageCollection KIPIInterface::currentSelection() {
329
 
        LOG("");
330
 
 
331
 
        KFileItemList fileList = d->mMainWindow->contextManager()->selectedFileItemList();
332
 
        KUrl::List list = fileList.urlList();
333
 
        KUrl url = d->mMainWindow->contextManager()->currentUrl();
334
 
        
335
 
        return KIPI::ImageCollection(new ImageCollection(url, url.fileName(), list));
336
 
}
337
 
 
338
 
 
339
 
QList<KIPI::ImageCollection> KIPIInterface::allAlbums() {
340
 
        LOG("");
341
 
        QList<KIPI::ImageCollection> list;
342
 
        list << currentAlbum() << currentSelection();
343
 
        return list;
344
 
}
345
 
 
346
 
 
347
 
KIPI::ImageInfo KIPIInterface::info(const KUrl& url) {
348
 
        LOG("");
349
 
        return KIPI::ImageInfo( new KIPIImageInfo(this, url) );
350
 
}
351
 
 
352
 
int KIPIInterface::features() const {
353
 
        return KIPI::HostAcceptNewImages;
 
214
KIPIInterface::~KIPIInterface()
 
215
{
 
216
    delete d;
 
217
}
 
218
 
 
219
static bool actionLessThan(QAction* a1, QAction* a2)
 
220
{
 
221
    QString a1Text = a1->text().replace("&", "");
 
222
    QString a2Text = a2->text().replace("&", "");
 
223
    return QString::compare(a1Text, a2Text, Qt::CaseInsensitive) < 0;
 
224
}
 
225
 
 
226
void KIPIInterface::loadPlugins()
 
227
{
 
228
    // Already done
 
229
    if (d->mPluginLoader) {
 
230
        return;
 
231
    }
 
232
 
 
233
    d->mMenuInfoMap[KIPI::ImagesPlugin]      = MenuInfo(i18nc("@title:menu", "Images"));
 
234
    d->mMenuInfoMap[KIPI::EffectsPlugin]     = MenuInfo(i18nc("@title:menu", "Effects"));
 
235
    d->mMenuInfoMap[KIPI::ToolsPlugin]       = MenuInfo(i18nc("@title:menu", "Tools"));
 
236
    d->mMenuInfoMap[KIPI::ImportPlugin]      = MenuInfo(i18nc("@title:menu", "Import"));
 
237
    d->mMenuInfoMap[KIPI::ExportPlugin]      = MenuInfo(i18nc("@title:menu", "Export"));
 
238
    d->mMenuInfoMap[KIPI::BatchPlugin]       = MenuInfo(i18nc("@title:menu", "Batch Processing"));
 
239
    d->mMenuInfoMap[KIPI::CollectionsPlugin] = MenuInfo(i18nc("@title:menu", "Collections"));
 
240
 
 
241
    d->mPluginLoader = new KIPI::PluginLoader(QStringList(), this);
 
242
    d->mPluginQueue = d->mPluginLoader->pluginList();
 
243
    d->createDummyPluginAction(i18n("Loading..."));
 
244
    loadOnePlugin();
 
245
}
 
246
 
 
247
void KIPIInterface::loadOnePlugin()
 
248
{
 
249
    while (!d->mPluginQueue.isEmpty()) {
 
250
        KIPI::PluginLoader::Info* pluginInfo = d->mPluginQueue.takeFirst();
 
251
        if (!pluginInfo->shouldLoad()) {
 
252
            continue;
 
253
        }
 
254
 
 
255
        KIPI::Plugin* plugin = pluginInfo->plugin();
 
256
        if (!plugin) {
 
257
            kWarning() << "Plugin from library" << pluginInfo->library() << "failed to load";
 
258
            continue;
 
259
        }
 
260
 
 
261
        plugin->setup(d->mMainWindow);
 
262
        QList<KAction*> actions = plugin->actions();
 
263
        Q_FOREACH(KAction * action, actions) {
 
264
            KIPI::Category category = plugin->category(action);
 
265
 
 
266
            if (!d->mMenuInfoMap.contains(category)) {
 
267
                kWarning() << "Unknown category '" << category;
 
268
                continue;
 
269
            }
 
270
 
 
271
            d->mMenuInfoMap[category].mActions << action;
 
272
        }
 
273
        // FIXME: Port
 
274
        //plugin->actionCollection()->readShortcutSettings();
 
275
 
 
276
        // If we reach this point, we just loaded one plugin. Go back to the
 
277
        // event loop. We will come back to load the remaining plugins or create
 
278
        // the menu later
 
279
        QMetaObject::invokeMethod(this, "loadOnePlugin", Qt::QueuedConnection);
 
280
        return;
 
281
    }
 
282
 
 
283
    // If we reach this point, all plugins have been loaded. We can fill the
 
284
    // menu
 
285
    bool atLeastOnePluginLoaded = false;
 
286
    MenuInfoMap::Iterator
 
287
    it = d->mMenuInfoMap.begin(),
 
288
    end = d->mMenuInfoMap.end();
 
289
    for (; it != end; ++it) {
 
290
        MenuInfo& info = it.value();
 
291
        if (!info.mActions.isEmpty()) {
 
292
            QMenu* menu = d->mPluginMenu->addMenu(info.mName);
 
293
            qSort(info.mActions.begin(), info.mActions.end(), actionLessThan);
 
294
            Q_FOREACH(QAction * action, info.mActions) {
 
295
                atLeastOnePluginLoaded = true;
 
296
                menu->addAction(action);
 
297
            }
 
298
        }
 
299
    }
 
300
 
 
301
    delete d->mMainWindow->actionCollection()->action("dummy_plugin");
 
302
    if (!atLeastOnePluginLoaded) {
 
303
        d->createDummyPluginAction(i18n("No Plugin Found"));
 
304
    }
 
305
}
 
306
 
 
307
QList<QAction*> KIPIInterface::pluginActions(KIPI::Category category) const
 
308
{
 
309
    const_cast<KIPIInterface*>(this)->loadPlugins();
 
310
    return d->mMenuInfoMap.value(category).mActions;
 
311
}
 
312
 
 
313
void KIPIInterface::init()
 
314
{
 
315
    slotDirectoryChanged();
 
316
    slotSelectionChanged();
 
317
}
 
318
 
 
319
KIPI::ImageCollection KIPIInterface::currentAlbum()
 
320
{
 
321
    LOG("");
 
322
    const ContextManager* contextManager = d->mMainWindow->contextManager();
 
323
    const KUrl url = contextManager->currentDirUrl();
 
324
    const SortedDirModel* model = contextManager->dirModel();
 
325
 
 
326
    KUrl::List list;
 
327
    const int count = model->rowCount();
 
328
    for (int row = 0; row < count; ++row) {
 
329
        const QModelIndex& index = model->index(row, 0);
 
330
        const KFileItem item = model->itemForIndex(index);
 
331
        if (MimeTypeUtils::fileItemKind(item) == MimeTypeUtils::KIND_RASTER_IMAGE) {
 
332
            list << item.targetUrl();
 
333
        }
 
334
    }
 
335
 
 
336
    return KIPI::ImageCollection(new ImageCollection(url, url.fileName(), list));
 
337
}
 
338
 
 
339
KIPI::ImageCollection KIPIInterface::currentSelection()
 
340
{
 
341
    LOG("");
 
342
 
 
343
    KFileItemList fileList = d->mMainWindow->contextManager()->selectedFileItemList();
 
344
    KUrl::List list = fileList.urlList();
 
345
    KUrl url = d->mMainWindow->contextManager()->currentUrl();
 
346
 
 
347
    return KIPI::ImageCollection(new ImageCollection(url, url.fileName(), list));
 
348
}
 
349
 
 
350
QList<KIPI::ImageCollection> KIPIInterface::allAlbums()
 
351
{
 
352
    LOG("");
 
353
    QList<KIPI::ImageCollection> list;
 
354
    list << currentAlbum() << currentSelection();
 
355
    return list;
 
356
}
 
357
 
 
358
KIPI::ImageInfo KIPIInterface::info(const KUrl& url)
 
359
{
 
360
    LOG("");
 
361
    return KIPI::ImageInfo(new KIPIImageInfo(this, url));
 
362
}
 
363
 
 
364
int KIPIInterface::features() const
 
365
{
 
366
    return KIPI::HostAcceptNewImages;
354
367
}
355
368
 
356
369
/**
357
370
 * KDirLister will pick up the image if necessary, so no updating is needed
358
371
 * here, it is however necessary to discard caches if the plugin preserves timestamp
359
372
 */
360
 
bool KIPIInterface::addImage(const KUrl&, QString&) {
361
 
//TODO  setContext(const KUrl& currentUrl, const KFileItemList& selection)?
362
 
        //Cache::instance()->invalidate( url );
363
 
        return true;
 
373
bool KIPIInterface::addImage(const KUrl&, QString&)
 
374
{
 
375
//TODO  setContext(const KUrl& currentUrl, const KFileItemList& selection)?
 
376
    //Cache::instance()->invalidate( url );
 
377
    return true;
364
378
}
365
379
 
366
 
void KIPIInterface::delImage(const KUrl&) {
 
380
void KIPIInterface::delImage(const KUrl&)
 
381
{
367
382
//TODO
368
383
}
369
384
 
370
 
void KIPIInterface::refreshImages( const KUrl::List&) {
 
385
void KIPIInterface::refreshImages(const KUrl::List&)
 
386
{
371
387
// TODO
372
388
}
373
389
 
374
 
KIPI::ImageCollectionSelector* KIPIInterface::imageCollectionSelector(QWidget *parent) {
375
 
        return new KIPIImageCollectionSelector(this, parent);
376
 
}
377
 
 
378
 
KIPI::UploadWidget* KIPIInterface::uploadWidget(QWidget *parent) {
379
 
        return (new KIPIUploadWidget(this, parent));
380
 
}
381
 
 
382
 
void KIPIInterface::slotSelectionChanged() {
383
 
        emit selectionChanged(!d->mMainWindow->contextManager()->selectedFileItemList().isEmpty());
384
 
}
385
 
 
386
 
 
387
 
void KIPIInterface::slotDirectoryChanged() {
388
 
        emit currentAlbumChanged(true);
 
390
KIPI::ImageCollectionSelector* KIPIInterface::imageCollectionSelector(QWidget *parent)
 
391
{
 
392
    return new KIPIImageCollectionSelector(this, parent);
 
393
}
 
394
 
 
395
KIPI::UploadWidget* KIPIInterface::uploadWidget(QWidget *parent)
 
396
{
 
397
    return (new KIPIUploadWidget(this, parent));
 
398
}
 
399
 
 
400
void KIPIInterface::slotSelectionChanged()
 
401
{
 
402
    emit selectionChanged(!d->mMainWindow->contextManager()->selectedFileItemList().isEmpty());
 
403
}
 
404
 
 
405
void KIPIInterface::slotDirectoryChanged()
 
406
{
 
407
    emit currentAlbumChanged(true);
389
408
}
390
409
 
391
410
} //namespace