~ubuntu-branches/ubuntu/trusty/bibletime/trusty

« back to all changes in this revision

Viewing changes to src/frontend/displaywindow/clexiconreadwindow.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs, Jonathan Marsden, Dmitrijs Ledkovs
  • Date: 2012-04-14 18:11:50 UTC
  • mfrom: (1.3.7)
  • Revision ID: package-import@ubuntu.com-20120414181150-17l2liq7bl7oaxjz
Tags: 2.9.1-1
[ Jonathan Marsden ]
* New upstream version 2.9.1
* debian/patches/*: Remove all patches (incorporated upstream)
* debian/control: bibletime now depends on a matching version of
  bibletime-data.

[ Dmitrijs Ledkovs ]
* Add more strict alternative build-dependency on the libqt4-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
CLexiconReadWindow::CLexiconReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent)
40
40
        : CReadWindow(moduleList, parent) {
41
 
    qDebug() << "CLexiconReadWindow::CLexiconReadWindow";
42
41
    moduleList.first();
43
42
    setKey( CSwordKey::createInstance(moduleList.first()) );
44
43
}
47
46
}
48
47
 
49
48
void CLexiconReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
50
 
    qDebug() << "CLexiconReadWindow::insertKeyboardActions";
51
49
    QAction* qaction;
52
50
    qaction = new QAction( tr("Next entry"), a);
53
51
    qaction->setShortcut(CResMgr::displaywindows::lexiconWindow::nextEntry::accel);
81
79
}
82
80
 
83
81
void CLexiconReadWindow::initActions() {
84
 
    qDebug() << "CLexiconReadWindow::initActions";
85
 
 
86
82
    BtActionCollection* ac = actionCollection();
87
83
    CReadWindow::initActions();
88
84
    CLexiconReadWindow::insertKeyboardActions(ac);
89
85
 
90
 
    m_actions.backInHistory = dynamic_cast<BtToolBarPopupAction*>(
91
 
                                  ac->action(CResMgr::displaywindows::general::backInHistory::actionName) );
 
86
    QAction *qaction = ac->action(CResMgr::displaywindows::general::backInHistory::actionName);
 
87
    Q_ASSERT(qaction != 0);
 
88
    m_actions.backInHistory = dynamic_cast<BtToolBarPopupAction*>(qaction);
92
89
    Q_ASSERT(m_actions.backInHistory);
93
90
    addAction(m_actions.backInHistory);
94
91
 
95
 
    m_actions.forwardInHistory = dynamic_cast<BtToolBarPopupAction*>(
96
 
                                     ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName) );
 
92
    qaction = ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName);
 
93
    Q_ASSERT(qaction != 0);
 
94
    m_actions.forwardInHistory = dynamic_cast<BtToolBarPopupAction*>(qaction);
97
95
    Q_ASSERT(m_actions.forwardInHistory);
98
96
    addAction(m_actions.forwardInHistory);
99
97
 
100
 
    QAction* qaction;
101
 
 
102
98
    qaction = ac->action("nextEntry");
103
 
    QObject::connect(qaction, SIGNAL(triggered()), this, SLOT( nextEntry() ) );
 
99
    Q_ASSERT(qaction != 0);
 
100
    connect(qaction, SIGNAL(triggered()),
 
101
            this,    SLOT(nextEntry()));
104
102
    addAction(qaction);
105
103
 
106
104
    qaction = ac->action("previousEntry");
107
 
    QObject::connect(qaction, SIGNAL(triggered()), this, SLOT( previousEntry() ) );
 
105
    Q_ASSERT(qaction != 0);
 
106
    connect(qaction, SIGNAL(triggered()),
 
107
            this,   SLOT(previousEntry()));
108
108
    addAction(qaction);
109
109
 
110
110
    m_actions.selectAll = ac->action("selectAll");
111
 
    Q_ASSERT(m_actions.selectAll);
 
111
    Q_ASSERT(m_actions.selectAll != 0);
112
112
 
113
113
    m_actions.findText = ac->action("findText");
114
 
    Q_ASSERT(m_actions.findText);
 
114
    Q_ASSERT(m_actions.findText != 0);
115
115
 
116
116
    m_actions.findStrongs = ac->action(CResMgr::displaywindows::general::findStrongs::actionName);
117
 
    QObject::connect(m_actions.findStrongs, SIGNAL(triggered()), this, SLOT(openSearchStrongsDialog()) );
 
117
    Q_ASSERT(m_actions.findStrongs != 0);
 
118
    connect(m_actions.findStrongs, SIGNAL(triggered()),
 
119
            this,                  SLOT(openSearchStrongsDialog()) );
118
120
    addAction(m_actions.findStrongs);
119
121
 
120
122
    m_actions.copy.reference = ac->action("copyReferenceOnly");
121
 
    QObject::connect(m_actions.copy.reference, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorOnly()) );
 
123
    Q_ASSERT(m_actions.copy.reference != 0);
 
124
    connect(m_actions.copy.reference,            SIGNAL(triggered()),
 
125
            displayWidget()->connectionsProxy(), SLOT(copyAnchorOnly()));
122
126
    addAction(m_actions.copy.reference);
123
127
 
124
128
    m_actions.copy.entry = ac->action("copyEntryWithText");
125
 
    QObject::connect(m_actions.copy.entry, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAll()) );
 
129
    Q_ASSERT(m_actions.copy.entry != 0);
 
130
    connect(m_actions.copy.entry,                SIGNAL(triggered()),
 
131
            displayWidget()->connectionsProxy(), SLOT(copyAll()));
126
132
    addAction(m_actions.copy.entry);
127
133
 
128
 
    Q_ASSERT(ac->action("copySelectedText"));
129
134
    m_actions.copy.selectedText = ac->action("copySelectedText");
 
135
    Q_ASSERT(m_actions.copy.selectedText != 0);
130
136
 
131
137
    m_actions.save.entryAsPlain = new QAction(tr("Entry as plain text"), ac );
132
 
    QObject::connect(m_actions.save.entryAsPlain, SIGNAL(triggered()), this, SLOT(saveAsPlain()) );
 
138
    connect(m_actions.save.entryAsPlain, SIGNAL(triggered()),
 
139
            this,                        SLOT(saveAsPlain()));
133
140
    addAction(m_actions.save.entryAsPlain);
134
141
 
135
142
    m_actions.save.entryAsHTML = ac->action("saveHtml");
136
 
    QObject::connect(m_actions.save.entryAsHTML, SIGNAL(triggered()), this, SLOT(saveAsHTML()));
 
143
    Q_ASSERT(m_actions.save.entryAsHTML != 0);
 
144
    connect(m_actions.save.entryAsHTML, SIGNAL(triggered()),
 
145
            this,                       SLOT(saveAsHTML()));
137
146
    addAction(m_actions.save.entryAsHTML);
138
147
 
139
148
    m_actions.print.reference = ac->action("printReferenceOnly");
140
 
    QObject::connect(m_actions.print.reference, SIGNAL(triggered()), this, SLOT(printAnchorWithText()));
 
149
    Q_ASSERT(m_actions.print.reference != 0);
 
150
    connect(m_actions.print.reference, SIGNAL(triggered()),
 
151
            this,                      SLOT(printAnchorWithText()));
141
152
    addAction(m_actions.print.reference);
142
153
 
143
154
    m_actions.print.entry = ac->action("printEntryWithText");
144
 
    QObject::connect(m_actions.print.entry, SIGNAL(triggered()), this, SLOT(printAll()));
 
155
    Q_ASSERT(m_actions.print.entry != 0);
 
156
    connect(m_actions.print.entry, SIGNAL(triggered()),
 
157
            this,                  SLOT(printAll()));
145
158
    addAction(m_actions.print.entry);
146
159
 
147
160
    // init with the user defined settings
148
 
    qDebug() << "call CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac); and end CLexiconReadWindow::initActions";
149
161
    CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac);
150
162
}
151
163
 
152
164
/** No descriptions */
153
165
void CLexiconReadWindow::initConnections() {
154
 
    qDebug() << "CLexiconReadWindow::initConnections";
155
166
    Q_ASSERT(keyChooser());
156
167
 
157
168
    connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
182
193
}
183
194
 
