]> git.lyx.org Git - lyx.git/commitdiff
Refactoring
authorYuriy Skalko <yuriy.skalko@gmail.com>
Mon, 5 Oct 2020 10:38:09 +0000 (13:38 +0300)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 5 Oct 2020 12:55:00 +0000 (14:55 +0200)
61 files changed:
src/Buffer.cpp
src/BufferParams.cpp
src/DepTable.cpp
src/ErrorList.cpp
src/Font.cpp
src/HunspellChecker.cpp
src/Language.cpp
src/LyXVC.cpp
src/Paragraph.cpp
src/PersonalWordList.cpp
src/Session.cpp
src/Text.cpp
src/Text3.cpp
src/TextMetrics.cpp
src/Trans.cpp
src/VCBackend.cpp
src/frontends/Painter.h
src/frontends/qt/CategorizedCombo.cpp
src/frontends/qt/FancyLineEdit.cpp
src/frontends/qt/FindAndReplace.cpp
src/frontends/qt/FloatPlacement.cpp
src/frontends/qt/GuiApplication.cpp
src/frontends/qt/GuiErrorList.cpp
src/frontends/qt/GuiImage.cpp
src/frontends/qt/GuiRef.cpp
src/frontends/qt/GuiSendto.cpp
src/frontends/qt/GuiSymbols.cpp
src/frontends/qt/GuiToolbar.cpp
src/frontends/qt/GuiView.cpp
src/frontends/qt/GuiWorkArea.cpp
src/frontends/qt/LayoutBox.cpp
src/frontends/qt/PanelStack.cpp
src/frontends/qt/Toolbars.cpp
src/insets/InsetIPAMacro.cpp
src/insets/InsetNewline.cpp
src/insets/InsetNewpage.cpp
src/insets/InsetNomencl.cpp
src/insets/InsetQuotes.cpp
src/insets/InsetSeparator.cpp
src/insets/InsetSpace.cpp
src/insets/InsetSpecialChar.cpp
src/insets/InsetTabular.cpp
src/insets/InsetVSpace.cpp
src/lyxfind.cpp
src/mathed/InsetMathColor.cpp
src/mathed/InsetMathFont.cpp
src/mathed/InsetMathFrac.cpp
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathMacro.cpp
src/mathed/InsetMathNest.cpp
src/mathed/InsetMathScript.cpp
src/mathed/MathExtern.cpp
src/mathed/MathFactory.cpp
src/mathed/MathParser.cpp
src/mathed/MathRow.cpp
src/output_latex.cpp
src/support/FileName.cpp
src/support/Package.cpp
src/support/docstring.cpp
src/tests/check_layout.cpp
src/tex2lyx/Parser.cpp

index 40db4aa6d39356e60826cfc4d9b3e53853e6bf64..6d25d51908cabbd10241d07ce432623fc43cf2ec 100644 (file)
@@ -664,7 +664,6 @@ void Buffer::cloneWithChildren(BufferMap & bufmap, CloneList_ptr clones) const
                buffer_clone->setChild(dit, child_clone);
        }
        buffer_clone->d->macro_lock = false;
-       return;
 }
 
 
@@ -4010,10 +4009,7 @@ InsetLabel const * Buffer::insetLabel(docstring const & label,
 
 bool Buffer::activeLabel(docstring const & label) const
 {
-       if (!insetLabel(label, true))
-               return false;
-
-       return true;
+       return insetLabel(label, true) != nullptr;
 }
 
 
index b5ae2d4cad6c7fd0ccba359d6b9687b06a94dff0..58a02c8683c6d47139efb955f679231e2f1aaf87 100644 (file)
@@ -1373,9 +1373,9 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
        if (!lineno_opts.empty())
                os << "\\lineno_options " << lineno_opts << '\n';
 
-       if (isbackgroundcolor == true)
+       if (isbackgroundcolor)
                os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
-       if (isfontcolor == true)
+       if (isfontcolor)
                os << "\\fontcolor " << lyx::X11hexname(fontcolor) << '\n';
        if (notefontcolor != lyx::rgbFromHexName("#cccccc"))
                os << "\\notefontcolor " << lyx::X11hexname(notefontcolor) << '\n';
@@ -1979,7 +1979,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        }
 
        // only output when the background color is not default
