- add entry to FORMATS file for Stefan's format change (Richards to 296 change is still not correctly listed)

- add support for hyerlink targets - fileformat changed
  (For Hyperlink.cpp I still need help to get rid of the strings and chars and use docstrings and char_type instead!)

Can anyone please open the changed Hyperlink.ui with a Qt 4.2 designer or below, save it and commit? Thanks. (Otherwise you cannot compile it.)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21347 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2007-11-01 17:37:43 +00:00
parent d795490816
commit 0a7567ce3b
7 changed files with 155 additions and 31 deletions

View File

@ -1,12 +1,19 @@
LyX file-format changes
-----------------------
2007-11-01 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 299: support for hyperlink types
2007-11-01 Stefan Schimanski <sts@1stein.org>
* Format incremented to 298: math-macro code has been rewritten,
now it supports definitions with optional parameters
2007-10-29 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 297: support for Albanian, lower Sorbian,
fixed upper Sorbian language
2007-10-?? Richard Heck <rgheck@bobjweil.com>
* Format incremented to 296: ??
* Format incremented to 296: ?Include insets are no longer insets?
2007-10-12 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 295: get rid of the htmlurl command that was

View File

@ -80,7 +80,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)),
("1_3", [221], minor_versions("1.3" , 7)),
("1_4", range(222,246), minor_versions("1.4" , 5)),
("1_5", range(246,277), minor_versions("1.5" , 2)),
("1_6", range(277,299), minor_versions("1.6" , 0))] # Schimmi: Optional parameters for macros
("1_6", range(277,300), minor_versions("1.6" , 0))] # Uwe: Hyperlink types
def formats_list():

View File

@ -689,12 +689,6 @@ def revert_lowersorbian(document):
j = j + 1
def revert_macro_optional_params(document):
"Convert macro definitions with optional parameters into ERTs"
# Stub to convert macro definitions with one or more optional parameters
# into uninterpreted ERT insets
def revert_uppersorbian(document):
"Set language uppersorbian to usorbian as this was used in LyX 1.5"
# Set document language from uppersorbian to usorbian
@ -731,6 +725,28 @@ def convert_usorbian(document):
j = j + 1
def revert_macro_optional_params(document):
"Convert macro definitions with optional parameters into ERTs"
# Stub to convert macro definitions with one or more optional parameters
# into uninterpreted ERT insets
def revert_hyperlinktype(document):
'Reverts hyperlink type'
i = 0
j = 0
while True:
i = find_token(document.body, "target", i)
if i == -1:
return
j = find_token(document.body, "type", i)
if j == -1:
return
if j == i + 1:
del document.body[j]
i = i + 1
##
# Conversion hub
#
@ -757,10 +773,12 @@ convert = [[277, [fix_wrong_tables]],
[295, [convert_htmlurl, convert_url]],
[296, [convert_include]],
[297, [convert_usorbian]],
[298, []]
[298, []],
[299, []]
]
revert = [[297, [revert_macro_optional_params]],
revert = [[298, [revert_hyperlinktype]],
[297, [revert_macro_optional_params]],
[296, [revert_albanian, revert_lowersorbian, revert_uppersorbian]],
[295, [revert_include]],
[294, [revert_href]],

View File

@ -157,7 +157,7 @@ namespace fs = boost::filesystem;
namespace {
int const LYX_FORMAT = 298; //Schimmi: Optional parameters in macros
int const LYX_FORMAT = 299; //Uwe: Hyperlink types
} // namespace anon

View File

@ -38,6 +38,12 @@ GuiHyperlink::GuiHyperlink(LyXView & lv)
this, SLOT(changed_adaptor()));
connect(nameED, SIGNAL(textChanged(const QString &)),
this, SLOT(changed_adaptor()));
connect(WebRB, SIGNAL(clicked()),
this, SLOT(changed_adaptor()));
connect(EmailRB, SIGNAL(clicked()),
this, SLOT(changed_adaptor()));
connect(FileRB, SIGNAL(clicked()),
this, SLOT(changed_adaptor()));
setFocusProxy(urlED);
@ -45,6 +51,9 @@ GuiHyperlink::GuiHyperlink(LyXView & lv)
bc().setCancel(closePB);
bc().addReadOnly(urlED);
bc().addReadOnly(nameED);
bc().addReadOnly(WebRB);
bc().addReadOnly(EmailRB);
bc().addReadOnly(FileRB);
}
@ -65,6 +74,12 @@ void GuiHyperlink::updateContents()
{
urlED->setText(toqstr(params_["target"]));
nameED->setText(toqstr(params_["name"]));
if (params_["type"] == "")
WebRB->setChecked(true);
else if (params_["type"] == "mailto:")
EmailRB->setChecked(true);
else if (params_["type"] == "file:")
FileRB->setChecked(true);
bc().setValid(isValid());
}
@ -73,6 +88,12 @@ void GuiHyperlink::applyView()
{
params_["target"] = qstring_to_ucs4(urlED->text());
params_["name"] = qstring_to_ucs4(nameED->text());
if (WebRB->isChecked())
params_["type"] = qstring_to_ucs4("");
else if (EmailRB->isChecked())
params_["type"] = qstring_to_ucs4("mailto:");
else if (FileRB->isChecked())
params_["type"] = qstring_to_ucs4("file:");
params_.setCmdName("href");
}

