Skip to content

Commit

Permalink
fixes #90, Several Qt deprecation warnings. Chagned 0 to nullptr. Pos…
Browse files Browse the repository at this point in the history
…sible incompatibility with older releases!
  • Loading branch information
gamecreature committed Jul 20, 2020
1 parent 182d0f1 commit d23f803
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 87 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

edbee.lib:

- fix #90, Fixed several Qt deprecation warnings. Chagned 0 to nullptr. Possible incompatibility with older releases!
- add #101, Support for JSON based grammar files.
- fix #67, PlacholderText support via TextEditorWidget::setPlaceholderText. (uses 70% opacity of foreground color)
- fix #98, Missing header include in Qt 5.15rc
Expand Down
2 changes: 2 additions & 0 deletions edbee-lib/edbee/commands/movelinecommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ MoveLineCommand::~MoveLineCommand()


/// Calculates the new ranges after moving
/*
static void calculateNewSelectionRanges( TextDocument* doc, TextRangeSet& newCaretSelection, int direction )
{
for( int i=0,cnt=newCaretSelection.rangeCount(); i<cnt; ++i) {
Expand All @@ -43,6 +44,7 @@ static void calculateNewSelectionRanges( TextDocument* doc, TextRangeSet& newCar
}
}
}
*/


/// all carets in the newCaretSelection are changed in the movedRange
Expand Down
25 changes: 13 additions & 12 deletions edbee-lib/edbee/models/change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ void Change::revert(TextDocument*)
/// @return true if the merge succeeded. The textChange ownership is only tranfered if true if returend
bool Change::giveAndMerge(TextDocument* document, Change* textChange)
{
Q_UNUSED(document);
Q_UNUSED(textChange );
Q_UNUSED(document)
Q_UNUSED(textChange )
return false;
}

Expand All @@ -59,14 +59,14 @@ bool Change::isPersistenceRequired()
/// warning a DOCUMENT change may NEVER return a controllerContext!!
TextEditorController*Change::controllerContext()
{
return 0;
return nullptr;
}


/// this method can be used to check if the given change is a document change
bool Change::isDocumentChange()
{
return controllerContext() == 0;
return controllerContext() == nullptr;
}


Expand Down Expand Up @@ -127,7 +127,7 @@ TextEditorController* ControllerChange::controllerContext()
/// returns the controller
TextEditorController* ControllerChange::controller()
{
return controllerRef_;;
return controllerRef_;
}


