text:
#region Licence

#endregion

using System;
using FluentAssertions;
using FluentAssertions.Extensions;
using Paramore.Brighter.Core.Tests.CommandProcessors.TestDoubles;
using Paramore.Brighter.Core.Tests.Monitoring.TestDoubles;
using Xunit;
using Paramore.Brighter.Monitoring.Configuration;
using Paramore.Brighter.Monitoring.Events;
using Paramore.Brighter.Monitoring.Handlers;
using Polly.Registry;
using Microsoft.Extensions.DependencyInjection;
using Paramore.Brighter.Extensions.DependencyInjection;
using System.Text.Json;

namespace Paramore.Brighter.Core.Tests.Monitoring
{
    [Trait("Category", "Monitoring")]
    public class MonitorHandlerPipelineTests : IDisposable
    {
        private readonly MyCommand _command;
        private readonly IAmACommandProcessor _commandProcessor;
        private readonly SpyControlBusSender _controlBusSender;
        private readonly DateTime _at;
        private readonly string _originalRequestAsJson;
        private MonitorEvent _beforeEvent;
        private MonitorEvent _afterEvent;

        public MonitorHandlerPipelineTests()
        {
            _controlBusSender = new SpyControlBusSender();
            var registry = new SubscriberRegistry();

            registry.Register<MyCommand, MyMonitoredHandler>();

            var container = new ServiceCollection();
            container.AddTransient<MyMonitoredHandler>();
            container.AddTransient<MonitorHandler<MyCommand>>();
            container.AddSingleton<IAmAControlBusSender>(_controlBusSender);
            container.AddSingleton(new MonitorConfiguration { IsMonitoringEnabled = true, InstanceName = "UnitTests" });
            container.AddSingleton<IBrighterOptions>(new BrighterOptions() {HandlerLifetime = ServiceLifetime.Transient});

            var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider());

            _commandProcessor = new CommandProcessor(registry, handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry());

            _command = new MyCommand();

            _originalRequestAsJson = JsonSerializer.Serialize(_command, JsonSerialisationOptions.Options);

            _at = DateTime.UtcNow.AddMilliseconds(-500);
        }

        [Fact]
        public void When_Monitoring_Is_On_For_A_Handler()
        {
            _commandProcessor.Send(_command);
            _beforeEvent = _controlBusSender.Observe<MonitorEvent>();
            _afterEvent = _controlBusSender.Observe<MonitorEvent>();

            //_should_have_an_instance_name_before
            _beforeEvent.InstanceName.Should().Be("UnitTests");
            //_should_post_the_event_type_to_the_control_bus_before
            _beforeEvent.EventType.Should().Be(MonitorEventType.EnterHandler);
            //_should_post_the_handler_fullname_to_the_control_bus_before
            _beforeEvent.HandlerFullAssemblyName.Should().Be(typeof(MyMonitoredHandler).AssemblyQualifiedName);
            //_should_post_the_handler_name_to_the_control_bus_before
            _beforeEvent.HandlerName.Should().Be(typeof(MyMonitoredHandler).FullName);
            //_should_include_the_underlying_request_details_before
            _beforeEvent.RequestBody.Should().Be(_originalRequestAsJson);
            //_should_post_the_time_of_the_request_before
            _beforeEvent.EventTime.AsUtc().Should().BeCloseTo(_at.AsUtc(), TimeSpan.FromSeconds(1));
            //_should_elapsed_before_as_zero
            _beforeEvent.TimeElapsedMs.Should().Be(0);
            //_should_have_an_instance_name_after
            _afterEvent.InstanceName.Should().Be("UnitTests");
            //_should_post_the_handler_fullname_to_the_control_bus_after
            _afterEvent.EventType.Should().Be(MonitorEventType.ExitHandler);
            //_should_post_the_handler_fullname_to_the_control_bus_after
            _afterEvent.HandlerFullAssemblyName.Should().Be(typeof(MyMonitoredHandler).AssemblyQualifiedName);
            //_should_post_the_handler_name_to_the_control_bus_after
            _afterEvent.HandlerName.Should().Be(typeof(MyMonitoredHandler).FullName);
            //_should_include_the_underlying_request_details_after
            _afterEvent.RequestBody.Should().Be(_originalRequestAsJson);
            //should_post_the_time_of_the_request_after
            _afterEvent.EventTime.AsUtc().Should().BeAfter(_at.AsUtc());
        }

        public void Dispose()
        {
            CommandProcessor.ClearExtServiceBus();
        }
    }
}


text:
import * as types from '../mutation-types'
import Vue from 'vue';

const state = {
  treeData: null,
  selectedTreeName: null,
  trees: null
}

const getters = {
  getTreeData: state => state.treeData,
  getSelectedTreeName: state => state.selectedTreeName,
  getTrees: state => state.trees
}

