case WarningException:
Alert::warning(e.title_, e.details_);
return false;
- };
+ }
}
catch (exception const & e) {
docstring s = _("LyX has caught an exception, it will now "
bool GuiToc::initialiseParams(string const & data)
{
LYXERR(Debug::GUI, data);
- QString str = QString::fromUtf8(data.c_str());
+ QString str = toqstr(data);
QString new_type;
- if (str.contains("tableofcontents"))
+ if (str.contains("tableofcontents")) {
new_type = "tableofcontents";
- else if (str.contains("floatlist")) {
+ } else if (str.contains("floatlist")) {
if (str.contains("\"figure"))
new_type = "figure";
else if (str.contains("\"table"))
new_type = "table";
else if (str.contains("\"algorithm"))
new_type = "algorithm";
- } else if (!data.empty())
- new_type = toqstr(data);
- else
+ } else if (!str.isEmpty()) {
+ new_type = str;
+ } else {
// Default to Outliner.
new_type = "tableofcontents";
+ }
types_.clear();
type_names_.clear();
toc_models_.push_back(new TocModel(it->second));
}
- int selected_type = -1;
- for (int i = 0; i != types_.size(); ++i) {
- if (new_type == types_[i]) {
- selected_type = i;
- break;
- }
- }
- widget_->updateGui(selected_type);
+ widget_->updateGui(types_.indexOf(new_type));
return true;
}
namespace lyx {
namespace frontend {
-
-TocModel::TocModel(Toc const & toc)
-{
- populate(toc);
-}
-
-
-TocModel const & TocModel::operator=(Toc const & toc)
-{
- populate(toc);
- return *this;
-}
+typedef std::pair<QModelIndex, TocIterator> TocPair;
-TocIterator const TocModel::tocIterator(QModelIndex const & index) const
+TocIterator TocModel::tocIterator(QModelIndex const & index) const
{
TocMap::const_iterator map_it = toc_map_.find(index);
BOOST_ASSERT(map_it != toc_map_.end());
}
-QModelIndex const TocModel::modelIndex(TocIterator const & it) const
+QModelIndex TocModel::modelIndex(TocIterator const & it) const
{
ModelMap::const_iterator map_it = model_map_.find(it);
//BOOST_ASSERT(it != model_map_.end());
///
TocModel() {}
///
- TocModel(Toc const & toc);
- ///
- ~TocModel() {}
- ///
- TocModel const & operator=(Toc const & toc);
+ TocModel(Toc const & toc) { populate(toc); }
///
void clear();
///
void populate(Toc const & toc);
///
- TocIterator const tocIterator(QModelIndex const & index) const;
+ TocIterator tocIterator(QModelIndex const & index) const;
///
- QModelIndex const modelIndex(TocIterator const & it) const;
+ QModelIndex modelIndex(TocIterator const & it) const;
///
int modelDepth() const;
///
typedef std::map<QModelIndex, TocIterator> TocMap;
///
- typedef std::pair<QModelIndex, TocIterator> TocPair;
- ///
typedef std::map<TocIterator, QModelIndex> ModelMap;
///
TocMap toc_map_;