summaryrefslogtreecommitdiffstats
path: root/libkipi/libkipi/interface.cpp
blob: e781b2398d01824aeb4037ec0910fbb0de46a8d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/* ============================================================
 * File   : interface.cpp
 * Authors: KIPI team developers (see AUTHORS files for details)
 *	    
 * Date   : 2004-02
 * Description :
 *
 * Copyright 2004 by the KIPI team
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU Library General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 *
 * ============================================================ */

/** @file interface.cpp */

// KDE includes.

#include <kdebug.h>
#include <kimageio.h>

// Local includes.
 
#include "pluginloader.h"
#include "interface.h"

/*!
  @enum KIPI::Features
  Not all host applications support the full subset of features that KIPI
  allows access to. As an example <a
  href="http://ktown.kde.org/kimdaba/">KimDaBa</a> do not support comments
  for albums. Thus before a plugin expect a decant value for the comment,
  it should check whether KIPI::AlbumsHaveComments are set. It does so
  using KIPI::Interface::hasFeature()
  When adding new items, remember to update "hasFeature( const TQString& feature )"
  and the hello world plugin.
  */

/*!
  \enum KIPI::AlbumsHaveComments
  This feature specify that albums have descriptions associated to them.
 */

/*!
  \enum KIPI::ImagesHasComments
  This feature specifies that images in the host application has descriptions associated to them.
 */

/*!
  \enum KIPI::ImagesHasTime
  This feature specifies that images has a date associated with it, which the host application can display and set
*/

/*!
  \enum KIPI::SupportsDateRanges
  This feature specify whether the host application supports that the user can specify a date range for images,
  like 1998-2000.
*/

/*!
  \enum KIPI::AcceptNewImages
  This feature specifies that the host application do accept new images.
  Use \ref ImageCollection::uploadPath to find the location to place the image, and
  \ref KIPI::Interface::addImage() to tell the host application about the new image.
*/

/*!
  \enum KIPI::ImageTitlesWritable
  This features specifies whether the plugin can change the title for images
*/

/*!
  \enum KIPI::AlbumsHaveCategory
  This feature specify that albums are category associated to them ('travels', 'friends', 'monuments', etc.).
*/

/*!
  \enum KIPI::AlbumsHaveCreationDate
  This feature specify that albums are a creation date associated to them.
*/

/*!
  \enum KIPI::AlbumsUseFirstImagePreview
  This feature specify that albums use the first image of the collection like preview.
  This flag is used in ImageGallery, CDArchiving, and FinDuplicateImages dialog for 
  to lauch a preview of the album.
*/


KIPI::Interface::Interface(TQObject *parent, const char *name )
    : TQObject(parent, name)
{
}

KIPI::Interface::~Interface()
{
}

/**
   Tells the host app that the following images has changed on disk
*/
void KIPI::Interface::refreshImages( const KURL::List& )
{
}

/**
   Tells whether the host application under which the plugin currently executes a given feature.
   See KIPI::Features for details on the individual features.
*/
bool KIPI::Interface::hasFeature( KIPI::Features feature )
{
    return ( features() & feature ) != 0;
}

bool KIPI::Interface::hasFeature( const TQString& feature )
{
    if ( feature == "AlbumsHaveComments" )
        return hasFeature( KIPI::AlbumsHaveComments );
    else if ( feature == "ImagesHasComments" )
        return hasFeature( KIPI::ImagesHasComments );
    else if ( feature == "ImagesHasTime" )
        return hasFeature( KIPI::ImagesHasTime );
    else if ( feature == "SupportsDateRanges" )
        return hasFeature( KIPI::SupportsDateRanges );
    else if ( feature == "AcceptNewImages" )
        return hasFeature( KIPI::AcceptNewImages );
    else if ( feature == "ImageTitlesWritable" )
        return hasFeature( KIPI::ImageTitlesWritable );
    else if ( feature == "AlbumsHaveCategory" )
        return hasFeature( KIPI::AlbumsHaveCategory );
    else if ( feature == "AlbumsHaveCreationDate" )
        return hasFeature( KIPI::AlbumsHaveCreationDate );
    else if ( feature == "AlbumsUseFirstImagePreview" )
        return hasFeature( KIPI::AlbumsUseFirstImagePreview );
    else if ( feature == "HostSupportsTags" )
        return hasFeature( KIPI::HostSupportsTags );
    else {
        kdWarning( 51000 ) << "Unknown feature asked for in KIPI::Interface::hasFeature: " << feature << endl;
        return false;
    }
}

/*!
  Tell the host application that a new image has been made available to it.
  Returns true if the host application did accept the new image, otherwise err will be filled with
  an error description.
*/
bool KIPI::Interface::addImage( const KURL&, TQString& /*err*/ )
{
    kdWarning(51000) << "Interface::addImage should only be invoked if the host application supports the KIPI::Features\n"
            "AcceptNewImages - if the host application do support that, then this function should\n"
            "have been overriden in the host application.\n";
    return false;
}

void KIPI::Interface::delImage( const KURL& )
{
}

/**
   Returns list of all images in current album.
   If there are no current album, the returned
   KIPI::ImageCollection::isValid() will return false.
*/
KIPI::ImageCollection KIPI::Interface::currentAlbum()
{
    // This implementation is just to be able to write documentation above.
    return KIPI::ImageCollection();
}

/**
   Current selection in a thumbnail view for example.
   If there are no current selection, the returned
   KIPI::ImageCollection::isValid() will return false.
*/
KIPI::ImageCollection KIPI::Interface::currentSelection()
{
    // This implementation is just to be able to write documentation above.
    return KIPI::ImageCollection();
}

/**
   Returns a list of albums.
*/
TQValueList<KIPI::ImageCollection> KIPI::Interface::allAlbums()
{
    // This implementation is just to be able to write documentation above.
    return TQValueList<KIPI::ImageCollection>();
}


/**
   Return a bitwise or of the KIPI::Features that thus application support.
*/
int KIPI::Interface::features() const
{
    // This implementation is just to be able to write documentation above.
    return 0;
}

/**
   Return a list of images file extention will be used in the plugins for 
   to sort the files list before a treatment. The default implementation return,
   the supported images formats by KDE.
*/
TQString KIPI::Interface::fileExtensions()
{
    TQStringList KDEImagetypes = KImageIO::mimeTypes( KImageIO::Reading );
    TQString imagesFileFilter = KDEImagetypes.join(" ");
    return ( imagesFileFilter.lower() + " " + imagesFileFilter.upper() );
}

#include "interface.moc"