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

« back to all changes in this revision

Viewing changes to digikam/albumselectwidget.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:
69
69
 
70
70
};
71
71
 
72
 
AlbumSelectTreeView::AlbumSelectTreeView(AlbumModel *model,
73
 
                                         AlbumModificationHelper *albumModificationHelper,
74
 
                                         QWidget *parent) :
75
 
                                         AlbumTreeView(model, parent),
76
 
                                         d(new AlbumSelectTreeViewPriv)
 
72
AlbumSelectTreeView::AlbumSelectTreeView(AlbumModel* model,
 
73
        AlbumModificationHelper* albumModificationHelper,
 
74
        QWidget* parent) :
 
75
    AlbumTreeView(model, parent),
 
76
    d(new AlbumSelectTreeViewPriv)
77
77
{
78
78
 
79
79
    d->albumModificationHelper = albumModificationHelper;
87
87
    delete d;
88
88
}
89
89
 
90
 
void AlbumSelectTreeView::addCustomContextMenuActions(ContextMenuHelper &cmh,
91
 
                                                      Album *album)
 
90
void AlbumSelectTreeView::addCustomContextMenuActions(ContextMenuHelper& cmh,
 
91
        Album* album)
92
92
{
93
93
    cmh.addAction(d->newAlbumAction);
94
94
    d->newAlbumAction->setEnabled(album);
95
95
}
96
96
 
97
 
void AlbumSelectTreeView::handleCustomContextMenuAction(QAction *action,
98
 
                                                        AlbumPointer<Album> album)
 
97
void AlbumSelectTreeView::handleCustomContextMenuAction(QAction* action,
 
98
        AlbumPointer<Album> album)
99
99
{
100
100
 
101
 
    Album *a = album;
102
 
    PAlbum *palbum = dynamic_cast<PAlbum*> (a);
 
101
    Album* a = album;
 
102
    PAlbum* palbum = dynamic_cast<PAlbum*> (a);
 
103
 
103
104
    if (palbum && action == d->newAlbumAction)
104
105
    {
105
106
        d->albumModificationHelper->slotAlbumNew(palbum);
109
110
 
110
111
void AlbumSelectTreeView::slotNewAlbum()
111
112
{
112
 
    PAlbum *palbum = currentAlbum();
 
113
    PAlbum* palbum = currentAlbum();
 
114
 
113
115
    if (palbum)
114
116
    {
115
 
        PAlbum *createdAlbum = d->albumModificationHelper->slotAlbumNew(palbum);
 
117
        PAlbum* createdAlbum = d->albumModificationHelper->slotAlbumNew(palbum);
 
118
 
116
119
        if (createdAlbum)
117
120
        {
118
121
            slotSelectAlbum(createdAlbum, false);
143
146
    KPushButton*             newAlbumBtn;
144
147
};
145
148
 
146
 
AlbumSelectWidget::AlbumSelectWidget(QWidget *parent, PAlbum* albumToSelect)
147
 
                 : QWidget(parent),
148
 
                   d(new AlbumSelectWidgetPriv)
 
149
AlbumSelectWidget::AlbumSelectWidget(QWidget* parent, PAlbum* albumToSelect)
 
150
    : QWidget(parent),
 
151
      d(new AlbumSelectWidgetPriv)
149
152
{
150
153
 
151
154
    setObjectName("AlbumSelectWidget");
155
158
    // TODO let this class implement StateSavingObject
156
159
    KConfigGroup group = KGlobal::config()->group(objectName());
157
160
 
158
 
    QGridLayout *grid = new QGridLayout(this);
 
161
    QGridLayout* grid = new QGridLayout(this);
159
162
    d->albumModel     = new AlbumModel(AbstractAlbumModel::IgnoreRootAlbum, this);
160
163
    d->albumTreeView  = new AlbumSelectTreeView(d->albumModel, d->albumModificationHelper, this);
161
164
    d->albumTreeView->setDragEnabled(false);
176
179
    d->albumTreeView->setEntryPrefix("AlbumTreeView");
177
180
 
178
181
    d->newAlbumBtn    = new KPushButton(KGuiItem(i18n("&New Album"), "albumfolder-new",
179
 
                                                 i18n("Create new album")), this);
 
182
                                        i18n("Create new album")), this);
180
183
 
181
184
    grid->addWidget(d->albumTreeView,  0, 0, 1, 2);
182
185
    grid->addWidget(d->searchBar,   1, 0, 1, 1);
187
190
 
188
191
    // ------------------------------------------------------------------------------------
189
192
 
190
 
    PAlbum *select = albumToSelect;
 
193
    PAlbum* select = albumToSelect;
 
194
 
191
195
    if (!select)
192
196
    {
193
197
        select = AlbumManager::instance()->currentPAlbum();
194
198
    }
 
199
 
195
200
    d->albumTreeView->slotSelectAlbum(select, false);
196
201
 
197
202
    // ------------------------------------------------------------------------------------
222
227
    return d->albumTreeView->currentAlbum();
223
228
}
224
229
 
225
 
void AlbumSelectWidget::setCurrentAlbum(PAlbum *albumToSelect)
 
230
void AlbumSelectWidget::setCurrentAlbum(PAlbum* albumToSelect)
226
231
{
227
232
    d->albumTreeView->slotSelectAlbum(albumToSelect);
228
233
}
230
235
KUrl AlbumSelectWidget::currentAlbumUrl() const
231
236
{
232
237
    PAlbum* palbum = d->albumTreeView->currentAlbum();
233
 
    if (palbum) return palbum->fileUrl();
 
238
 
 
239
    if (palbum)
 
240
    {
 
241
        return palbum->fileUrl();
 
242
    }
234
243
 
235
244
    return KUrl();
236
245
}
237
246
 
238
247
void AlbumSelectWidget::setCurrentAlbumUrl(const KUrl& albumUrl)
239
248
{
240
 
    PAlbum *urlAlbum = AlbumManager::instance()->findPAlbum(albumUrl);
 
249
    PAlbum* urlAlbum = AlbumManager::instance()->findPAlbum(albumUrl);
 
250
 
241
251
    if (urlAlbum)
242
252
    {
243
253
        d->albumTreeView->slotSelectAlbum(urlAlbum);
256
266
    }
257
267
 
258
268
    QModelIndex index = d->albumModel->indexForAlbum(album);
 
269
 
259
270
    if (index.isValid())
260
271
    {
261
272
        emit itemSelectionChanged();