Skip to content

Commit

Permalink
great cleanup phase 1
Browse files Browse the repository at this point in the history
  • Loading branch information
psemiletov committed Jul 6, 2017
1 parent bae8a31 commit e0f7e1d
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 106 deletions.
75 changes: 37 additions & 38 deletions document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ CDocument* document_holder::create_new()

CDocument* document_holder::get_document_by_fname (const QString &fileName)
{
if (fileName.isNull() || fileName.isEmpty())
if (fileName.isEmpty())
return NULL;

foreach (CDocument *d, list)
Expand Down Expand Up @@ -585,20 +585,20 @@ void CDocument::set_hl (bool mode_auto, const QString &theext)
else
ext = theext;

if (ext.isNull() || ext.isEmpty())
{
QFileInfo fi (file_name);
ext = fnameswoexts[fi.fileName()];
}
if (ext.isEmpty())
{
QFileInfo fi (file_name);
ext = fnameswoexts[fi.fileName()];
}

if (ext.isNull() || ext.isEmpty())
if (ext.isEmpty())
return;

QString fname = holder->hls.value (ext);

//qDebug() << "hl fname is " << fname;

if (fname.isNull() || fname.isEmpty())
if (fname.isEmpty())
return;

if (highlighter)
Expand Down Expand Up @@ -1015,13 +1015,13 @@ QStringList CDocument::get_words()

QString stext = cr.selectedText();

if (! stext.isNull() && stext.endsWith ("\""))
if (! stext.isEmpty() && stext.endsWith ("\""))
{
cr.movePosition (QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);
stext = cr.selectedText();
}

if (! stext.isNull() || ! stext.isEmpty())
if (! stext.isEmpty())
result.append (stext);
}
while (cr.movePosition (QTextCursor::NextWord));
Expand All @@ -1035,7 +1035,7 @@ QTextCharFormat tformat_from_style (const QString &fontstyle, const QString &col
QTextCharFormat tformat;
tformat.setForeground (QBrush (QColor (color).darker (darker_val)));

if (fontstyle.isNull() || fontstyle.isEmpty())
if (fontstyle.isEmpty())
return tformat;

if (fontstyle.contains ("bold"))
Expand Down Expand Up @@ -1099,16 +1099,16 @@ void CSyntaxHighlighterQRegularExpression::load_from_xml (const QString &fname)
if (attr_name == "options")
{
QString s_xml_format = xml.attributes().value ("xml_format").toString();
if (! s_xml_format.isNull() || ! s_xml_format.isEmpty())
if (! s_xml_format.isEmpty())
xml_format = s_xml_format.toInt();

QString s_wrap = xml.attributes().value ("wrap").toString();
if (! s_wrap.isNull() || ! s_wrap.isEmpty())
if (! s_wrap.isEmpty())
if (s_wrap == "0" || s_wrap == "false")
wrap = false;

QString s_casecare = xml.attributes().value ("casecare").toString();
if (! s_casecare.isNull() || ! s_casecare.isEmpty())
if (! s_casecare.isEmpty())
if (s_casecare == "0" || s_casecare == "false")
casecare = false;

Expand All @@ -1129,7 +1129,7 @@ void CSyntaxHighlighterQRegularExpression::load_from_xml (const QString &fname)
HighlightingRule rule;

for (int i = 0; i < keywordPatterns.size(); i++)
if (! keywordPatterns.at(i).isNull())
if (! keywordPatterns.at(i).isEmpty())
{
rule.pattern = QRegularExpression (keywordPatterns.at(i).trimmed(), pattern_opts);
rule.format = fmt;
Expand Down Expand Up @@ -1297,12 +1297,12 @@ void CSyntaxHighlighterQRegExp::load_from_xml (const QString &fname)
if (attr_name == "options")
{
QString s_wrap = xml.attributes().value ("wrap").toString();
if (! s_wrap.isNull() || ! s_wrap.isEmpty())
if (! s_wrap.isEmpty())
if (s_wrap == "0" || s_wrap == "false")
wrap = false;

QString s_casecare = xml.attributes().value ("casecare").toString();
if (! s_casecare.isNull() || ! s_casecare.isEmpty())
if (! s_casecare.isEmpty())
if (s_casecare == "0" || s_casecare == "false")
casecare = false;

Expand All @@ -1322,7 +1322,7 @@ void CSyntaxHighlighterQRegExp::load_from_xml (const QString &fname)
HighlightingRule rule;

for (int i = 0; i < keywordPatterns.size(); i++)
if (! keywordPatterns.at(i).isNull())
if (! keywordPatterns.at(i).isEmpty())
{
rule.pattern = QRegExp (keywordPatterns.at(i).trimmed(), cs, QRegExp::RegExp);
rule.format = fmt;
Expand Down Expand Up @@ -1499,15 +1499,15 @@ QHash <QString, QString> document_holder::load_eclipse_theme_xml (const QString
if (tag_name == "singleLineComment")
{
QString t = xml.attributes().value ("color").toString();
if (! t.isNull() || ! t.isEmpty())
if (! t.isEmpty())
result.insert ("single comment", t);
}
if (tag_name == "class")
{
QString t = xml.attributes().value ("color").toString();
if (! t.isNull() || ! t.isEmpty())
if (! t.isEmpty())
{
result.insert ("class", t);
result.insert ("type", t);
Expand All @@ -1518,7 +1518,7 @@ QHash <QString, QString> document_holder::load_eclipse_theme_xml (const QString
if (tag_name == "operator")
{
QString t = xml.attributes().value ("color").toString();
if (! t.isNull() || ! t.isEmpty())
if (! t.isEmpty())
result.insert ("operator", t);
}
Expand All @@ -1527,7 +1527,7 @@ QHash <QString, QString> document_holder::load_eclipse_theme_xml (const QString
if (tag_name == "string")
{
QString t = xml.attributes().value ("color").toString();
if (! t.isNull() || ! t.isEmpty())
if (! t.isEmpty())
result.insert ("quotes", t);
}
Expand All @@ -1536,7 +1536,7 @@ QHash <QString, QString> document_holder::load_eclipse_theme_xml (const QString
if (tag_name == "multiLineComment")
{
QString t = xml.attributes().value ("color").toString();
if (! t.isNull() || ! t.isEmpty())
if (! t.isEmpty())
result.insert ("mcomment-start", t);
}
Expand All @@ -1545,7 +1545,7 @@ QHash <QString, QString> document_holder::load_eclipse_theme_xml (const QString
if (tag_name == "foreground")
{
QString t = xml.attributes().value ("color").toString();
if (! t.isNull() || ! t.isEmpty())
if (! t.isEmpty())
{
result.insert ("text", t);
result.insert ("functions", t);
Expand All @@ -1562,7 +1562,7 @@ QHash <QString, QString> document_holder::load_eclipse_theme_xml (const QString
if (tag_name == "background")
{
QString t = xml.attributes().value ("color").toString();
if (! t.isNull() || ! t.isEmpty())
if (! t.isEmpty())
{
result.insert ("background", t);
result.insert ("linenums_bg", t);
Expand All @@ -1573,7 +1573,7 @@ QHash <QString, QString> document_holder::load_eclipse_theme_xml (const QString
if (tag_name == "selectionForeground")
{
QString t = xml.attributes().value ("color").toString();
if (! t.isNull() || ! t.isEmpty())
if (! t.isEmpty())
result.insert ("sel-text", t);
}
Expand All @@ -1582,15 +1582,15 @@ QHash <QString, QString> document_holder::load_eclipse_theme_xml (const QString
if (tag_name == "selectionBackground")
{
QString t = xml.attributes().value ("color").toString();
if (! t.isNull() || ! t.isEmpty())
if (! t.isEmpty())
result.insert ("sel-background", t);
}
if (tag_name == "keyword")
{
QString t = xml.attributes().value ("color").toString();
if (! t.isNull() || ! t.isEmpty())
if (! t.isEmpty())
{
result.insert ("keywords", t);
result.insert ("tags", t);
Expand All @@ -1602,15 +1602,15 @@ QHash <QString, QString> document_holder::load_eclipse_theme_xml (const QString
if (tag_name == "currentLine")
{
QString t = xml.attributes().value ("color").toString();
if (! t.isNull() || ! t.isEmpty())
if (! t.isEmpty())
result.insert ("cur_line_color", t);
}
if (tag_name == "bracket")
{
QString t = xml.attributes().value ("color").toString();
if (! t.isNull() || ! t.isEmpty())
if (! t.isEmpty())
result.insert ("brackets", t);
}
Expand Down Expand Up @@ -2138,7 +2138,7 @@ void CTEAEdit::update_rect_sel()

int y1 = std::min (rect_sel_start.y(), rect_sel_end.y());
int y2 = std::max (rect_sel_start.y(), rect_sel_end.y());
int ydiff = y2 - y1;
//int ydiff = y2 - y1;


int x1 = std::min (rect_sel_start.x(), rect_sel_end.x());
Expand Down Expand Up @@ -2490,18 +2490,17 @@ QString CTEAEdit::get_rect_sel()

for (int y = y1; y <= y2; y++)
{
// qDebug() << "y:" << y;

int sel_len = xdiff;
//int sel_len = xdiff;

QTextBlock b = document()->findBlockByNumber (y);

if ((b.text().length() - x1) < xdiff)
sel_len = b.text().length() - x1;
//if ((b.text().length() - x1) < xdiff)
// sel_len = b.text().length() - x1;

QString t = b.text();
//qDebug() << t;

result += t.mid (x1, xdiff);

if (y != y2)
result += '\n';
}
Expand All @@ -2519,7 +2518,7 @@ void CTEAEdit::rect_sel_cut (bool just_del)

int x1 = std::min (rect_sel_start.x(), rect_sel_end.x());
int x2 = std::max (rect_sel_start.x(), rect_sel_end.x());
int xdiff = x2 - x1;
//int xdiff = x2 - x1;

int how_many_copy_from_source = ydiff;

Expand Down
9 changes: 8 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ int main (int argc, char *argv[])
return app.exec();

#endif

//Q_INIT_RESOURCE (rlvn);

#if defined(Q_OS_WIN)
Expand Down Expand Up @@ -82,18 +81,26 @@ int main (int argc, char *argv[])

#endif


mainWindow = new rvln();



#if defined(Q_OS_WIN)
QObject::connect(&app, SIGNAL(messageAvailable(QString)), mainWindow, SLOT(receiveMessage(QString)));
#endif


#if defined(Q_OS_UNIX)

QObject::connect(&app, SIGNAL(messageAvailable(QStringList)), mainWindow, SLOT(receiveMessageShared(QStringList)));


// QObject::connect(&app, SIGNAL(signal_commit_data()), mainWindow, SLOT(app_commit_data()));
// QObject::connect(&app, SIGNAL(commitDataRequest(QSessionManager & )), mainWindow, SLOT(slot_commitDataRequest(QSessionManager & )));

#endif


mainWindow->show();

Expand Down
Loading

0 comments on commit e0f7e1d

Please sign in to comment.