~pkgcrosswire/bibletime/main

« back to all changes in this revision

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

  • Committer: Jonathan Marsden
  • Date: 2011-12-23 20:32:12 UTC
  • Revision ID: jmarsden@fastmail.fm-20111223203212-1g3e35rlhbys07iu
New upstream version 2.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        m_popupMenu(0),
49
49
        m_displayWidget(0),
50
50
        m_history(0) {
51
 
    qDebug() << "CDisplayWindow::CDisplayWindow";
52
51
    setAttribute(Qt::WA_DeleteOnClose); //we want to destroy this window when it is closed
53
52
    m_actionCollection = new BtActionCollection(this);
54
53
    setModules(modules);
108
107
 
109
108
/** Returns the used modules as a pointer list */
110
109
const QList<const CSwordModuleInfo*> CDisplayWindow::modules() const {
111
 
    //qDebug() << "CDisplayWindow::modules";
112
 
 
113
110
    return CSwordBackend::instance()->getConstPointerList(m_modules);
114
111
}
115
112
 
116
113
void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
117
114
    namespace DU = util::directory;
118
115
 
119
 
    qDebug() << "CDisplayWindow::insertKeyboardActions: ac: " << a;
120
 
 
121
 
    QAction* actn = new QAction(QIcon(), tr("Zoom in"), a);
122
 
    actn->setShortcut(QKeySequence::ZoomIn);
123
 
    a->addAction("zoomIn", actn);
124
 
 
125
 
    actn = new QAction(QIcon(), tr("Zoom out"), a);
126
 
    actn->setShortcut(QKeySequence::ZoomOut);
127
 
    a->addAction("zoomOut", actn);
128
 
 
129
 
    actn = new QAction(QIcon(), tr("Select all"), a);
 
116
    QAction* actn = new QAction(QIcon(), tr("Select all"), a);
130
117
    actn->setShortcut(QKeySequence::SelectAll);
131
118
    a->addAction("selectAll", actn);
132
119
 
165
152
}
166
153
 
167
154
void CDisplayWindow::initActions() {
168
 
    qDebug() << "CDisplayWindow::initActions";
169
 
 
170
155
    BtActionCollection* ac = actionCollection();
171
156
 
172
157
    CDisplayWindow::insertKeyboardActions(ac);
173
158
 
174
159
    QAction* actn = ac->action(CResMgr::displaywindows::general::search::actionName);
175
 
    QObject::connect(actn, SIGNAL(triggered()), this, SLOT(slotSearchInModules()));
 
160
    Q_ASSERT(actn != 0);
 
161
    QObject::connect(actn, SIGNAL(triggered()),
 
162
                     this, SLOT(slotSearchInModules()));
176
163
 
177
164
    CDisplayConnections* conn = displayWidget()->connectionsProxy();
178
165
 
179
166
    actn = ac->action("openLocation");
180
 
    QObject::connect(actn, SIGNAL(triggered()), this, SLOT(setFocusKeyChooser()));
181
 
    addAction(actn);
182
 
 
183
 
    actn = ac->action("zoomIn");
184
 
    QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(zoomIn()));
185
 
    addAction(actn);
186
 
 
187
 
    actn = ac->action("zoomOut");
188
 
    QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(zoomOut()));
 
167
    Q_ASSERT(actn != 0);
 
168
    QObject::connect(actn, SIGNAL(triggered()),
 
169
                     this, SLOT(setFocusKeyChooser()));
189
170
    addAction(actn);
190
171
 
191
172
    actn = ac->action("selectAll");
192
 
    QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(selectAll()));
 
173
    Q_ASSERT(actn != 0);
 
174
    QObject::connect(actn, SIGNAL(triggered()),
 
175
                     conn, SLOT(selectAll()));
193
176
    addAction(actn);
194
177
 
195
178
    actn = ac->action("copySelectedText");
196
 
    QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(copySelection()));
 
179
    Q_ASSERT(actn != 0);
 
180
    QObject::connect(actn, SIGNAL(triggered()),
 
181
                     conn, SLOT(copySelection()));
197
182
    addAction(actn);
198
183
 
199
184
    actn = ac->action("findText");
200
 
    QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(openFindTextDialog()));
201
 
    addAction(actn);
202
 
 
203
 
    QAction* popupaction = ac->action(CResMgr::displaywindows::general::backInHistory::actionName);
