2013-01-17 09:08:53 +00:00
|
|
|
/* This file is (c) 2013 Tvangeste <i.4m.l33t@yandex.ru>
|
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#ifndef __HISTORYPANEWIDGET_HH_INCLUDED__
|
|
|
|
#define __HISTORYPANEWIDGET_HH_INCLUDED__
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QSize>
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QListView>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QMenu>
|
|
|
|
|
|
|
|
#include <config.hh>
|
|
|
|
#include "history.hh"
|
2013-07-06 15:31:31 +00:00
|
|
|
#include "delegate.hh"
|
2013-01-17 09:08:53 +00:00
|
|
|
|
|
|
|
/// A widget holding the contents of the 'History' docklet.
|
|
|
|
class HistoryPaneWidget: public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2023-07-20 08:02:22 +00:00
|
|
|
|
2013-01-17 09:08:53 +00:00
|
|
|
public:
|
|
|
|
explicit HistoryPaneWidget( QWidget * parent = 0 ):
|
|
|
|
QWidget( parent ),
|
|
|
|
itemSelectionChanged( false ),
|
2013-07-06 15:31:31 +00:00
|
|
|
listItemDelegate( 0 )
|
2013-01-17 09:08:53 +00:00
|
|
|
{
|
|
|
|
}
|
2013-07-06 15:31:31 +00:00
|
|
|
virtual ~HistoryPaneWidget();
|
2013-01-17 09:08:53 +00:00
|
|
|
|
|
|
|
virtual QSize sizeHint() const
|
|
|
|
{
|
|
|
|
return QSize( 204, 204 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void setUp( Config::Class * cfg, History * history, QMenu * menu );
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void historyItemRequested( QString const & word );
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void updateHistoryCounts();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void emitHistoryItemRequested( QModelIndex const & );
|
2023-06-11 14:31:47 +00:00
|
|
|
void onSelectionChanged( const QItemSelection & selection, const QItemSelection & deselected );
|
2013-01-17 09:08:53 +00:00
|
|
|
void onItemClicked( QModelIndex const & idx );
|
|
|
|
void showCustomMenu( QPoint const & pos );
|
|
|
|
void deleteSelectedItems();
|
2013-01-17 13:03:16 +00:00
|
|
|
void copySelectedItems();
|
2013-01-17 09:08:53 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual bool eventFilter( QObject *, QEvent * );
|
|
|
|
|
|
|
|
Config::Class * m_cfg;
|
|
|
|
History * m_history;
|
|
|
|
QListView * m_historyList;
|
|
|
|
QMenu * m_historyMenu;
|
|
|
|
QAction * m_deleteSelectedAction;
|
|
|
|
QAction * m_separator;
|
2013-01-17 13:03:16 +00:00
|
|
|
QAction * m_copySelectedToClipboard;
|
2013-01-17 09:08:53 +00:00
|
|
|
|
|
|
|
QWidget historyPaneTitleBar;
|
|
|
|
QHBoxLayout historyPaneTitleBarLayout;
|
|
|
|
QLabel historyLabel;
|
|
|
|
QLabel historyCountLabel;
|
|
|
|
|
|
|
|
/// needed to avoid multiple notifications
|
|
|
|
/// when selecting history items via mouse and keyboard
|
|
|
|
bool itemSelectionChanged;
|
|
|
|
|
2013-07-06 15:31:31 +00:00
|
|
|
WordListItemDelegate * listItemDelegate;
|
2013-01-17 09:08:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class HistoryModel: public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2023-07-20 08:02:22 +00:00
|
|
|
|
2013-01-17 09:08:53 +00:00
|
|
|
public:
|
|
|
|
explicit HistoryModel( History * history, QObject * parent = 0 );
|
|
|
|
|
|
|
|
int rowCount( QModelIndex const & parent = QModelIndex() ) const;
|
|
|
|
|
|
|
|
QVariant data( QModelIndex const & index, int role = Qt::DisplayRole ) const;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void historyChanged();
|
|
|
|
|
|
|
|
private:
|
|
|
|
History * m_history;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // HISTORYPANEWIDGET_HH
|