Commit 2a2a56d7 authored by Kurt Hindenburg's avatar Kurt Hindenburg

modernize use nullptr

parent caefa412
......@@ -46,7 +46,7 @@ using namespace Konsole;
Application::Application(QSharedPointer<QCommandLineParser> parser,
const QStringList &customCommand) :
_backgroundInstance(0),
_backgroundInstance(nullptr),
m_parser(parser),
m_customCommand(customCommand)
{
......@@ -397,19 +397,19 @@ void Application::createTabFromArgs(MainWindow *window, const QHash<QString, QSt
// If --new-tab is given, use existing window.
MainWindow *Application::processWindowArgs(bool &createdNewMainWindow)
{
MainWindow *window = 0;
MainWindow *window = nullptr;
if (m_parser->isSet(QStringLiteral("new-tab"))) {
QListIterator<QWidget *> iter(QApplication::topLevelWidgets());
iter.toBack();
while (iter.hasPrevious()) {
window = qobject_cast<MainWindow *>(iter.previous());
if (window != 0) {
if (window != nullptr) {
break;
}
}
}
if (window == 0) {
if (window == nullptr) {
createdNewMainWindow = true;
window = newMainWindow();
......
......@@ -45,10 +45,10 @@ BookmarkHandler::BookmarkHandler(KActionCollection *collection, QMenu *menu, boo
QObject(parent),
KBookmarkOwner(),
_menu(menu),
_bookmarkMenu(0),
_bookmarkMenu(nullptr),
_file(QString()),
_toplevel(toplevel),
_activeView(0),
_activeView(nullptr),
_views(QList<ViewProperties *>())
{
setObjectName(QStringLiteral("BookmarkHandler"));
......@@ -70,7 +70,7 @@ BookmarkHandler::BookmarkHandler(KActionCollection *collection, QMenu *menu, boo
if (toplevel) {
_bookmarkMenu = new KBookmarkMenu(manager, this, _menu, collection);
} else {
_bookmarkMenu = new KBookmarkMenu(manager, this, _menu, 0);
_bookmarkMenu = new KBookmarkMenu(manager, this, _menu, nullptr);
}
}
......
......@@ -161,30 +161,30 @@ QString ColorScheme::translatedColorNameForIndex(int index)
ColorScheme::ColorScheme() :
_description(QString()),
_name(QString()),
_table(0),
_randomTable(0),
_table(nullptr),
_randomTable(nullptr),
_opacity(1.0),
_wallpaper(0)
_wallpaper(nullptr)
{
setWallpaper(QString());
}
ColorScheme::ColorScheme(const ColorScheme &other) :
_table(0),
_randomTable(0),
_table(nullptr),
_randomTable(nullptr),
_opacity(other._opacity),
_wallpaper(other._wallpaper)
{
setName(other.name());
setDescription(other.description());
if (other._table != 0) {
if (other._table != nullptr) {
for (int i = 0; i < TABLE_COLORS; i++) {
setColorTableEntry(i, other._table[i]);
}
}
if (other._randomTable != 0) {
if (other._randomTable != nullptr) {
for (int i = 0; i < TABLE_COLORS; i++) {
const RandomizationRange &range = other._randomTable[i];
setRandomizationRange(i, range.hue, range.saturation, range.value);
......@@ -239,7 +239,7 @@ ColorEntry ColorScheme::colorEntry(int index, uint randomSeed) const
ColorEntry entry = colorTable()[index];
if (randomSeed == 0 || _randomTable == 0 || _randomTable[index].isNull()) {
if (randomSeed == 0 || _randomTable == nullptr || _randomTable[index].isNull()) {
return entry;
}
......@@ -288,7 +288,7 @@ void ColorScheme::getColorTable(ColorEntry *table, uint randomSeed) const
bool ColorScheme::randomizedBackgroundColor() const
{
return _randomTable == 0 ? false : !_randomTable[BGCOLOR_INDEX].isNull();
return _randomTable == nullptr ? false : !_randomTable[BGCOLOR_INDEX].isNull();
}
void ColorScheme::setRandomizedBackgroundColor(bool randomize)
......@@ -311,7 +311,7 @@ void ColorScheme::setRandomizationRange(int index, quint16 hue, quint8 saturatio
Q_ASSERT(hue <= MAX_HUE);
Q_ASSERT(index >= 0 && index < TABLE_COLORS);
if (_randomTable == 0) {
if (_randomTable == nullptr) {
_randomTable = new RandomizationRange[TABLE_COLORS];
}
......@@ -374,7 +374,7 @@ void ColorScheme::readColorEntry(const KConfig &config, int index)
{
KConfigGroup configGroup = config.group(colorNameForIndex(index));
if (!configGroup.hasKey("Color") && _table != 0) {
if (!configGroup.hasKey("Color") && _table != nullptr) {
setColorTableEntry(index, _table[index%BASE_COLORS]);
return;
}
......@@ -426,7 +426,7 @@ void ColorScheme::writeColorEntry(KConfig &config, int index) const
configGroup.deleteEntry("Bold");
}
RandomizationRange random = _randomTable != 0 ? _randomTable[index] : RandomizationRange();
RandomizationRange random = _randomTable != nullptr ? _randomTable[index] : RandomizationRange();
// record randomization if this color has randomization or
// if one of the keys already exists
......@@ -449,7 +449,7 @@ ColorSchemeWallpaper::Ptr ColorScheme::wallpaper() const
ColorSchemeWallpaper::ColorSchemeWallpaper(const QString &aPath) :
_path(aPath),
_picture(0)
_picture(nullptr)
{
}
......
......@@ -58,7 +58,7 @@ const int FAINT_COLOR_COLUMN = 3; // column 2 : faint colors
ColorSchemeEditor::ColorSchemeEditor(QWidget *aParent) :
QDialog(aParent),
_isNewScheme(false),
_colors(0)
_colors(nullptr)
{
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Apply);
auto mainWidget = new QWidget(this);
......
......@@ -199,7 +199,7 @@ const ColorScheme *ColorSchemeManager::findColorScheme(const QString &name)
qCDebug(KonsoleDebug) << "Could not find color scheme - " << name;
return 0;
return nullptr;
}
}
......
......@@ -50,7 +50,7 @@ class CopyInputDialog : public QDialog
Q_OBJECT
public:
explicit CopyInputDialog(QWidget *parent = 0);
explicit CopyInputDialog(QWidget *parent = nullptr);
~CopyInputDialog() Q_DECL_OVERRIDE;
/**
* Sets the 'source' session whose input will be copied to
......
......@@ -64,7 +64,7 @@ using namespace Konsole;
EditProfileDialog::EditProfileDialog(QWidget *aParent) :
QDialog(aParent),
_delayedPreviewTimer(new QTimer(this)),
_colorDialog(0)
_colorDialog(nullptr)
{
setWindowTitle(i18n("Edit Profile"));
mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Apply);
......@@ -568,7 +568,7 @@ void EditProfileDialog::updateColorSchemeList(bool selectCurrentScheme)
model->clear();
QStandardItem *selectedItem = 0;
QStandardItem *selectedItem = nullptr;
QList<const ColorScheme *> schemeList = ColorSchemeManager::instance()->allColorSchemes();
......@@ -614,7 +614,7 @@ void EditProfileDialog::updateKeyBindingsList(bool selectCurrentTranslator)
model->clear();
QStandardItem *selectedItem = 0;
QStandardItem *selectedItem = nullptr;
QStringList translatorNames = keyManager->allTranslators();
foreach (const QString &translatorName, translatorNames) {
......@@ -766,7 +766,7 @@ void EditProfileDialog::showColorSchemeEditor(bool isNewScheme)
// Finding selected ColorScheme
QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes();
QAbstractItemModel *model = _ui->colorSchemeList->model();
const ColorScheme *colors = 0;
const ColorScheme *colors = nullptr;
if (!selected.isEmpty()) {
colors = model->data(selected.first(), Qt::UserRole + 1).value<const ColorScheme *>();
} else {
......@@ -972,7 +972,7 @@ void EditProfileDialog::showKeyBindingEditor(bool isNewTranslator)
QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes();
QAbstractItemModel *model = _ui->keyBindingList->model();
const KeyboardTranslator *translator = 0;
const KeyboardTranslator *translator = nullptr;
if (!selected.isEmpty()) {
translator = model->data(selected.first(), Qt::UserRole + 1).value<const KeyboardTranslator *>();
} else {
......@@ -1041,7 +1041,7 @@ void EditProfileDialog::editKeyBinding()
void EditProfileDialog::setupCheckBoxes(BooleanOption *options, const Profile::Ptr profile)
{
while (options->button != 0) {
while (options->button != nullptr) {
options->button->setChecked(profile->property<bool>(options->property));
connect(options->button, SIGNAL(toggled(bool)), this, options->slot);
......@@ -1051,7 +1051,7 @@ void EditProfileDialog::setupCheckBoxes(BooleanOption *options, const Profile::P
void EditProfileDialog::setupRadio(RadioOption *possibilities, int actual)
{
while (possibilities->button != 0) {
while (possibilities->button != nullptr) {
if (possibilities->value == actual) {
possibilities->button->setChecked(true);
} else {
......@@ -1072,7 +1072,7 @@ void EditProfileDialog::setupScrollingPage(const Profile::Ptr profile)
RadioOption positions[] = { {_ui->scrollBarHiddenButton, Enum::ScrollBarHidden, SLOT(hideScrollBar())},
{_ui->scrollBarLeftButton, Enum::ScrollBarLeft, SLOT(showScrollBarLeft())},
{_ui->scrollBarRightButton, Enum::ScrollBarRight, SLOT(showScrollBarRight())},
{0, 0, 0}};
{nullptr, 0, nullptr}};
setupRadio(positions, scrollBarPosition);
......@@ -1092,7 +1092,7 @@ void EditProfileDialog::setupScrollingPage(const Profile::Ptr profile)
RadioOption pageamounts[] = {
{_ui->scrollHalfPage, Enum::ScrollPageHalf, SLOT(scrollHalfPage())},
{_ui->scrollFullPage, Enum::ScrollPageFull, SLOT(scrollFullPage())},
{0, 0, 0}
{nullptr, 0, nullptr}
};
setupRadio(pageamounts, scrollFullPage);
......@@ -1168,7 +1168,7 @@ void EditProfileDialog::setupMousePage(const Profile::Ptr profile)
_ui->dropUrlsAsText, Profile::DropUrlsAsText,
SLOT(toggleDropUrlsAsText(bool))
},
{ 0, Profile::Property(0), 0 }
{ nullptr, Profile::Property(0), nullptr }
};
setupCheckBoxes(options, profile);
......@@ -1177,7 +1177,7 @@ void EditProfileDialog::setupMousePage(const Profile::Ptr profile)
RadioOption pasteModes[] = {
{_ui->pasteFromX11SelectionButton, Enum::PasteFromX11Selection, SLOT(pasteFromX11Selection())},
{_ui->pasteFromClipboardButton, Enum::PasteFromClipboard, SLOT(pasteFromClipboard())},
{0, 0, 0}
{nullptr, 0, nullptr}
};
setupRadio(pasteModes, middleClickPasteMode);
......@@ -1216,7 +1216,7 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
_ui->enableBidiRenderingButton, Profile::BidiRenderingEnabled,
SLOT(togglebidiRendering(bool))
},
{ 0, Profile::Property(0), 0 }
{ nullptr, Profile::Property(0), nullptr }
};
setupCheckBoxes(options, profile);
......
......@@ -62,7 +62,7 @@ class KONSOLEPRIVATE_EXPORT EditProfileDialog : public QDialog
public:
/** Constructs a new dialog with the specified parent. */
explicit EditProfileDialog(QWidget *parent = 0);
explicit EditProfileDialog(QWidget *parent = nullptr);
~EditProfileDialog() Q_DECL_OVERRIDE;
/**
......@@ -266,7 +266,7 @@ class ColorSchemeViewDelegate : public QAbstractItemDelegate
Q_OBJECT
public:
explicit ColorSchemeViewDelegate(QObject *parent = 0);
explicit ColorSchemeViewDelegate(QObject *parent = nullptr);
// reimplemented
void paint(QPainter *painter, const QStyleOptionViewItem &option,
......
......@@ -34,10 +34,10 @@
using namespace Konsole;
Emulation::Emulation() :
_currentScreen(0),
_codec(0),
_decoder(0),
_keyTranslator(0),
_currentScreen(nullptr),
_codec(nullptr),
_decoder(nullptr),
_keyTranslator(nullptr),
_usesMouse(false),
_bracketedPasteMode(false),
_imageSizeInitialized(false)
......
......@@ -121,7 +121,7 @@ ushort *ExtendedCharTable::lookupExtendedChar(ushort hash, ushort &length) const
return buffer + 1;
} else {
length = 0;
return 0;
return nullptr;
}
}
......@@ -141,7 +141,7 @@ bool ExtendedCharTable::extendedCharMatch(ushort hash, const ushort *unicodePoin
// compare given length with stored sequence length ( given as the first ushort in the
// stored buffer )
if (entry == 0 || entry[0] != length) {
if (entry == nullptr || entry[0] != length) {
return false;
}
// if the lengths match, each character must be checked. the stored buffer starts at
......
......@@ -100,12 +100,12 @@ Filter::HotSpot *FilterChain::hotSpotAt(int line, int column) const
while (iter.hasNext()) {
Filter *filter = iter.next();
Filter::HotSpot *spot = filter->hotSpotAt(line, column);
if (spot != 0) {
if (spot != nullptr) {
return spot;
}
}
return 0;
return nullptr;
}
QList<Filter::HotSpot *> FilterChain::hotSpots() const
......@@ -120,8 +120,8 @@ QList<Filter::HotSpot *> FilterChain::hotSpots() const
}
TerminalImageFilterChain::TerminalImageFilterChain() :
_buffer(0),
_linePositions(0)
_buffer(nullptr),
_linePositions(nullptr)
{
}
......@@ -183,8 +183,8 @@ void TerminalImageFilterChain::setImage(const Character * const image, int lines
Filter::Filter() :
_hotspots(QMultiHash<int, HotSpot *>()),
_hotspotList(QList<HotSpot *>()),
_linePositions(0),
_buffer(0)
_linePositions(nullptr),
_buffer(nullptr)
{
}
......@@ -278,7 +278,7 @@ Filter::HotSpot *Filter::hotSpotAt(int line, int column) const
return spot;
}
return 0;
return nullptr;
}
Filter::HotSpot::HotSpot(int startLine, int startColumn, int endLine, int endColumn) :
......
......@@ -110,7 +110,7 @@ public:
* one of the objects from the actions() list. In which case the associated
* action should be performed.
*/
virtual void activate(QObject *object = 0) = 0;
virtual void activate(QObject *object = nullptr) = 0;
/**
* Returns a list of actions associated with the hotspot which can be used in a
* menu or toolbar
......@@ -194,7 +194,7 @@ public:
public:
HotSpot(int startLine, int startColumn, int endLine, int endColumn,
const QStringList &capturedTexts);
void activate(QObject *object = 0) Q_DECL_OVERRIDE;
void activate(QObject *object = nullptr) Q_DECL_OVERRIDE;
/** Returns the texts found by the filter when matching the filter's regular expression */
QStringList capturedTexts() const;
......@@ -258,7 +258,7 @@ public:
* Open a web browser at the current URL. The url itself can be determined using
* the capturedTexts() method.
*/
void activate(QObject *object = 0) Q_DECL_OVERRIDE;
void activate(QObject *object = nullptr) Q_DECL_OVERRIDE;
private:
enum UrlType {
......@@ -306,7 +306,7 @@ public:
/**
* Opens kate for editing the file.
*/
void activate(QObject *object = 0) Q_DECL_OVERRIDE;
void activate(QObject *object = nullptr) Q_DECL_OVERRIDE;
private:
FilterObject *_fileObject;
......
......@@ -62,7 +62,7 @@ Q_GLOBAL_STATIC(QString, historyFileLocation)
// History File ///////////////////////////////////////////
HistoryFile::HistoryFile() :
_length(0),
_fileMap(0),
_fileMap(nullptr),
_readWriteBalance(0)
{
// Determine the temp directory once
......@@ -105,7 +105,7 @@ HistoryFile::~HistoryFile()
//to avoid this.
void HistoryFile::map()
{
Q_ASSERT(_fileMap == 0);
Q_ASSERT(_fileMap == nullptr);
if (_tmpFile.flush()) {
Q_ASSERT(_tmpFile.size() >= _length);
......@@ -113,7 +113,7 @@ void HistoryFile::map()
}
//if mmap'ing fails, fall back to the read-lseek combination
if (_fileMap == 0) {
if (_fileMap == nullptr) {
_readWriteBalance = 0;
qCDebug(KonsoleDebug) << "mmap'ing history failed. errno = " << errno;
}
......@@ -121,18 +121,18 @@ void HistoryFile::map()
void HistoryFile::unmap()
{
Q_ASSERT(_fileMap != 0);
Q_ASSERT(_fileMap != nullptr);
if (_tmpFile.unmap(_fileMap))
_fileMap = 0;
_fileMap = nullptr;
Q_ASSERT(_fileMap == 0);
Q_ASSERT(_fileMap == nullptr);
}
bool HistoryFile::isMapped() const
{
return _fileMap != 0;
return _fileMap != nullptr;
}
void HistoryFile::add(const char *buffer, qint64 count)
......@@ -335,7 +335,7 @@ void *CompactHistoryBlock::allocate(size_t size)
{
Q_ASSERT(size > 0);
if (_tail - _blockStart + size > _blockLength) {
return 0;
return nullptr;
}
void *block = _tail;
......@@ -400,8 +400,8 @@ void *CompactHistoryLine::operator new(size_t size, CompactHistoryBlockList &blo
CompactHistoryLine::CompactHistoryLine(const TextLine &line, CompactHistoryBlockList &bList) :
_blockListRef(bList),
_formatArray(0),
_text(0),
_formatArray(nullptr),
_text(nullptr),
_formatLength(0),
_wrapped(false)
{
......@@ -423,9 +423,9 @@ CompactHistoryLine::CompactHistoryLine(const TextLine &line, CompactHistoryBlock
////qDebug() << "number of different formats in string: " << _formatLength;
_formatArray = (CharacterFormat *)_blockListRef.allocate(sizeof(CharacterFormat) * _formatLength);
Q_ASSERT(_formatArray != 0);
Q_ASSERT(_formatArray != nullptr);
_text = (quint16 *)_blockListRef.allocate(sizeof(quint16) * line.size());
Q_ASSERT(_text != 0);
Q_ASSERT(_text != nullptr);
_length = line.size();
_wrapped = false;
......@@ -625,7 +625,7 @@ HistoryScroll *HistoryTypeFile::scroll(HistoryScroll *old) const
HistoryScroll *newScroll = new HistoryScrollFile(_fileName);
Character line[LINE_SIZE];
int lines = (old != 0) ? old->getLines() : 0;
int lines = (old != nullptr) ? old->getLines() : 0;
for (int i = 0; i < lines; i++) {
int size = old->getLineLen(i);
if (size > LINE_SIZE) {
......
......@@ -37,7 +37,7 @@ class HistorySizeDialog : public QDialog
Q_OBJECT
public:
explicit HistorySizeDialog(QWidget *parent = 0);
explicit HistorySizeDialog(QWidget *parent = nullptr);
~HistorySizeDialog() Q_DECL_OVERRIDE;
/** See HistorySizeWidget::setMode. */
......
......@@ -38,14 +38,14 @@ using namespace Konsole;
IncrementalSearchBar::IncrementalSearchBar(QWidget *aParent) :
QWidget(aParent),
_searchEdit(0),
_caseSensitive(0),
_regExpression(0),
_highlightMatches(0),
_reverseSearch(0),
_findNextButton(0),
_findPreviousButton(0),
_searchFromButton(0)
_searchEdit(nullptr),
_caseSensitive(nullptr),
_regExpression(nullptr),
_highlightMatches(nullptr),
_reverseSearch(nullptr),
_findNextButton(nullptr),
_findPreviousButton(nullptr),
_searchFromButton(nullptr)
{
auto barLayout = new QHBoxLayout(this);
......
......@@ -73,7 +73,7 @@ public:
/**
* Constructs a new incremental search bar with the given parent widget
*/
explicit IncrementalSearchBar(QWidget *parent = 0);
explicit IncrementalSearchBar(QWidget *parent = nullptr);
/* Returns search options that are checked */
const QBitArray optionsChecked();
......
......@@ -51,7 +51,7 @@ class KeyBindingEditor : public QWidget
public:
/** Constructs a new key bindings editor with the specified parent. */
explicit KeyBindingEditor(QWidget *parent = 0);
explicit KeyBindingEditor(QWidget *parent = nullptr);
~KeyBindingEditor() Q_DECL_OVERRIDE;
/**
......
......@@ -41,7 +41,7 @@ using namespace Konsole;
KeyboardTranslatorWriter::KeyboardTranslatorWriter(QIODevice *destination) :
_destination(destination),
_writer(0)
_writer(nullptr)
{
Q_ASSERT(destination && destination->isWritable());
......
......@@ -34,7 +34,7 @@ using namespace Konsole;
KeyboardTranslatorManager::KeyboardTranslatorManager() :
_haveLoadedAll(false),
_fallbackTranslator(0),
_fallbackTranslator(nullptr),
_translators(QHash<QString, KeyboardTranslator *>())
{
_fallbackTranslator = new FallbackKeyboardTranslator();
......@@ -103,7 +103,7 @@ void KeyboardTranslatorManager::findTranslators()
QString name = QFileInfo(translatorPath).baseName();
if (!_translators.contains(name)) {
_translators.insert(name, 0);
_translators.insert(name, nullptr);
}
}
......@@ -116,13 +116,13 @@ const KeyboardTranslator *KeyboardTranslatorManager::findTranslator(const QStrin
return defaultTranslator();
}
if (_translators.contains(name) && _translators[name] != 0) {
if (_translators.contains(name) && _translators[name] != nullptr) {
return _translators[name];
}
KeyboardTranslator *translator = loadTranslator(name);
if (translator != 0) {
if (translator != nullptr) {
_translators[name] = translator;
} else if (!name.isEmpty()) {
qCDebug(KonsoleDebug) << "Unable to load translator" << name;
......@@ -167,7 +167,7 @@ KeyboardTranslator *KeyboardTranslatorManager::loadTranslator(const QString &nam
QFile source(path);
if (name.isEmpty() || !source.open(QIODevice::ReadOnly | QIODevice::Text)) {
return 0;
return nullptr;
}
return loadTranslator(&source, name);
......@@ -189,7 +189,7 @@ KeyboardTranslator *KeyboardTranslatorManager::loadTranslator(QIODevice *source,
return translator;
} else {
delete translator;
return 0;
return nullptr;
}
}
......
......@@ -62,8 +62,8 @@ using namespace Konsole;
MainWindow::MainWindow() :
KXmlGuiWindow(),
_bookmarkHandler(0),
_pluggedController(0),
_bookmarkHandler(nullptr),
_pluggedController(nullptr),
_menuBarInitialVisibility(true),
_menuBarInitialVisibilityApplied(false)
{
......@@ -222,14 +222,14 @@ void MainWindow::disconnectController(SessionController *controller)
guiFactory()->removeClient(controller);
}
controller->setSearchBar(0);
controller->setSearchBar(nullptr);
}
void MainWindow::activeViewChanged(SessionController *controller)
{
// associate bookmark menu with current session
bookmarkHandler()->setActiveView(controller);
disconnect(bookmarkHandler(), &Konsole::BookmarkHandler::openUrl, 0, 0);