const actions = {
  loadTreeData({ commit, state }, profile) {
    commit(types.LOAD_TREE_DATA);
    firebase.database().ref('/treeIndex/' + profile.id).once('value').then(function (treesRef) {
      treesRef = treesRef.val();
      var trees = {};
      if (!treesRef) {
        commit(types.LOAD_TREE_DATA_FAILURE);
        return;
      }
      treesRef.forEach((treeRef, index) => {
        firebase.database().ref(treeRef.treePath).on('value', function (treeData) {
          treeData = treeData.val();
          commit(types.UPDATE_TREE_SYNC, { treeData, treeRef });
        });
      });
    });
  },
  loadTreeRootProfile({ commit, state }, { profile, treeName }) {
    commit(types.LOAD_TREE_ROOT_PROFILE, { profile, treeName });
    commit(types.ATTACH_TREE_TO_MEMBER, profile.email);
  },
  saveTreeDataInStorage({ commit, state }, profile) {
    commit(types.SAVE_TREE_DATA_ON_CHANGE, profile);
  },
  attachTreeToMember({ commit, state }, email) {
    commit(types.ATTACH_TREE_TO_MEMBER, email);
  },
  addParent({ commit, state }, member) {
    commit(types.ADD_PARENT, member);
  },
  deleteTree({ commit, state }, profile) {
    commit(types.DELETE_TREE, profile);
  },
  setTree({ commit, state }, treeName) {
    commit(types.SET_TREE, treeName);
  },
  openTree({ commit, state }, ref) {
    firebase.database().ref(ref.treePath).once('value').then(function (treeData) {
      var treeData = treeData.val();
      commit(types.OPEN_TREE, { treeData, ref });
    });
  },
  loadMemberTreesReferences({ commit, state }, member) {
    if (member.email) {
      var email = member.email.replace(/\./g, "");
      firebase.database().ref('/treeIndex/' + email).once('value').then(function (treesRef) {
        treesRef = treesRef.val();
        commit(types.LOAD_MEMBER_TREES_REFERENCE, { member, treesRef });
      });
    }
  }
}

