Restore docked outline widget. Warning: still instable!

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20147 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-09-08 17:28:14 +00:00
parent 48901a7dc6
commit 9e3823945a
5 changed files with 38 additions and 49 deletions

View File

@ -193,7 +193,9 @@ Dialog * Dialogs::build(string const & name)
dialog = new GuiThesaurusDialog(lyxview_); dialog = new GuiThesaurusDialog(lyxview_);
#endif #endif
} else if (name == "toc") { } else if (name == "toc") {
dialog = new GuiToc(lyxview_); // On Mac show as a drawer at the right
dialog = new DockView<GuiToc, TocWidget>(
guiview, name, Qt::RightDockWidgetArea, Qt::Drawer);
} else if (name == "url") { } else if (name == "url") {
dialog = new GuiURLDialog(lyxview_); dialog = new GuiURLDialog(lyxview_);
} else if (name == "vspace") { } else if (name == "vspace") {

View File

@ -32,11 +32,9 @@ namespace lyx {
namespace frontend { namespace frontend {
GuiToc::GuiToc(LyXView & lv) GuiToc::GuiToc(Dialog & dialog)
: GuiDialog(lv, "toc") : ControlToc(dialog)
{ {
setViewTitle(_("Outline"));
setController(new ControlToc(*this));
#ifdef Q_WS_MACX #ifdef Q_WS_MACX
// On Mac show as a drawer at the right // On Mac show as a drawer at the right
//setView(new DockView<GuiToc, TocWidget>( //setView(new DockView<GuiToc, TocWidget>(
@ -45,13 +43,6 @@ GuiToc::GuiToc(LyXView & lv)
//setView(new DockView<GuiToc, TocWidget>( //setView(new DockView<GuiToc, TocWidget>(
// *dialog, qtoc, &gui_view, _("Outline"))); // *dialog, qtoc, &gui_view, _("Outline")));
#endif #endif
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
}
ControlToc & GuiToc::controller() const
{
return static_cast<ControlToc &>(Dialog::controller());
} }
@ -60,7 +51,7 @@ bool GuiToc::canOutline(int type) const
if (type < 0) if (type < 0)
return false; return false;
return controller().canOutline(type); return canOutline(type);
} }
@ -103,7 +94,7 @@ QModelIndex const GuiToc::getCurrentIndex(int type) const
if(!canOutline(type)) if(!canOutline(type))
return QModelIndex(); return QModelIndex();
return toc_models_[type]->modelIndex(controller().getCurrentTocItem(type)); return toc_models_[type]->modelIndex(getCurrentTocItem(type));
} }
@ -123,13 +114,13 @@ void GuiToc::goTo(int type, QModelIndex const & index)
LYXERR(Debug::GUI) << "GuiToc::goTo " << to_utf8(it->str()) << endl; LYXERR(Debug::GUI) << "GuiToc::goTo " << to_utf8(it->str()) << endl;
controller().goTo(*it); ControlToc::goTo(*it);
} }
bool GuiToc::initialiseParams(std::string const & data) bool GuiToc::initialiseParams(std::string const & data)
{ {
if (!controller().initialiseParams(data)) if (!ControlToc::initialiseParams(data))
return false; return false;
updateView(); updateView();
modelReset(); modelReset();
@ -140,8 +131,8 @@ bool GuiToc::initialiseParams(std::string const & data)
void GuiToc::updateView() void GuiToc::updateView()
{ {
toc_models_.clear(); toc_models_.clear();
TocList::const_iterator it = controller().tocs().begin(); TocList::const_iterator it = tocs().begin();
TocList::const_iterator end = controller().tocs().end(); TocList::const_iterator end = tocs().end();
for (; it != end; ++it) for (; it != end; ++it)
toc_models_.push_back(new TocModel(it->second)); toc_models_.push_back(new TocModel(it->second));
} }

View File

@ -14,7 +14,6 @@
#ifndef GUITOC_H #ifndef GUITOC_H
#define GUITOC_H #define GUITOC_H
#include "GuiDialog.h"
#include "ControlToc.h" #include "ControlToc.h"
#include <QObject> #include <QObject>
@ -26,13 +25,13 @@ namespace frontend {
class TocModel; class TocModel;
class GuiToc : public GuiDialog class GuiToc : public QObject, public ControlToc
{ {
Q_OBJECT Q_OBJECT
public: public:
/// ///
GuiToc(LyXView & lv); GuiToc(Dialog &);
/// \c ControlToc inherited method. /// \c ControlToc inherited method.
virtual bool initialiseParams(std::string const & data); virtual bool initialiseParams(std::string const & data);
@ -51,8 +50,6 @@ public:
/// ///
int getTocDepth(int type); int getTocDepth(int type);
ControlToc & controller() const;
Q_SIGNALS: Q_SIGNALS:
/// Signal that the internal toc_models_ has been reset. /// Signal that the internal toc_models_ has been reset.
void modelReset(); void modelReset();

View File

@ -42,13 +42,13 @@ using support::libFileSearch;
namespace frontend { namespace frontend {
TocWidget::TocWidget(GuiToc * form, QWidget * parent) TocWidget::TocWidget(GuiToc & form, QWidget * parent)
: QWidget(parent), depth_(0) : QWidget(parent), depth_(0), form_(form)
{ {
setupUi(this); setupUi(this);
form_ = form; setWindowTitle(qt_("Outline"));
connect(form_, SIGNAL(modelReset()), SLOT(updateGui())); connect(&form_, SIGNAL(modelReset()), SLOT(updateGui()));
FileName icon_path = libFileSearch("images", "promote.png"); FileName icon_path = libFileSearch("images", "promote.png");
moveOutTB->setIcon(QIcon(toqstr(icon_path.absFilename()))); moveOutTB->setIcon(QIcon(toqstr(icon_path.absFilename())));
@ -85,7 +85,7 @@ void TocWidget::selectionChanged(const QModelIndex & current,
<< ", " << current.column() << ", " << current.column()
<< endl; << endl;
form_->goTo(typeCO->currentIndex(), current); form_.goTo(typeCO->currentIndex(), current);
} }
@ -94,7 +94,7 @@ void TocWidget::on_updateTB_clicked()
// The backend update can take some time so we disable // The backend update can take some time so we disable
// the controls while waiting. // the controls while waiting.
enableControls(false); enableControls(false);
form_->controller().updateBackend(); form_.updateBackend();
} }
/* FIXME (Ugras 17/11/06): /* FIXME (Ugras 17/11/06):
@ -153,8 +153,8 @@ void TocWidget::on_moveUpTB_clicked()
QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes(); QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
if (!list.isEmpty()) { if (!list.isEmpty()) {
enableControls(false); enableControls(false);
form_->goTo(typeCO->currentIndex(), list[0]); form_.goTo(typeCO->currentIndex(), list[0]);
form_->controller().outlineUp(); form_.outlineUp();
enableControls(true); enableControls(true);
} }
} }
@ -166,8 +166,8 @@ void TocWidget::on_moveDownTB_clicked()
QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes(); QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
if (!list.isEmpty()) { if (!list.isEmpty()) {
enableControls(false); enableControls(false);
form_->goTo(typeCO->currentIndex(), list[0]); form_.goTo(typeCO->currentIndex(), list[0]);
form_->controller().outlineDown(); form_.outlineDown();
enableControls(true); enableControls(true);
} }
} }
@ -179,8 +179,8 @@ void TocWidget::on_moveInTB_clicked()
QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes(); QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
if (!list.isEmpty()) { if (!list.isEmpty()) {
enableControls(false); enableControls(false);
form_->goTo(typeCO->currentIndex(), list[0]); form_.goTo(typeCO->currentIndex(), list[0]);
form_->controller().outlineIn(); form_.outlineIn();
enableControls(true); enableControls(true);
} }
} }
@ -191,8 +191,8 @@ void TocWidget::on_moveOutTB_clicked()
QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes(); QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
if (!list.isEmpty()) { if (!list.isEmpty()) {
enableControls(false); enableControls(false);
form_->goTo(typeCO->currentIndex(), list[0]); form_.goTo(typeCO->currentIndex(), list[0]);
form_->controller().outlineOut(); form_.outlineOut();
enableControls(true); enableControls(true);
} }
} }
@ -217,7 +217,7 @@ void TocWidget::enableControls(bool enable)
{ {
updateTB->setEnabled(enable); updateTB->setEnabled(enable);
if (!form_->canOutline(typeCO->currentIndex())) if (!form_.canOutline(typeCO->currentIndex()))
enable = false; enable = false;
moveUpTB->setEnabled(enable); moveUpTB->setEnabled(enable);
@ -229,17 +229,16 @@ void TocWidget::enableControls(bool enable)
} }
void TocWidget::update() void TocWidget::updateView()
{ {
LYXERR(Debug::GUI) << "In TocWidget::updateView()" << endl; LYXERR(Debug::GUI) << "In TocWidget::updateView()" << endl;
select(form_->getCurrentIndex(typeCO->currentIndex())); select(form_.getCurrentIndex(typeCO->currentIndex()));
QWidget::update();
} }
void TocWidget::updateGui() void TocWidget::updateGui()
{ {
vector<docstring> const & type_names = form_->controller().typeNames(); vector<docstring> const & type_names = form_.typeNames();
if (type_names.empty()) { if (type_names.empty()) {
enableControls(false); enableControls(false);
typeCO->clear(); typeCO->clear();
@ -262,7 +261,7 @@ void TocWidget::updateGui()
if (current_type != -1) if (current_type != -1)
typeCO->setCurrentIndex(current_type); typeCO->setCurrentIndex(current_type);
else else
typeCO->setCurrentIndex(form_->controller().selectedType()); typeCO->setCurrentIndex(form_.selectedType());
typeCO->blockSignals(false); typeCO->blockSignals(false);
setTocModel(typeCO->currentIndex()); setTocModel(typeCO->currentIndex());
@ -272,7 +271,7 @@ void TocWidget::updateGui()
void TocWidget::setTocModel(size_t type) void TocWidget::setTocModel(size_t type)
{ {
bool controls_enabled = false; bool controls_enabled = false;
QStandardItemModel * toc_model = form_->tocModel(type); QStandardItemModel * toc_model = form_.tocModel(type);
if (toc_model) { if (toc_model) {
controls_enabled = toc_model->rowCount() > 0; controls_enabled = toc_model->rowCount() > 0;
tocTV->setModel(toc_model); tocTV->setModel(toc_model);
@ -284,13 +283,13 @@ void TocWidget::setTocModel(size_t type)
reconnectSelectionModel(); reconnectSelectionModel();
if (controls_enabled) { if (controls_enabled) {
depthSL->setMaximum(form_->getTocDepth(type)); depthSL->setMaximum(form_.getTocDepth(type));
depthSL->setValue(depth_); depthSL->setValue(depth_);
} }
LYXERR(Debug::GUI) << "In TocWidget::updateGui()" << endl; LYXERR(Debug::GUI) << "In TocWidget::updateGui()" << endl;
select(form_->getCurrentIndex(typeCO->currentIndex())); select(form_.getCurrentIndex(typeCO->currentIndex()));
if (toc_model) { if (toc_model) {
LYXERR(Debug::GUI) LYXERR(Debug::GUI)

View File

@ -27,10 +27,10 @@ class TocWidget : public QWidget, public Ui::TocUi
{ {
Q_OBJECT Q_OBJECT
public: public:
TocWidget(GuiToc * form, QWidget * parent); TocWidget(GuiToc & form, QWidget * parent = 0);
/// Update the display of the dialog whilst it is still visible. /// Update the display of the dialog whilst it is still visible.
void update(); void updateView();
protected Q_SLOTS: protected Q_SLOTS:
/// Update Gui of the display. /// Update Gui of the display.
@ -69,7 +69,7 @@ private:
/// depth of list shown /// depth of list shown
int depth_; int depth_;
/// ///
GuiToc * form_; GuiToc & form_;
}; };
} // namespace frontend } // namespace frontend