~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to digikam/tagmodificationhelper.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
};
60
60
 
61
61
TagModificationHelper::TagModificationHelper(QObject* parent, QWidget* dialogParent)
62
 
                     : QObject(parent), d(new TagModificationHelperPriv)
 
62
    : QObject(parent), d(new TagModificationHelperPriv)
63
63
{
64
64
    d->dialogParent = dialogParent;
65
65
}
74
74
    d->parentTag = parent;
75
75
}
76
76
 
77
 
TAlbum* TagModificationHelper::slotTagNew(TAlbum* parent, const QString &title, const QString& iconName)
 
77
TAlbum* TagModificationHelper::slotTagNew(TAlbum* parent, const QString& title, const QString& iconName)
78
78
{
79
79
    // ensure that there is a parent
80
80
    TAlbum* p = parent;
 
81
 
81
82
    if (!p)
82
83
    {
83
84
        p = AlbumManager::instance()->findTAlbum(0);
 
85
 
84
86
        if (!p)
85
87
        {
86
88
            kError() << "Could not find root tag album";
94
96
    if (title.isEmpty())
95
97
    {
96
98
        bool doCreate = TagEditDlg::tagCreate(d->dialogParent, p, editTitle, editIconName);
97
 
        if(!doCreate)
 
99
 
 
100
        if (!doCreate)
98
101
        {
99
102
            return 0;
100
103
        }
131
134
 
132
135
void TagModificationHelper::slotTagEdit(TAlbum* tag)
133
136
{
134
 
    if(!tag)
 
137
    if (!tag)
135
138
    {
136
139
        return;
137
140
    }
138
141
 
139
142
    QString title, icon;
140
143
    bool doEdit = TagEditDlg::tagEdit(d->dialogParent, tag, title, icon);
141
 
    if(!doEdit)
 
144
 
 
145
    if (!doEdit)
142
146
    {
143
147
        return;
144
148
    }
145
149
 
146
 
    if(tag->title() != title)
 
150
    if (tag->title() != title)
147
151
    {
148
152
        QString errMsg;
149
 
        if(!AlbumManager::instance()->renameTAlbum(tag, title, errMsg))
 
153
 
 
154
        if (!AlbumManager::instance()->renameTAlbum(tag, title, errMsg))
150
155
        {
151
156
            KMessageBox::error(0, errMsg);
152
157
        }
153
158
    }
154
159
 
155
 
    if(tag->icon() != icon)
 
160
    if (tag->icon() != icon)
156
161
    {
157
162
        QString errMsg;
 
163
 
158
164
        if (!AlbumManager::instance()->updateTAlbumIcon(tag, icon, 0, errMsg))
159
165
        {
160
166
            KMessageBox::error(0, errMsg);
167
173
void TagModificationHelper::slotTagEdit()
168
174
{
169
175
    if (d->parentTag)
 
176
    {
170
177
        slotTagEdit(d->parentTag);
 
178
    }
171
179
}
172
180
 
173
181
void TagModificationHelper::slotTagDelete(TAlbum* tag)
180
188
    // find number of subtags
181
189
    int children = 0;
182
190
    AlbumIterator iter(tag);
183
 
    while(iter.current())
 
191
 
 
192
    while (iter.current())
184
193
    {
185
194
        ++children;
186
195
        ++iter;
187
196
    }
188
197
 
189
198
    // ask for deletion of children
190
 
    if(children)
 
199
    if (children)
191
200
    {
192
201
        int result = KMessageBox::warningContinueCancel(d->dialogParent,
193
 
                       i18np("Tag '%2' has one subtag. "
194
 
                             "Deleting this will also delete "
195
 
                             "the subtag. "
196
 
                             "Do you want to continue?",
197
 
                             "Tag '%2' has %1 subtags. "
198
 
                             "Deleting this will also delete "
199
 
                             "the subtags. "
200
 
                             "Do you want to continue?",
201
 
                             children,
202
 
                             tag->title()));
 
202
                     i18np("Tag '%2' has one subtag. "
 
203
                           "Deleting this will also delete "
 
204
                           "the subtag. "
 
205
                           "Do you want to continue?",
 
206
                           "Tag '%2' has %1 subtags. "
 
207
                           "Deleting this will also delete "
 
208
                           "the subtags. "
 
209
                           "Do you want to continue?",
 
210
                           children,
 
211
                           tag->title()));
203
212
 
204
 
        if(result != KMessageBox::Continue)
 
213
        if (result != KMessageBox::Continue)
205
214
        {
206
215
            return;
207
216
        }
209
218
 
210
219
    QString message;
211
220
    QList<qlonglong> assignedItems = DatabaseAccess().db()->getItemIDsInTag(tag->id());
 
221
 
212
222
    if (!assignedItems.isEmpty())
213
223
    {
214
224
        message = i18np("Tag '%2' is assigned to one item. "
223
233
    }
224
234
 
225
235
    int result = KMessageBox::warningContinueCancel(0, message,
226
 
                                                    i18n("Delete Tag"),
227
 
                                                    KGuiItem(i18n("Delete"),
228
 
                                                    "edit-delete"));
 
236
                 i18n("Delete Tag"),
 
237
                 KGuiItem(i18n("Delete"),
 
238
                          "edit-delete"));
229
239
 
230
 
    if(result == KMessageBox::Continue)
 
240
    if (result == KMessageBox::Continue)
231
241
    {
232
242
        emit aboutToDeleteTag(tag);
233
243
        QString errMsg;
 
244
 
234
245
        if (!AlbumManager::instance()->deleteTAlbum(tag, errMsg))
235
246
        {
236
247
            KMessageBox::error(0, errMsg);
241
252
void TagModificationHelper::slotTagDelete()
242
253
{
243
254
    if (d->parentTag)
 
255
    {
244
256
        slotTagDelete(d->parentTag);
 
257
    }
245
258
}
246
259
 
247
260
} // namespace Digikam