const mutations = {
  [types.LOAD_TREE_DATA](state, treeName) {
    // state.treeData = null;
    // state.trees = null;
  },
  [types.LOAD_TREE_DATA_SUCCESS](state, treeData) {
    state.trees = treeData;
    // Vue.set(state, "trees", treeData);
    var treeId = Object.keys(treeData)[0];
    if (!state.selectedTreeName) {
      state.selectedTreeName = treeId;
    }
    if (treeData[treeId] && !treeData[treeId].children) {
      Vue.set(treeData[treeId], 'children', []);
    }
    // Vue.set(state, "treeData", treeData[treeId]);
  },
  [types.LOAD_TREE_DATA_FAILURE](state, profile) {

  },
  [types.UPDATE_TREE_SYNC](state, { treeData, treeRef }) {
    if (!treeData) {
      return;
    }
    var treeId = treeRef.treeName;
    if (!state.trees) {
      state.trees = {};
    }
    if (!state.selectedTreeName) {
      state.selectedTreeName = treeId;
    }
    if (treeData[treeId] && !treeData[treeId].children) {
      Vue.set(treeData[treeId], 'children', []);
    }
    state.treeData = treeData;
    Vue.set(state.trees, treeRef.treeName, treeData);
  },
  [types.LOAD_TREE_ROOT_PROFILE](state, { profile, treeName }) {
    state.selectedTreeName = treeName;
    profile.id = profile.id || new Date().getTime();
    state.treeData = {
      partners: [profile],
      children: [],
      id: profile.id
    }
    if (!state.trees) {
      Vue.set(state, 'trees', {});
      Vue.set(state.trees, state.selectedTreeName, state.treeData);
    } else {
      Vue.set(state.trees, state.selectedTreeName, state.treeData);
    }

  },
  [types.SAVE_TREE_DATA_ON_CHANGE](state, profile) {
    if (state.trees && profile.id) {
      setTimeout(function () {
        firebase.database().ref('/treeData/' + profile.id).set(state.trees);
      });
    }
  },
  [types.ATTACH_TREE_TO_MEMBER](state, email) {
    if (email) {
      email = email.replace(/\./g, "");
      var ref = firebase.database().ref('/treeIndex/' + email);

      ref.once('value').then(function (snapshot) {
        var trees = snapshot.val() || [];
        var treePath = "/treeData/" + state.treeData.id + "/" + state.selectedTreeName;
        if (trees.indexOf(treePath) == -1) {
          trees.push({
            treeName: state.selectedTreeName,
            treePath: treePath
          });
        }
        ref.set(trees);
      });
    }
  },
  [types.ADD_PARENT](state, member) {
    state.treeData = {
      id: new Date().getTime(),
      children: [state.treeData],
      partners: []
    };
    member.id = new Date().getTime();
    state.treeData.partners.push(member);
    Vue.set(state.trees , state.selectedTreeName, state.treeData);
  },
  [types.DELETE_TREE](state, profile) {
    state.treeData = null;
    firebase.database().ref('/treeData/' + profile.id + "/" + state.selectedTreeName).set(null);
  },
  [types.SET_TREE](state, treeName) {
    state.selectedTreeName = treeName;
    Vue.set(state, 'treeData', state.trees[treeName]);
  },
  [types.OPEN_TREE](state, { treeData, ref }) {
    state.selectedTreeName = ref.treeName;

    if (treeData && !treeData.children) {
      Vue.set(treeData, 'children', []);
    }

    state.treeData = treeData;
    Vue.set(state.trees, state.selectedTreeName, treeData);
  },
  [types.LOAD_MEMBER_TREES_REFERENCE](state, { member, treesRef }) {
    if (treesRef) {
      Vue.set(member, 'treesRef', []);
      treesRef.forEach((treeRef, index) => {
        if (state.selectedTreeName != treeRef.treeName) {
          if (!member.treesRef) {
            Vue.set(member, 'treesRef', []);
            member.treesRef.push(treeRef);
          } else {
            member.treesRef.push(treeRef);
          }
        }
      });
    }
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace PHPExiftool\Driver\Tag\ICCHeader;

use JMS\Serializer\Annotation\ExclusionPolicy;
use PHPExiftool\Driver\AbstractTag;

/**
 * @ExclusionPolicy("all")
 */
class ProfileConnectionSpace extends AbstractTag
{

    protected $Id = 20;

    protected $Name = 'ProfileConnectionSpace';

    protected $FullName = 'ICC_Profile::Header';

    protected $GroupName = 'ICC-header';

    protected $g0 = 'ICC_Profile';

    protected $g1 = 'ICC-header';

    protected $g2 = 'Image';

    protected $Type = 'string';

    protected $Writable = false;

    protected $Description = 'Profile Connection Space';

    protected $MaxLength = 4;
}


text:
package com.siyeh.ig.errorhandling;

import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.PsiParameter;
import com.intellij.psi.PsiTryStatement;
import com.intellij.psi.PsiType;
import com.intellij.psi.PsiTypeElement;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.ui.AddAction;
import com.siyeh.ig.ui.IGTable;
import com.siyeh.ig.ui.ListWrappingTableModel;
import com.siyeh.ig.ui.RemoveAction;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class BadExceptionCaughtInspection extends BaseInspection {

    /** @noinspection PublicField*/
    public String exceptionsString =
            "java.lang.NullPointerException" + ',' +
            "java.lang.IllegalMonitorStateException" + ',' +
            "java.lang.ArrayIndexOutOfBoundsException";

    final List<String> exceptionList = new ArrayList<String>(32);

    public BadExceptionCaughtInspection() {
        parseString(exceptionsString, exceptionList);
    }

    @NotNull
    public String getID() {
        return "ProhibitedExceptionCaught";
    }

    @NotNull
    public String getDisplayName() {
        return InspectionGadgetsBundle.message(
                "bad.exception.caught.display.name");
    }

    @NotNull
    public String buildErrorString(Object... infos) {
        return InspectionGadgetsBundle.message(
                "bad.exception.caught.problem.descriptor");
    }

    public JComponent createOptionsPanel() {
        final Form form = new Form();
        return form.getContentPanel();
    }

    public void readSettings(Element element) throws InvalidDataException {
        super.readSettings(element);
        parseString(exceptionsString, exceptionList);
    }

    public void writeSettings(Element element) throws WriteExternalException {
        exceptionsString = formatString(exceptionList);
        super.writeSettings(element);
    }

    public BaseInspectionVisitor buildVisitor() {
        return new BadExceptionCaughtVisitor();
    }

    private class BadExceptionCaughtVisitor extends BaseInspectionVisitor {

        private final Set<String> exceptionSet = new HashSet(exceptionList);

        @Override public void visitTryStatement(@NotNull PsiTryStatement statement) {
            super.visitTryStatement(statement);
            final PsiParameter[] catchBlockParameters =
                    statement.getCatchBlockParameters();
            for (PsiParameter parameter : catchBlockParameters) {
                if(parameter == null) {
                    continue;
                }
                final PsiType type = parameter.getType();
                final String text = type.getCanonicalText();
                if (text == null) {
                    continue;
                }
                if (exceptionSet.contains(text)) {
                    final PsiTypeElement typeElement =
                            parameter.getTypeElement();
                    registerError(typeElement);
                }
            }
        }
    }

    private class Form {

        JPanel contentPanel;
        JButton addButton;
        JButton removeButton;
        IGTable table;

        Form() {
            super();
            removeButton.setAction(new RemoveAction(table));
            addButton.setAction(new AddAction(table));
        }

        private void createUIComponents() {
            table = new IGTable(new ListWrappingTableModel(exceptionList,
                    InspectionGadgetsBundle.message(
                            "exception.class.column.name")));
        }

        public JComponent getContentPanel() {
            return contentPanel;
        }
    }
}


text:
package gigigo.com.orchextra.data.datasources.db.model.mappers;

import com.gigigo.orchextra.domain.model.vo.Theme;

import org.junit.Test;

import gigigo.com.orchextra.data.datasources.builders.ThemeBuilder;
import gigigo.com.orchextra.data.datasources.db.model.ThemeRealm;

import static org.junit.Assert.assertEquals;

public class ThemeRealmMapperTest {

    @Test
    public void shouldMapModelToData() throws Exception {
        Theme theme = ThemeBuilder.Builder().builder();

        ThemeRealmMapper mapper = new ThemeRealmMapper();
        ThemeRealm themeRealm = mapper.modelToExternalClass(theme);

        assertEquals(ThemeBuilder.PRIMARY_COLOR, themeRealm.getPrimaryColor());
        assertEquals(ThemeBuilder.SECONDARY_COLOR, themeRealm.getSecondaryColor());
    }

    @Test
    public void shouldMapDataToModel() throws Exception {
        ThemeRealm themeRealm = new ThemeRealm();
        themeRealm.setPrimaryColor(ThemeBuilder.PRIMARY_COLOR);
        themeRealm.setSecondaryColor(ThemeBuilder.SECONDARY_COLOR);

        ThemeRealmMapper mapper = new ThemeRealmMapper();
        Theme theme = mapper.externalClassToModel(themeRealm);

        assertEquals(ThemeBuilder.PRIMARY_COLOR, theme.getPrimaryColor());
        assertEquals(ThemeBuilder.SECONDARY_COLOR, theme.getSecondaryColor());
    }
}


text:
require_relative "./../lib/golf_switch"
GolfSwitch.configure do |config|
  config.reseller_id="GHE"
  config.partner_id=""
  config.source_cd="A"
  config.lang=""
  config.user_ip="120.62.161.103"
  config.user_session_id="some_session"
  config.access_key="some_access_key"
  config.gs_source=""
end
course_info = GolfSwitch::CourseInfo.new("18633")
course_info.commit
course_info.parse_response
course_info.api_response


text:
/*
Weather Station Task Runner

This task runner is designed to separate source folder from build folder.  The source folder is where all of the resources for bootstrapping the app are located.  Running the default task will download dependencies, build and copy code to the build folder, and start the watch task with automatic browser reload.
*/

var browserSync   = require('browser-sync');
var del           = require('del')
var gulp          = require('gulp');
var autoprefixer  = require('gulp-autoprefixer');
var bower         = require('gulp-bower');
var filter        = require('gulp-filter');
var gulpif        = require('gulp-if');
var minifyHtml    = require('gulp-minify-html');
var notify        = require('gulp-notify');
var print         = require('gulp-print');
var rm            = require('gulp-rimraf');
var runSequence   = require('run-sequence');
var sass          = require('gulp-sass');
var sourcemaps    = require('gulp-sourcemaps');
var uglify        = require('gulp-uglify');

var CleanCSS      = require('clean-css');
var map           = require('vinyl-map');
var handleErrors  = require('../util/handleErrors');

/******** Config ********/

var config = {
  paths: {
    app: {
      root:   'app',
      lib:    'lib',
      js:     'app/js',
      cmp:    'app/components',
      styles: 'app/styles'
    },

    build: {
      root:   'build',
      lib:    'build/lib',
      js:     'build/js',
      cmp:    'build/components',
      styles:    'build/styles'
    }
  },

  globs: {
    app: {
      js:     'app/**/*.js',
      css:    ['app/**/*.css','app/**/*.map'],
      html:   'app/**/*.html',
      styles:  ['app/**/*.scss','lib/bootstrap-sass/assets/stylesheets','lib/fontawesome/scss'],
      lib:    ['lib/**/*']
    }
  }
}

/******** Main tasks ********/

//Development
gulp.task('dev', ['clean'], function() {
  config.prod = false;
  runSequence(['html', 'js', 'css', 'sass', 'lib'], 'watch');
});

//Production
gulp.task('prod', ['clean'], function() {
  config.prod = true;
  runSequence(['html', 'js', 'css', 'sass', 'lib'], 'watch');
});

/******** Individual tasks ********/

//Add karma tests

gulp.task('clean', function(cb) {
  return gulp.src(config.paths.build.root+'/*').pipe(rm());
});

//Watch files and when they change, rerun build task
gulp.task('watch', ['browserSync'], function() {
  gulp.watch(config.globs.app.html, ['html']);
  gulp.watch(config.globs.app.js, ['js']);
  gulp.watch(config.globs.app.css, ['css']);
  gulp.watch(config.globs.app.styles, ['sass']);
});

//Build html, minify if prod
gulp.task('html', function(){
  return gulp.src(config.globs.app.html)
    .pipe(gulpif(config.prod, minifyHtml()))
    .pipe(gulp.dest(config.paths.build.root))
    .pipe(gulpif(!config.prod, browserSync.reload({stream:true})))
    .on('error', handleErrors);
})

//Build JS, minify if prod
gulp.task('js', function() {
  return gulp.src(config.globs.app.js)
    .pipe(gulpif(config.prod, uglify()))
    .pipe(gulp.dest(config.paths.build.root))
    .pipe(gulpif(!config.prod, browserSync.reload({stream:true})))
    .on('error', handleErrors);
});

//Build CSS, add sourcemaps, minify if prod
gulp.task('css', function() {
  var cssFilter = filter('**/*.css');
  var minifyCss = map(function (buff, filename) {
    return new CleanCSS({
      processImport: false
    }).minify(buff.toString()).styles;
  });

  return gulp.src(config.globs.app.css)
    .pipe(cssFilter)
    .pipe(sourcemaps.init())
    .pipe(gulpif(config.prod, minifyCss))
    .pipe(sourcemaps.write('.'))
    .pipe(cssFilter.restore())
    .pipe(gulp.dest(config.paths.build.root))
    .pipe(gulpif(!config.prod, browserSync.reload({stream:true})))
    .on('error', handleErrors);
});

//Build scss, add sourcemaps if dev, compress if prod, autoprefix
gulp.task('sass', function() {
  return gulp.src(config.paths.app.styles + '/style.scss')
    .pipe(gulpif(!config.prod, sourcemaps.init()))
    .pipe(sass({
      includePaths: config.globs.app.styles,
      outputStyle: config.prod ? 'compressed' : 'nested',
      errLogToConsole: true
    }))
    .pipe(gulpif(!config.prod, sourcemaps.write({includeContent: false, sourceRoot: '.'})))
    .pipe(gulpif(!config.prod, sourcemaps.init({loadMaps: true})))
    .pipe(gulpif(!config.prod, sourcemaps.write()))
    .pipe(autoprefixer({browsers: ["last 2 versions", "> 1%", "ie 8"], cascade: false}))
    .pipe(gulp.dest(config.paths.build.styles))
    .pipe(gulpif(!config.prod, browserSync.reload({stream:true})))
    .on('error', handleErrors);
});

gulp.task('lib', function() {
  return gulp.src(config.globs.app.lib)
    .pipe(gulp.dest(config.paths.build.lib))
    .on('error', handleErrors);
});

//Load browser synching
gulp.task('browserSync', function() {
  var syncConfig = {
    server: {
      baseDir: config.paths.build.root
    }
  };
  browserSync(syncConfig);
});


text:
/* Fixes */
.spacewatch,
.spacewatch *,
.spacewatch *:before,
.spacewatch *:after {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

/* Overrides */
.spacewatch a:before,
.spacewatch span:before {
    display: none!important;
}
#dashboard_right_now li.spacewatch {
    width: 100%;
}

/* Styles */
.spacewatch,
.spacewatch > .progress,
.spacewatch > .progress > .percentage {
    clear: both;
    display: block;
    margin: 0;
    overflow: visible;
    padding: 0;
    position: relative;
    width: 100%;
}
.spacewatch {
    margin: 0 0 10px;
}
.spacewatch > .progress {
    background: #f1f1f1;
    border: 1px solid #ddd;
    -moz-border-radius: 25px;
    -webkit-border-radius: 25px;
    border-radius: 25px;
    padding: 5px;
    -webkit-box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3);
    -moz-box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3);
    box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3);
}
.spacewatch > .progress > .percentage {
    background: #43ac6a none;
    border: 1px solid #3a945b;
    color: #FFF;
    height: 14px;
    -moz-border-radius: 25px;
    -webkit-border-radius: 25px;
    border-radius: 25px;
}
.spacewatch > .progress[data-warning-level='1'] > .percentage {
    background-color: #eef024;
    border-color: #b6b728;
    color: #FFF;
}
.spacewatch > .progress[data-warning-level='2'] > .percentage {
    background-color: #f08a24;
    border-color: #de770f;
    color: #FFF;
}
.spacewatch > .progress[data-warning-level='3'] > .percentage {
    background-color: #f04124;
    border-color: #cf280e;
    color: #FFF;
}


