~ubuntu-branches/ubuntu/lucid/skrooge/lucid

« back to all changes in this revision

Viewing changes to skrooge_bookmark/skgbookmarkplugindockwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2009-07-28 15:38:43 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090728153843-91b74m0vcam50krt
Tags: 0.2.9-0ubuntu1
* New upstream release
* Added kubuntu_01_cmake_fix.patch:
  Fix FTBFS

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        ui.kBookmarksList->setModel(modelproxy);
78
78
 
79
79
        connect(ui.kBookmarksList->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(refresh()));
80
 
        connect(ui.kBookmarksList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onOpenBookmark()));
 
80
        connect(ui.kBookmarksList, SIGNAL(pressed(QModelIndex)), this, SLOT(onBeforeOpenBookmark()));
 
81
        connect(ui.kBookmarksList, SIGNAL(clicked(QModelIndex)), this, SLOT(onOpenBookmark(QModelIndex)));
 
82
        connect(ui.kBookmarksList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onOpenBookmarkFolder(QModelIndex)));
81
83
}
82
84
 
83
85
SKGBookmarkPluginDockWidget::~SKGBookmarkPluginDockWidget()
97
99
        if (mainMenu) mainMenu->popup(ui.kBookmarksList->mapToGlobal(pos));
98
100
}
99
101
 
100
 
int SKGBookmarkPluginDockWidget::getNbSelectedBookmarks()
 
102
int SKGBookmarkPluginDockWidget::getNbSelectedObjects()
101
103
{
102
 
        QItemSelectionModel *selModel=ui.kBookmarksList->selectionModel();
103
 
        return (selModel ? selModel->selectedRows().count() : 0);
 
104
        return ui.kBookmarksList->getNbSelectedObjects();
104
105
}
105
106
 
106
 
SKGObjectBase::SKGListSKGObjectBase SKGBookmarkPluginDockWidget::getBookmarks()
 
107
SKGObjectBase::SKGListSKGObjectBase SKGBookmarkPluginDockWidget::getSelectedObjects()
107
108
{
108
 
        //Get Selection
109
 
        SKGObjectBase::SKGListSKGObjectBase selection;
110
 
        QItemSelectionModel *selModel=ui.kBookmarksList->selectionModel();
111
 
        QSortFilterProxyModel* proxyModel=(QSortFilterProxyModel*) ui.kBookmarksList->model();
112
 
        SKGObjectModelBase* model=(SKGObjectModelBase*) proxyModel->sourceModel();
113
 
        if (model) {
114
 
                QModelIndexList indexes=selModel->selectedRows();
115
 
                foreach(const QModelIndex& index, indexes) {
116
 
                        SKGObjectBase obj=model->getObject(proxyModel->mapToSource(index));
117
 
                        selection.push_back(obj);
118
 
                }
119
 
        }
120
 
        return selection;
 
109
        return ui.kBookmarksList->getSelectedObjects();
121
110
}
122
111
 
123
112
void SKGBookmarkPluginDockWidget::onBookmarkFilterRegExpChanged()
144
133
        SKGTRACEIN(10, "SKGBookmarkPluginDockWidget::setAutostart");
145
134
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
146
135
 
147
 
        SKGObjectBase::SKGListSKGObjectBase selectedBookmarks = getBookmarks();
 
136
        SKGObjectBase::SKGListSKGObjectBase selectedBookmarks = getSelectedObjects();
148
137
 
149
138
        SKGError err;
150
139
 
180
169
        int nbTab=getMainPanel()->countTab();
