summaryrefslogtreecommitdiff
path: root/src/frontend/displaywindow/clexiconreadwindow.cpp
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:40 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:40 -0400
commit00bc0a3de99e088902379dcb2905fb1546c7eca2 (patch)
treed248b25166e49de203f8b85702a8c88af52c0339 /src/frontend/displaywindow/clexiconreadwindow.cpp
parentdf8f1d512c60a96f9041f9663b3fdc2db51cba33 (diff)
Imported Upstream version 2.9.1
Diffstat (limited to 'src/frontend/displaywindow/clexiconreadwindow.cpp')
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp101
1 files changed, 47 insertions, 54 deletions
diff --git a/src/frontend/displaywindow/clexiconreadwindow.cpp b/src/frontend/displaywindow/clexiconreadwindow.cpp
index dae85e3..7d76293 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.cpp
+++ b/src/frontend/displaywindow/clexiconreadwindow.cpp
@@ -38,7 +38,6 @@
CLexiconReadWindow::CLexiconReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent)
: CReadWindow(moduleList, parent) {
- qDebug() << "CLexiconReadWindow::CLexiconReadWindow";
moduleList.first();
setKey( CSwordKey::createInstance(moduleList.first()) );
}
@@ -47,7 +46,6 @@ CLexiconReadWindow::~CLexiconReadWindow() {
}
void CLexiconReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
- qDebug() << "CLexiconReadWindow::insertKeyboardActions";
QAction* qaction;
qaction = new QAction( tr("Next entry"), a);
qaction->setShortcut(CResMgr::displaywindows::lexiconWindow::nextEntry::accel);
@@ -81,77 +79,90 @@ void CLexiconReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
}
void CLexiconReadWindow::initActions() {
- qDebug() << "CLexiconReadWindow::initActions";
-
BtActionCollection* ac = actionCollection();
CReadWindow::initActions();
CLexiconReadWindow::insertKeyboardActions(ac);
- m_actions.backInHistory = dynamic_cast<BtToolBarPopupAction*>(
- ac->action(CResMgr::displaywindows::general::backInHistory::actionName) );
+ QAction *qaction = ac->action(CResMgr::displaywindows::general::backInHistory::actionName);
+ Q_ASSERT(qaction != 0);
+ m_actions.backInHistory = dynamic_cast<BtToolBarPopupAction*>(qaction);
Q_ASSERT(m_actions.backInHistory);
addAction(m_actions.backInHistory);
- m_actions.forwardInHistory = dynamic_cast<BtToolBarPopupAction*>(
- ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName) );
+ qaction = ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName);
+ Q_ASSERT(qaction != 0);
+ m_actions.forwardInHistory = dynamic_cast<BtToolBarPopupAction*>(qaction);
Q_ASSERT(m_actions.forwardInHistory);
addAction(m_actions.forwardInHistory);
- QAction* qaction;
-
qaction = ac->action("nextEntry");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT( nextEntry() ) );
+ Q_ASSERT(qaction != 0);
+ connect(qaction, SIGNAL(triggered()),
+ this, SLOT(nextEntry()));
addAction(qaction);
qaction = ac->action("previousEntry");
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT( previousEntry() ) );
+ Q_ASSERT(qaction != 0);
+ connect(qaction, SIGNAL(triggered()),
+ this, SLOT(previousEntry()));
addAction(qaction);
m_actions.selectAll = ac->action("selectAll");
- Q_ASSERT(m_actions.selectAll);
+ Q_ASSERT(m_actions.selectAll != 0);
m_actions.findText = ac->action("findText");
- Q_ASSERT(m_actions.findText);
+ Q_ASSERT(m_actions.findText != 0);
m_actions.findStrongs = ac->action(CResMgr::displaywindows::general::findStrongs::actionName);
- QObject::connect(m_actions.findStrongs, SIGNAL(triggered()), this, SLOT(openSearchStrongsDialog()) );
+ Q_ASSERT(m_actions.findStrongs != 0);
+ connect(m_actions.findStrongs, SIGNAL(triggered()),
+ this, SLOT(openSearchStrongsDialog()) );
addAction(m_actions.findStrongs);
m_actions.copy.reference = ac->action("copyReferenceOnly");
- QObject::connect(m_actions.copy.reference, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorOnly()) );
+ Q_ASSERT(m_actions.copy.reference != 0);
+ connect(m_actions.copy.reference, SIGNAL(triggered()),
+ displayWidget()->connectionsProxy(), SLOT(copyAnchorOnly()));
addAction(m_actions.copy.reference);
m_actions.copy.entry = ac->action("copyEntryWithText");
- QObject::connect(m_actions.copy.entry, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAll()) );
+ Q_ASSERT(m_actions.copy.entry != 0);
+ connect(m_actions.copy.entry, SIGNAL(triggered()),
+ displayWidget()->connectionsProxy(), SLOT(copyAll()));
addAction(m_actions.copy.entry);
- Q_ASSERT(ac->action("copySelectedText"));
m_actions.copy.selectedText = ac->action("copySelectedText");
+ Q_ASSERT(m_actions.copy.selectedText != 0);
m_actions.save.entryAsPlain = new QAction(tr("Entry as plain text"), ac );
- QObject::connect(m_actions.save.entryAsPlain, SIGNAL(triggered()), this, SLOT(saveAsPlain()) );
+ connect(m_actions.save.entryAsPlain, SIGNAL(triggered()),
+ this, SLOT(saveAsPlain()));
addAction(m_actions.save.entryAsPlain);
m_actions.save.entryAsHTML = ac->action("saveHtml");
- QObject::connect(m_actions.save.entryAsHTML, SIGNAL(triggered()), this, SLOT(saveAsHTML()));
+ Q_ASSERT(m_actions.save.entryAsHTML != 0);
+ connect(m_actions.save.entryAsHTML, SIGNAL(triggered()),
+ this, SLOT(saveAsHTML()));
addAction(m_actions.save.entryAsHTML);
m_actions.print.reference = ac->action("printReferenceOnly");
- QObject::connect(m_actions.print.reference, SIGNAL(triggered()), this, SLOT(printAnchorWithText()));
+ Q_ASSERT(m_actions.print.reference != 0);
+ connect(m_actions.print.reference, SIGNAL(triggered()),
+ this, SLOT(printAnchorWithText()));
addAction(m_actions.print.reference);
m_actions.print.entry = ac->action("printEntryWithText");
- QObject::connect(m_actions.print.entry, SIGNAL(triggered()), this, SLOT(printAll()));
+ Q_ASSERT(m_actions.print.entry != 0);
+ connect(m_actions.print.entry, SIGNAL(triggered()),
+ this, SLOT(printAll()));
addAction(m_actions.print.entry);
// init with the user defined settings
- qDebug() << "call CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac); and end CLexiconReadWindow::initActions";
CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac);
}
/** No descriptions */
void CLexiconReadWindow::initConnections() {
- qDebug() << "CLexiconReadWindow::initConnections";
Q_ASSERT(keyChooser());
connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
@@ -182,8 +193,6 @@ void CLexiconReadWindow::initConnections() {
}
void CLexiconReadWindow::initView() {
- qDebug() << "CLexiconReadWindow::initView";
-
// Create display widget for this window
setDisplayWidget( CDisplay::createReadInstance(this) );
setCentralWidget( displayWidget()->view() );
@@ -219,12 +228,10 @@ void CLexiconReadWindow::initToolbars() {
mainToolBar()->addAction(m_actions.forwardInHistory); //2nd button
//Tools toolbar
- QAction* action = qobject_cast<QAction*>(actionCollection()->action(
- CResMgr::displaywindows::general::search::actionName));
- Q_ASSERT( action );
- if (action) {
- buttonsToolBar()->addAction(action);
- }
+ QAction *action = actionCollection()->action(CResMgr::displaywindows::general::search::actionName);
+ Q_ASSERT(action != 0);
+ buttonsToolBar()->addAction(action);
+
BtDisplaySettingsButton* button = new BtDisplaySettingsButton(buttonsToolBar());
setDisplaySettingsButton(button);
buttonsToolBar()->addWidget(button);
@@ -249,12 +256,9 @@ void CLexiconReadWindow::setupMainWindowToolBars() {
btMainWindow()->worksToolBar()->setModules(getModuleList(), modules().first()->type(), this);
// Tools toolbar
- QAction* action = actionCollection()->action(
- CResMgr::displaywindows::general::search::actionName);
- Q_ASSERT( action );
- if (action) {
- btMainWindow()->toolsToolBar()->addAction(action);
- }
+ QAction *action = actionCollection()->action(CResMgr::displaywindows::general::search::actionName);
+ Q_ASSERT(action != 0);
+ btMainWindow()->toolsToolBar()->addAction(action);
BtDisplaySettingsButton* button = new BtDisplaySettingsButton(buttonsToolBar());
setDisplaySettingsButton(button);
btMainWindow()->toolsToolBar()->addWidget(button);
@@ -305,7 +309,7 @@ void CLexiconReadWindow::setupPopupMenu() {
void CLexiconReadWindow::updatePopupMenu() {
//enable the action depending on the supported module features
- m_actions.findStrongs->setEnabled( displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null );
+ m_actions.findStrongs->setEnabled(!displayWidget()->getCurrentNodeInfo().isNull());
m_actions.copy.reference->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
m_actions.copy.selectedText->setEnabled( displayWidget()->hasSelection() );
@@ -336,43 +340,35 @@ CSwordLDKey* CLexiconReadWindow::ldKey() {
/** This function saves the entry as html using the CExportMgr class. */
void CLexiconReadWindow::saveAsHTML() {
- CExportManager mgr(tr("Saving entry ..."), true, tr("Saving"), filterOptions(), displayOptions());
+ CExportManager mgr(true, tr("Saving"), filterOptions(), displayOptions());
mgr.saveKey(key(), CExportManager::HTML, true);
}
/** Saving the raw HTML for debugging purposes */
void CLexiconReadWindow::saveRawHTML() {
- //qDebug() << "CLexiconReadWindow::saveRawHTML";
QString savefilename = QFileDialog::getSaveFileName();
if (savefilename.isEmpty()) return;
- QFile file(savefilename);
BtHtmlReadDisplay* disp = dynamic_cast<BtHtmlReadDisplay*>(displayWidget());
if (disp) {
+ QFile file(savefilename);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- qDebug() << "could not open file";
+ qWarning() << "saveRawHTML: could not open file" << savefilename;
return;
}
QString source = disp->getCurrentSource();
file.write(source.toUtf8());
- //qDebug() << "wrote" << bytes << "bytes";
file.close();
file.flush();
}
- else {
- qDebug() << "No htmlreaddisplay widget!";
- }
-
}
/** This function saves the entry as html using the CExportMgr class. */
void CLexiconReadWindow::saveAsPlain() {
- CExportManager mgr(tr("Saving entry ..."), true, tr("Saving"), filterOptions(), displayOptions());
+ CExportManager mgr(true, tr("Saving"), filterOptions(), displayOptions());
mgr.saveKey(key(), CExportManager::Text, true);
}
void CLexiconReadWindow::slotFillBackHistory() {
- qDebug() << "CLexiconReadWindow::slotFillBackHistory";
-
QMenu* menu = m_actions.backInHistory->popupMenu();
menu->clear();
@@ -384,8 +380,6 @@ void CLexiconReadWindow::slotFillBackHistory() {
}
void CLexiconReadWindow::slotFillForwardHistory() {
- qDebug() << "CLexiconReadWindow::slotFillForwardHistory";
-
QMenu* menu = m_actions.forwardInHistory->popupMenu();
menu->clear();
/// \todo take the history list and fill the menu using addAction
@@ -397,7 +391,6 @@ void CLexiconReadWindow::slotFillForwardHistory() {
void CLexiconReadWindow::slotUpdateHistoryButtons(bool backEnabled, bool fwEnabled) {
- qDebug() << "CLexiconReadWindow::slotUpdateHistoryButtons";
Q_ASSERT(m_actions.backInHistory);
Q_ASSERT(keyChooser());