text:
#include "qapplication_p.h"
#include "qcolormap.h"
#include "qpalette.h"
#include "qpixmapcache.h"
#ifndef QT_NO_CURSOR
#include "private/qcursor_p.h"
#endif
#include "qscreen.h"

#include "private/qwidget_p.h"
#include "private/qevent_p.h"

#include <qpa/qplatformintegrationfactory_p.h>
#include <qdesktopwidget.h>
#include <qpa/qplatformcursor.h>
#include <qpa/qplatformtheme.h>
#include <qpa/qplatformwindow.h>

#include <qdebug.h>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qwindowsysteminterface_p.h>
#include <qpa/qplatformintegration.h>

#include "qdesktopwidget_qpa_p.h"
#include "qwidgetwindow_qpa_p.h"
#include "qtooltip.h"

#ifdef Q_OS_WIN
#  include <QtCore/qt_windows.h> // for qt_win_display_dc()
#endif

QT_BEGIN_NAMESPACE

static QString appFont;
static bool popupGrabOk;
extern QWidget *qt_button_down;
extern QWidget *qt_popup_down;
extern bool qt_replay_popup_mouse_event;
int openPopupCount = 0;
extern QPointer<QWidget> qt_last_mouse_receiver;

void QApplicationPrivate::createEventDispatcher()
{
    QGuiApplicationPrivate::createEventDispatcher();
}

