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

« back to all changes in this revision

Viewing changes to utilities/queuemanager/toolslistview.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:
43
43
{
44
44
 
45
45
ToolListViewGroup::ToolListViewGroup(QTreeWidget* parent, BatchTool::BatchToolGroup group)
46
 
                 : QTreeWidgetItem(parent)
 
46
    : QTreeWidgetItem(parent)
47
47
{
48
48
    setFlags(Qt::ItemIsEnabled);
49
49
 
52
52
 
53
53
    m_group = group;
54
54
 
55
 
    switch(m_group)
 
55
    switch (m_group)
56
56
    {
57
57
        case BatchTool::ColorTool:
58
58
            setIcon(0, SmallIcon("digikam"));
105
105
// ---------------------------------------------------------------------------
106
106
 
107
107
ToolListViewItem::ToolListViewItem(ToolListViewGroup* parent, BatchTool* tool)
108
 
                : QTreeWidgetItem(parent)
 
108
    : QTreeWidgetItem(parent)
109
109
{
110
110
    setDisabled(false);
111
111
    setSelected(false);
112
112
 
113
113
    m_tool = tool;
 
114
 
114
115
    if (m_tool)
115
116
    {
116
117
        setIcon(0, m_tool->toolIcon());
131
132
// ---------------------------------------------------------------------------
132
133
 
133
134
ToolsListView::ToolsListView(QWidget* parent)
134
 
             : QTreeWidget(parent)
 
135
    : QTreeWidget(parent)
135
136
{
136
137
    setContextMenuPolicy(Qt::CustomContextMenu);
137
138
    setIconSize(QSize(22, 22));
157
158
    BatchToolsList list;
158
159
 
159
160
    QTreeWidgetItemIterator it(this);
 
161
 
160
162
    while (*it)
161
163
    {
162
164
        ToolListViewItem* item = dynamic_cast<ToolListViewItem*>(*it);
 
165
 
163
166
        if (item)
 
167
        {
164
168
            list.append(item->tool());
 
169
        }
165
170
 
166
171
        ++it;
167
172
    }
171
176
 
172
177
void ToolsListView::addTool(BatchTool* tool)
173
178
{
174
 
    if (!tool) return;
 
179
    if (!tool)
 
180
    {
 
181
        return;
 
182
    }
175
183
 
176
184
    ToolListViewGroup* parent = findToolGroup(tool->toolGroup());
 
185
 
177
186
    if (parent)
 
187
    {
178
188
        new ToolListViewItem(parent, tool);
 
189
    }
179
190
}
180
191
 
181
192
bool ToolsListView::removeTool(BatchTool* tool)
182
193
{
183
194
    QTreeWidgetItemIterator it(this);
 
195
 
184
196
    while (*it)
185
197
    {
186
198
        ToolListViewItem* item = dynamic_cast<ToolListViewItem*>(*it);
 
199
 
187
200
        if (item && item->tool() == tool)
188
201
        {
189
202
            delete item;
190
203
            return true;
191
204
        }
 
205
 
192
206
        ++it;
193
207
    }
 
208
 
194
209
    return false;
195
210
}
196
211
 
197
212
ToolListViewGroup* ToolsListView::findToolGroup(BatchTool::BatchToolGroup group)
198
213
{
199
214
    QTreeWidgetItemIterator it(this);
 
215
 
200
216
    while (*it)
201
217
    {
202
218
        ToolListViewGroup* item = dynamic_cast<ToolListViewGroup*>(*it);
 
219
 
203
220
        if (item && item->toolGroup() == group)
 
221
        {
204
222
            return item;
 
223
        }
205
224
 
206
225
        ++it;
207
226
    }
212
231
bool ToolsListView::findTool(BatchTool* tool)
213
232
{
214
233
    QTreeWidgetItemIterator it(this);
 
234
 
215
235
    while (*it)
216
236
    {
217
237
        ToolListViewItem* item = dynamic_cast<ToolListViewItem*>(*it);
 
238
 
218
239
        if (item && item->tool() == tool)
 
240
        {
219
241
            return true;
 
242
        }
220
243
 
221
244
        ++it;
222
245
    }
227
250
void ToolsListView::startDrag(Qt::DropActions /*supportedActions*/)
228
251
{
229
252
    QList<QTreeWidgetItem*> items = selectedItems();
 
253
 
230
254
    if (items.isEmpty())
 
255
    {
231
256
        return;
 
257
    }
232
258
 
233
259
    QPixmap icon(DesktopIcon("system-run", 48));
234
260
    int w = icon.width();
269
295
void ToolsListView::mouseDoubleClickEvent(QMouseEvent*)
270
296
{
271
297
    if (viewport()->isEnabled())
 
298
    {
272
299
        slotAssignTools();
 
300
    }
273
301
}
274
302
 
275
303
void ToolsListView::slotAssignTools()
276
304
{
277
305
    QList<QTreeWidgetItem*> items = selectedItems();
 
306
 
278
307
    if (items.isEmpty())
 
308
    {
279
309
        return;
 
310
    }
280
311
 
281
312
    QMap<int, QString> map = itemsToMap(items);
282
313
    emit signalAssignTools(map);
302
333
    foreach(QTreeWidgetItem* itm, items)
303
334
    {
304
335
        ToolListViewItem* tlwi = dynamic_cast<ToolListViewItem*>(itm);
 
336
 
305
337
        if (tlwi)
 
338
        {
306
339
            map.insertMulti((int)(tlwi->tool()->toolGroup()), tlwi->tool()->objectName());
 
340
        }
307
341
    }
308
342
    return map;
309
343
}