diff options
Diffstat (limited to 'src/frontend/mainindex/bookmarks/cbookmarkindex.cpp')
-rw-r--r-- | src/frontend/mainindex/bookmarks/cbookmarkindex.cpp | 123 |
1 files changed, 59 insertions, 64 deletions
diff --git a/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp b/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp index 6d35793..dda763b 100644 --- a/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp +++ b/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp @@ -7,52 +7,44 @@ * **********/ -//BibleTime includes -#include "cbookmarkindex.h" - -#include "btbookmarkitembase.h" -#include "btbookmarkitem.h" -#include "btbookmarkfolder.h" -#include "btbookmarkloader.h" - -#include "backend/managers/creferencemanager.h" -#include "backend/drivers/cswordmoduleinfo.h" - -#include "frontend/searchdialog/csearchdialog.h" -#include "backend/config/cbtconfig.h" -#include "frontend/cinfodisplay.h" - -#include "frontend/cprinter.h" -#include "frontend/cdragdrop.h" - -#include "util/cresmgr.h" -#include "util/directoryutil.h" -#include "util/ctoolclass.h" +#include "frontend/mainindex/bookmarks/cbookmarkindex.h" #include <boost/scoped_ptr.hpp> - -//Qt includes -#include <QInputDialog> +#include <QAction> +#include <QApplication> +#include <QCursor> +#include <QDebug> +#include <QDrag> #include <QDragLeaveEvent> #include <QDragMoveEvent> #include <QDropEvent> #include <QHeaderView> -#include <QTimer> -#include <QToolTip> +#include <QInputDialog> #include <QList> -#include <QTreeWidget> -#include <QTreeWidgetItem> -#include <QCursor> -#include <QMouseEvent> -#include <QMessageBox> #include <QMenu> -#include <QAction> -#include <QPaintEvent> +#include <QMouseEvent> #include <QPainter> -#include <QApplication> -#include <QDrag> +#include <QPaintEvent> +#include <QTimer> +#include <QTreeWidget> +#include <QTreeWidgetItem> +#include <QToolTip> +#include "backend/config/cbtconfig.h" +#include "backend/drivers/cswordmoduleinfo.h" +#include "backend/managers/referencemanager.h" +#include "frontend/cdragdrop.h" +#include "frontend/cinfodisplay.h" +#include "frontend/cprinter.h" +#include "frontend/mainindex/bookmarks/btbookmarkitembase.h" +#include "frontend/mainindex/bookmarks/btbookmarkitem.h" +#include "frontend/mainindex/bookmarks/btbookmarkfolder.h" +#include "frontend/mainindex/bookmarks/btbookmarkloader.h" +#include "frontend/searchdialog/csearchdialog.h" +#include "util/cresmgr.h" +#include "util/tool.h" +#include "util/directory.h" +#include "util/dialogutil.h" -#include <QDebug> CBookmarkIndex::CBookmarkIndex(QWidget *parent) : QTreeWidget(parent), @@ -74,7 +66,7 @@ CBookmarkIndex::~CBookmarkIndex() { /** Initializes the view. */ void CBookmarkIndex::initView() { - //qDebug("CBookmarkIndex::initView"); + //qDebug() << "CBookmarkIndex::initView"; header()->hide(); @@ -123,7 +115,7 @@ void CBookmarkIndex::initView() { m_popup->addAction(separator); m_popup->addAction(m_actions.deleteEntries); - //qDebug("CBookmarkIndex::initView end"); + //qDebug() << "CBookmarkIndex::initView end"; } /** Convenience function for creating a new QAction. @@ -131,14 +123,15 @@ void CBookmarkIndex::initView() { * than to modify all QAction constructors. */ QAction* CBookmarkIndex::newQAction(const QString& text, const QString& pix, const int /*shortcut*/, const QObject* receiver, const char* slot, QObject* parent) { - QAction* action = new QAction(util::filesystem::DirectoryUtil::getIcon(pix), text, parent); + namespace DU = util::directory; + QAction* action = new QAction(DU::getIcon(pix), text, parent); QObject::connect(action, SIGNAL(triggered()), receiver, slot); return action; } /** Initialize the SIGNAL<->SLOT connections */ void CBookmarkIndex::initConnections() { - //qDebug("CBookmarkIndex::initConnections"); + //qDebug() << "CBookmarkIndex::initConnections"; bool ok; ok = connect(this, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*))); Q_ASSERT(ok); @@ -156,14 +149,14 @@ void CBookmarkIndex::initConnections() { * Hack to get single click and selection working. See slotExecuted. */ void CBookmarkIndex::mouseReleaseEvent(QMouseEvent* event) { - //qDebug("CBookmarkIndex::mouseReleaseEvent"); + //qDebug() << "CBookmarkIndex::mouseReleaseEvent"; m_mouseReleaseEventModifiers = event->modifiers(); QTreeWidget::mouseReleaseEvent(event); } /** Called when an item is clicked with mouse or activated with keyboard. */ void CBookmarkIndex::slotExecuted( QTreeWidgetItem* i ) { - qDebug("CBookmarkIndex::slotExecuted"); + qDebug() << "CBookmarkIndex::slotExecuted"; //HACK: checking the modifier keys from the last mouseReleaseEvent //depends on executing order: mouseReleaseEvent first, then itemClicked signal @@ -212,7 +205,7 @@ QMimeData* CBookmarkIndex::dragObject() { } void CBookmarkIndex::dragEnterEvent( QDragEnterEvent* event ) { - //qDebug("CBookmarkIndex::dragEnterEvent"); + //qDebug() << "CBookmarkIndex::dragEnterEvent"; setState(QAbstractItemView::DraggingState); QTreeWidget::dragEnterEvent(event); if (event->source() == this || event->mimeData()->hasFormat("BibleTime/Bookmark")) { @@ -222,7 +215,7 @@ void CBookmarkIndex::dragEnterEvent( QDragEnterEvent* event ) { void CBookmarkIndex::dragMoveEvent( QDragMoveEvent* event ) { - //qDebug("CBookmarkIndex::dragMoveEvent"); + //qDebug() << "CBookmarkIndex::dragMoveEvent"; // do this first, otherwise the event may be ignored QTreeWidget::dragMoveEvent(event); @@ -237,13 +230,15 @@ void CBookmarkIndex::dragMoveEvent( QDragMoveEvent* event ) { } void CBookmarkIndex::dragLeaveEvent( QDragLeaveEvent* ) { - qDebug("CBookmarkIndex::dragLeaveEvent"); + qDebug() << "CBookmarkIndex::dragLeaveEvent"; setState(QAbstractItemView::NoState); // not dragging anymore viewport()->update(); // clear the arrow } void CBookmarkIndex::paintEvent(QPaintEvent* event) { + namespace DU = util::directory; + static QPixmap pix; static int halfPixHeight; static bool arrowInitialized = false; @@ -251,14 +246,14 @@ void CBookmarkIndex::paintEvent(QPaintEvent* event) { // Initialize the static variables, including the arrow pixmap if (!arrowInitialized) { arrowInitialized = true; - int arrowSize = CToolClass::mWidth(this, 1); + int arrowSize = util::tool::mWidth(this, 1); QString fileName; - if (util::filesystem::DirectoryUtil::getIconDir().exists("pointing_arrow.svg")) { - fileName = util::filesystem::DirectoryUtil::getIconDir().filePath("pointing_arrow.svg"); + if (DU::getIconDir().exists("pointing_arrow.svg")) { + fileName = DU::getIconDir().filePath("pointing_arrow.svg"); } else { - if (util::filesystem::DirectoryUtil::getIconDir().exists("pointing_arrow.png")) { - fileName = util::filesystem::DirectoryUtil::getIconDir().filePath("pointing_arrow.png"); + if (DU::getIconDir().exists("pointing_arrow.png")) { + fileName = DU::getIconDir().filePath("pointing_arrow.png"); } else { qWarning() << "Picture file pointing_arrow.svg or .png not found!"; @@ -323,7 +318,7 @@ void CBookmarkIndex::paintEvent(QPaintEvent* event) { void CBookmarkIndex::dropEvent( QDropEvent* event ) { - qDebug("CBookmarkIndex::dropEvent"); + qDebug() << "CBookmarkIndex::dropEvent"; //setState(QAbstractItemView::NoState); // Try to prevent annoying timed autocollapsing. Remember to disconnect before return. @@ -384,7 +379,7 @@ void CBookmarkIndex::dropEvent( QDropEvent* event ) { if ( event->source() == this ) { - qDebug("dropping internal drag"); + qDebug() << "dropping internal drag"; event->accept(); bool bookmarksOnly = true; @@ -436,7 +431,7 @@ void CBookmarkIndex::dropEvent( QDropEvent* event ) { void CBookmarkIndex::createBookmarkFromDrop(QDropEvent* event, QTreeWidgetItem* parentItem, int indexInParent) { - //qDebug("CBookmarkIndex::createBookmarkFromDrop"); + //qDebug() << "CBookmarkIndex::createBookmarkFromDrop"; //take the bookmark data from the mime source const BTMimeData* mdata = dynamic_cast<const BTMimeData*>(event->mimeData()); if (mdata) { @@ -454,7 +449,7 @@ void CBookmarkIndex::createBookmarkFromDrop(QDropEvent* event, QTreeWidgetItem* /** Load the tree from file */ void CBookmarkIndex::initTree() { - qDebug("CBookmarkIndex::initTree"); + qDebug() << "CBookmarkIndex::initTree"; BtBookmarkLoader loader; addTopLevelItems(loader.loadTree()); @@ -502,7 +497,7 @@ QAction* CBookmarkIndex::action( BtBookmarkItemBase::MenuAction type ) const { /** Shows the context menu at the given position. */ void CBookmarkIndex::contextMenu(const QPoint& p) { - //qDebug("CBookmarkIndex::contextMenu"); + //qDebug() << "CBookmarkIndex::contextMenu"; //setup menu entries depending on current selection QTreeWidgetItem* i = itemAt(p); QList<QTreeWidgetItem *> items = selectedItems(); @@ -566,12 +561,12 @@ void CBookmarkIndex::contextMenu(const QPoint& p) { } //finally, open the popup m_popup->exec(mapToGlobal(p)); - //qDebug("CBookmarkIndex::contextMenu end"); + //qDebug() << "CBookmarkIndex::contextMenu end"; } /** Adds a new subfolder to the current item. */ void CBookmarkIndex::createNewFolder() { - //qDebug("CBookmarkIndex::createNewFolder"); + //qDebug() << "CBookmarkIndex::createNewFolder"; QList<QTreeWidgetItem*> selected = selectedItems(); if (selected.count() > 0) { BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem()); @@ -677,7 +672,7 @@ void CBookmarkIndex::deleteEntries(bool confirm) { } } - if (QMessageBox::question(this, tr("Delete Items"), tr("Do you really want to delete the selected items and child-items?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes) { + if (util::showQuestion(this, tr("Delete Items"), tr("Do you really want to delete the selected items and child-items?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes) { return; } } @@ -697,7 +692,7 @@ a BibleTime mimedata object. It can be dragged and dropped to a text view or som The internal drag is handled differently, it doesn't use the mimedata (see dropEvent()). */ void CBookmarkIndex::startDrag(Qt::DropActions) { - qDebug("CBookmarkIndex::startDrag"); + qDebug() << "CBookmarkIndex::startDrag"; QMimeData* mData = dragObject(); // create the data which can be used in other widgets QDrag* drag = new QDrag(this); @@ -739,10 +734,10 @@ bool CBookmarkIndex::isMultiAction( const BtBookmarkItemBase::MenuAction type ) /* Saves the bookmarks to the default bookmarks file. */ void CBookmarkIndex::saveBookmarks() { - qDebug("CBookmarkIndex::saveBookmarks()"); + qDebug() << "CBookmarkIndex::saveBookmarks()"; BtBookmarkLoader loader; loader.saveTreeFromRootItem(invisibleRootItem()); - //qDebug("CBookmarkIndex::saveBookmarks end"); + //qDebug() << "CBookmarkIndex::saveBookmarks end"; } void CBookmarkIndex::mouseMoveEvent(QMouseEvent* event) { @@ -751,7 +746,7 @@ void CBookmarkIndex::mouseMoveEvent(QMouseEvent* event) { // Restart the mag timer if we have moved to another item and shift was not pressed. QTreeWidgetItem* itemUnderPointer = itemAt(event->pos()); if (itemUnderPointer && (itemUnderPointer != m_previousEventItem) ) { - //qDebug("CBookmarkIndex::mouseMoveEvent, moved onto another item"); + //qDebug() << "CBookmarkIndex::mouseMoveEvent, moved onto another item"; if ( !(event->modifiers() & Qt::ShiftModifier)) { m_magTimer.start(); // see the ctor for the timer properties } @@ -767,7 +762,7 @@ void CBookmarkIndex::mouseMoveEvent(QMouseEvent* event) { } void CBookmarkIndex::magTimeout() { - //qDebug("CBookmarkIndex::magTimeout"); + //qDebug() << "CBookmarkIndex::magTimeout"; QTreeWidgetItem* itemUnderPointer = 0; if (underMouse()) { @@ -777,7 +772,7 @@ void CBookmarkIndex::magTimeout() { if (itemUnderPointer && (m_previousEventItem == itemUnderPointer)) { BtBookmarkItem* bitem = dynamic_cast<BtBookmarkItem*>(itemUnderPointer); if (bitem) { - //qDebug("CBookmarkIndex::timerEvent: update the infodisplay"); + //qDebug() << "CBookmarkIndex::timerEvent: update the infodisplay"; // Update the mag if (bitem->module()) { (CPointers::infoDisplay())->setInfo( |