181
170
        if (nbTab) {
182
171
                setForcusOn=nbTab-1;
183
 
                if (QApplication::keyboardModifiers()&Qt::ControlModifier) {
 
172
                if (middleClick) {
184
173
                        setForcusOn=nbTab;
185
174
                } else {
186
175
                        setForcusOn=getMainPanel()->currentTabIndex();
187
176
                }
188
177
        }
189
178
 
190
 
        int tabNumberForNextOpen=(QApplication::keyboardModifiers()&Qt::ControlModifier || iFirstInNewPage ? -1 : getMainPanel()->currentTabIndex());
 
179
        int tabNumberForNextOpen=(middleClick || iFirstInNewPage ? -1 : getMainPanel()->currentTabIndex());
191
180
        for (int i=0; i<nodes.count(); ++i) { //WARNING: This list is modified dynamically
192
181
                SKGNodeObject selectedNode=nodes.at(i);
193
182
                QStringList data=SKGServices::splitCSVLine(selectedNode.getData());
215
204
        QApplication::restoreOverrideCursor();
216
205
}
217
206
 
218
 
void SKGBookmarkPluginDockWidget::onOpenBookmark()
 
207
void SKGBookmarkPluginDockWidget::onBeforeOpenBookmark()
 
208
{
 
209
        middleClick=QApplication::keyboardModifiers() &Qt::ControlModifier || QApplication::mouseButtons () &Qt::MidButton;
 
210
}
 
211
 
 
212
void SKGBookmarkPluginDockWidget::onOpenBookmark(const QModelIndex & index )
219
213
{
220
214
        SKGTRACEIN(1, "SKGBookmarkPluginDockWidget::onOpenBookmark");
221
215
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
222
 
        SKGObjectBase::SKGListSKGObjectBase bookmarks=getBookmarks();
223
 
        if (bookmarks.count()) openBookmark(bookmarks.at(0));
 
216
        QSortFilterProxyModel* proxyModel=(QSortFilterProxyModel*) ui.kBookmarksList->model();
 
217
        SKGObjectModelBase* model=(SKGObjectModelBase*) proxyModel->sourceModel();
 
218
        if (model) {
 
219
                SKGNodeObject node=model->getObject(proxyModel->mapToSource(index));
 
220
                bool isFolder=node.getData().isEmpty();
 
221
                if (!isFolder) openBookmark(node);
 
222
        }
 
223
        QApplication::restoreOverrideCursor();
 
224
}
 
225
 
 
226
void SKGBookmarkPluginDockWidget::onOpenBookmarkFolder(const QModelIndex & index )
 
227
{
 
228
        SKGTRACEIN(1, "SKGBookmarkPluginDockWidget::onOpenBookmarkFolder");
 
229
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 
230
        QSortFilterProxyModel* proxyModel=(QSortFilterProxyModel*) ui.kBookmarksList->model();
 
231
        SKGObjectModelBase* model=(SKGObjectModelBase*) proxyModel->sourceModel();
 
232
        if (model) {
 
233
                SKGNodeObject node=model->getObject(proxyModel->mapToSource(index));
 
234
                bool isFolder=node.getData().isEmpty();
 
235
                if (isFolder) openBookmark(node);
 
236
        }
224
237
        QApplication::restoreOverrideCursor();
225
238
}
226
239
 
232
245
        {
233
246
                //Get current selection name
234
247
                QString name;
235
 
                SKGObjectBase::SKGListSKGObjectBase bookmarks=getBookmarks();
 
248
                SKGObjectBase::SKGListSKGObjectBase bookmarks=getSelectedObjects();
236
249
                if (bookmarks.count()) {
237
250
                        SKGNodeObject parentNode=bookmarks.at(0);
238
251
                        name=parentNode.getFullName();
268
281
        if (currentPage) {
269
282
                //Get current selection name
270
283
                QString name;
271
 
                SKGObjectBase::SKGListSKGObjectBase bookmarks=getBookmarks();
 
284
                SKGObjectBase::SKGListSKGObjectBase bookmarks=getSelectedObjects();
272
285
                if (bookmarks.count()) {
273
286
                        SKGNodeObject parentNode=bookmarks.at(0);
274
287
                        name=parentNode.getFullName();
315
328
        SKGObjectBase::SKGListSKGObjectBase selection;
316
329
        QItemSelectionModel *selModel=ui.kBookmarksList->selectionModel();
317
330
        QSortFilterProxyModel* proxyModel=(QSortFilterProxyModel*) ui.kBookmarksList->model();
318
 
        SKGObjectModelBase* model=(SKGObjectModelBase*) proxyModel->sourceModel();
319
 
        if (model) {
320
 
                QModelIndexList indexes=selModel->selectedRows();
321
 
                if (indexes.count()==1) {
322
 
                        ui.kBookmarksList->edit ( indexes.at(0) );
 
331
        if (proxyModel) {
 
332
                SKGObjectModelBase* model=(SKGObjectModelBase*) proxyModel->sourceModel();
 
333
                if (model) {
 
334
                        QModelIndexList indexes=selModel->selectedRows();
 
335
                        if (indexes.count()==1) {
 
336
                                ui.kBookmarksList->edit ( indexes.at(0) );
 
337
                        }
323
338
                }
324
339
        }
325
340
}
333
348
        {
334
349
                SKGBEGINTRANSACTION(*getDocument(), i18n("Bookmark delete"), err);
335
350
                //Get current selection
336
 
                SKGObjectBase::SKGListSKGObjectBase bookmarks=getBookmarks();
 
351
                SKGObjectBase::SKGListSKGObjectBase bookmarks=getSelectedObjects();
337
352
                int nb=bookmarks.count();
338
353
                for (int i=0; i<nb && err.isSucceeded(); ++i) {
339
354
                        SKGNodeObject node=bookmarks.at(i);
353
368
        SKGTRACEIN(10, "SKGBookmarkPluginDockWidget::onBookmarkEditorChanged");
354
369
 
355
370
        //Bookmarks
356
 
        SKGObjectBase::SKGListSKGObjectBase bookmarks=getBookmarks();
 
371
        SKGObjectBase::SKGListSKGObjectBase bookmarks=getSelectedObjects();
357
372
        int nbSelectedObjects=bookmarks.count();
358
373
        int isFolder=true;
359
374
        if (nbSelectedObjects==1) {
373
388
{
374
389
        SKGTRACEIN(10, "SKGBookmarkPluginDockWidget::refresh");
375
390
        //Automatic open of autostart bookmark
376
 
        QString doc_id=getDocument()->getParameter("SKG_UNIQUE_ID");
 
391
        QString doc_id=getDocument()->getUniqueIdentifier();
377
392
 
378
393
        if (docUniqueIdentifier!=doc_id) {
379
394
                docUniqueIdentifier=doc_id;
389
404
        }
390
405
 
391
406
        //Bookmarks
392
 
        SKGObjectBase::SKGListSKGObjectBase bookmarks=getBookmarks();
 
407
        SKGObjectBase::SKGListSKGObjectBase bookmarks=getSelectedObjects();
393
408
        int nbSelectedObjects=bookmarks.count();
394
409
        if (nbSelectedObjects==1) {
395
410
                SKGNodeObject node=bookmarks.at(0);