bool qt_try_modal(QWidget *widget, QEvent::Type type)
{
    QWidget * top = 0;

    if (QApplicationPrivate::tryModalHelper(widget, &top))
        return true;

    bool block_event  = false;
    bool paint_event = false;

    switch (type) {
#if 0
    case QEvent::Focus:
        if (!static_cast<QWSFocusEvent*>(event)->simpleData.get_focus)
            break;
        // drop through
#endif
    case QEvent::MouseButtonPress:                        // disallow mouse/key events
    case QEvent::MouseButtonRelease:
    case QEvent::MouseMove:
    case QEvent::KeyPress:
    case QEvent::KeyRelease:
        block_event         = true;
        break;
    default:
        break;
    }

    if ((block_event || paint_event) && top->parentWidget() == 0)
        top->raise();

    return !block_event;
}

bool QApplicationPrivate::modalState()
{
    return !self->modalWindowList.isEmpty();
}

QWidget *qt_tlw_for_window(QWindow *wnd)
{
    while (wnd && !wnd->isTopLevel()) // QTBUG-32177, wnd might be a QQuickView embedded via window container.
        wnd = wnd->parent();
    if (wnd)
        foreach (QWidget *tlw, qApp->topLevelWidgets())
            if (tlw->windowHandle() == wnd)
                return tlw;
    return 0;
}

