2006-03-05 17:24:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2007-03-12 14:23:44 +00:00
|
|
|
* \file TocWidget.h
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2007-03-12 14:23:44 +00:00
|
|
|
#ifndef TOC_WIDGET_H
|
|
|
|
#define TOC_WIDGET_H
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-08-11 15:48:15 +00:00
|
|
|
#include "ui_TocUi.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2009-04-08 21:06:58 +00:00
|
|
|
#include "Cursor.h"
|
2010-02-26 19:51:06 +00:00
|
|
|
#include "FuncCode.h"
|
2009-04-08 21:06:58 +00:00
|
|
|
|
2008-05-30 11:33:24 +00:00
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
class QModelIndex;
|
2008-05-02 12:09:51 +00:00
|
|
|
class QString;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2008-05-30 11:33:24 +00:00
|
|
|
class GuiView;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-03 20:28:26 +00:00
|
|
|
class TocWidget : public QWidget, public Ui::TocUi
|
|
|
|
{
|
2006-03-05 17:24:44 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2008-05-30 11:33:24 +00:00
|
|
|
///
|
|
|
|
TocWidget(GuiView & gui_view, QWidget * parent = 0);
|
2008-05-02 12:09:51 +00:00
|
|
|
|
|
|
|
/// Initialise GUI.
|
|
|
|
void init(QString const & str);
|
2009-04-11 11:43:13 +00:00
|
|
|
///
|
2009-04-09 18:24:28 +00:00
|
|
|
void doDispatch(Cursor & cur, FuncRequest const & fr);
|
2009-04-11 11:43:13 +00:00
|
|
|
///
|
|
|
|
bool getStatus(Cursor & cur, FuncRequest const & fr, FuncStatus & status)
|
|
|
|
const;
|
2009-04-08 21:06:58 +00:00
|
|
|
|
2008-04-27 22:24:20 +00:00
|
|
|
public Q_SLOTS:
|
2010-12-19 22:27:21 +00:00
|
|
|
/// Schedule new update of the display unless already scheduled.
|
2007-09-08 17:28:14 +00:00
|
|
|
void updateView();
|
2010-12-19 22:27:21 +00:00
|
|
|
/// Update the display of the dialog whilst it is still visible.
|
|
|
|
void updateViewForce();
|
2006-04-18 09:57:47 +00:00
|
|
|
|
2008-02-12 07:47:16 +00:00
|
|
|
protected Q_SLOTS:
|
2007-03-16 14:14:55 +00:00
|
|
|
///
|
2006-04-18 09:57:47 +00:00
|
|
|
void select(QModelIndex const & index);
|
|
|
|
///
|
2008-05-17 17:03:53 +00:00
|
|
|
void goTo(QModelIndex const &);
|
2006-04-18 09:57:47 +00:00
|
|
|
|
2008-05-17 17:03:53 +00:00
|
|
|
void on_tocTV_activated(QModelIndex const &);
|
2009-04-08 17:39:14 +00:00
|
|
|
void on_tocTV_pressed(QModelIndex const &);
|
2007-05-04 17:37:05 +00:00
|
|
|
void on_updateTB_clicked();
|
2008-09-28 17:14:29 +00:00
|
|
|
void on_sortCB_stateChanged(int state);
|
2008-10-02 15:00:43 +00:00
|
|
|
void on_persistentCB_stateChanged(int state);
|
2006-03-31 13:17:44 +00:00
|
|
|
void on_depthSL_valueChanged(int depth);
|
2007-05-10 16:25:11 +00:00
|
|
|
void on_typeCO_currentIndexChanged(int value);
|
2007-05-04 17:37:05 +00:00
|
|
|
void on_moveUpTB_clicked();
|
|
|
|
void on_moveDownTB_clicked();
|
|
|
|
void on_moveInTB_clicked();
|
|
|
|
void on_moveOutTB_clicked();
|
2010-02-13 08:30:16 +00:00
|
|
|
void filterContents();
|
2006-03-29 16:57:47 +00:00
|
|
|
|
2009-04-08 21:06:58 +00:00
|
|
|
void showContextMenu(const QPoint & pos);
|
|
|
|
|
2008-05-02 12:09:51 +00:00
|
|
|
private:
|
2006-04-18 09:57:47 +00:00
|
|
|
///
|
2007-04-17 10:27:53 +00:00
|
|
|
void enableControls(bool enable = true);
|
2006-11-17 17:19:43 +00:00
|
|
|
///
|
2016-04-29 21:29:27 +00:00
|
|
|
bool canOutline()
|
2010-02-26 19:48:20 +00:00
|
|
|
{ return current_type_ == "tableofcontents"; }
|
|
|
|
/// It is not possible to have synchronous navigation in a correct
|
|
|
|
/// and efficient way with the label and change type because Toc::item()
|
|
|
|
/// does a linear search. Even when fixed, it might even not be desirable
|
|
|
|
/// to do so if we want to support drag&drop of labels and references.
|
2016-04-29 21:29:27 +00:00
|
|
|
bool canNavigate()
|
2010-02-26 19:48:20 +00:00
|
|
|
{ return current_type_ != "label" && current_type_ != "change"; }
|
2016-04-29 21:29:27 +00:00
|
|
|
///
|
2010-02-26 19:48:20 +00:00
|
|
|
bool isSortable()
|
|
|
|
{ return current_type_ != "tableofcontents"; }
|
|
|
|
///
|
2007-03-12 14:23:44 +00:00
|
|
|
void setTreeDepth(int depth);
|
2008-05-30 11:59:57 +00:00
|
|
|
///
|
2010-02-26 19:51:06 +00:00
|
|
|
void outline(FuncCode func_code);
|
2009-04-11 11:43:13 +00:00
|
|
|
/// finds the inset that is connected to the current item,
|
|
|
|
/// if any, otherwise return null
|
|
|
|
Inset * itemInset() const;
|
2008-06-17 15:10:03 +00:00
|
|
|
///
|
|
|
|
QString current_type_;
|
2006-04-05 23:56:29 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
/// depth of list shown
|
|
|
|
int depth_;
|
2008-10-02 15:00:43 +00:00
|
|
|
/// persistence of uncollapsed nodes in toc view
|
|
|
|
bool persistent_;
|
2007-09-05 20:33:29 +00:00
|
|
|
///
|
2008-05-30 11:33:24 +00:00
|
|
|
GuiView & gui_view_;
|
2010-12-19 22:27:21 +00:00
|
|
|
// next delay for outliner update in ms. -1 when already scheduled.
|
|
|
|
int update_delay_;
|
2006-03-05 17:24:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2007-03-12 14:23:44 +00:00
|
|
|
#endif // TOC_WIDGET_H
|