View File

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>332</width>
<height>109</height>
<width>336</width>
<height>155</height>
</rect>
</property>
<property name="windowTitle" >
@ -16,25 +16,26 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="urlLA" >
<property name="toolTip" >
<string>URL</string>
</property>
<property name="text" >
<string>&amp;URL:</string>
<string>&amp;Target:</string>
</property>
<property name="buddy" >
<cstring>urlED</cstring>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QLineEdit" name="urlED" >
<property name="toolTip" >
<string>URL</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="nameLA" >
<property name="toolTip" >
@ -48,28 +49,97 @@
</property>
</widget>
</item>
<item row="1" column="1" >
<item row="1" column="1" colspan="2" >
<widget class="QLineEdit" name="nameED" >
<property name="toolTip" >
<string>Name associated with the URL</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="urlED" >
<item row="2" column="1" >
<widget class="QGroupBox" name="TypeGB" >
<property name="toolTip" >
<string>URL</string>
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">specify the link target&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="title" >
<string>Link type</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QRadioButton" name="WebRB" >
<property name="toolTip" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;">Link to the web or to every other target&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="text" >
<string>&amp;Web</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QRadioButton" name="EmailRB" >
<property name="toolTip" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;">Link to an email address&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="text" >
<string>&amp;Email</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QRadioButton" name="FileRB" >
<property name="toolTip" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Link to a file&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="text" >
<string>&amp;File</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
<item row="2" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<spacer>
<property name="orientation" >
@ -110,6 +180,9 @@
<tabstops>
<tabstop>urlED</tabstop>
<tabstop>nameED</tabstop>
<tabstop>WebRB</tabstop>
<tabstop>EmailRB</tabstop>
<tabstop>FileRB</tabstop>
<tabstop>okPB</tabstop>
<tabstop>closePB</tabstop>
</tabstops>

View File

@ -47,9 +47,9 @@ InsetHyperlink::InsetHyperlink(InsetCommandParams const & p)
CommandInfo const * InsetHyperlink::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] =
{"name", "target", ""};
{"name", "target", "type", ""};
static const bool isoptional[] = {true, false};
static const CommandInfo info = {2, paramnames, isoptional};
static const CommandInfo info = {3, paramnames, isoptional};
return &info;
}
@ -124,13 +124,18 @@ int InsetHyperlink::latex(Buffer const &, odocstream & os,
} // end if (!name.empty())
//for the case there is no name given, the target is set as name
string urlname = url;
// set the hyperlink type
url = to_utf8(getParam("type")) + url;
if (runparams.moving_arg)
os << "\\protect";
//set the target for the name when no name is given
if (!name.empty())
os << "\\href{" << from_utf8(url) << "}{" << from_utf8(name) << '}';
else
os << "\\href{" << from_utf8(url) << "}{" << from_utf8(url) << '}';
os << "\\href{" << from_utf8(url) << "}{" << from_utf8(urlname) << '}';
return 0;
}