void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous)
{
    Q_UNUSED(previous);
    QWindow *wnd = QGuiApplicationPrivate::focus_window;
    if (inPopupMode()) // some delayed focus event to ignore
        return;
    QWidget *tlw = qt_tlw_for_window(wnd);
    QApplication::setActiveWindow(tlw);
}

static void ungrabKeyboardForPopup(QWidget *popup)
{
    if (QWidget::keyboardGrabber())
        qt_widget_private(QWidget::keyboardGrabber())->stealKeyboardGrab(true);
    else
        qt_widget_private(popup)->stealKeyboardGrab(false);
}

static void ungrabMouseForPopup(QWidget *popup)
{
    if (QWidget::mouseGrabber())
        qt_widget_private(QWidget::mouseGrabber())->stealMouseGrab(true);
    else
        qt_widget_private(popup)->stealMouseGrab(false);
}

static void grabForPopup(QWidget *popup)
{
    Q_ASSERT(popup->testAttribute(Qt::WA_WState_Created));
    popupGrabOk = qt_widget_private(popup)->stealKeyboardGrab(true);
    if (popupGrabOk) {
        popupGrabOk = qt_widget_private(popup)->stealMouseGrab(true);
        if (!popupGrabOk) {
            // transfer grab back to the keyboard grabber if any
            ungrabKeyboardForPopup(popup);
        }
    }
}

void QApplicationPrivate::closePopup(QWidget *popup)
{
    if (!popupWidgets)
        return;
    popupWidgets->removeAll(popup);

     if (popup == qt_popup_down) {
         qt_button_down = 0;
         qt_popup_down = 0;
     }

    if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup
        delete QApplicationPrivate::popupWidgets;
        QApplicationPrivate::popupWidgets = 0;

        if (popupGrabOk) {
            popupGrabOk = false;

            if (popup->geometry().contains(QPoint(QGuiApplicationPrivate::mousePressX,
                                                  QGuiApplicationPrivate::mousePressY))
                || popup->testAttribute(Qt::WA_NoMouseReplay)) {
                // mouse release event or inside
                qt_replay_popup_mouse_event = false;
            } else { // mouse press event
                qt_replay_popup_mouse_event = true;
            }

            // transfer grab back to mouse grabber if any, otherwise release the grab
            ungrabMouseForPopup(popup);

            // transfer grab back to keyboard grabber if any, otherwise release the grab
            ungrabKeyboardForPopup(popup);
        }

        if (active_window) {
            if (QWidget *fw = active_window->focusWidget()) {
                if (fw != QApplication::focusWidget()) {
                    fw->setFocus(Qt::PopupFocusReason);
                } else {
                    QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason);
                    QCoreApplication::sendEvent(fw, &e);
                }
            }
        }

    } else {
        // A popup was closed, so the previous popup gets the focus.
        QWidget* aw = QApplicationPrivate::popupWidgets->last();
        if (QWidget *fw = aw->focusWidget())
            fw->setFocus(Qt::PopupFocusReason);

        if (QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard
            grabForPopup(aw);
    }

}

void QApplicationPrivate::openPopup(QWidget *popup)
{
    openPopupCount++;
    if (!popupWidgets) // create list
        popupWidgets = new QWidgetList;
    popupWidgets->append(popup); // add to end of list

    if (QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard
        grabForPopup(popup);

    // popups are not focus-handled by the window system (the first
    // popup grabbed the keyboard), so we have to do that manually: A
    // new popup gets the focus
    if (popup->focusWidget()) {
        popup->focusWidget()->setFocus(Qt::PopupFocusReason);
    } else if (popupWidgets->count() == 1) { // this was the first popup
        if (QWidget *fw = QApplication::focusWidget()) {
            QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason);
            QApplication::sendEvent(fw, &e);
        }
    }
}

void QApplicationPrivate::initializeMultitouch_sys()
{
}

void QApplicationPrivate::cleanupMultitouch_sys()
{
}

static void setPossiblePalette(const QPalette *palette, const char *className)
{
    if (palette == 0)
        return;
    QApplicationPrivate::setPalette_helper(*palette, className, false);
}

