"Fossies" - the Fresh Open Source Software Archive

Member "cb2bib-2.0.1/src/c2bCitePatternLineEedit.cpp" (12 Feb 2021, 2718 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "c2bCitePatternLineEedit.cpp" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2  *   Copyright (C) 2004-2021 by Pere Constans
    3  *   constans@molspaces.com
    4  *   cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
    5  *   See the LICENSE file that comes with this distribution.
    6  ***************************************************************************/
    7 #include "c2bCitePatternLineEedit.h"
    8 
    9 #include "c2bUtils.h"
   10 
   11 #include <cb2bib_parameters.h>
   12 
   13 #include <QAction>
   14 
   15 
   16 c2bCitePatternLineEedit::c2bCitePatternLineEedit(QWidget* parentw) : c2bLineEdit(parentw)
   17 {
   18     a_citeid = new QAction(this);
   19     a_citeids_comma = new QAction(this);
   20     a_citeids_semicolon = new QAction(this);
   21     a_latex = new QAction(this);
   22     a_markdown = new QAction(this);
   23 
   24     c2bUtils::addSeparator(this);
   25     addAction(a_latex);
   26     addAction(a_markdown);
   27     c2bUtils::addSeparator(this);
   28     addAction(a_citeid);
   29     addAction(a_citeids_comma);
   30     addAction(a_citeids_semicolon);
   31     c2bUtils::addSeparator(this);
   32 
   33     a_citeid->setText(tr("Insert <<citeid>>"));
   34     a_citeids_comma->setText(tr("Insert << |citeids|,>>"));
   35     a_citeids_semicolon->setText(tr("Insert << |citeids|;>>"));
   36     a_latex->setText(tr("LaTeX Command"));
   37     a_markdown->setText(tr("Markdown Command"));
   38 
   39     connect(a_citeid, SIGNAL(triggered()), this, SLOT(citeid()));
   40     connect(a_citeids_comma, SIGNAL(triggered()), this, SLOT(citeids_comma()));
   41     connect(a_citeids_semicolon, SIGNAL(triggered()), this, SLOT(citeids_semicolon()));
   42     connect(a_latex, SIGNAL(triggered()), this, SLOT(latex()));
   43     connect(a_markdown, SIGNAL(triggered()), this, SLOT(markdown()));
   44     connect(this, SIGNAL(textEdited(QString)), this, SLOT(check(QString)));
   45 
   46     setPlaceholderText(C2B_CITE_COMMAND_PATTERN);
   47     _citeids = QRegExp("^[^<]*<<[^\\|]*\\|citeids\\|[^>]*>>.*$");
   48 }
   49 
   50 c2bCitePatternLineEedit::~c2bCitePatternLineEedit() {}
   51 
   52 
   53 void c2bCitePatternLineEedit::check(const QString& pattern)
   54 {
   55     if (!pattern.isEmpty() && ((!pattern.contains(_citeids) && !pattern.contains(QLatin1String("<<citeid>>"))) ||
   56                                pattern.count(QLatin1String("citeid")) > 1))
   57         emit statusMessage(tr("Cite Command Pattern is misspecified"));
   58     else
   59         emit statusMessage(QString());
   60 }
   61 
   62 void c2bCitePatternLineEedit::latex()
   63 {
   64     setText(C2B_CITE_COMMAND_PATTERN);
   65 }
   66 
   67 void c2bCitePatternLineEedit::markdown()
   68 {
   69     setText(QLatin1String("[<<@|citeids|;>>]"));
   70 }
   71 
   72 void c2bCitePatternLineEedit::citeid()
   73 {
   74     insert(QLatin1String("<<citeid>>"));
   75 }
   76 
   77 void c2bCitePatternLineEedit::citeids_comma()
   78 {
   79     insert(QLatin1String("<< |citeids|,>>"));
   80 }
   81 
   82 void c2bCitePatternLineEedit::citeids_semicolon()
   83 {
   84     insert(QLatin1String("<< |citeids|;>>"));
   85 }