2006-03-05 17:24:44 +00:00
|
|
|
/**
|
|
|
|
* \file QTocDialog.C
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "QTocDialog.h"
|
|
|
|
#include "QToc.h"
|
2006-04-11 09:56:56 +00:00
|
|
|
#include "Qt2BC.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "qt_helpers.h"
|
|
|
|
#include "controllers/ControlToc.h"
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
#include <QTreeWidgetItem>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QCloseEvent>
|
2006-04-18 09:57:47 +00:00
|
|
|
#include <QHeaderView>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <stack>
|
|
|
|
|
|
|
|
using std::endl;
|
|
|
|
using std::pair;
|
|
|
|
using std::stack;
|
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
QTocDialog::QTocDialog(Dialog & dialog, QToc * form)
|
|
|
|
: Dialog::View(dialog, "Toc"), form_(form), depth_(2)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
update();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
connect(tocTV->selectionModel(),
|
|
|
|
SIGNAL(currentChanged(const QModelIndex &,
|
|
|
|
const QModelIndex &)),
|
|
|
|
this, SLOT(selectionChanged(const QModelIndex &,
|
|
|
|
const QModelIndex &)));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QTocDialog::~QTocDialog()
|
|
|
|
{
|
2006-03-31 13:17:44 +00:00
|
|
|
accept();
|
|
|
|
}
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
void QTocDialog::selectionChanged(const QModelIndex & current,
|
|
|
|
const QModelIndex & previous)
|
|
|
|
{
|
|
|
|
lyxerr[Debug::GUI]
|
|
|
|
<< "selectionChanged index " << current.row() << ", " << current.column()
|
|
|
|
<< endl;
|
|
|
|
|
|
|
|
form_->goTo(current);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QTocDialog::on_tocTV_clicked(const QModelIndex & index )
|
2006-03-31 13:17:44 +00:00
|
|
|
{
|
2006-04-18 09:57:47 +00:00
|
|
|
lyxerr[Debug::GUI]
|
|
|
|
<< "on_tocTV_clicked index " << index.row() << ", " << index.column()
|
|
|
|
<< endl;
|
|
|
|
|
|
|
|
form_->goTo(index);
|
2006-03-31 13:17:44 +00:00
|
|
|
}
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
|
2006-03-31 13:17:44 +00:00
|
|
|
void QTocDialog::on_closePB_clicked()
|
|
|
|
{
|
|
|
|
accept();
|
|
|
|
}
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
|
2006-03-31 13:17:44 +00:00
|
|
|
void QTocDialog::on_updatePB_clicked()
|
|
|
|
{
|
|
|
|
form_->update();
|
2006-04-18 09:57:47 +00:00
|
|
|
update();
|
2006-03-31 13:17:44 +00:00
|
|
|
}
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
|
2006-04-05 23:56:29 +00:00
|
|
|
void QTocDialog::on_depthSL_valueChanged(int depth)
|
2006-03-31 13:17:44 +00:00
|
|
|
{
|
|
|
|
if (depth == depth_)
|
|
|
|
return;
|
|
|
|
|
|
|
|
depth_ = depth;
|
2006-04-18 09:57:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
while (
|
|
|
|
tocTv->setExpanded();
|
|
|
|
if (iter->depth > depth_)
|
|
|
|
tocTV->collapseItem(topLevelItem);
|
|
|
|
else if (iter->depth <= depth_)
|
|
|
|
tocTV->expandItem(topLevelItem);
|
|
|
|
*/
|
2006-03-31 13:17:44 +00:00
|
|
|
}
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
|
2006-03-31 13:17:44 +00:00
|
|
|
void QTocDialog::on_typeCO_activated(int value)
|
|
|
|
{
|
2006-04-18 09:57:47 +00:00
|
|
|
form_->setTocModel(value);
|
|
|
|
enableButtons();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
|
2006-03-29 16:57:47 +00:00
|
|
|
void QTocDialog::on_moveUpPB_clicked()
|
|
|
|
{
|
2006-04-18 09:57:47 +00:00
|
|
|
move(toc::UP);
|
2006-03-29 16:57:47 +00:00
|
|
|
}
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
|
2006-03-29 16:57:47 +00:00
|
|
|
void QTocDialog::on_moveDownPB_clicked()
|
|
|
|
{
|
2006-04-18 09:57:47 +00:00
|
|
|
move(toc::DOWN);
|
2006-03-29 16:57:47 +00:00
|
|
|
}
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
|
2006-03-29 16:57:47 +00:00
|
|
|
void QTocDialog::on_moveInPB_clicked()
|
|
|
|
{
|
2006-04-18 09:57:47 +00:00
|
|
|
move(toc::IN);
|
2006-03-29 16:57:47 +00:00
|
|
|
}
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
|
2006-03-29 16:57:47 +00:00
|
|
|
void QTocDialog::on_moveOutPB_clicked()
|
|
|
|
{
|
2006-04-18 09:57:47 +00:00
|
|
|
move(toc::OUT);
|
2006-03-29 16:57:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
void QTocDialog::move(toc::OutlineOp const operation)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-04-18 09:57:47 +00:00
|
|
|
enableButtons(false);
|
|
|
|
QModelIndex index = tocTV->selectionModel()->selectedIndexes()[0];
|
|
|
|
form_->move(operation, index);
|
|
|
|
select(index);
|
|
|
|
enableButtons();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
void QTocDialog::select(QModelIndex const & index)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-04-18 09:57:47 +00:00
|
|
|
tocTV->setModel(form_->tocModel());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
if (index.isValid()) {
|
|
|
|
tocTV->scrollTo(index);
|
|
|
|
tocTV->selectionModel()->select(index, QItemSelectionModel::Select);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
2006-04-18 09:57:47 +00:00
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
void QTocDialog::enableButtons(bool enable)
|
|
|
|
{
|
|
|
|
updatePB->setEnabled(enable);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
if (!form_->canOutline())
|
|
|
|
enable = false;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
moveUpPB->setEnabled(enable);
|
|
|
|
moveDownPB->setEnabled(enable);
|
|
|
|
moveInPB->setEnabled(enable);
|
|
|
|
moveOutPB->setEnabled(enable);
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
void QTocDialog::update()
|
|
|
|
{
|
|
|
|
typeCO->setModel(form_->typeModel());
|
|
|
|
tocTV->setModel(form_->tocModel());
|
|
|
|
tocTV->showColumn(0);
|
|
|
|
// hide the pointless QHeader for now
|
|
|
|
// in the future, new columns may appear
|
|
|
|
// like labels, bookmarks, etc...
|
|
|
|
// tocTV->header()->hide();
|
|
|
|
tocTV->header()->setVisible(true);
|
|
|
|
enableButtons();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
connect(tocTV->selectionModel(),
|
|
|
|
SIGNAL(currentChanged(const QModelIndex &,
|
|
|
|
const QModelIndex &)),
|
|
|
|
this, SLOT(selectionChanged(const QModelIndex &,
|
|
|
|
const QModelIndex &)));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
lyxerr[Debug::GUI]
|
|
|
|
<< "form_->tocModel()->rowCount " << form_->tocModel()->rowCount()
|
|
|
|
<< "\nform_->tocModel()->columnCount " << form_->tocModel()->columnCount()
|
|
|
|
<< endl;
|
|
|
|
// setTitle(form_->guiname())
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
void QTocDialog::apply()
|
|
|
|
{
|
|
|
|
// Nothing to do here... for now.
|
|
|
|
// Ideas welcome... (Abdel, 17042006)
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
void QTocDialog::hide()
|
|
|
|
{
|
|
|
|
accept();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
|
|
|
|
void QTocDialog::show()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-04-18 09:57:47 +00:00
|
|
|
form_->update();
|
|
|
|
update();
|
|
|
|
QDialog::show();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
bool QTocDialog::isVisible() const
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-04-18 09:57:47 +00:00
|
|
|
return QDialog::isVisible();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|