void QApplicationPrivate::initializeWidgetPaletteHash()
{
    QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme();
    if (!platformTheme)
        return;
    qt_app_palettes_hash()->clear();

    setPossiblePalette(platformTheme->palette(QPlatformTheme::ToolButtonPalette), "QToolButton");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::ButtonPalette), "QAbstractButton");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::CheckBoxPalette), "QCheckBox");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::RadioButtonPalette), "QRadioButton");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::HeaderPalette), "QHeaderView");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::ItemViewPalette), "QAbstractItemView");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::MessageBoxLabelPelette), "QMessageBoxLabel");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::TabBarPalette), "QTabBar");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::LabelPalette), "QLabel");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::GroupBoxPalette), "QGroupBox");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::MenuPalette), "QMenu");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::MenuBarPalette), "QMenuBar");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::TextEditPalette), "QTextEdit");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::TextEditPalette), "QTextControl");
    setPossiblePalette(platformTheme->palette(QPlatformTheme::TextLineEditPalette), "QLineEdit");
}

void QApplicationPrivate::initializeWidgetFontHash()
{
    const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme();
    if (!theme)
        return;
    FontHash *fontHash = qt_app_fonts_hash();
    fontHash->clear();

    if (const QFont *font = theme->font(QPlatformTheme::MenuFont))
        fontHash->insert(QByteArrayLiteral("QMenu"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::MenuBarFont))
        fontHash->insert(QByteArrayLiteral("QMenuBar"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::MenuItemFont))
        fontHash->insert(QByteArrayLiteral("QMenuItem"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::MessageBoxFont))
        fontHash->insert(QByteArrayLiteral("QMessageBox"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::LabelFont))
        fontHash->insert(QByteArrayLiteral("QLabel"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::TipLabelFont))
        fontHash->insert(QByteArrayLiteral("QTipLabel"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::TitleBarFont))
        fontHash->insert(QByteArrayLiteral("QTitleBar"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::StatusBarFont))
        fontHash->insert(QByteArrayLiteral("QStatusBar"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::MdiSubWindowTitleFont))
        fontHash->insert(QByteArrayLiteral("QMdiSubWindowTitleBar"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::DockWidgetTitleFont))
        fontHash->insert(QByteArrayLiteral("QDockWidgetTitle"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::PushButtonFont))
        fontHash->insert(QByteArrayLiteral("QPushButton"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::CheckBoxFont))
        fontHash->insert(QByteArrayLiteral("QCheckBox"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::RadioButtonFont))
        fontHash->insert(QByteArrayLiteral("QRadioButton"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::ToolButtonFont))
        fontHash->insert(QByteArrayLiteral("QToolButton"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::ItemViewFont))
        fontHash->insert(QByteArrayLiteral("QAbstractItemView"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::ListViewFont))
        fontHash->insert(QByteArrayLiteral("QListViewFont"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::HeaderViewFont))
        fontHash->insert(QByteArrayLiteral("QHeaderViewFont"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::ListBoxFont))
        fontHash->insert(QByteArrayLiteral("QListBox"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::ComboMenuItemFont))
        fontHash->insert(QByteArrayLiteral("QComboMenuItemFont"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::ComboLineEditFont))
        fontHash->insert(QByteArrayLiteral("QComboLineEditFont"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::SmallFont))
        fontHash->insert(QByteArrayLiteral("QSmallFont"), *font);
    if (const QFont *font = theme->font(QPlatformTheme::MiniFont))
        fontHash->insert(QByteArrayLiteral("QMiniFont"), *font);
}

#ifndef QT_NO_WHEELEVENT
void QApplication::setWheelScrollLines(int lines)
{
    QApplicationPrivate::wheel_scroll_lines = lines;
}

int QApplication::wheelScrollLines()
{
    return QApplicationPrivate::wheel_scroll_lines;
}
#endif

static inline int uiEffectToFlag(Qt::UIEffect effect)
{
    switch (effect) {
    case Qt::UI_General:
        return QPlatformTheme::GeneralUiEffect;
    case Qt::UI_AnimateMenu:
        return QPlatformTheme::AnimateMenuUiEffect;
    case Qt::UI_FadeMenu:
        return QPlatformTheme::FadeMenuUiEffect;
    case Qt::UI_AnimateCombo:
        return QPlatformTheme::AnimateComboUiEffect;
    case Qt::UI_AnimateTooltip:
        return QPlatformTheme::AnimateTooltipUiEffect;
    case Qt::UI_FadeTooltip:
        return QPlatformTheme::FadeTooltipUiEffect;
    case Qt::UI_AnimateToolBox:
        return QPlatformTheme::AnimateToolBoxUiEffect;
    }
    return 0;
}

void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
{
    int effectFlags = uiEffectToFlag(effect);
    if (enable) {
        if (effectFlags & QPlatformTheme::FadeMenuUiEffect)
            effectFlags |= QPlatformTheme::AnimateMenuUiEffect;
        if (effectFlags & QPlatformTheme::FadeTooltipUiEffect)
            effectFlags |= QPlatformTheme::AnimateTooltipUiEffect;
        QApplicationPrivate::enabledAnimations |= effectFlags;
    } else {
        QApplicationPrivate::enabledAnimations &= ~effectFlags;
    }
}

bool QApplication::isEffectEnabled(Qt::UIEffect effect)
{
    return QColormap::instance().depth() >= 16
           && (QApplicationPrivate::enabledAnimations & QPlatformTheme::GeneralUiEffect)
           && (QApplicationPrivate::enabledAnimations & uiEffectToFlag(effect));
}