-       if (isbackgroundcolor == true) {
+       if (isbackgroundcolor) {
                // only require color here, the background color will be defined
                // in LaTeXFeatures.cpp to avoid interferences with the LaTeX
                // package pdfpages
@@ -1988,7 +1988,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        }
 
        // only output when the font color is not default
-       if (isfontcolor == true) {
+       if (isfontcolor) {
                // only require color here, the font color will be defined
                // in LaTeXFeatures.cpp to avoid interferences with the LaTeX
                // package pdfpages
index 47daf3911324d8f95d4c94a014f2bfacc41061ce..853edf22c857c19270ba8ac104c43b939ff2ba13 100644 (file)
@@ -228,7 +228,7 @@ bool DepTable::read(FileName const & f)
 
                deplist[FileName(nome)] = di;
        }
-       return deplist.size();
+       return !deplist.empty();
 }
 
 
index 1613ce7e611259843d920b9c261f4af09d474cff..7022c7bcf50a6ca59f5d41c4d3f2c4b1ade26953 100644 (file)
@@ -32,7 +32,7 @@ ErrorItem::ErrorItem(docstring const & error_, docstring const & description_,
 
 
 ErrorItem::ErrorItem()
-       : start(TexRow::text_none), end(TexRow::text_none), buffer(0)
+       : start(TexRow::text_none), end(TexRow::text_none), buffer(nullptr)
 {}
 
 
index 327bc1821befb52e3a0a19c02e4afeb2b797ff51..fda0854fe1f9819dabbf90564dc127f7fa88b8bb 100644 (file)
@@ -864,7 +864,7 @@ ostream & operator<<(ostream & os, FontInfo const & f)
 ostream & operator<<(ostream & os, Font const & font)
 {
        return os << font.bits_
-               << " lang: " << (font.lang_ ? font.lang_->lang() : nullptr);
+               << " lang: " << (font.lang_ ? font.lang_->lang() : "");
 }
 
 
index dcdc1bbbd7a7fa3cfab48f4045427c78813bf023..015973e1f43b43825ff2ff0079563b995b661bfe 100644 (file)
@@ -234,11 +234,11 @@ Hunspell * HunspellChecker::Private::lookup(Language const * lang)
 }
 
 
-Hunspell * HunspellChecker::Private::addSpeller(Language const * lang,string & path)
+Hunspell * HunspellChecker::Private::addSpeller(Language const * lang, string & path)
 {
        if (!haveDictionary(lang, path)) {
-               spellers_[lang->lang()] = 0;
-               return 0;
+               spellers_[lang->lang()] = nullptr;
+               return nullptr;
        }
 
        FileName const affix(path + ".aff");
index 4f625b55b9e18bb97e8b6d971669809a7dd388fb..84e03b1e9e2f85d1baf0c70de46d3793132d50e6 100644 (file)
@@ -37,10 +37,10 @@ using namespace lyx::support;
 namespace lyx {
 
 Languages languages;
-Language const * ignore_language = 0;
-Language const * default_language = 0;
-Language const * latex_language = 0;
-Language const * reset_language = 0;
+Language const * ignore_language = nullptr;
+Language const * default_language = nullptr;
+Language const * latex_language = nullptr;
+Language const * reset_language = nullptr;
 
 
 bool Language::isPolyglossiaExclusive() const
@@ -344,12 +344,12 @@ void Languages::read(FileName const & filename)
                        break;
                if (l.lang() == "latex") {
                        // Check if latex language was not already defined.
-                       LASSERT(latex_language == 0, continue);
+                       LASSERT(latex_language == nullptr, continue);
                        static const Language latex_lang = l;
                        latex_language = &latex_lang;
                } else if (l.lang() == "ignore") {
                        // Check if ignore language was not already defined.
-                       LASSERT(ignore_language == 0, continue);
+                       LASSERT(ignore_language == nullptr, continue);
                        static const Language ignore_lang = l;
                        ignore_language = &ignore_lang;
                } else
@@ -436,7 +436,7 @@ Language const * Languages::getFromCode(string const & code) const
                if (match(code, l.second) == ApproximateMatch)
                        return &l.second;
        }
-       return 0;
+       return nullptr;
 }
 
 
@@ -460,7 +460,7 @@ Language const * Languages::getFromCode(string const & code,
        return getFromCode(code);
 
        LYXERR0("Unknown language `" << code << "'");
-       return 0;
+       return nullptr;
 }
 
 
index 806d5e81436790e8bc6ed4b949fb9e68e5353443..7e36a1ce9cf0438841432df971bed3d6092f6d95 100644 (file)
@@ -348,9 +348,7 @@ string LyXVC::toggleReadOnly()
 
 bool LyXVC::inUse() const
 {
-       if (vcs)
-               return true;
-       return false;
+       return vcs != nullptr;
 }
 
 
index 242f644ce6df00b0ee2c56e131da649610ce79f3..bdda5d012b83ff6ba1a3fe2548d6529851d08f7c 100644 (file)
@@ -4810,7 +4810,7 @@ void Paragraph::spellCheck() const
                        // start the spell checker on the unit of meaning
                        docstring word = asString(first, last, AS_STR_INSETS + AS_STR_SKIPDELETE);
                        WordLangTuple wl = WordLangTuple(word, lang);
-                       SpellChecker::Result result = word.size() ?
+                       SpellChecker::Result result = !word.empty() ?
                                speller->check(wl) : SpellChecker::WORD_OK;
                        d->markMisspelledWords(first, last, result, word, skips);
                        first = ++last;
index 665eb331b573ba45ecebbeb8dab558ec165bdf80..4d3292e3f582578c79567528cccca1032cc4af7b 100644 (file)
@@ -54,7 +54,7 @@ void PersonalWordList::load()
        LYXERR(Debug::FILES, "load personal dictionary from: " << fn);
        ifstream ifs(fn.toFilesystemEncoding().c_str());
 
-       dirty(words_.size() > 0);
+       dirty(!words_.empty());
        words_.clear();
        string line;
        getline(ifs, line);
index 3bb9c03a330005d0702de9f0d4f00246e4b971ae..8fc8fa23d84e2523d487cbc3950ad96003ad308c 100644 (file)
@@ -494,10 +494,7 @@ void AuthFilesSection::write(ostream & os) const
 
 bool AuthFilesSection::find(string const & name) const
 {
-       if (auth_files_.find(name) != auth_files_.end())
-               return true;
-
-       return false;
+       return auth_files_.find(name) != auth_files_.end();
 }
 
 
@@ -547,10 +544,7 @@ bool ShellEscapeSection::find(string const & name) const
 
 bool ShellEscapeSection::findAuth(string const & name) const
 {
-       if (shellescape_files_.find(name + ",1") != shellescape_files_.end())
-               return true;
-
-       return false;
+       return shellescape_files_.find(name + ",1") != shellescape_files_.end();
 }
 
 
index 0e058641d6fc5bddc3d83158b9d0fd31739c131e..e4eb4abf101c3826d8541c987dccef14ab2b11fd 100644 (file)
@@ -1778,7 +1778,7 @@ bool Text::backspace(Cursor & cur)
                Cursor prev_cur = cur;
                --prev_cur.pit();
 
-               if (cur.paragraph().size() > 0
+               if (!cur.paragraph().empty()
                    && !prev_cur.paragraph().isMergedOnEndOfParDeletion(cur.buffer()->params().track_changes)) {
                        cur.recordUndo(prev_cur.pit(), prev_cur.pit());
                        prev_cur.paragraph().setChange(prev_cur.lastpos(), Change(Change::DELETED));
index 6631d49012c1f2ff1d3a1b4a7f2fbdf9e9b1121b..af904041c29ffa04e133a70d0260a0ca3d55ca1f 100644 (file)
@@ -1276,7 +1276,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                Paragraph const & nextpar = lastpar ? par : pars_[pit + 1];
                pit_type prev = pit > 0 ? depthHook(pit, par.getDepth()) : pit;
                if (prev < pit && cur.pos() == par.beginOfBody()
-                   && !par.size() && !par.isEnvSeparator(cur.pos())
+                   && par.empty() && !par.isEnvSeparator(cur.pos())
                    && !par.layout().keepempty
                    && !par.layout().isCommand()
                    && pars_[prev].layout() != par.layout()
index 8e9a157a7aab284b95c53ccaca5225c889de33f5..07c2b2799028b802f11a92f37d4f56f8dddd1d3b 100644 (file)
@@ -1486,7 +1486,7 @@ InsetList::Element * TextMetrics::checkInsetHit(pit_type pit, int x, int y)
        }
 
        LYXERR(Debug::DEBUG, "No inset hit. ");
-       return 0;
+       return nullptr;
 }
 
 
index 679866da84d361a0a304c6ee1edc814fecfb0e90..2f0f317355f5bcb49df054c740b685e9f348af00 100644 (file)
@@ -510,7 +510,7 @@ docstring const TransDeadkeyState::deadkey(char_type c, KmodInfo d)
        KmodException::const_iterator cit = deadkey_info_.exception_list.begin();
        KmodException::const_iterator end = deadkey_info_.exception_list.end();
        for (; cit != end; ++cit) {
-               if (cit->combined == true && cit->accent == d.accent) {
+               if (cit->combined && cit->accent == d.accent) {
                        deadkey2_ = c;
                        deadkey2_info_ = d;
                        comb_info_ = (*cit);
@@ -656,7 +656,7 @@ void TransManager::deadkey(char_type c, tex_accent accent, Text * t, Cursor & cu
                // A deadkey was pressed that cannot be printed
                // or a accent command was typed in the minibuffer
                KmodInfo i;
-               if (active_->isAccentDefined(accent, i) == true) {
+               if (active_->isAccentDefined(accent, i)) {
                        docstring const res = trans_fsm_
                                .currentState->deadkey(c, i);
                        insert(res, t, cur);
index 3ea462439999a3e84256491a4e9614dbd5a1afcc..309d705372728a30dbf51d0360d23bc58ca76c00 100644 (file)
@@ -1156,7 +1156,7 @@ SVN::SVN(FileName const & m, Buffer * b) : VCS(b)
        // Here we know that the buffer file is either already in SVN or
        // about to be registered
        master_ = m;
-       locked_mode_ = 0;
+       locked_mode_ = false;
        scanMaster();
 }
 
index 718718f9798a30682dc6b9f9efee81f851ec0d82..e2796d97d92e518f13adb015de42b7eaba0bc2ac 100644 (file)
@@ -154,7 +154,7 @@ public:
 
        double pixelRatio() const { return pixel_ratio_; }
 
-       double develMode() const { return devel_mode_; }
+       bool develMode() const { return devel_mode_; }
 
        /// draw the underbar, strikeout, xout, uuline and uwave font attributes
        virtual void textDecoration(FontInfo const & f, int x, int y, int width) = 0;
index d86bd382f89310ff77138eef60e71aade8a3d3b5..4aebcf6a917e85ed0c2bfc371cc52ae31c785ee3 100644 (file)
@@ -71,7 +71,7 @@ private:
 class CCFilterModel : public QSortFilterProxyModel {
 public:
        ///
-       CCFilterModel(QObject * parent = 0)
+       CCFilterModel(QObject * parent = nullptr)
                : QSortFilterProxyModel(parent)
        {}
 };
index c7035ac7c905a249af19c51e1d3dc6d4997f0f23..dae744489962f41d2d15d43ce859f5632a07b197 100644 (file)
@@ -60,7 +60,7 @@ FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) :
     m_lineEdit(parent)
 {
     for (int i = 0; i < 2; ++i) {
-        m_menu[i] = 0;
+        m_menu[i] = nullptr;
         m_menuTabFocusTrigger[i] = false;
         m_iconbutton[i] = new IconButton(parent);
         m_iconbutton[i]->installEventFilter(this);
index 271ce9be90aeed66b135ec3c73752a1882aaed5b..af2bbbbea393d40bab97ffc370478180f1807787 100644 (file)
@@ -599,7 +599,7 @@ FindAndReplace::FindAndReplace(GuiView & parent,
 
 FindAndReplace::~FindAndReplace()
 {
-       setFocusProxy(0);
+       setFocusProxy(nullptr);
        delete widget_;
 }
 
@@ -620,7 +620,7 @@ void FindAndReplaceWidget::updateGUI()
                                old_buffer_ = &bv->buffer();
                }
        } else
-               old_buffer_ = 0;
+               old_buffer_ = nullptr;
 
        bool const replace_enabled = bv && !bv->buffer().isReadonly();
        replace_work_area_->setEnabled(replace_enabled);
index dbbaa5961b35679b320b4134d345075659b1a619..d11458716f7b8d53586563eba8c5b9ed6c280c71 100644 (file)
@@ -35,7 +35,7 @@ namespace frontend {
 
 FloatPlacement::FloatPlacement(bool show_options, QWidget * parent)
        : InsetParamsWidget(parent), standardfloat_(true),
-         allows_wide_(true), allows_sideways_(true), float_list_(0)
+         allows_wide_(true), allows_sideways_(true), float_list_(nullptr)
 {
        setupUi(this);
 
index bf917891785023b75888b3ebe18c95a31605d3fa..1763abdfc011910db4291d464aab541d6eb0ba33 100644 (file)
@@ -895,8 +895,8 @@ public:
 
 struct GuiApplication::Private
 {
-       Private(): language_model_(0), meta_fake_bit(NoModifier),
-               global_menubar_(0)
+       Private(): language_model_(nullptr), meta_fake_bit(NoModifier),
+               global_menubar_(nullptr)
        {
        #if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
        #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
@@ -993,7 +993,7 @@ GuiApplication::~GuiApplication()
 
 
 GuiApplication::GuiApplication(int & argc, char ** argv)
-       : QApplication(argc, argv), current_view_(0),
+       : QApplication(argc, argv), current_view_(nullptr),
          d(new GuiApplication::Private)
 {
        QString app_name = "LyX";
@@ -1123,8 +1123,8 @@ FuncStatus GuiApplication::getStatus(FuncRequest const & cmd) const
 {
        FuncStatus status;
 
-       BufferView * bv = 0;
-       BufferView * doc_bv = 0;
+       BufferView * bv = nullptr;
+       BufferView * doc_bv = nullptr;
 
        if (cmd.action() == LFUN_NOACTION) {
                status.message(from_utf8(N_("Nothing to do")));
@@ -1289,7 +1289,7 @@ bool GuiApplication::getStatus(FuncRequest const & cmd, FuncStatus & flag) const
                break;
 
        case LFUN_WINDOW_CLOSE:
-               enable = d->views_.size() > 0;
+               enable = !d->views_.empty();
                break;
 
        case LFUN_BUFFER_NEW:
index 0b625ccd519bf5ad2a73fca67919a165d0973b5e..9fbdedafaf166c7e61a6391936d8067c37ccccb4 100644 (file)
@@ -58,7 +58,7 @@ namespace lyx {
 namespace frontend {
 
 GuiErrorList::GuiErrorList(GuiView & lv)
-       : GuiDialog(lv, "errorlist", qt_("Error List")), buf_(0), from_master_(false)
+       : GuiDialog(lv, "errorlist", qt_("Error List")), buf_(nullptr), from_master_(false)
 {
        setupUi(this);
 
index c73fe7cede6e53c54741cf7226ecb78d1f925638..0c3df0b65da30a41bfbed0cd743031d2e72abbbb 100644 (file)
@@ -173,7 +173,7 @@ bool GuiImage::clip(Params const & params)
 
 bool GuiImage::rotate(Params const & params)
 {
-       if (!params.angle)
+       if (params.angle == 0)
                return false;
 
        QImage const & image = is_transformed_ ? transformed_ : original_;
index a727700005a8f829efb76a7bbf5872dd23a14434..8583d0cd26143b87fa81dc065fa19072fad3e8c5 100644 (file)
@@ -187,7 +187,6 @@ void GuiRef::selectionChanged()
                return;
        QTreeWidgetItem * sel = selections.first();
        refHighlighted(sel);
-       return;
 }
 
 
index a42bbb472cc03bdca08c88367cb5f83039702232..b14db45304f4fac1ea1b1e99fa43d354b21a9d2e 100644 (file)
@@ -38,7 +38,7 @@ namespace frontend {
 
 
 GuiSendTo::GuiSendTo(GuiView & lv)
-       : GuiDialog(lv, "sendto", qt_("Export or Send Document")), format_(0)
+       : GuiDialog(lv, "sendto", qt_("Export or Send Document")), format_(nullptr)
 {
        setupUi(this);
 
@@ -77,7 +77,7 @@ void GuiSendTo::updateContents()
        Format const * current_format = nullptr;
        int const line = formatLW->currentRow();
        if (line >= 0 && static_cast<unsigned int>(line) < all_formats.size()
-           && formatLW->selectedItems().size() > 0)
+           && !formatLW->selectedItems().empty())
                current_format = all_formats[line];
        // Reset the list widget
        formatLW->clear();
@@ -115,14 +115,14 @@ bool GuiSendTo::isValid()
        if (line < 0 || (line > int(formatLW->count())))
                return false;
 
-       return (formatLW->selectedItems().size() > 0
+       return (!formatLW->selectedItems().empty()
                && formatLW->count() != 0);
 }
 
 
 bool GuiSendTo::initialiseParams(string const &)
 {
-       format_ = 0;
+       format_ = nullptr;
        paramsToDialog(format_, command_);
        return true;
 }
index a4fd4af650da3d2c0afc4fc5cd29010bf9053210..4a6b0d61787fbec3f782900a8f45607e6dda0e0c 100644 (file)
@@ -207,7 +207,7 @@ class GuiSymbols::Model : public QAbstractListModel
 {
 public:
        Model(GuiSymbols * parent)
-               : QAbstractListModel(parent), encoding_(0)
+               : QAbstractListModel(parent), encoding_(nullptr)
        {}
 
        QModelIndex index(int row, int column, QModelIndex const &) const override
index 65f81c9b211b326d3c9637d1de68fe51c91ec0eb..5c8c603daf660a939b63bb621c13a17c4d9d0388 100644 (file)
@@ -64,7 +64,7 @@ namespace frontend {
 
 GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
        : QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0),
-         owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false),
+         owner_(owner), command_buffer_(nullptr), tbinfo_(tbinfo), filled_(false),
          restored_(false)
 {
        setIconSize(owner.iconSize());
@@ -297,7 +297,7 @@ class DynamicMenuButton::Private
        Private(Private const &);
        void operator=(Private const &);
 public:
-       Private() : inset_(0) {}
+       Private() : inset_(nullptr) {}
        ///
        DocumentClassConstPtr text_class_;
        ///
index cb351d1177fefd81bd6070cefd4ecd34f69294b6..00f3b96ea4f7bb52e19daaaf00c7a9858f330436 100644 (file)
@@ -1187,7 +1187,7 @@ void GuiView::dropEvent(QDropEvent * event)
                                found_formats.push_back(*it);
 
                FuncRequest cmd;
-               if (found_formats.size() >= 1) {
+               if (!found_formats.empty()) {
                        if (found_formats.size() > 1) {
                                //FIXME: show a dialog to choose the correct importable format
                                LYXERR(Debug::FILES,
index 7c21088643dfd16fcc1e08f7b42c4d66f073ca8c..0104c8dd83f667ac56d2b8b0db30aee75741a7ad 100644 (file)
@@ -1061,7 +1061,6 @@ void GuiWorkArea::generateSyntheticMouseEvent()
        cur.boundary(bound);
 
        d->buffer_view_->buffer().changed(false);
-       return;
 }
 
 
index 95814c942f604ab58e49fec129e0618d3a76db80..719a2d324dd1f8b9176340bb62c0c3b13ccf0387 100644 (file)
@@ -85,7 +85,7 @@ private:
 class GuiLayoutFilterModel : public QSortFilterProxyModel {
 public:
        ///
-       GuiLayoutFilterModel(QObject * parent = 0)
+       GuiLayoutFilterModel(QObject * parent = nullptr)
                : QSortFilterProxyModel(parent)
        {}
 
@@ -111,7 +111,7 @@ class LayoutBox::Private
        void operator=(Private const &);
 public:
        Private(LayoutBox * parent, GuiView & gv) : p(parent), owner_(gv),
-               inset_(0),
+               inset_(nullptr),
                // set the layout model with two columns
                // 1st: translated layout names
                // 2nd: raw layout names
@@ -567,7 +567,7 @@ void LayoutBox::updateContents(bool reset)
                setEnabled(false);
                setMinimumWidth(sizeHint().width());
                d->text_class_.reset();
-               d->inset_ = 0;
+               d->inset_ = nullptr;
                return;
        }
        // we'll only update the layout list if the text class has changed
index 4b6b875c8b15fa52b7cea4c7abf9ffd9f48885c5..ef9c599a340cbf9f53fa7da3602cc44a0d47646a 100644 (file)
@@ -97,7 +97,7 @@ PanelStack::PanelStack(QWidget * parent)
 
 void PanelStack::addCategory(QString const & name, QString const & parent)
 {
-       QTreeWidgetItem * item = 0;
+       QTreeWidgetItem * item = nullptr;
 
        LYXERR(Debug::GUI, "addCategory n= " << name << "   parent= ");
 
index d7a28b8025aff20cd06874073df30bdfd82088f3..7d29344732e8d44a05fdb1cdc59689a148135ea1 100644 (file)
@@ -418,7 +418,7 @@ ToolbarInfo const * Toolbars::info(std::string const & name) const
        for (Infos::const_iterator it = toolbar_info_.begin(); it != end; ++it)
                if (it->name == name)
                        return &(*it);
-       return 0;
+       return nullptr;
 }
 
 
index 4e8afcfa7ecac8384f60063beb82bbe691918f52..82f6c48e84deff326b6deebaabab094ef6d320de 100644 (file)
@@ -393,7 +393,7 @@ bool InsetIPADeco::insetAllowed(InsetCode code) const
 
 
 InsetIPAChar::InsetIPAChar(Kind k)
-       : Inset(0), kind_(k)
+       : Inset(nullptr), kind_(k)
 {}
 
 
index 4c6f17e1d16ec5db1b6cc80a18fa3af9ab0e4713..0e07af13f7ea408493e59499e5c35a97fd85de91 100644 (file)
@@ -36,7 +36,7 @@ using namespace std;
 
 namespace lyx {
 
-InsetNewline::InsetNewline() : Inset(0)
+InsetNewline::InsetNewline() : Inset(nullptr)
 {}
 
 
index 6e9f34211fb62803496086b01795403935ed37e3..6f89eac03bb4f8b9186c1d757f902da55b7c93ce 100644 (file)
@@ -37,12 +37,12 @@ using namespace std;
 
 namespace lyx {
 
-       InsetNewpage::InsetNewpage() : Inset(0)
+       InsetNewpage::InsetNewpage() : Inset(nullptr)
 {}
 
 
 InsetNewpage::InsetNewpage(InsetNewpageParams const & params)
-       : Inset(0), params_(params)
+       : Inset(nullptr), params_(params)
 {}
 
 
index c762e33d67e60586e694187e7cf6ee8f5524782f..5e3c637a60c2910c9f9b13cc2cd212ac397f5b91 100644 (file)
@@ -171,7 +171,7 @@ docstring InsetPrintNomencl::screenLabel() const
 
 
 struct NomenclEntry {
-       NomenclEntry() : par(0) {}
+       NomenclEntry() : par(nullptr) {}
        NomenclEntry(docstring s, docstring d, Paragraph const * p)
          : symbol(s), desc(d), par(p)
        {}
@@ -381,7 +381,7 @@ docstring nomenclWidest(Buffer const & buffer, OutputParams const & runparams)
 
        int w = 0;
        docstring symb;
-       InsetNomencl const * nomencl = 0;
+       InsetNomencl const * nomencl = nullptr;
        ParagraphList::const_iterator it = buffer.paragraphs().begin();
        ParagraphList::const_iterator end = buffer.paragraphs().end();
 
index b90f1c27dda850ae94e035260994dc5ec9ba11f2..c93de5a06395c4ad301d04838659cfc1f9e73346 100644 (file)
@@ -1057,10 +1057,10 @@ void InsetQuotes::validate(LaTeXFeatures & features) const
        switch (type) {
        case 0x0027: {
                if (features.runparams().isFullUnicode() && fontspec_)
-                               features.require("textquotesinglep");
-                       else
-                               features.require("textcomp");
-                       break;
+                       features.require("textquotesinglep");
+               else
+                       features.require("textcomp");
+               break;
        }
        case 0x0022: {
                if (features.runparams().isFullUnicode() && fontspec_)
index efe6a483b09464682f1456f22f4ee2dcc50967bb..16f7cdcbdf3fd5023cb7e4c9a05a7258a7d7fdf2 100644 (file)
@@ -36,12 +36,12 @@ using namespace lyx::frontend;
 
 namespace lyx {
 
-InsetSeparator::InsetSeparator() : Inset(0)
+InsetSeparator::InsetSeparator() : Inset(nullptr)
 {}
 
 
 InsetSeparator::InsetSeparator(InsetSeparatorParams const & params)
-       : Inset(0), params_(params)
+       : Inset(nullptr), params_(params)
 {}
 
 
index 7656a14e106bf5248262fa72f30c2a74ad7354d5..d4cb7361b45462a838ba4ddc08832ba211084201 100644 (file)
@@ -45,7 +45,7 @@ namespace lyx {
 
 
 InsetSpace::InsetSpace(InsetSpaceParams const & params)
-       : Inset(0), params_(params)
+       : Inset(nullptr), params_(params)
 {}
 
 
index 56925c4f32202006c9601fca084bb1d537f22821..3ecdaf12e94315f2f4bbb438d0183e5e70154603 100644 (file)
@@ -38,7 +38,7 @@ namespace lyx {
 
 
 InsetSpecialChar::InsetSpecialChar(Kind k)
-       : Inset(0), kind_(k)
+       : Inset(nullptr), kind_(k)
 {}
 
 
index 8458ce47285d0449566a37a614e990a38ad3a486..d24d174cbc74a9eeac2fac136d1d3edd6ae97ded 100644 (file)
@@ -2189,9 +2189,7 @@ bool Tabular::needRotating() const
 
 bool Tabular::isLastCell(idx_type cell) const
 {
-       if (cell + 1 < numberofcells)
-               return false;
-       return true;
+       return cell + 1 >= numberofcells;
 }
 
 
index a6092cb8a337ba8f5098a4e143f5cece21a37521..03a272e65001377597b5b277dd4381785b1866d4 100644 (file)
@@ -50,7 +50,7 @@ int const ADD_TO_VSPACE_WIDTH = 5;
 
 
 InsetVSpace::InsetVSpace(VSpace const & space)
-       : Inset(0), space_(space)
+       : Inset(nullptr), space_(space)
 {}
 
 
index 5f9e2d309307a160930786348584ad4c0df09b63..f36e02bf77af83d35c0e48dc1fe657c138b525c8 100644 (file)
@@ -360,7 +360,7 @@ pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
        if (!cur.selection()) {
                // no selection, non-empty search string: find it
                if (!searchstr.empty()) {
-                       bool found = findOne(bv, searchstr, case_sens, whole, forward, true, findnext);
+                       bool const found = findOne(bv, searchstr, case_sens, whole, forward, true, findnext);
                        return make_pair(found, 0);
                }
                // empty search string
@@ -389,7 +389,7 @@ pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
        // no selection or current selection is not search word:
        // just find the search word
        if (!have_selection || !match) {
-               bool found = findOne(bv, searchstr, case_sens, whole, forward, true, findnext);
+               bool const found = findOne(bv, searchstr, case_sens, whole, forward, true, findnext);
                return make_pair(found, 0);
        }
 
@@ -3592,7 +3592,7 @@ static bool firstUppercase(Cursor const & cur)
 static void changeFirstCase(Buffer & buffer, TextCase first_case, TextCase others_case)
 {
        ParagraphList::iterator pit = buffer.paragraphs().begin();
-       LASSERT(pit->size() >= 1, /**/);
+       LASSERT(!pit->empty(), /**/);
        pos_type right = pos_type(1);
        pit->changeCase(buffer.params(), pos_type(0), right, first_case);
        right = pit->size();
@@ -3605,7 +3605,7 @@ static void changeFirstCase(Buffer & buffer, TextCase first_case, TextCase other
 static int findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, MatchStringAdv & matchAdv)
 {
        Cursor & cur = bv->cursor();
-       if (opt.repl_buf_name == docstring()
+       if (opt.repl_buf_name.empty()
            || theBufferList().getBuffer(FileName(to_utf8(opt.repl_buf_name)), true) == 0
            || theBufferList().getBuffer(FileName(to_utf8(opt.find_buf_name)), true) == 0)
                return 0;
index 94a6c42e642c9dbc774bf84379e51505c1a2eed5..31ba778fafb0ddb507d39cfa9aaf2caaf607ddb1 100644 (file)
@@ -99,10 +99,10 @@ void InsetMathColor::write(WriteStream & os) const
        // We have to ensure correct spacing when the front and/or back
        // atoms are not ordinary ones (bug 11827).
        docstring const frontclass =
-               cell(0).size() ? class_to_string(cell(0).front()->mathClass())
+               !cell(0).empty() ? class_to_string(cell(0).front()->mathClass())
                               : from_ascii("mathord");
        docstring const backclass =
-               cell(0).size() ? class_to_string(cell(0).back()->mathClass())
+               !cell(0).empty() ? class_to_string(cell(0).back()->mathClass())
                               : from_ascii("mathord");
        bool adjchk = os.latex() && !os.inMathClass() && (normalcolor(color_) || oldstyle_);
        bool adjust_front = frontclass != "mathord" && adjchk;
index f199ee5bcf8ad7f719c998539ae27919429a72d7..1de00464a7326641ee8b3cb6012de649c9f77df4 100644 (file)
@@ -58,9 +58,7 @@ InsetMath::mode_type InsetMathFont::currentMode() const
 
 bool InsetMathFont::lockedMode() const
 {
-       if (key_->extra == "forcetext")
-               return true;
-       return false;
+       return key_->extra == "forcetext";
 }
 
 
index 90d507cfbe38fdeee2fca069d312a29d0e6d51af..03125e99ca34dc85222f32060e2060c2dcfc7664 100644 (file)
@@ -80,13 +80,13 @@ Inset * InsetMathFrac::clone() const
 
 InsetMathFrac * InsetMathFrac::asFracInset()
 {
-       return kind_ == ATOP ? 0 : this;
+       return kind_ == ATOP ? nullptr : this;
 }
 
 
 InsetMathFrac const * InsetMathFrac::asFracInset() const
 {
-       return kind_ == ATOP ? 0 : this;
+       return kind_ == ATOP ? nullptr : this;
 }
 
 
index e7326b64e59ae95d96328884d42748f443c9c5b3..156cbec2fd2dd7ad087d86dfcce37f9e0b1d7d86 100644 (file)
@@ -1579,7 +1579,7 @@ void InsetMathHull::mutate(HullType newtype)
                        numbered(0, false);
                } else {
                        setType(hullEquation);
-                       numbered(0, label_[0] ? true : false);
+                       numbered(0, label_[0] != nullptr);
                        mutate(newtype);
                }
                break;
index 15b5d29d9c1ef11f4a9ccaaa1d7b9890987d221c..862ee8a4d78384e3c4a00424d06b7f99c38c7fd7 100644 (file)
@@ -205,7 +205,7 @@ public:
                : name_(name), displayMode_(DISPLAY_INIT),
                  expanded_(buf), definition_(buf), attachedArgsNum_(0),
                  optionals_(0), nextFoldMode_(true), macroBackup_(buf),
-                 macro_(0), needsUpdate_(false), isUpdating_(false),
+                 macro_(nullptr), needsUpdate_(false), isUpdating_(false),
                  appetite_(9), nesting_(0), limits_(AUTO_LIMITS)
        {
        }
@@ -649,7 +649,7 @@ void InsetMathMacro::updateMacro(MacroContext const & mc)
                        d->needsUpdate_ = true;
                }
        } else {
-               d->macro_ = 0;
+               d->macro_ = nullptr;
        }
 }
 
@@ -684,7 +684,7 @@ void InsetMathMacro::updateRepresentation(Cursor * cur, MacroContext const & mc,
        UpdateLocker locker(*this);
 
        // known macro?
-       if (d->macro_ == 0)
+       if (d->macro_ == nullptr)
                return;
 
        // remember nesting level of this macro
@@ -837,7 +837,7 @@ void InsetMathMacro::setDisplayMode(InsetMathMacro::DisplayMode mode, int appeti
 
 InsetMathMacro::DisplayMode InsetMathMacro::computeDisplayMode() const
 {
-       if (d->nextFoldMode_ == true && d->macro_ && !d->macro_->locked())
+       if (d->nextFoldMode_ && d->macro_ && !d->macro_->locked())
                return DISPLAY_NORMAL;
        else
                return DISPLAY_UNFOLDED;
@@ -1172,10 +1172,10 @@ void InsetMathMacro::write(WriteStream & os) const
                // contains macros with optionals.
                bool braced = false;
                size_type last = cell(i).size() - 1;
-               if (cell(i).size() && cell(i)[last]->asUnknownInset()) {
+               if (!cell(i).empty() && cell(i)[last]->asUnknownInset()) {
                        latexkeys const * l = in_word_set(cell(i)[last]->name());
                        braced = (l && l->inset == "big");
-               } else if (cell(i).size() && cell(i)[0]->asScriptInset()) {
+               } else if (!cell(i).empty() && cell(i)[0]->asScriptInset()) {
                        braced = cell(i)[0]->asScriptInset()->nuc().empty();
                } else {
                        for (size_type j = 0; j < cell(i).size(); ++j) {
index be6fecc52654cf7a62c17f76bcc479dcada16a50..9d88b1337b9eb6efd4829b725a1dc928dd1e8f72 100644 (file)
@@ -2027,7 +2027,7 @@ CompletionList const *
 InsetMathNest::createCompletionList(Cursor const & cur) const
 {
        if (!cur.inMacroMode())
-               return 0;
+               return nullptr;
 
        return new MathCompletionList(cur);
 }
index cbef2fafb10bf58369e3ef80d4eaf9734474ea8c..e40db4f16488064b6c91b18c6a0c3dcf1a9c2408 100644 (file)
@@ -388,7 +388,7 @@ void InsetMathScript::removeScript(bool up)
                if (up == cell_1_is_up_)
                        cells_.pop_back();
        } else if (nargs() == 3) {
-               if (up == true) {
+               if (up) {
                        swap(cells_[1], cells_[2]);
                        cell_1_is_up_ = false;
                } else {
index 18340e11c89eb46944d4730c4cad355a2d29e459..092de56ee519f169f00f5febdcc40093b96b592b 100644 (file)
@@ -75,7 +75,7 @@ static char const * function_names[] = {
        "det", "dim", "exp", "gcd", "hom", "inf", "ker",
        "lg", "lim", "liminf", "limsup", "ln", "log",
        "max", "min", "sec", "sin", "sinh", "sup",
-       "tan", "tanh", "Pr", 0
+       "tan", "tanh", "Pr", nullptr
 };
 
 static size_t const npos = lyx::docstring::npos;
index afee57ef1c305a4ca1ed9c010b280984cc7d3712..54fe012857007c3a554ba66e05ba0fba05f3fae4 100644 (file)
@@ -444,9 +444,9 @@ latexkeys const * in_word_set(docstring const & str)
 {
        MathWordList::iterator it = theMathWordList.find(str);
        if (it == theMathWordList.end())
-               return 0;
+               return nullptr;
        if (it->second.inset == "macro")
-               return 0;
+               return nullptr;
        return &(it->second);
 }
 
index c3bea0d540e7363c79ed3159d4f4cbe6634be7d0..32d7ef642468cdfb3c82b1e0052d115a13504518 100644 (file)
@@ -1497,7 +1497,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                if (ar[i].size() == 1)
                                        script[i] = ar[i][0].nucleus()->asScriptInset();
                        }
-                       bool const hasscript[2] = {script[0] ? true : false, script[1] ? true : false};
+                       bool const hasscript[2] = {script[0] != nullptr, script[1] != nullptr};
                        cell->push_back(MathAtom(new InsetMathSideset(buf, hasscript[0], hasscript[1])));
                        if (hasscript[0]) {
                                if (script[0]->hasDown())
index d78815acf3ffba8ed6c26eb671c9c41c479aa786..be61c8a39c21131f169e182a529e8fd7d9f46331 100644 (file)
@@ -39,7 +39,7 @@ namespace lyx {
 
 MathRow::Element::Element(MetricsInfo const & mi, Type t, MathClass mc)
        : type(t), mclass(mc), before(0), after(0), macro_nesting(mi.base.macro_nesting),
-         marker(InsetMath::NO_MARKER), inset(0), compl_unique_to(0), ar(0),
+         marker(InsetMath::NO_MARKER), inset(nullptr), compl_unique_to(0), ar(nullptr),
          color(Color_red)
 {}
 
index fefa62fa1071fa13e9d9b488afa67f5c07a7ff82..b2d51488cdb33b5969f0b63c9a5eff152b2fa679 100644 (file)
@@ -109,7 +109,7 @@ bool atSameLastLangSwitchDepth(OutputState const * state)
        // commands. Instead, return always true when using babel with
        // only a begin command.
 
-       return state->lang_switch_depth_.size() == 0
+       return state->lang_switch_depth_.empty()
                        ? true
                        : abs(state->lang_switch_depth_.top()) == state->nest_level_;
 }
@@ -119,7 +119,7 @@ bool isLocalSwitch(OutputState const * state)
 {
        // Return true if the language was opened by a local command switch.
 
-       return state->lang_switch_depth_.size()
+       return !state->lang_switch_depth_.empty()
                && state->lang_switch_depth_.top() < 0;
 }
 
@@ -128,7 +128,7 @@ bool langOpenedAtThisLevel(OutputState const * state)
 {
        // Return true if the language was opened at the current nesting level.
 
-       return state->lang_switch_depth_.size()
+       return !state->lang_switch_depth_.empty()
                && abs(state->lang_switch_depth_.top()) == state->nest_level_;
 }
 
@@ -241,7 +241,7 @@ static TeXEnvironmentData prepareEnvironment(Buffer const & buf,
                // polyglossia or begin/end commands, then the current
                // language is the document language.
                string const & cur_lang = using_begin_end
-                                         && state->lang_switch_depth_.size()
+                                         && !state->lang_switch_depth_.empty()
                                                  ? openLanguageName(state)
                                                  : doc_lang;
 
@@ -442,7 +442,7 @@ void TeXEnvironment(Buffer const & buf, Text const & text,
                        if ((par->layout() != nextpar->layout()
                             || par->params().depth() == nextpar->params().depth()
                             || par->params().leftIndent() == nextpar->params().leftIndent())
-                           && !runparams.for_search && cpar.size() > 0
+                           && !runparams.for_search && !cpar.empty()
                            && cpar.isDeleted(0, cpar.size()) && !buf.params().output_changes) {
                                if (!buf.params().output_changes && !cpar.parEndChange().deleted())
                                        os << '\n' << '\n';
@@ -761,7 +761,7 @@ void TeXOnePar(Buffer const & buf,
        // Do not output empty commands if the whole paragraph has
        // been deleted with ct and changes are not output.
        if (!runparams_in.for_search && style.latextype != LATEX_ENVIRONMENT
-           && par.size() > 0 && par.isDeleted(0, par.size()) && !bparams.output_changes)
+           && !par.empty() && par.isDeleted(0, par.size()) && !bparams.output_changes)
                return;
 
        LYXERR(Debug::LATEX, "TeXOnePar for paragraph " << pit << " ptr " << &par << " '"
@@ -1312,7 +1312,7 @@ void TeXOnePar(Buffer const & buf,
                                                && nextpar
                                                && style != nextpar->layout())))
                                    || (atSameLastLangSwitchDepth(state)
-                                       && state->lang_switch_depth_.size()
+                                       && !state->lang_switch_depth_.empty()
                                        && cur_lang != par_lang)
                                    || in_polyglossia_rtl_env)
                                {
@@ -1355,7 +1355,7 @@ void TeXOnePar(Buffer const & buf,
        }
 
        bool const last_was_separator =
-               par.size() > 0 && par.isEnvSeparator(par.size() - 1);
+               !par.empty() && par.isEnvSeparator(par.size() - 1);
 
        // Signify added/deleted par break in output if show changes in output
        if (nextpar && !os.afterParbreak() && !last_was_separator
@@ -1666,7 +1666,7 @@ void latexParagraphs(Buffer const & buf,
                        if ((par->layout() != nextpar->layout()
                             || par->params().depth() == nextpar->params().depth()
                             || par->params().leftIndent() == nextpar->params().leftIndent())
-                           && !runparams.for_search && cpar.size() > 0
+                           && !runparams.for_search && !cpar.empty()
                            && cpar.isDeleted(0, cpar.size()) && !bparams.output_changes) {
                                if (!cpar.parEndChange().deleted())
                                        os << '\n' << '\n';
index a6b849407a5156d4da27263e30a9b1533f10a0f2..9714965bdf1859a5265c3a4e99d46faf050838d8 100644 (file)
@@ -89,7 +89,7 @@ struct FileName::Private
                : fi(toqstr(handleTildeName(abs_filename)))
        {
                name = fromqstr(fi.absoluteFilePath());
-               fi.setCaching(fi.exists() ? true : false);
+               fi.setCaching(fi.exists());
        }
        ///
        inline void refresh()
index f931ddf7059bcbe0c28fba650b2d2aa0e3dede12..a349a5e755fef7e3812952967490016e4fb32027 100644 (file)
@@ -366,10 +366,7 @@ bool inBuildDir(FileName const & abs_binary,
 bool doesFileExist(FileName & result, string const & search_dir, string const & name)
 {
     result = fileSearch(search_dir, name);
-    if (!result.empty()) {
-        return true;
-    }
-    return false;
+    return !result.empty();
 }
 
 
@@ -382,7 +379,7 @@ bool lyxBinaryPath(FileName & lyx_binary, string const & search_dir, string cons
     } else if (doesFileExist(lyx_binary, search_dir, "lyx" + string(PROGRAM_SUFFIX) + ext)) {
     } else if (doesFileExist(lyx_binary, search_dir, "LyX" + string(PROGRAM_SUFFIX) + ext)){
     }
-    return !lyx_binary.empty() ? true : false;
+    return !lyx_binary.empty();
 }
 
 
index e73c3f09c0190a30a49fab0a817469e6681df64d..cbee18a20a4584ce9f41e87eec322d080cb102f6 100644 (file)
@@ -625,7 +625,7 @@ protected:
                        }
                        if (ok) {
                                err = ios_base::goodbit;
-                               v = truename == s ? true : false;
+                               v = (truename == s);
                        } else
                                err = ios_base::failbit;
                        if (iit == eit)
index 7100c712d8c22971be4ff8ba1aab39ffdc1821ec..2fa0fe11e94e8447fc59ebd280117918da8ce843 100644 (file)
@@ -57,7 +57,7 @@ bool test_Layout(string const & input, string const & output)
                return false;
        }
        LayoutFile const & f = l[i];
-       ostream * os = NULL;
+       ostream * os = nullptr;
        if (output == "-")
                os = &cout;
        else if (!output.empty())
index cc8dd5aa58c77e7513603c895becf308b3eaa7de..e44aa3e69a1fb85603cce5b979fc40e476e7f117 100644 (file)
@@ -154,7 +154,7 @@ iparserdocstream & iparserdocstream::get(char_type &c)
 
 
 Parser::Parser(idocstream & is, std::string const & fixedenc)
-       : lineno_(0), pos_(0), iss_(0), is_(is),
+       : lineno_(0), pos_(0), iss_(nullptr), is_(is),
          encoding_iconv_(fixedenc.empty() ? "UTF-8" : fixedenc),
          theCatcodesType_(NORMAL_CATCODES), curr_cat_(UNDECIDED_CATCODES),
          fixed_enc_(!fixedenc.empty())