コード例 #1
1
ファイル: Hosts.cpp プロジェクト: credfeto/HostsMerge
void RemoveMatchingEntries(
	__inout IPAddressMap & f_cache,
	__in std::string const & f_name )
{
	IPAddressMap::iterator const itEnd( f_cache.end() );

	IPAddressMap::iterator itItem( f_cache.begin() );

	while( itEnd != itItem )
	{
		if( AreEqualCaseInsensitive( itItem->second.c_str(), f_name.c_str() ) )
		{
			itItem = RemoveItemAndMoveToNext( f_cache, itItem );
		}
		else if( EndsWith( itItem->second, f_name ) )
		{
			itItem = RemoveItemAndMoveToNext( f_cache, itItem );
		}
		else
		{
			++itItem;
		}
	}
}
コード例 #2
0
void QtGroupBoxPropertyBrowserPrivate::slotUpdate()
{
  QListIterator<WidgetItem *> itItem(m_recreateQueue);
  while (itItem.hasNext())
  {
    WidgetItem *item = itItem.next();

    WidgetItem *par = item->parent;
    QWidget *w = 0;
    QGridLayout *l = 0;
    int oldRow = -1;
    if (!par)
    {
      w = q_ptr;
      l = m_mainLayout;
      oldRow = m_children.indexOf(item);
    }
    else
    {
      w = par->groupBox;
      l = par->layout;
      oldRow = par->children.indexOf(item);
      if (hasHeader(par))
        oldRow += 2;
    }

    if (item->widget)
    {
      item->widget->setParent(w);
    }
    else if (item->widgetLabel)
    {
      item->widgetLabel->setParent(w);
    }
    else
    {
      item->widgetLabel = new QLabel(w);
      item->widgetLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
            QSizePolicy::Fixed));
      item->widgetLabel->setTextFormat(Qt::PlainText);
    }
    int span = 1;
    if (item->widget)
      l->addWidget(item->widget, oldRow, 1, 1, 1);
    else if (item->widgetLabel)
      l->addWidget(item->widgetLabel, oldRow, 1, 1, 1);
    else
      span = 2;
    item->label = new QLabel(w);
    item->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
          QSizePolicy::Fixed));
    l->addWidget(item->label, oldRow, 0, 1, span);

    updateItem(item);
  }
  m_recreateQueue.clear();
}
コード例 #3
0
ファイル: propertyeditor.cpp プロジェクト: Fale/qtmoko
void PropertyEditor::updateColors()
{
    if (m_treeBrowser && m_currentBrowser == m_treeBrowser) {
        QList<QtBrowserItem *> items = m_treeBrowser->topLevelItems();
        QListIterator<QtBrowserItem *> itItem(items);
        while (itItem.hasNext()) {
            QtBrowserItem *item = itItem.next();
            m_treeBrowser->setBackgroundColor(item, propertyColor(item->property()));
        }
    }
}
コード例 #4
0
ファイル: LoadHostsFile.cpp プロジェクト: credfeto/HostsMerge
__checkReturn size_t LoadCache(
                               __inout IPAddressMap & f_cache,
                               __in_z char const * const f_szFileName )
{
    FILE *finf = OpenFile( f_szFileName );
    if( !finf )
    {
        // some error, abort
        return 0;
    }

    size_t  nItems( 0 );
    size_t const knLineLength( 8192 );
    char szLine[ knLineLength + 1 ];
    while( fgets( szLine, knLineLength, finf ) )
    {
        if( IsComment( szLine ) )
        {
            continue;
        }
        
        int ip1;
        int ip2;
        int ip3;
        int ip4;
        if( !ReadIP( szLine, ip1, ip2, ip3, ip4 ))
        {
            continue;
        }
        
        char const szDelimiters[] = "\t ";
        char *next_token = 0;
        char const *pTok = strtok_s( szLine, szDelimiters, &next_token );
        if( pTok )
        {
            PackedIP const recordIP( PackIP( static_cast<char >(ip1 & 0xff), static_cast<char >(ip2 & 0xff), static_cast<char >(ip3 & 0xff), static_cast<char >(ip4 & 0xff) ) );

            bool const bIsBlockedIp( IsBlockedIp( recordIP ) );

            PackedIP const ip( bIsBlockedIp
                ? BlockedIP()
                : recordIP );

            for( pTok = strtok_s( 0, szDelimiters, &next_token );
                pTok;
                pTok = strtok_s( 0, szDelimiters, &next_token ) )
            {
                if( IsComment( pTok ) )
                {
                    break;
                }

                std::string const sHostName( CleanHostName( pTok ) );

                // skip blanks
                if( sHostName.empty() )
                {
                    continue;
                }

                // skip localhost
                if( sHostName == "localhost" )
                {
                    continue;
                }

                bool bFound( false );
                if( !bIsBlockedIp )
                {
                    // Perform search
                    IPAddressMap::const_iterator const itLower( f_cache.lower_bound( ip ) );
                    IPAddressMap::const_iterator const itUpper( f_cache.upper_bound( ip ) );

                    for( IPAddressMap::const_iterator itItem( itLower );
                        itUpper != itItem;
                        ++itItem )
                    {
                        if( itItem->second == sHostName )
                        {
                            bFound = true;
                            break;
                        }
                    }
                }
				else
				{
					// Blocked IP with no .
					if( std::string::npos == sHostName.find("."))
					{
						continue;
					}
				}


                if( !bFound )
                {
                    (void)f_cache.insert(
                        IPAddressMap::value_type( ip, sHostName ) );
                    ++nItems;
                }
            }
        }
    }

    fclose( finf );

    return nItems;
}