QWidget *QApplication::topLevelAt(const QPoint &pos)
{
    QList<QScreen *> screens = QGuiApplication::screens();
    QList<QScreen *>::const_iterator screen = screens.constBegin();
    QList<QScreen *>::const_iterator end = screens.constEnd();

    while (screen != end) {
        if ((*screen)->geometry().contains(pos)) {
            QWidgetWindow *w = qobject_cast<QWidgetWindow *>((*screen)->handle()->topLevelAt(pos));
            return w ? w->widget() : 0;
        }
        ++screen;
    }
    return 0;
}

void QApplication::beep()
{
    QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), "beep");
}

void QApplication::alert(QWidget *widget, int duration)
{
    if (widget) {
       if (widget->window()->isActiveWindow() && !(widget->window()->windowState() & Qt::WindowMinimized))
            return;
        if (QWindow *window= QApplicationPrivate::windowForWidget(widget))
            window->alert(duration);
    } else {
        foreach (QWidget *topLevel, topLevelWidgets())
            QApplication::alert(topLevel, duration);
    }
}

void qt_init(QApplicationPrivate *priv, int type)
{
    Q_UNUSED(priv);
    Q_UNUSED(type);

    QColormap::initialize();

#ifndef QT_NO_TOOLTIP
    if (const QPalette *toolTipPalette = QGuiApplicationPrivate::platformTheme()->palette(QPlatformTheme::ToolTipPalette))
        QToolTip::setPalette(*toolTipPalette);
#endif

    QApplicationPrivate::initializeWidgetFontHash();
}

#ifdef Q_OS_WIN
// #fixme: Remove.
static HDC         displayDC        = 0;                // display device context

Q_WIDGETS_EXPORT HDC qt_win_display_dc()                        // get display DC
{
    Q_ASSERT(qApp && qApp->thread() == QThread::currentThread());
    if (!displayDC)
        displayDC = GetDC(0);
    return displayDC;
}
#endif

void qt_cleanup()
{
    QPixmapCache::clear();
    QColormap::cleanup();

    QApplicationPrivate::active_window = 0; //### this should not be necessary
#ifdef Q_OS_WIN
    if (displayDC) {
        ReleaseDC(0, displayDC);
        displayDC = 0;
    }
#endif
}

QT_END_NAMESPACE


text:
The `stable?` method returns `true` if the build is `nil`,
otherwise `false`.

    v = Version::Number[1,2,3]

    v.assert.stable?

    v = Version::Number[1,2,3,'pre',4]

    v.refute.stable?

## Version::Number#stable_release?

    v = Version::Number[1,2,3]

    v.assert.stable_release?

    v = Version::Number[1,2,3,'pre',4]

    v.refute.stable_release?


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace hihapi.Models.Event
{
    [Table("T_EVENT_RECUR")]
    public class RecurEvent : BaseModel
    {
        [Key]
        [Required]
        [Column("ID", TypeName = "INT")]
        public Int32 Id { get; set; }

        [Required]
        [Column("HID", TypeName = "INT")]
        public Int32 HomeID { get; set; }

        [StringLength(50)]
        [Column("NAME", TypeName = "NVARCHAR(50)")]
        public String Name { get; set; }

        [Required]
        [Column("STARTDATE", TypeName = "DATE")]
        [DataType(DataType.Date)]
        public DateTime StartDate { get; set; }

        [Required]
        [Column("ENDDATE", TypeName = "DATE")]
        [DataType(DataType.Date)]
        public DateTime EndDate { get; set; }

        [Required]
        [Column("RPTTYPE", TypeName = "TINYINT")]
        public RepeatFrequency RecurType { get; set; }

        [Column("CONTENT", TypeName = "NVARCHAR(MAX)")]
        public String Content { get; set; }

        [Column("ISPUBLIC", TypeName = "BIT")]
        public Boolean IsPublic { get; set; }

        [StringLength(40)]
        [Column("ASSIGNEE", TypeName = "NVARCHAR(40)")]
        public String Assignee { get; set; }

        public HomeDefine CurrentHome { get; set; }
        public IList<NormalEvent> RelatedEvents { get; set; }

        public RecurEvent()
        {
            this.IsPublic = true;
            this.StartDate = DateTime.Today;
            this.RelatedEvents = new List<NormalEvent>();
        }
    }
}


text:
package br.com.objectos.jabuticava.cnab;

import java.util.LinkedHashMap;
import java.util.Map;

import br.com.objectos.jabuticava.cnab.io.FixedLine;

/**
 * @author marcio.endo@objectos.com.br (Marcio Endo)
 */
abstract class RegistroPadrao implements Registro {

  final Banco banco;

  final Map<CnabKey<?, ?>, Object> map;

  public RegistroPadrao(Banco banco, Spec spec, FixedLine line) {
    this.banco = banco;

    Map<CnabKey<?, ?>, Object> map = new LinkedHashMap<>();

    for (CnabKey<?, ?> key : spec.keySet()) {
      Object value = key.apply(banco, line);
      map.put(key, value);
    }

    this.map = map;
  }

  @Override
  public Banco getBanco() {
    return banco;
  }

  @Override
  public String toString() {
    return map.toString();
  }

}