Expand Down Expand Up @@ -177,7 +177,7 @@ void ChangeGroup::groupClosed()
/// @param document the document the document to execute this for
void ChangeGroup::execute(TextDocument* document)
{
Q_UNUSED(document);
Q_UNUSED(document)
for( int i=0,cnt=size(); i<cnt; ++i ) {
at(i)->execute(document);
}
Expand All @@ -187,7 +187,7 @@ void ChangeGroup::execute(TextDocument* document)
/// Reverts the command gorup
void ChangeGroup::revert(TextDocument* document)
{
Q_UNUSED(document);
Q_UNUSED(document)
for( int i=size()-1; i>=0; --i ) {
at(i)->revert(document);
}
Expand Down Expand Up @@ -237,6 +237,7 @@ void ChangeGroup::flatten()

void ChangeGroup::giveChange(TextDocument *doc, Change *change)
{
Q_UNUSED(doc)
changeList_.append(change);
}

Expand Down Expand Up @@ -269,7 +270,7 @@ void ChangeGroup::clear(bool performDelete)
/// @return the last textchange
Change* ChangeGroup::last()
{
if( size() == 0 ) { return 0; }
if( size() == 0 ) { return nullptr; }
return at(size()-1);
}

Expand All @@ -278,7 +279,7 @@ Change* ChangeGroup::last()
/// @return the last textchange
Change* ChangeGroup::takeLast()
{
if( size() == 0 ) { return 0; }
if( size() == 0 ) { return nullptr; }
return take(size()-1);
}

Expand All @@ -304,13 +305,13 @@ int ChangeGroup::recursiveSize()
/// Then this context is returned else 0 is returned
TextEditorController* ChangeGroup::controllerContext()
{
TextEditorController* context = 0;
TextEditorController* context = nullptr;
for( int i=size()-1; i>=0; --i ) {
TextEditorController* commandContext = at(i)->controllerContext();

// multiple context in 1 group means it's a 'hard' undo
if( commandContext == 0 ) return 0; /// 0 is always 0!
if( commandContext && context && commandContext != context ) { return 0; }
if( commandContext == nullptr ) return nullptr; /// 0 is always 0!
if( commandContext && context && commandContext != context ) { return nullptr; }
if( !context && commandContext ) {
context = commandContext;
}
Expand Down
2 changes: 1 addition & 1 deletion edbee-lib/edbee/models/dynamicvariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void DynamicVariables::setAndGiveScopedSelector(const QString& name, const QVari
{
/// Todo, perhaps we should detect identical scope selectors and replace the original
variableNames_.insert(name);
scopedVariableMap_.insertMulti( name, new ScopedDynamicVariable(value, new TextScopeSelector(selector) ) );
scopedVariableMap_.insert( name, new ScopedDynamicVariable(value, new TextScopeSelector(selector) ) );
}


Expand Down
1 change: 1 addition & 0 deletions edbee-lib/edbee/models/textdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ Change *TextDocument::executeAndGiveChange(Change* change, int coalesceId )
beginUndoGroup(); // automaticly group changes together (when changes happend on emition)
change->execute( this );
Change* result = giveChangeWithoutFilter( change, coalesceId );
Q_UNUSED(result)
endUndoGroup(coalesceId, true);
return textUndoStack()->last();
// return result;
Expand Down
6 changes: 3 additions & 3 deletions edbee-lib/edbee/models/texteditorkeymap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ TextEditorKey* TextEditorKeyMap::get(const QString& name) const
QHash<QString,TextEditorKey*>::const_iterator itr = keyMap_.find(name);
if( itr != keyMap_.end() ) { return itr.value(); }
if( parentRef_ ) { return parentRef_->get(name); }
return 0;
return nullptr;
}


Expand Down Expand Up @@ -137,7 +137,7 @@ bool TextEditorKeyMap::has(const QString& name) const
/// @param sequence the keysequence
void TextEditorKeyMap::add(const QString& command, TextEditorKey* sequence)
{
keyMap_.insertMulti(command,sequence);
keyMap_.insert(command,sequence);
}


Expand All @@ -146,7 +146,7 @@ void TextEditorKeyMap::add(const QString& command, TextEditorKey* sequence)
/// @param sequence the keysequence
void TextEditorKeyMap::add(const QString& command, const QKeySequence& seq)
{
keyMap_.insertMulti(command, new TextEditorKey(seq) );
keyMap_.insert(command, new TextEditorKey(seq) );
}


Expand Down
3 changes: 2 additions & 1 deletion edbee-lib/edbee/models/texteditorkeymap.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <QKeySequence>
#include <QHash>
#include <QMultiHash>
#include <QStringList>

namespace edbee {
Expand Down Expand Up @@ -68,7 +69,7 @@ class EDBEE_EXPORT TextEditorKeyMap {
private:

TextEditorKeyMap* parentRef_; ///< a reference to a parent keymap
QHash<QString,TextEditorKey*> keyMap_; ///< a map to convert a name to a
QMultiHash<QString,TextEditorKey*> keyMap_; ///< a map to convert a name to a
};


Expand Down
16 changes: 9 additions & 7 deletions edbee-lib/edbee/util/mem/debug_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ void* debug_malloc(size_t size, const char* file, const int line)
void* p = ::malloc(size);
if( allocList->isRunning() ) {
edbee::DebugAllocation* info = allocList->find(p);
if (info != 0) {
if (info != nullptr) {
printf("already exist %p %s %d\n", p, file, line);
printf("existing info : %p(%u) %s:%d\n", info->pointer, (unsigned int)info->size, info->file, info->line);
printf("existing info : %p(%u) %s:%d\n", info->pointer, static_cast<unsigned int>(info->size), info->file, info->line);
::free(p);
return 0;
return nullptr;
}
info = allocList->add(p, size, (char*)file, (int)line);
if (info == 0) {
printf("can not add %p(%u) %s:%d\n", p,(unsigned int)size, file, line);
info = allocList->add(p, size, const_cast<char*>(file), static_cast<int>(line));
if (info == nullptr) {
printf("can not add %p(%u) %s:%d\n", p, static_cast<unsigned int>(size), file, line);
::free(p);
return 0;
return nullptr;
}
}
return p;
Expand Down Expand Up @@ -122,6 +122,8 @@ void pause_memleak_detection(bool value)
{
#ifdef EDBEE_DEBUG_NEW_ACTIVE
DebugAllocationList::instance()->pause(value);
#else
Q_UNUSED(value)
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion edbee-lib/edbee/util/mem/debug_new.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
void operator delete[] (void* p) throw();

#define debug_new new(__FILE__, __LINE__)
#define new debug_new
#define new new(__FILE__, __LINE__)
#define malloc(A) debug_malloc((A), __FILE__, __LINE__)
#define free(A) debug_free((A), __FILE__, __LINE__)
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ void TextEditorAutoCompleteComponent::showInfoTip()
}
if( sDetail.contains(" = ") ){
sType = QString("%1").arg(sDetail.split(" = ").value(0));
int width = fm.width(QString("%1 %2").arg(sLabel).arg(sType)) + widthMod;
int width = fm.horizontalAdvance(QString("%1 %2").arg(sLabel).arg(sType)) + widthMod;
maxWidth = qMax(width, maxWidth);
} else {
int width = fm.width(QString("%1").arg(sLabel)) + widthMod;
int width = fm.horizontalAdvance(QString("%1").arg(sLabel)) + widthMod;
maxWidth = qMax(width, maxWidth);
}
}
Expand Down Expand Up @@ -474,8 +474,8 @@ void AutoCompleteDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
QPen typePen = QPen(themeRef_->findHighlightForegroundColor());
QPen namePen = QPen(themeRef_->foregroundColor());

hyphenRect.setX(hyphenRect.x() + fm.width(sLabel));
typeRect.setX(nameRect.x() + nameRect.width() - fm.width(sType) - 1);
hyphenRect.setX(hyphenRect.x() + fm.horizontalAdvance(sLabel));
typeRect.setX(nameRect.x() + nameRect.width() - fm.horizontalAdvance(sType) - 1);
painter->setFont(font);
painter->drawText(nameRect, sLabel);

Expand Down
16 changes: 8 additions & 8 deletions edbee-lib/edbee/views/components/texteditorcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ namespace edbee {
/// @param parent the parent QObject
TextEditorComponent::TextEditorComponent(TextEditorController* controller, QWidget* parent)
: QWidget(parent)
, caretTimer_(0)
, caretTimer_(nullptr)
, controllerRef_(controller)
, textEditorRenderer_(0)
, textEditorRenderer_(nullptr)
{
textEditorRenderer_ = new TextEditorRenderer( controller->textRenderer());

Expand Down Expand Up @@ -213,12 +213,12 @@ void TextEditorComponent::paintEvent(QPaintEvent* paintEvent)

void TextEditorComponent::moveEvent(QMoveEvent *moveEvent)
{

Q_UNUSED(moveEvent)
}

void TextEditorComponent::hideEvent(QHideEvent *hideEvent)
{

Q_UNUSED(hideEvent)
}


Expand Down Expand Up @@ -317,7 +317,7 @@ void TextEditorComponent::keyPressEvent(QKeyEvent* event)
/// the key release event
void TextEditorComponent::keyReleaseEvent(QKeyEvent *event)
{
Q_UNUSED(event);
Q_UNUSED(event)
}


Expand Down Expand Up @@ -484,14 +484,14 @@ void TextEditorComponent::mouseMoveEvent(QMouseEvent* event )
/// A focus in event occured
void TextEditorComponent::focusInEvent(QFocusEvent *event)
{
Q_UNUSED(event);
Q_UNUSED(event)
}


/// The focus is lost, we must STOP coalescing of undo-events!
void TextEditorComponent::focusOutEvent(QFocusEvent *event)
{
Q_UNUSED(event);
Q_UNUSED(event)
// no merging for new changes!!
textDocument()->textUndoStack()->resetAllLastCoalesceIds();
}
Expand All @@ -501,7 +501,7 @@ void TextEditorComponent::focusOutEvent(QFocusEvent *event)
/// Add the default menu actions
void TextEditorComponent::contextMenuEvent(QContextMenuEvent* event)
{
Q_UNUSED(event);
Q_UNUSED(event)

QMenu* menu = new QMenu();
menu->addAction( controller()->createAction("cut", tr("Cut") ) );
Expand Down
Loading

0 comments on commit d23f803

Please sign in to comment.