Added File > New in the title block template editor

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1444 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2012-01-09 18:50:26 +00:00
parent 364750f09d
commit 980490fd82
4 changed files with 32 additions and 2 deletions

View File

@@ -51,7 +51,10 @@ QString TitleBlockTemplateLocationChooser::name() const {
@param location to be displayed by this widget
*/
void TitleBlockTemplateLocationChooser::setLocation(const TitleBlockTemplateLocation &location) {
collections_ -> setCurrentIndex(collections_index_.keys(location.parentCollection()).first());
// hack: if o suitable index was found, set it to 1, which is supposed to be the user collection
int index = indexForCollection(location.parentCollection());
if (index == -1 && collections_ -> count() > 1) index = 1;
collections_ -> setCurrentIndex(index);
if (!location.name().isEmpty()) {
int template_index = templates_ -> findText(location.name());
@@ -83,6 +86,16 @@ void TitleBlockTemplateLocationChooser::init() {
setLayout(form_layout);
}
/**
@param coll A Title block templates collection which we want to know the index within the combo box of this dialog.
@return -1 if the collection is unknown to this dialog, or the index of \a coll
*/
int TitleBlockTemplateLocationChooser::indexForCollection(TitleBlockTemplatesCollection *coll) const {
QList<int> indexes = collections_index_.keys(coll);
if (indexes.count()) return(indexes.first());
return(-1);
}
/**
Update the collections list
*/