3
* This file is part of BibleTime's source code, http://www.bibletime.info/.
5
* Copyright 1999-2008 by the BibleTime developers.
6
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
10
#include "cbookshelfindex.h"
12
#include "btindexitem.h"
13
#include "btindexmodule.h"
14
#include "btindexfolder.h"
15
#include "chidemodulechooserdialog.h"
17
#include "backend/btmoduletreeitem.h"
18
#include "backend/managers/creferencemanager.h"
20
#include "frontend/searchdialog/csearchdialog.h"
21
#include "backend/config/cbtconfig.h"
22
#include "frontend/cinfodisplay.h"
23
#include "frontend/btaboutmoduledialog.h"
24
#include "frontend/cprinter.h"
25
#include "frontend/cdragdrop.h"
27
#include "util/cresmgr.h"
28
#include "util/directoryutil.h"
31
#include <QDragLeaveEvent>
32
#include <QDragMoveEvent>
34
#include <QHeaderView> //for hiding the header
35
#include <QTimer> // for delayed auto-opening of folders
37
#include <QTreeWidget>
38
#include <QTreeWidgetItem>
39
#include <QInputDialog> // for unlocking key
43
#include <boost/scoped_ptr.hpp>
47
CBookshelfIndex::CBookshelfIndex(QWidget *parent)
48
: QTreeWidget(parent),
53
m_grouping = (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping);
54
m_showHidden = CBTConfig::get(CBTConfig::bookshelfShowHidden);
55
setContextMenuPolicy(Qt::CustomContextMenu);
61
CBookshelfIndex::~CBookshelfIndex() {}
65
/** Initializes the view. */
66
void CBookshelfIndex::initView()
68
// qDebug("CBookshelfIndex::initView");
72
setFocusPolicy(Qt::WheelFocus);
73
setAcceptDrops( false ); // TODO: accept drops
74
setDragEnabled( true );
75
setDropIndicatorShown( true );
77
setItemsExpandable(true);
78
viewport()->setAcceptDrops(false); //TODO: accept drops
79
setRootIsDecorated(false);
80
setAllColumnsShowFocus(true);
81
setSelectionMode(QAbstractItemView::ExtendedSelection);
83
//setup the popup menu
84
m_popup = new QMenu(viewport());
85
m_popup->setTitle(tr("Bookshelf"));
89
// qDebug("CBookshelfIndex::initView end");
92
void CBookshelfIndex::initActions()
95
// Each action has a type attached to it as a dynamic property, see actionenum.h.
96
// Menuitem and its subitems can have the same type.
97
// Actions can have also "singleItemAction" property if
98
// it supports only one item.
99
// See contextMenu() and BTIndexItem for how these properties are used later.
101
// Actions are added to the popup menu and also to a list for easy foreach access.
103
QMenu* actionMenu = 0;
106
// -------------------------Grouping --------------------------------------
107
actionMenu = new QMenu(tr("Grouping"), this);
108
actionMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::grouping::icon));
109
actionMenu->setProperty("indexActionType", QVariant(Grouping));
111
m_groupingGroup = new QActionGroup(this);
112
QObject::connect(m_groupingGroup, SIGNAL(triggered(QAction*)), this, SLOT(actionChangeGrouping(QAction*)) );
114
//TODO: set the inital checked state
115
action = newQAction(tr("Category/Language"), CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
116
action->setCheckable(true);
117
action->setProperty("indexActionType", QVariant(Grouping));
118
action->setProperty("grouping", BTModuleTreeItem::CatLangMod);
119
actionMenu->addAction(action);
120
m_groupingGroup->addAction(action);
121
if (m_grouping == BTModuleTreeItem::CatLangMod) action->setChecked(true);
122
m_actionList.append(action);
124
action = newQAction(tr("Category"),CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
125
action->setCheckable(true);
126
m_groupingGroup->addAction(action);
127
if (m_grouping == BTModuleTreeItem::CatMod) action->setChecked(true);
128
action->setProperty("indexActionType", QVariant(Grouping));
129
action->setProperty("grouping", BTModuleTreeItem::CatMod);
130
actionMenu->addAction(action);
131
m_actionList.append(action);
133
action = newQAction(tr("Language/Category"),CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
134
action->setCheckable(true);
135
m_groupingGroup->addAction(action);
136
if (m_grouping == BTModuleTreeItem::LangCatMod) action->setChecked(true);
137
actionMenu->addAction(action);
138
action->setProperty("indexActionType", QVariant(Grouping));
139
action->setProperty("grouping", BTModuleTreeItem::LangCatMod);
140
m_actionList.append(action);
142
action = newQAction(tr("Language"),CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
143
action->setCheckable(true);
144
m_groupingGroup->addAction(action);
145
if (m_grouping == BTModuleTreeItem::LangMod) action->setChecked(true);
146
actionMenu->addAction(action);
147
action->setProperty("indexActionType", QVariant(Grouping));
148
action->setProperty("grouping", BTModuleTreeItem::LangMod);
149
m_actionList.append(action);
151
action = newQAction(tr("Works only"),CResMgr::mainIndex::grouping::icon, 0, 0, 0, this);
152
action->setCheckable(true);
153
m_groupingGroup->addAction(action);
154
if (m_grouping == BTModuleTreeItem::Mod) action->setChecked(true);
155
actionMenu->addAction(action);
156
action->setProperty("indexActionType", QVariant(Grouping));
157
action->setProperty("grouping", BTModuleTreeItem::Mod);
158
m_actionList.append(action);
160
action = m_popup->addMenu(actionMenu);
161
action->setProperty("indexActionType", QVariant(Grouping));
162
m_actionList.append(action);
165
// ------------Hide---------------------
166
action = newQAction(tr("Hide/unhide works..."),CResMgr::mainIndex::search::icon, 0, this, SLOT(actionHideModules()), this);
167
action->setProperty("indexActionType", QVariant(HideModules));
168
//action->setProperty("multiItemAction", QVariant(true));
169
m_popup->addAction(action);
170
m_actionList.append(action);
172
// -------------------Show hidden---------------------------
173
action = newQAction(tr("Show hidden"),CResMgr::mainIndex::search::icon, 0, 0, 0, this);
174
action->setProperty("indexActionType", QVariant(ShowAllModules));
175
action->setCheckable(true);
176
QObject::connect(action, SIGNAL(toggled(bool)), this, SLOT(actionShowModules(bool)));
177
if (m_showHidden) action->setChecked(true); else action->setChecked(false);
178
m_popup->addAction(action);
179
m_actionList.append(action);
182
m_popup->addSeparator();
184
//------------------------------------------------------------
185
//----------------- Actions for items ------------------------
187
// -------------------------Edit module --------------------------------
188
actionMenu = new QMenu(tr("Edit"), this);
189
actionMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::editModuleMenu::icon) );
190
// actionMenu->setDelayed(false);
191
actionMenu->setProperty("indexActionType", QVariant(EditModule));
192
actionMenu->setProperty("singleItemAction", QVariant(true));
193
//m_actionList.append(actionMenu);
195
action = newQAction(tr("Plain text..."),CResMgr::mainIndex::editModulePlain::icon, 0, this, SLOT(actionEditModulePlain()), this);
196
actionMenu->addAction(action);
197
m_actionList.append(action);
198
action->setProperty("indexActionType", QVariant(EditModule));
199
action->setProperty("singleItemAction", QVariant(true));
201
action = newQAction(tr("HTML..."),CResMgr::mainIndex::editModuleHTML::icon, 0, this, SLOT(actionEditModuleHTML()), this);
202
actionMenu->addAction(action);
203
m_actionList.append(action);
204
action->setProperty("indexActionType", QVariant(EditModule));
205
action->setProperty("singleItemAction", QVariant(true));
207
m_actionList.append(m_popup->addMenu(actionMenu));
210
// ------------------------ Misc actions -------------------------------------
211
action = newQAction(tr("Search..."),CResMgr::mainIndex::search::icon, 0, this, SLOT(actionSearchInModules()), this);
212
action->setProperty("indexActionType", QVariant(SearchModules));
213
action->setProperty("multiItemAction", QVariant(true));
214
m_popup->addAction(action);
215
m_actionList.append(action);
217
action = newQAction(tr("Unlock..."),CResMgr::mainIndex::unlockModule::icon, 0, this, SLOT(actionUnlockModule()), this);
218
m_popup->addAction(action);
219
action->setProperty("indexActionType", QVariant(UnlockModule));
220
action->setProperty("singleItemAction", QVariant(true));
221
m_actionList.append(action);
223
action = newQAction(tr("About..."),CResMgr::mainIndex::aboutModule::icon, 0, this, SLOT(actionAboutModule()), this);
224
m_popup->addAction(action);
225
action->setProperty("singleItemAction", QVariant(true));
226
action->setProperty("indexActionType", QVariant(AboutModule));
227
m_actionList.append(action);
232
/** Convenience function for creating a new QAction.
233
* Should be replaced with something better; it was easier to make a new function
234
* than to modify all QAction constructors.
236
QAction* CBookshelfIndex::newQAction(const QString& text, const QString& pix, const int /*shortcut*/, const QObject* receiver, const char* slot, QObject* parent)
238
QAction* action = new QAction(util::filesystem::DirectoryUtil::getIcon(pix), text, parent);
239
if (receiver && !QString(slot).isEmpty())
241
QObject::connect(action, SIGNAL(triggered()), receiver, slot);
246
/** Initialize the SIGNAL<->SLOT connections */
247
void CBookshelfIndex::initConnections()
249
//Connect this to the backend module list changes.
251
ok = connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(reloadSword(CSwordBackend::SetupChangedReason)));
254
ok = connect(this, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
257
// Single/double click item activation is style dependend
258
if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) == 0)
260
ok = connect(this, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
264
ok = connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(contextMenu(const QPoint&)));
267
ok = connect(&m_autoOpenTimer, SIGNAL(timeout()), this, SLOT(autoOpenTimeout()));
270
ok = connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(slotModifySelection()));
274
void CBookshelfIndex::slotModifySelection()
276
// This creates recursion if a folder is selected, but not infinite.
277
//qDebug("CBookshelfIndex::slotModifySelection");
278
QList<QTreeWidgetItem*> selection = selectedItems();
279
foreach (QTreeWidgetItem* item, selection) {
280
BTIndexFolder* folder = dynamic_cast<BTIndexFolder*>(item);
282
item->setSelected(false);
289
* Hack to get single click and selection working. See slotExecuted.
291
void CBookshelfIndex::mouseReleaseEvent(QMouseEvent* event) {
292
//qDebug("CBookshelfIndex::mouseReleaseEvent");
293
//qDebug() << event->type() << event->modifiers();
294
if (itemAt(event->pos())) {
295
if (m_frozenModules.contains( itemAt(event->pos())->text(0) )) {
301
m_mouseReleaseEventModifiers = event->modifiers();
302
QTreeWidget::mouseReleaseEvent(event);
306
/** Called when an item is clicked with mouse or activated with keyboard. */
307
void CBookshelfIndex::slotExecuted( QTreeWidgetItem* i )
309
qDebug("CBookshelfIndex::slotExecuted");
311
//HACK: checking the modifier keys from the last mouseReleaseEvent
312
//depends on executing order: mouseReleaseEvent first, then itemClicked signal
313
int modifiers = m_mouseReleaseEventModifiers;
314
m_mouseReleaseEventModifiers = Qt::NoModifier;
315
if (modifiers != Qt::NoModifier) {
319
BTIndexItem* btItem = dynamic_cast<BTIndexItem*>(i);
321
qWarning("item was not BTIndexItem!");
325
if (BTIndexModule* m = dynamic_cast<BTIndexModule*>(i)) { //clicked on a module
326
CSwordModuleInfo* mod = m->moduleInfo();
327
if (!m_frozenModules.contains(mod->name())) {
328
m_frozenModules.insert(mod->name());
329
QList<CSwordModuleInfo*> modules;
331
qDebug("will emit createReadDisplayWindow");
332
emit createReadDisplayWindow(modules, QString::null);
336
i->setExpanded( !i->isExpanded() );
340
void CBookshelfIndex::unfreezeModules(QList<CSwordModuleInfo*> modules)
342
foreach (CSwordModuleInfo* mInfo, modules) {
343
m_frozenModules.remove(mInfo->name());
347
/** Reimplementation. Returns the drag object for the current selection. */
348
QMimeData* CBookshelfIndex::dragObject()
350
//TODO: we have to add a mime type "module" if we want to for example enable draggin a module to a displaywindow
355
/** Reimplementation from QTreeWidget. Returns true if the drag is acceptable for the widget. */
356
void CBookshelfIndex::dragEnterEvent( QDragEnterEvent* event )
358
//qDebug("CBookshelfIndex::dragEnterEvent");
359
event->acceptProposedAction();
362
void CBookshelfIndex::dragMoveEvent( QDragMoveEvent* event )
364
const QPoint pos = event->pos();
366
BTIndexItem* i = dynamic_cast<BTIndexItem*>(itemAt(pos));
367
//TODO: implement accepting drop in item
368
if (i && i->acceptDrop(event->mimeData()) ) {
369
event->acceptProposedAction();
375
void CBookshelfIndex::dropEvent( QDropEvent* event )
377
const QPoint pos = event->pos();
379
BTIndexItem* i = dynamic_cast<BTIndexItem*>(itemAt(pos));
380
//TODO: implement accepting drop in item
381
if (i && i->acceptDrop(event->mimeData()) ) {
382
QMenu* menu = new QMenu(this);
383
QAction* openAction = menu->addAction("Open reference in new subwindow");
384
QAction* searchRefAction = menu->addAction("Search for reference as crossreference");
385
QAction* searchAction = menu->addAction("Search text");
386
QAction* selectedAction = menu->exec(this->mapToGlobal(pos));
387
if (selectedAction == openAction) {;}
388
if (selectedAction == searchAction) {;}
389
if (selectedAction == searchRefAction) {;}
390
event->acceptProposedAction();
396
void CBookshelfIndex::changeEvent(QEvent* e)
398
if (e->type() == QEvent::StyleChange) {
399
// Single/double click item activation is style dependend
400
QObject::disconnect(this, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
401
if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) == 0) {
402
QObject::connect(this, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
405
QTreeWidget::changeEvent(e);
408
/** No descriptions */
409
void CBookshelfIndex::initTree() {
410
qDebug("CBookshelfIndex::initTree");
412
//first clean the tree
414
//m_grouping = (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping);
416
BTModuleTreeItem::HiddenOff hiddenFilter;
417
QList<BTModuleTreeItem::Filter*> filters;
419
filters.append(&hiddenFilter);
421
BTModuleTreeItem root(filters, m_grouping);
422
addToTree(&root, this->invisibleRootItem());
425
void CBookshelfIndex::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem)
427
foreach (BTModuleTreeItem* i, item->children()) {
428
if (i->type() == BTModuleTreeItem::Module) {
429
addToTree(i, new BTIndexModule(i, widgetItem));
432
addToTree(i, new BTIndexFolder(i, widgetItem));
434
// Possible TODO: if item is Language and it's under Category and Category is Glossaries,
435
// add the second language name - but how to add other language group?
436
// do we have to modify btmoduletreeitem?
440
/** No descriptions */
441
void CBookshelfIndex::emitModulesChosen( QList<CSwordModuleInfo*> modules, QString key ) {
442
emit createReadDisplayWindow(modules, key);
447
/** Shows the context menu at the given position. */
448
void CBookshelfIndex::contextMenu(const QPoint& p) {
449
qDebug("CBookshelfIndex::contextMenu");
450
qDebug() << "list of actions: ";
451
foreach (QAction* action, m_actionList) {
452
qDebug() << action->text();
454
//setup menu entries depending on current selection
455
QTreeWidgetItem* i = itemAt(p);
456
qDebug() << "item at point: " << i;
457
QList<QTreeWidgetItem *> items = selectedItems();
458
//The item which was clicked may not be selected - but don't add folder
459
if (i && !dynamic_cast<BTIndexFolder*>(i) && !items.contains(i))
462
// disable those menu entries which are item dependent,
463
// dis/enable some others
464
qDebug()<<"grouping action type:"<<(int)Grouping;
465
foreach (QAction* action, m_actionList) {
466
IndexAction actionType = (IndexAction)action->property("indexActionType").toInt();
467
qDebug() << "action type:" << actionType;
468
if ( actionType == Grouping ) {
469
qDebug()<<"grouping action, enabling...";
470
action->setEnabled(true);
471
qDebug()<< action->isEnabled();
473
else if (actionType == ShowAllModules) {
474
//enabled only if there are hidden modules
475
if (!CBTConfig::get(CBTConfig::hiddenModules).empty()) {
476
action->setEnabled(true);
478
action->setEnabled(false);
480
action->setChecked(m_showHidden);
483
else if (actionType == SearchModules) {
484
action->setText(tr("Search"));
485
if (items.count() > 0)
486
action->setEnabled(true);
487
else action->setEnabled(false);
489
else if (actionType == HideModules) {
490
//action->setText(tr("Hide"));
491
action->setEnabled(true);
493
else action->setEnabled(false);
497
if (items.count() == 0) {
498
//special handling for no selection: do nothing
501
if (items.count() == 1) {
502
//special handling for one selected item
503
qDebug("there was one selected item");
504
BTIndexItem* btItem = dynamic_cast<BTIndexItem*>(items.at(0));
506
if (btItem && !dynamic_cast<BTIndexFolder*>(btItem)) {
507
foreach (QAction* action, m_actionList) {
508
if ( (IndexAction)action->property("indexActionType").toInt() == AboutModule ) {
509
qDebug() << "enabling action" << action->text();
510
action->setEnabled(true);
512
else if ((IndexAction)action->property("indexActionType").toInt() == SearchModules ) {
513
// Change the text of the menu item to reflect the module name
514
BTIndexModule* modItem = dynamic_cast<BTIndexModule*>(btItem);
516
CSwordModuleInfo* info = modItem->moduleInfo();
517
action->setText(tr("Search in %1...").arg(info->name()));
521
qDebug() << "ask item" << items.at(0)->text(0) << "to enable the action" << action->text();
522
btItem->enableAction(action);
524
qDebug() << "action enabled is: " << action->isEnabled();
528
else { // more than one item
529
foreach (QAction* action, m_actionList) {
530
// Change the text of some menu items to reflect multiple selection
531
if ((IndexAction)action->property("indexActionType").toInt() == SearchModules ) {
532
action->setText(tr("Search in selected..."));
535
foreach(QTreeWidgetItem* item, items) {
536
BTIndexItem* btItem = dynamic_cast<BTIndexItem*>(item);
537
if (btItem && !action->property("singleItemAction").isValid()) {
538
btItem->enableAction(action);
544
//finally, open the popup
545
m_popup->exec(mapToGlobal(p));
548
void CBookshelfIndex::actionChangeGrouping(QAction* action)
550
BTModuleTreeItem::Grouping grouping = (BTModuleTreeItem::Grouping)action->property("grouping").toInt();
551
m_grouping = grouping;
552
CBTConfig::set(CBTConfig::bookshelfGrouping, grouping);
557
/** Opens the searchdialog for the selected modules. */
558
void CBookshelfIndex::actionSearchInModules() {
559
QList<QTreeWidgetItem *> items = selectedItems();
560
QListIterator<QTreeWidgetItem *> it(items);
561
QList<CSwordModuleInfo*> modules;
562
while(it.hasNext()) {
563
if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(it.next())) {
564
if (i->moduleInfo()) {
565
modules.append(i->moduleInfo());
570
if (modules.isEmpty()) { //get a list of useful default modules for the search if no modules were selected
571
CSwordModuleInfo* m = CBTConfig::get(CBTConfig::standardBible);
577
Search::CSearchDialog::openDialog(modules, QString::null);
580
/** Unlocks the current module. */
581
void CBookshelfIndex::actionUnlockModule() {
582
if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(currentItem())) {
584
const QString unlockKey =
585
QInputDialog::getText(
588
tr("Enter the unlock key for this work."),
590
i->moduleInfo()->config(CSwordModuleInfo::CipherKey),
595
i->moduleInfo()->unlock( unlockKey );
596
CPointers::backend()->reloadModules(CSwordBackend::OtherChange);
601
void CBookshelfIndex::actionShowModules(bool checked)
603
qDebug("CBookshelfIndex::actionShowModules");
604
m_showHidden = checked;
605
CBTConfig::set(CBTConfig::bookshelfShowHidden, m_showHidden);
606
// show hidden status is changed, notify others who may rebuild their module lists
607
CPointers::backend()->notifyChange(CSwordBackend::HidedModules);
611
void CBookshelfIndex::actionHideModules()
613
qDebug("CBookshelfIndex::actionHideModules");
615
if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(currentItem())) {
616
current = i->text(0);
619
QString title(tr("Hide/Unhide Works"));
620
QString label(tr("Select the works to be hidden."));
621
CHideModuleChooserDialog* dlg = new CHideModuleChooserDialog(this, title, label, current);
622
connect(dlg, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>)),
623
this, SLOT(setHiddenModules(QList<CSwordModuleInfo*>)));
624
int code = dlg->exec();
625
if (code == QDialog::Accepted) {
626
// notify all who may rebuild their module lists
627
CPointers::backend()->notifyChange(CSwordBackend::HidedModules);
632
/** Shows information about the current module. */
633
void CBookshelfIndex::actionAboutModule() {
634
if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(currentItem())) {
635
BTAboutModuleDialog* dialog = new BTAboutModuleDialog(this, i->moduleInfo());
641
/** Reimplementation. Takes care of movable items. */
642
void CBookshelfIndex::startDrag(Qt::DropActions /*supportedActions*/) {
646
/** Reimplementation to support the items dragEnter and dragLeave functions. */
647
void CBookshelfIndex::contentsDragMoveEvent( QDragMoveEvent* /*event*/ ) {
648
// // qWarning("void CBookshelfIndex:: drag move event ( QDragLeaveEvent* e )");
649
// CIndexItemBase* i = dynamic_cast<CIndexItemBase*>( itemAt( contentsToViewport(event->pos())) );
651
// if (i->allowAutoOpen(event) || (i->acceptDrop(event) && i->isFolder() && i->allowAutoOpen(event) && !i->isOpen() && autoOpen()) ) {
652
// if (m_autoOpenFolder != i) {
653
// m_autoOpenTimer.stop();
656
// m_autoOpenFolder = i;
657
// m_autoOpenTimer.start( 400 );
660
// m_autoOpenFolder = 0;
664
// m_autoOpenFolder = 0;
667
// QTreeWidget::contentsDragMoveEvent(event);
671
void CBookshelfIndex::autoOpenTimeout() {
672
m_autoOpenTimer.stop();
673
if (m_autoOpenFolder && !m_autoOpenFolder->isExpanded() && m_autoOpenFolder->childCount()) {
674
m_autoOpenFolder->setExpanded(true);
678
/** No descriptions */
679
void CBookshelfIndex::contentsDragLeaveEvent( QDragLeaveEvent* /*e*/ ) {
680
// m_autoOpenTimer.stop();
681
// QTreeWidget::contentsDragLeaveEvent(e);
685
/** Opens an editor window to edit the modules content. */
686
void CBookshelfIndex::actionEditModulePlain() {
687
QList<CSwordModuleInfo*> modules;
688
QList<QTreeWidgetItem *> items = selectedItems();
689
QListIterator<QTreeWidgetItem *> it(items);
691
while(it.hasNext()) {
692
if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(it.next())) {
693
modules.append(i->moduleInfo());
696
if (modules.count() == 1) {
697
emit createWriteDisplayWindow(modules.first(), QString::null, CDisplayWindow::PlainTextWindow);
701
/** Opens an editor window to edit the modules content. */
702
void CBookshelfIndex::actionEditModuleHTML() {
703
QList<CSwordModuleInfo*> modules;
704
QList<QTreeWidgetItem *> items = selectedItems();
705
QListIterator<QTreeWidgetItem *> it(items);
706
while(it.hasNext()) {
707
if (BTIndexModule* i = dynamic_cast<BTIndexModule*>(it.next())) {
708
modules.append(i->moduleInfo());
712
if (modules.count() == 1) {
713
emit createWriteDisplayWindow(modules.first(), QString::null, CDisplayWindow::HTMLWindow);
717
/** Reloads the main index's Sword dependend things like modules */
718
void CBookshelfIndex::reloadSword(CSwordBackend::SetupChangedReason) {
720
qDebug("CBookshelfIndex::reloadSword");