204
 
    bool ok = QObject::connect(popupaction, SIGNAL(triggered()), keyChooser()->history(), SLOT(back()));
205
 
    Q_ASSERT(ok);
206
 
    addAction(popupaction);
207
 
 
208
 
    popupaction = ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName);
209
 
    ok = QObject::connect(popupaction, SIGNAL(triggered()), keyChooser()->history(), SLOT(fw()) );
210
 
    Q_ASSERT(ok);
211
 
    addAction(popupaction);
 
185
    Q_ASSERT(actn != 0);
 
186
    QObject::connect(actn, SIGNAL(triggered()),
 
187
                     conn, SLOT(openFindTextDialog()));
 
188
    addAction(actn);
 
189
 
 
190
    actn = ac->action(CResMgr::displaywindows::general::backInHistory::actionName);
 
191
    Q_ASSERT(actn != 0);
 
192
    bool ok = QObject::connect(actn,                    SIGNAL(triggered()),
 
193
                               keyChooser()->history(), SLOT(back()));
 
194
    Q_ASSERT(ok);
 
195
    addAction(actn);
 
196
 
 
197
    actn = ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName);
 
198
    Q_ASSERT(actn != 0);
 
199
    ok = QObject::connect(actn,                    SIGNAL(triggered()),
 
200
                          keyChooser()->history(), SLOT(fw()));
 
201
    Q_ASSERT(ok);
 
202
    addAction(actn);
212
203
 
213
204
    CBTConfig::setupAccelSettings(CBTConfig::allWindows, ac);
214
205
}
215
206
 
216
207
/** Refresh the settings of this window. */
217
208
void CDisplayWindow::reload(CSwordBackend::SetupChangedReason) {
218
 
    qDebug() << "CDisplayWindow::reload";
219
209
    //first make sure all used Sword modules are still present
220
210
    QMutableStringListIterator it(m_modules);
221
211
    while (it.hasNext()) {
224
214
        }
225
215
    }
226
216
 
227
 
    if (m_modules.count() == 0) {
 
217
    if (m_modules.isEmpty()) {
228
218
        close();
229
219
        return;
230
220
    }
235
225
 
236
226
    CBTConfig::setupAccelSettings(CBTConfig::allWindows, actionCollection());
237
227
    CBTConfig::setupAccelSettings(CBTConfig::readWindow, actionCollection());
238
 
    qDebug() << "CDisplayWindow::reload emits sigModuleListSet...";
239
228
    emit sigModuleListSet(m_modules);
240
229
}
241
230
 
242
231
void CDisplayWindow::slotAddModule(int index, QString module) {
243
 
    qDebug() << "CDisplayWindow::slotAddModule";
244
232
    m_modules.insert(index, module);
245
233
    lookup();
246
234
    modulesChanged();
257
245
}
258
246
 
259
247
void CDisplayWindow::slotRemoveModule(int index) {
260
 
    qDebug() << "CDisplayWindow::slotRemoveModule";
261
248
    m_modules.removeAt(index);
262
249
    lookup();
263
250
    modulesChanged();
320
307
 
321
308
/** Sets the module chooser bar. */
322
309
void CDisplayWindow::setModuleChooserBar( BtModuleChooserBar* bar ) {
323
 
    qDebug() << "CDisplayWindow::setModuleChooserBar";
324
310
    if (m_moduleChooserBar) {
325
311
        m_moduleChooserBar->deleteLater();
326
312
    }
344
330
 
345
331
/** Sets the modules. */
346
332
void CDisplayWindow::setModules( const QList<CSwordModuleInfo*>& newModules ) {
347
 
    qDebug() << "CDisplayWindow::setModules";
348
333
    m_modules.clear();
349
334
 
350
335
    foreach (CSwordModuleInfo* mod, newModules) {
354
339
 
355
340
/** Initialize the window. Call this method from the outside, because calling this in the constructor is not possible! */
356
341
bool CDisplayWindow::init() {
357
 
    qDebug() << "CDisplayWindow::init";
358
342
    initView();
359
343
    setMinimumSize( 100, 100 );
360
344
 
490
474
    */
491
475
    Q_ASSERT(modules().first());
492
476
 
493
 
    qDebug() << "CDisplayWindow::lookupKey: " << keyName;
494
477
    lookupModKey(modules().first()->name(), keyName);
495
478
}
496
479