2006-03-05 17:24:44 +00:00
|
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
|
* \file GuiSendto.cpp
|
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 J<EFBFBD>rgen Spitzm<EFBFBD>ller
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
|
#include "GuiSendto.h"
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
|
|
#include "ControlSendto.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Format.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
|
#include <QListWidget>
|
|
|
|
|
#include <QPushButton>
|
2007-04-25 10:57:54 +00:00
|
|
|
|
#include <QCloseEvent>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
using std::string;
|
|
|
|
|
|
2007-04-25 10:57:54 +00:00
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
namespace frontend {
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
GuiSendtoDialog::GuiSendtoDialog(LyXView & lv)
|
|
|
|
|
: GuiDialog(lv, "sendto")
|
2007-04-25 10:57:54 +00:00
|
|
|
|
{
|
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
setViewTitle(_("Send Document to Command"));
|
|
|
|
|
setController(new ControlSendto(*this));
|
|
|
|
|
|
|
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
|
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
|
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
|
|
|
|
|
|
|
|
|
connect(formatLW, SIGNAL(itemClicked(QListWidgetItem *)),
|
|
|
|
|
this, SLOT(slotFormatHighlighted(QListWidgetItem *)));
|
|
|
|
|
connect(formatLW, SIGNAL(itemActivated(QListWidgetItem *)),
|
|
|
|
|
this, SLOT(slotFormatSelected(QListWidgetItem *)));
|
|
|
|
|
connect(formatLW, SIGNAL(itemClicked(QListWidgetItem *)),
|
|
|
|
|
this, SLOT(changed_adaptor()));
|
|
|
|
|
connect(commandCO, SIGNAL(textChanged(const QString&)),
|
|
|
|
|
this, SLOT(changed_adaptor()));
|
|
|
|
|
|
|
|
|
|
bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
|
|
|
|
|
bc().setOK(okPB);
|
|
|
|
|
bc().setApply(applyPB);
|
|
|
|
|
bc().setCancel(closePB);
|
2007-04-25 10:57:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-11 18:33:42 +00:00
|
|
|
|
ControlSendto & GuiSendtoDialog::controller()
|
2007-04-25 10:57:54 +00:00
|
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
|
return static_cast<ControlSendto &>(GuiDialog::controller());
|
2007-04-25 10:57:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
void GuiSendtoDialog::changed_adaptor()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
|
changed();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
void GuiSendtoDialog::closeEvent(QCloseEvent * e)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-09-11 17:06:15 +00:00
|
|
|
|
slotClose();
|
2007-09-05 20:33:29 +00:00
|
|
|
|
e->accept();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-11 18:33:42 +00:00
|
|
|
|
void GuiSendtoDialog::updateContents()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
|
|
|
|
all_formats_ = controller().allFormats();
|
|
|
|
|
|
|
|
|
|
// Check whether the current contents of the browser will be
|
|
|
|
|
// changed by loading the contents of formats
|
|
|
|
|
vector<string> keys;
|
|
|
|
|
keys.resize(all_formats_.size());
|
|
|
|
|
|
|
|
|
|
vector<string>::iterator result = keys.begin();
|
|
|
|
|
vector<Format const *>::const_iterator it = all_formats_.begin();
|
|
|
|
|
vector<Format const *>::const_iterator end = all_formats_.end();
|
2007-09-05 20:33:29 +00:00
|
|
|
|
for (; it != end; ++it, ++result)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
*result = (*it)->prettyname();
|
|
|
|
|
|
|
|
|
|
// Reload the browser
|
2007-09-05 20:33:29 +00:00
|
|
|
|
formatLW->clear();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
for (vector<string>::const_iterator it = keys.begin();
|
2007-09-05 20:33:29 +00:00
|
|
|
|
it != keys.end(); ++it) {
|
|
|
|
|
formatLW->addItem(toqstr(*it));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
commandCO->addItem(toqstr(controller().getCommand()));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
void GuiSendtoDialog::applyView()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
|
int const line = formatLW->currentRow();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
if (line < 0 || line > int(formatLW->count()))
|
2006-03-05 17:24:44 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
controller().setFormat(all_formats_[line]);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
controller().setCommand(fromqstr(commandCO->currentText()));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
bool GuiSendtoDialog::isValid()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
|
int const line = formatLW->currentRow();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
if (line < 0 || line > int(formatLW->count()))
|
2006-03-05 17:24:44 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
return formatLW->count() != 0 &&
|
|
|
|
|
!commandCO->currentText().isEmpty();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
|
} // namespace lyx
|
2007-04-25 10:57:54 +00:00
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
|
#include "GuiSendto_moc.cpp"
|