~ubuntu-branches/ubuntu/natty/digikam/natty

« back to all changes in this revision

Viewing changes to digikam/albumselectdialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Luka Renko
  • Date: 2009-11-12 18:02:13 UTC
  • mfrom: (1.2.24 upstream) (3.2.7 sid)
  • Revision ID: james.westby@ubuntu.com-20091112180213-8p63z8taug49ji3t
Tags: 2:1.0.0~beta6-1ubuntu1
* Merge with Debian, remaining changes:
  - Export .pot name and copy to plugins in debian/rules
  - Remove liblqr-1-0-dev from build-deps, not in main

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
 
63
63
    AlbumSelectDialogPrivate()
64
64
    {
65
 
        allowRootSelection = false;
66
65
        albumSel           = 0;
67
66
        searchBar          = 0;
68
67
    }
69
68
 
70
 
    bool               allowRootSelection;
71
 
 
72
69
    QString            newAlbumString;
73
70
 
74
71
    AlbumSelectWidget *albumSel;
78
75
 
79
76
AlbumSelectDialog::AlbumSelectDialog(QWidget* parent, PAlbum* albumToSelect,
80
77
                                     const QString& header,
81
 
                                     const QString& newAlbumString,
82
 
                                     bool allowRootSelection)
 
78
                                     const QString& newAlbumString)
83
79
                 : KDialog(parent), d(new AlbumSelectDialogPrivate)
84
80
{
85
 
    d->allowRootSelection = allowRootSelection;
86
 
    d->newAlbumString     = newAlbumString;
 
81
    d->newAlbumString = newAlbumString;
87
82
 
88
83
    setCaption(i18n("Select Album"));
89
84
    setButtons(Help|Ok|Cancel);
136
131
{
137
132
    QTreeWidgetItem* selItem = d->albumSel->albumView()->currentItem();
138
133
 
139
 
    if ((!selItem || (selItem == d->albumSel->albumView()->topLevelItem(0))) &&
140
 
        !d->allowRootSelection)
 
134
    if (!selItem || (selItem == d->albumSel->albumView()->topLevelItem(0)))
141
135
    {
142
136
        enableButtonOk(false);
143
137
        return;
149
143
PAlbum* AlbumSelectDialog::selectAlbum(QWidget* parent,
150
144
                                       PAlbum* albumToSelect,
151
145
                                       const QString& header,
152
 
                                       const QString& newAlbumString,
153
 
                                       bool allowRootSelection )
 
146
                                       const QString& newAlbumString)
154
147
{
155
 
    QPointer<AlbumSelectDialog> dlg = new AlbumSelectDialog(parent, albumToSelect,
156
 
                                                            header, newAlbumString,
157
 
                                                            allowRootSelection);
 
148
    QPointer<AlbumSelectDialog> dlg = new AlbumSelectDialog(parent, albumToSelect, header, newAlbumString);
158
149
 
159
150
    if (dlg->exec() != KDialog::Accepted)
160
151
    {
162
153
        return 0;
163
154
    }
164
155
 
165
 
    TreeAlbumItem* item = (TreeAlbumItem*) dlg->d->albumSel->albumView()->currentItem();
166
 
    if ((!item || (item == dlg->d->albumSel->albumView()->topLevelItem(0))) &&
167
 
        !allowRootSelection)
 
156
    QTreeWidgetItem* cItem  = dlg->d->albumSel->albumView()->currentItem();
 
157
    QTreeWidgetItem* tlItem = dlg->d->albumSel->albumView()->topLevelItem(0);
 
158
    if (!cItem || (cItem == tlItem))
168
159
    {
169
160
        delete dlg;
170
161
        return 0;
171
162
    }
172
163
 
 
164
    TreeAlbumItem* item = dynamic_cast<TreeAlbumItem*>(cItem);
 
165
    PAlbum* album       = 0;
 
166
    if (item && item->album())
 
167
    {
 
168
        album = dynamic_cast<PAlbum*>(item->album());
 
169
    }
 
170
 
173
171
    delete dlg;
174
 
    return (dynamic_cast<PAlbum*>(item->album()));
 
172
    return album;
175
173
}
176
174
 
177
175
}  // namespace Digikam