184
195
void CLexiconReadWindow::initView() {
185
 
    qDebug() << "CLexiconReadWindow::initView";
186
 
 
187
196
    // Create display widget for this window
188
197
    setDisplayWidget( CDisplay::createReadInstance(this) );
189
198
    setCentralWidget( displayWidget()->view() );
219
228
    mainToolBar()->addAction(m_actions.forwardInHistory); //2nd button
220
229
 
221
230
    //Tools toolbar
222
 
    QAction* action = qobject_cast<QAction*>(actionCollection()->action(
223
 
                          CResMgr::displaywindows::general::search::actionName));
224
 
    Q_ASSERT( action );
225
 
    if (action) {
226
 
        buttonsToolBar()->addAction(action);
227
 
    }
 
231
    QAction *action = actionCollection()->action(CResMgr::displaywindows::general::search::actionName);
 
232
    Q_ASSERT(action != 0);
 
233
    buttonsToolBar()->addAction(action);
 
234
 
228
235
    BtDisplaySettingsButton* button = new BtDisplaySettingsButton(buttonsToolBar());
229
236
    setDisplaySettingsButton(button);
230
237
    buttonsToolBar()->addWidget(button);
249
256
    btMainWindow()->worksToolBar()->setModules(getModuleList(), modules().first()->type(), this);
250
257
 
251
258
    // Tools toolbar
252
 
    QAction* action = actionCollection()->action(
253
 
                          CResMgr::displaywindows::general::search::actionName);
254
 
    Q_ASSERT( action );
255
 
    if (action) {
256
 
        btMainWindow()->toolsToolBar()->addAction(action);
257
 
    }
 
259
    QAction *action = actionCollection()->action(CResMgr::displaywindows::general::search::actionName);
 
260
    Q_ASSERT(action != 0);
 
261
    btMainWindow()->toolsToolBar()->addAction(action);
258
262
    BtDisplaySettingsButton* button = new BtDisplaySettingsButton(buttonsToolBar());
259
263
    setDisplaySettingsButton(button);
260
264
    btMainWindow()->toolsToolBar()->addWidget(button);
305
309
void CLexiconReadWindow::updatePopupMenu() {
306
310
    //enable the action depending on the supported module features
307
311
 
308
 
    m_actions.findStrongs->setEnabled( displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null );
 
312
    m_actions.findStrongs->setEnabled(!displayWidget()->getCurrentNodeInfo().isNull());
309
313
 
310
314
    m_actions.copy.reference->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
311
315
    m_actions.copy.selectedText->setEnabled( displayWidget()->hasSelection() );
336
340
 
337
341
/** This function saves the entry as html using the CExportMgr class. */
338
342
void CLexiconReadWindow::saveAsHTML() {
339
 
    CExportManager mgr(tr("Saving entry ..."), true, tr("Saving"), filterOptions(), displayOptions());
 
343
    CExportManager mgr(true, tr("Saving"), filterOptions(), displayOptions());
340
344
    mgr.saveKey(key(), CExportManager::HTML, true);
341
345
}
342
346
 
343
347
/** Saving the raw HTML for debugging purposes */
344
348
void CLexiconReadWindow::saveRawHTML() {
345
 
    //qDebug() << "CLexiconReadWindow::saveRawHTML";
346
349
    QString savefilename = QFileDialog::getSaveFileName();
347
350
    if (savefilename.isEmpty()) return;
348
 
    QFile file(savefilename);
349
351
    BtHtmlReadDisplay* disp = dynamic_cast<BtHtmlReadDisplay*>(displayWidget());
350
352
    if (disp) {
 
353
        QFile file(savefilename);
351
354
        if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
352
 
            qDebug() << "could not open file";
 
355
            qWarning() << "saveRawHTML: could not open file" << savefilename;
353
356
            return;
354
357
        }
355
358
        QString source = disp->getCurrentSource();
356
359
        file.write(source.toUtf8());
357
 
        //qDebug() << "wrote" << bytes << "bytes";
358
360
        file.close();
359
361
        file.flush();
360
362
    }
361
 
    else {
362
 
        qDebug() << "No htmlreaddisplay widget!";
363
 
    }
364
 
 
365
363
}
366
364
 
367
365
/** This function saves the entry as html using the CExportMgr class. */
368
366
void CLexiconReadWindow::saveAsPlain() {
369
 
    CExportManager mgr(tr("Saving entry ..."), true, tr("Saving"), filterOptions(), displayOptions());
 
367
    CExportManager mgr(true, tr("Saving"), filterOptions(), displayOptions());
370
368
    mgr.saveKey(key(), CExportManager::Text, true);
371
369
}
372
370
 
373
371
void CLexiconReadWindow::slotFillBackHistory() {
374
 
    qDebug() << "CLexiconReadWindow::slotFillBackHistory";
375
 
 
376
372
    QMenu* menu = m_actions.backInHistory->popupMenu();
377
373
    menu->clear();
378
374
 
384
380
}
385
381
 
386
382
void CLexiconReadWindow::slotFillForwardHistory() {
387
 
    qDebug() << "CLexiconReadWindow::slotFillForwardHistory";
388
 
 
389
383
    QMenu* menu = m_actions.forwardInHistory->popupMenu();
390
384
    menu->clear();
391
385
    /// \todo take the history list and fill the menu using addAction
397
391
 
398
392
 
399
393
void CLexiconReadWindow::slotUpdateHistoryButtons(bool backEnabled, bool fwEnabled) {
400
 
    qDebug() << "CLexiconReadWindow::slotUpdateHistoryButtons";
401
394
    Q_ASSERT(m_actions.backInHistory);
402
395
    Q_ASSERT(keyChooser());
403
396