~smartboyhw/ubuntu/raring/calligra/2.6.0-0ubuntu1

« back to all changes in this revision

Viewing changes to plan/libs/ui/kptaccountseditor.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-10-23 21:09:16 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20121023210916-m82w6zxnxhaxz7va
Tags: 1:2.5.90-0ubuntu1
* New upstream alpha release (LP: #1070436)
  - Add libkactivities-dev and libopenimageio-dev to build-depends
  - Add kubuntu_build_calligraactive.diff to build calligraactive by default
  - Add package for calligraauthor and move files that are shared between
    calligrawords and calligraauthor to calligrawords-common
* Document the patches
* Remove numbers from patches so they follow the same naming scheme as
  the rest of our patches.
* calligra-data breaks replaces krita-data (<< 1:2.5.3) (LP: #1071686)

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "kptdebug.h"
32
32
 
33
33
#include <KoDocument.h>
 
34
#include <KoPageLayoutWidget.h>
 
35
#include <KoIcon.h>
34
36
 
35
37
#include <QList>
36
38
#include <QVBoxLayout>
37
39
#include <QHeaderView>
38
40
#include <QContextMenuEvent>
39
41
#include <QDragMoveEvent>
 
42
#include <QMenu>
40
43
 
41
44
#include <kaction.h>
42
 
#include <kicon.h>
43
45
#include <kglobal.h>
44
46
#include <klocale.h>
45
47
#include <kactioncollection.h>
49
51
{
50
52
 
51
53
 
 
54
AccountseditorConfigDialog::AccountseditorConfigDialog( ViewBase *view, AccountTreeView *treeview, QWidget *p)
 
55
    : KPageDialog(p),
 
56
    m_view( view ),
 
57
    m_treeview( treeview )
 
58
{
 
59
    setCaption( i18n("Settings") );
 
60
    setButtons( Ok|Cancel );
 
61
    setDefaultButton( Ok );
 
62
    showButtonSeparator( true );
 
63
 
 
64
    QTabWidget *tab = new QTabWidget();
 
65
 
 
66
    QWidget *w = ViewBase::createPageLayoutWidget( view );
 
67
    tab->addTab( w, w->windowTitle() );
 
68
    m_pagelayout = w->findChild<KoPageLayoutWidget*>();
 
69
    Q_ASSERT( m_pagelayout );
 
70
 
 
71
    m_headerfooter = ViewBase::createHeaderFooterWidget( view );
 
72
    m_headerfooter->setOptions( view->printingOptions() );
 
73
    tab->addTab( m_headerfooter, m_headerfooter->windowTitle() );
 
74
 
 
75
    KPageWidgetItem *page = addPage( tab, i18n( "Printing" ) );
 
76
    page->setHeader( i18n( "Printing Options" ) );
 
77
 
 
78
    connect( this, SIGNAL(okClicked()), this, SLOT(slotOk()));
 
79
}
 
80
 
 
81
void AccountseditorConfigDialog::slotOk()
 
82
{
 
83
    kDebug(planDbg());
 
84
    m_view->setPageLayout( m_pagelayout->pageLayout() );
 
85
    m_view->setPrintingOptions( m_headerfooter->options() );
 
86
}
 
87
 
 
88
 
52
89
//--------------------
53
90
AccountTreeView::AccountTreeView( QWidget *parent )
54
91
    : TreeViewBase( parent )
123
160
 
124
161
 
125
162
//-----------------------------------
126
 
AccountsEditor::AccountsEditor( KoDocument *part, QWidget *parent )
127
 
    : ViewBase( part, parent )
 
163
AccountsEditor::AccountsEditor(KoPart *part, KoDocument *doc, QWidget *parent)
 
164
    : ViewBase(part, doc, parent)
128
165
{
129
166
    setupGui();
130
167
    
134
171
    l->addWidget( m_view );
135
172
    m_view->setEditTriggers( m_view->editTriggers() | QAbstractItemView::EditKeyPressed );
136
173
 
137
 
    connect( model(), SIGNAL( executeCommand( KUndo2Command* ) ), part, SLOT( addCommand( KUndo2Command* ) ) );
 
174
    connect( model(), SIGNAL( executeCommand( KUndo2Command* ) ), doc, SLOT( addCommand( KUndo2Command* ) ) );
138
175
    
139
176
    connect( m_view, SIGNAL( currentChanged( QModelIndex ) ), this, SLOT( slotCurrentChanged( QModelIndex ) ) );
140
177
 
141
178
    connect( m_view, SIGNAL( selectionChanged( const QModelIndexList ) ), this, SLOT( slotSelectionChanged( const QModelIndexList ) ) );
142
179
    
143
180
    connect( m_view, SIGNAL( contextMenuRequested( QModelIndex, const QPoint& ) ), this, SLOT( slotContextMenuRequested( QModelIndex, const QPoint& ) ) );
 
181
    connect( m_view, SIGNAL( headerContextMenuRequested( const QPoint& ) ), SLOT( slotHeaderContextMenuRequested( const QPoint& ) ) );
144
182
}
145
183
 
146
184
void AccountsEditor::updateReadWrite( bool readwrite )
173
211
void AccountsEditor::slotContextMenuRequested( QModelIndex index, const QPoint& pos )
174
212
{
175
213
    kDebug(planDbg())<<index.row()<<","<<index.column()<<":"<<pos;
176
 
    QString name;
177
 
    if ( index.isValid() ) {
178
 
        Account *a = m_view->model()->account( index );
179
 
        if ( a ) {
180
 
            name = "accountseditor_accounts_popup";
181
 
        } else {
182
 
            name = "accountseditor_popup";
183
 
        }
 
214
    slotHeaderContextMenuRequested( pos );
 
215
}
 
216
 
 
217
void AccountsEditor::slotHeaderContextMenuRequested( const QPoint &pos )
 
218
{
 
219
    kDebug(planDbg());
 
220
    QList<QAction*> lst = contextActionList();
 
221
    if ( ! lst.isEmpty() ) {
 
222
        QMenu::exec( lst, pos,  lst.first() );
184
223
    }
185
 
    kDebug(planDbg())<<name;
186
 
    emit requestPopupMenu( name, pos );
187
224
}
188
225
 
189
226
Account *AccountsEditor::currentAccount() const
224
261
{
225
262
    QString name = "accountseditor_edit_list";
226
263
    
227
 
    actionAddAccount  = new KAction(KIcon( "document-new" ), i18n("Add Account"), this);
 
264
    actionAddAccount  = new KAction(koIcon("document-new"), i18n("Add Account"), this);
228
265
    actionCollection()->addAction("add_account", actionAddAccount );
229
266
    actionAddAccount->setShortcut( KShortcut( Qt::CTRL + Qt::Key_I ) );
230
267
    connect( actionAddAccount, SIGNAL( triggered( bool ) ), SLOT( slotAddAccount() ) );
231
268
    addAction( name, actionAddAccount );
232
 
    
233
 
    actionAddSubAccount  = new KAction(KIcon( "document-new" ), i18n("Add Subaccount"), this);
 
269
 
 
270
    actionAddSubAccount  = new KAction(koIcon("document-new"), i18n("Add Subaccount"), this);
234
271
    actionCollection()->addAction("add_subaccount", actionAddSubAccount );
235
272
    actionAddSubAccount->setShortcut( KShortcut( Qt::SHIFT + Qt::CTRL + Qt::Key_I ) );
236
273
    connect( actionAddSubAccount, SIGNAL( triggered( bool ) ), SLOT( slotAddSubAccount() ) );
237
274
    addAction( name, actionAddSubAccount );
238
 
    
239
 
    actionDeleteSelection  = new KAction(KIcon( "edit-delete" ), i18nc( "@action", "Delete"), this);
 
275
 
 
276
    actionDeleteSelection  = new KAction(koIcon("edit-delete"), i18nc("@action", "Delete"), this);
240
277
    actionCollection()->addAction("delete_selection", actionDeleteSelection );
241
278
    actionDeleteSelection->setShortcut( KShortcut( Qt::Key_Delete ) );
242
279
    connect( actionDeleteSelection, SIGNAL( triggered( bool ) ), SLOT( slotDeleteSelection() ) );
243
280
    addAction( name, actionDeleteSelection );
244
 
    
 
281
 
 
282
    createOptionAction();
 
283
}
 
284
 
 
285
void AccountsEditor::slotOptions()
 
286
{
 
287
    kDebug(planDbg());
 
288
    AccountseditorConfigDialog *dlg = new AccountseditorConfigDialog( this, m_view, this );
 
289
    connect(dlg, SIGNAL(finished(int)), SLOT(slotOptionsFinished(int)));
 
290
    dlg->show();
 
291
    dlg->raise();
 
292
    dlg->activateWindow();
245
293
}
246
294
 
247
295
void AccountsEditor::slotAddAccount()