#include "qt_helpers.h"
#include "Buffer.h"
+#include "BufferParams.h"
#include "BufferView.h"
#include "Cursor.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
-#include "LyXFunc.h"
+#include "LyX.h"
#include "insets/Inset.h"
#include "support/debug.h"
+#include "support/gettext.h"
#include "support/lassert.h"
#include <QLabel>
namespace lyx {
namespace frontend {
-bool CheckedLineEdit2::check() const
-{
- bool const valid = input_->hasAcceptableInput();
- // Visual feedback.
- setValid(input_, valid);
- if (label_)
- setValid(label_, valid);
- return valid;
-}
-
-
Dialog::Dialog(GuiView & lv, QString const & name, QString const & title)
: name_(name), title_(title), lyxview_(&lv)
{}
{}
-void Dialog::addCheckedWidget(QLineEdit * input, QWidget * label)
-{
- checked_line_edits_.append(CheckedLineEdit2(input, label));
-}
-
-
-bool Dialog::checkWidgets() const
-{
- bool valid = true;
- Q_FOREACH(CheckedLineEdit2 const & le, checked_line_edits_)
- valid &= le.check();
- return valid;
-}
-
-
bool Dialog::canApply() const
{
FuncRequest const fr(getLfun(), fromqstr(name_));
}
-QString Dialog::bufferFilepath() const
+QString Dialog::bufferFilePath() const
{
return toqstr(buffer().filePath());
}
KernelDocType Dialog::docType() const
{
- if (buffer().isLatex())
+ if (buffer().params().isLatex())
return LATEX;
- if (buffer().isLiterate())
+ if (buffer().params().isLiterate())
return LITERATE;
return DOCBOOK;
Buffer const & Dialog::buffer() const
{
- LASSERT(lyxview_->currentBufferView(), /**/);
+ LAPPERR(lyxview_->currentBufferView());
return lyxview_->currentBufferView()->buffer();
}
+Buffer const & Dialog::documentBuffer() const
+{
+ LAPPERR(lyxview_->documentBufferView());
+ return lyxview_->documentBufferView()->buffer();
+}
+
+
void Dialog::showData(string const & data)
{
if (isBufferDependent() && !isBufferAvailable())
Inset const * Dialog::inset(InsetCode code) const
{
+ // ins: the innermost inset of the type we look for
+ // that contains the cursor
Inset * ins = bufferview()->cursor().innerInsetOfType(code);
- if (!ins)
- ins = bufferview()->cursor().nextInset();
- if (!ins || ins->lyxCode() != code)
- return 0;
+ // next: a potential inset at cursor position
+ Inset * next = bufferview()->cursor().nextInset();
+ // Check if next is of the type we look for
+ if (next)
+ if (next->lyxCode() != code)
+ next = 0;
+ if (ins) {
+ // prefer next if it is of the requested type (bug 8716)
+ if (next)
+ ins = next;
+ } else
+ // no containing inset of requested type
+ // use next (which might also be 0)
+ ins = next;
return ins;
}