当前位置: 首页>>代码示例>>C++>>正文


C++ KStaticDeleter类代码示例

本文整理汇总了C++中KStaticDeleter的典型用法代码示例。如果您正苦于以下问题:C++ KStaticDeleter类的具体用法?C++ KStaticDeleter怎么用?C++ KStaticDeleter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了KStaticDeleter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: defaultFilter

namespace KSpell2
{

static Word endWord;
static KStaticDeleter<Filter> sd;
static Filter* defFilter = 0;

class Filter::Private
{
public:
    // The reason it's not in the class directly is that
    // i'm not 100% sure that having the settings() here is
    // the way i want to be doing this.
    Settings *settings;
};

Filter* Filter::defaultFilter()
{
    if ( !defFilter )
        sd.setObject( defFilter, new Filter() );
    return defFilter;
}

Word Filter::end()
{
    return endWord;
}

Filter::Filter()
    : m_currentPosition( 0 )
{
    d = new Private;
    d->settings = 0;
}

Filter::~Filter()
{
    delete d; d = 0;
}

void Filter::setSettings( Settings *conf )
{
    d->settings = conf;
}

Settings *Filter::settings() const
{
    return d->settings;
}

void Filter::restart()
{
    m_currentPosition = 0;
}

void Filter::setBuffer( const QString& buffer )
{
    m_buffer          = buffer;
    m_currentPosition = 0;
}

QString Filter::buffer() const
{
    return m_buffer;
}

bool Filter::atEnd() const
{
    if ( m_currentPosition >= m_buffer.length() ) {
        return true;
    } else
        return false;
}

Word Filter::nextWord() const
{
    QChar currentChar = skipToLetter( m_currentPosition );

    if ( m_currentPosition >= m_buffer.length() ) {
        return Filter::end();
    }

    bool allUppercase = currentChar.category() & QChar::Letter_Uppercase;
    bool runTogether = false;

    QString foundWord;
    int start = m_currentPosition;
    while ( currentChar.isLetter() ) {
        if ( currentChar.category() & QChar::Letter_Lowercase )
            allUppercase = false;

	/* FIXME: this does not work for Hebrew for example
        //we consider run-together words as mixed-case words
        if ( !allUppercase &&
             currentChar.category() & QChar::Letter_Uppercase )
            runTogether = true;
	*/

        foundWord += currentChar;
        ++m_currentPosition;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例2:

KstCurveDialogI *KstCurveDialogI::globalInstance() {
  if (!_inst) {
    _inst = _cuInst.setObject(new KstCurveDialogI);
  }
return _inst;
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例3: if

KJavaAppletViewer::KJavaAppletViewer(QWidget *wparent, const char *, QObject *parent, const char *name, const QStringList &args)
    : KParts::ReadOnlyPart(parent, name)
    , m_browserextension(new KJavaAppletViewerBrowserExtension(this))
    , m_liveconnect(new KJavaAppletViewerLiveConnectExtension(this))
    , m_statusbar(new KParts::StatusBarExtension(this))
    , m_statusbar_icon(0L)
    , m_closed(true)
{
    if(!serverMaintainer)
    {
        serverMaintainerDeleter.setObject(serverMaintainer, new KJavaServerMaintainer);
    }
    m_view = new CoverWidget(wparent);
    QString classname, classid, codebase, khtml_codebase, src_param;
    int width = -1;
    int height = -1;
    KJavaApplet *const applet = m_view->appletWidget()->applet();
    QStringList::const_iterator it = args.begin();
    const QStringList::const_iterator itEnd = args.end();
    for(; it != itEnd; ++it)
    {
        const int equalPos = (*it).find("=");
        if(equalPos > 0)
        {
            const QString name = (*it).left(equalPos).upper();
            QString value = (*it).right((*it).length() - equalPos - 1);
            if(value.at(0) == '\"')
                value = value.right(value.length() - 1);
            if(value.at(value.length() - 1) == '\"')
                value.truncate(value.length() - 1);
            kdDebug(6100) << "name=" << name << " value=" << value << endl;
            if(!name.isEmpty())
            {
                const QString name_lower = name.lower();
                if(name == "__KHTML__PLUGINBASEURL")
                {
                    baseurl = KURL(KURL(value), QString(".")).url();
                }
                else if(name == "__KHTML__CODEBASE")
                    khtml_codebase = value;
                else if(name_lower == QString::fromLatin1("codebase") || name_lower == QString::fromLatin1("java_codebase"))
                {
                    if(!value.isEmpty())
                        codebase = value;
                }
                else if(name == "__KHTML__CLASSID")
                    // else if (name.lower()==QString::fromLatin1("classid"))
                    classid = value;
                else if(name_lower == QString::fromLatin1("code") || name_lower == QString::fromLatin1("java_code"))
                    classname = value;
                else if(name_lower == QString::fromLatin1("src"))
                    src_param = value;
                else if(name_lower == QString::fromLatin1("archive") || name_lower == QString::fromLatin1("java_archive")
                        || name_lower.startsWith("cache_archive"))
                    applet->setArchives(value);
                else if(name_lower == QString::fromLatin1("name"))
                    applet->setAppletName(value);
                else if(name_lower == QString::fromLatin1("width"))
                    width = value.toInt();
                else if(name_lower == QString::fromLatin1("height"))
                    height = value.toInt();
                if(!name.startsWith("__KHTML__"))
                {
                    applet->setParameter(name, value);
                }
            }
        }
    }
    if(!classid.isEmpty())
    {
        applet->setParameter("CLSID", classid);
        kdDebug(6100) << "classid=" << classid << classid.startsWith("clsid:") << endl;
        if(classid.startsWith("clsid:"))
            // codeBase contains the URL to the plugin page
            khtml_codebase = baseurl;
        else if(classname.isEmpty() && classid.startsWith("java:"))
            classname = classid.mid(5);
    }
    if(classname.isEmpty())
        classname = src_param;
    else if(!src_param.isEmpty())
        applet->setParameter(QString("SRC"), src_param);
    if(codebase.isEmpty())
        codebase = khtml_codebase;
    if(baseurl.isEmpty())
    {
        // not embeded in khtml
        QString pwd = QDir().absPath();
        if(!pwd.endsWith(QChar(QDir::separator())))
            pwd += QDir::separator();
        baseurl = KURL(KURL(pwd), codebase).url();
    }
    if(width > 0 && height > 0)
    {
        m_view->resize(width, height);
        applet->setSize(QSize(width, height));
    }
    applet->setBaseURL(baseurl);
    // check codebase first
    const KURL kbaseURL(baseurl);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例4: KFileSharePrivate

KFileSharePrivate *KFileSharePrivate::self()
{
    if(!_self)
        _self = kstFileShare.setObject(_self, new KFileSharePrivate());
    return _self;
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例5: self

ArticleInterceptorManager* ArticleInterceptorManager::self()
{
    if (!m_self)
        interceptormanagersd.setObject(m_self, new ArticleInterceptorManager);
    return m_self;
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例6:

KURIFilter *KURIFilter::self()
{
    if (!s_self)
        s_self = kurifiltersd.setObject(s_self, new KURIFilter);
    return s_self;
}
开发者ID:Fat-Zer,项目名称:tdelibs,代码行数:6,代码来源:kurifilter.cpp

示例7: setNamedColor

void khtml::setNamedColor(QColor &color, const QString &_name)
{
    if( !htmlColors )
        htmlColors = hcsd.setObject( new HTMLColors );

    int pos;
    QString name = _name;
    // remove white spaces for those broken websites out there :-(
    while ( ( pos = name.find( ' ' ) ) != -1 )  name.remove( pos, 1 );

    int len = name.length();
    char ch = name[0].latin1();

    if(len == 0 || (len == 11 && name.find("transparent", 0, false) == 0) )
    {
        color = QColor(); // invalid color == transparent
        return;
    }

    // also recognize "color=ffffff"
    if (len == 6)
    {
        bool ok;
        int val = name.toInt(&ok, 16);
        if(ok)
        {
            color.setRgb((0xff << 24) | val);
            return;
        }
        // recognize #12345 (duplicate the last character)
        if(name[0] == '#') {
            bool ok;
            int val = name.right(5).toInt(&ok, 16);
            if(ok)
            {
                color.setRgb((0xff << 24) | (val * 16 + val&0xf));
                return;
            }
        }
        if ( !name[0].isLetter() ) {
	    color = QColor();
	    return;
	}
    }

    if ( len > 4 && ch == 'r' && name[1].lower() == 'g' &&
         name[2].lower() == 'b' && name[3].cell() == '(' &&
         name[len-1].cell() == ')')
    {
        // CSS like rgb(r, g, b) style
        DOMString rgb = name.mid(4, name.length()-5);
        QList<Length> *l = rgb.implementation()->toLengthList();
        if(l->count() != 3)
        {
	    // transparent in case of an invalid color.
            color = QColor();
            delete l;
            return;
        }
        int r = l->at(0)->isUndefined() ? 0 : l->at(0)->width(255);
        if(r < 0) r = 0;
        if(r > 255) r = 255;
        int g = l->at(1)->isUndefined() ? 0 : l->at(1)->width(255);
        if(g < 0) g = 0;
        if(g > 255) g = 255;
        int b = l->at(2)->isUndefined() ? 0 : l->at(2)->width(255);
        if(b < 0) b = 0;
        if(b > 255) b = 255;

        color.setRgb(r, g, b);
        delete l;
    }
    else
    {
        QColor tc = htmlColors->map[name];
        if ( !tc.isValid() )
            tc = htmlColors->map[name.lower()];

        if (tc.isValid())
            color = tc;
        else {
            color.setNamedColor(name);
            if ( !color.isValid() )  color.setNamedColor( name.lower() );
            if(!color.isValid()) {
                bool hasalpha = false;
                for(unsigned int i = 0; i < name.length(); i++)
                    if(name[i].isLetterOrNumber()) {
                        hasalpha = true;
                        break;
                    }

                if(!hasalpha)
                  color = Qt::black;
            }
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:nirvana-svn,代码行数:97,代码来源:helper.cpp

示例8: setArgExpressions

void ArgExtractor::setArgExpressions( QStringList* list )
{
    sdAL.setObject( _argList, new QStringList );
    for( QStringList::Iterator it = list->begin() ; it != list->end() ; ++it )
        _argList->append(*it);
}
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:6,代码来源:argextractor.cpp

示例9: next

QColor KstColorSequence::next(const KstVCurveList& curves, const QColor& badColor) {
  QColor color;
  int dark_factor;
  int ptrMin;
  int start;

  if (!_self) {
    _self = sdColorSequence.setObject(_self, new KstColorSequence);
  }
  _self->createPalette();
  
  QMemArray<int> usage(_self->_count*2);
  
  for (int i = 0; i < _self->_count*2; i++) {
    usage[i] = 0;
  }

  // check we are not already using this color, but if
  //  we are then count the number of usages of each color
  //  in the palette.
  start = _self->_ptr;
  if (start >= _self->_count * 2) {
    start = 0;
  }

  while (_self->_ptr != start) {
    if (_self->_ptr >= _self->_count * 2) {
      _self->_ptr = 0;
    }

    dark_factor = 100 + ( 50 * ( _self->_ptr / _self->_count ) );
    color = _self->_pal->color( _self->_ptr % _self->_count).dark(dark_factor);

    // if we are too close to the bad color then increase the usage count
    //  to try and not use it.
    if (badColor.isValid() && colorsTooClose(color, badColor) ) {
      usage[_self->_ptr] += 100;
    }

    for (int i = 0; i < (int)curves.count(); i++) {
      if (color == curves[i]->color()) {
        usage[_self->_ptr]++;
      }
    }

    if (usage[_self->_ptr] == 0) {
      break;
    }

    _self->_ptr++;
  }

  // if we are already using this color then use the least used color for all the curves.
  if (usage[_self->_ptr] != 0) {
    ptrMin = _self->_ptr;

    while (_self->_ptr != start) {
      if (_self->_ptr >= _self->_count * 2) {
        _self->_ptr = 0;
      }

      if (usage[_self->_ptr] < usage[ptrMin]) {
        ptrMin = _self->_ptr;
      }

      _self->_ptr++;
    }

    _self->_ptr = ptrMin;
  }

  dark_factor = 100 + ( 50 * ( _self->_ptr / _self->_count ) );
  color = _self->_pal->color( _self->_ptr++ % _self->_count).dark(dark_factor);

  return color;
}
开发者ID:,项目名称:,代码行数:76,代码来源:

示例10:

KStandardDirsSingleton *KStandardDirsSingleton::self()
{
    if(!s_self)
        kstds_sd.setObject(s_self, new KStandardDirsSingleton);
    return s_self;
}
开发者ID:serghei,项目名称:kde3-kdelibs,代码行数:6,代码来源:kstandarddirs.cpp

示例11:

XineCfg::~XineCfg()
{
  if ( mSelf == this )
    staticXineCfgDeleter.setObject( mSelf, 0, false );
}
开发者ID:delight,项目名称:Pana,代码行数:5,代码来源:xinecfg.cpp

示例12: replaceSelf

void KstDialogs::replaceSelf(KstDialogs *newInstance) {
  delete _self;
  _self = 0L;
  _self = sdDialogs.setObject(_self, newInstance);
}
开发者ID:,项目名称:,代码行数:5,代码来源:

示例13: initGUI

void KKeyChooser::initGUI(ActionType type, bool bAllowLetterShortcuts)
{
    d = new KKeyChooserPrivate();

    m_type = type;
    d->bAllowLetterShortcuts = bAllowLetterShortcuts;

    d->bPreferFourModifierKeys = KGlobalAccel::useFourModifierKeys();

    //
    // TOP LAYOUT MANAGER
    //
    // The following layout is used for the dialog
    //            LIST LABELS LAYOUT
    //            SPLIT LIST BOX WIDGET
    //            CHOOSE KEY GROUP BOX WIDGET
    //            BUTTONS LAYOUT
    // Items are added to topLayout as they are created.
    //

    QBoxLayout *topLayout = new QVBoxLayout(this, 0, KDialog::spacingHint());

    //
    // ADD SEARCHLINE
    //
    QHBoxLayout *searchLayout = new QHBoxLayout(0, 0, KDialog::spacingHint());
    topLayout->addLayout(searchLayout, 10);

    QToolButton *clearSearch = new QToolButton(this);
    clearSearch->setTextLabel(i18n("Clear Search"), true);
    clearSearch->setIconSet(SmallIconSet(QApplication::reverseLayout() ? "clear_left" : "locationbar_erase"));
    searchLayout->addWidget(clearSearch);
    QLabel *slbl = new QLabel(i18n("&Search:"), this);
    searchLayout->addWidget(slbl);
    KListViewSearchLine *listViewSearch = new KListViewSearchLine(this);
    searchLayout->addWidget(listViewSearch);
    slbl->setBuddy(listViewSearch);
    connect(clearSearch, SIGNAL(pressed()), listViewSearch, SLOT(clear()));

    QString wtstr = i18n(
        "Search interactively for shortcut names (e.g. Copy) "
        "or combination of keys (e.g. Ctrl+C) by typing them here.");

    QWhatsThis::add(slbl, wtstr);
    QWhatsThis::add(listViewSearch, wtstr);

    //
    // CREATE SPLIT LIST BOX
    //
    // fill up the split list box with the action/key pairs.
    //
    QGridLayout *stackLayout = new QGridLayout(2, 2, 2);
    topLayout->addLayout(stackLayout, 10);
    stackLayout->setRowStretch(1, 10); // Only list will stretch

    d->pList = new KListView(this);
    listViewSearch->setListView(d->pList); // Plug into search line
    QValueList< int > columns;
    columns.append(0);
    listViewSearch->setSearchColumns(columns);

    stackLayout->addMultiCellWidget(d->pList, 1, 1, 0, 1);

    wtstr = i18n(
        "Here you can see a list of key bindings, "
        "i.e. associations between actions (e.g. 'Copy') "
        "shown in the left column and keys or combination "
        "of keys (e.g. Ctrl+V) shown in the right column.");

    QWhatsThis::add(d->pList, wtstr);
    new KKeyChooserWhatsThis(d->pList);

    d->pList->setAllColumnsShowFocus(true);
    d->pList->addColumn(i18n("Action"));
    d->pList->addColumn(i18n("Shortcut"));
    d->pList->addColumn(i18n("Alternate"));

    connect(d->pList, SIGNAL(currentChanged(QListViewItem *)), SLOT(slotListItemSelected(QListViewItem *)));

    // handle double clicking an item
    connect(d->pList, SIGNAL(doubleClicked(QListViewItem *, const QPoint &, int)), SLOT(captureCurrentItem()));
    connect(d->pList, SIGNAL(spacePressed(QListViewItem *)), SLOT(captureCurrentItem()));
    //
    // CREATE CHOOSE KEY GROUP
    //
    d->fCArea = new QGroupBox(this);
    topLayout->addWidget(d->fCArea, 1);

    d->fCArea->setTitle(i18n("Shortcut for Selected Action"));
    d->fCArea->setFrameStyle(QFrame::GroupBoxPanel | QFrame::Plain);

    //
    // CHOOSE KEY GROUP LAYOUT MANAGER
    //
    QGridLayout *grid = new QGridLayout(d->fCArea, 3, 4, KDialog::spacingHint());
    grid->addRowSpacing(0, fontMetrics().lineSpacing());

    d->kbGroup = new QButtonGroup(d->fCArea);
    d->kbGroup->hide();
    d->kbGroup->setExclusive(true);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例14: fromXml

KABC::Addressee Contact::fromXml(const QString &xml)
{
    QDomDocument document;

    QString errorMsg;
    int errorLine, errorColumn;
    if(!document.setContent(xml, true, &errorMsg, &errorLine, &errorColumn))
    {
        qDebug("Error parsing XML in Scalix::Contact::fromXml: %s (%d,%d)", errorMsg.latin1(), errorLine, errorColumn);
        return KABC::Addressee();
    }

    QDomElement contactElement = document.documentElement();
    if(contactElement.tagName() != "contact")
    {
        if(contactElement.tagName() == "distlist")
        {
            const QDomNodeList names = contactElement.elementsByTagName("display_name");
            const QString listName = (names.count() == 1 ? names.item(0).toElement().text() : "Scalix Dummy List");

            /**
             * As we can't provide distribution list functionality we store the entry
             * here and return it on save.
             */
            KPIM::DistributionList list;
            list.setName(listName);

            if(!s_distListMap)
                sd.setObject(s_distListMap, new QMap<QString, QString>());

            s_distListMap->insert(list.uid(), xml);

            return list;
        }
        else
        {
            qDebug("Error interpreting XML in Scalix::Contact::fromXml: no 'contact' or 'distlist' tag found");
            return KABC::Addressee();
        }
    }

    QString emails[ 3 ];
    KABC::Address homeAddress(KABC::Address::Home);
    KABC::Address workAddress(KABC::Address::Work);
    KABC::Address otherAddress(KABC::Address::Dom);

    KABC::Addressee addr;
    setCustom("comes_from_scalix", "true", addr);

    QDomNode node = contactElement.firstChild();
    while(!node.isNull())
    {
        QDomElement element = node.toElement();
        if(!element.isNull())
        {
            if(element.tagName() == "direct_ref")
                addr.setUid(element.text());
            else if(element.tagName() == "sensitivity")
                setCustom("sensitivity", element.text(), addr);
            else if(element.tagName() == "is_recurring")
                setCustom("is_recurring", element.text(), addr);
            else if(element.tagName() == "reminder_set")
                setCustom("reminder_set", element.text(), addr);
            else if(element.tagName() == "send_rich_info")
                setCustom("send_rich_info", element.text(), addr);
            else if(element.tagName() == "last_modification_time")
                addr.setRevision(QDateTime::fromString(element.text(), Qt::ISODate));

            // name
            else if(element.tagName() == "display_name_prefix")
                addr.setPrefix(element.text());
            else if(element.tagName() == "first_name")
                addr.setGivenName(element.text());
            else if(element.tagName() == "middle_name")
                addr.setAdditionalName(element.text());
            else if(element.tagName() == "last_name")
                addr.setFamilyName(element.text());
            else if(element.tagName() == "suffix")
                addr.setSuffix(element.text());
            else if(element.tagName() == "file_as")
                addr.setFormattedName(element.text());
            else if(element.tagName() == "nickname")
                addr.setNickName(element.text());

            // job
            else if(element.tagName() == "web_page_address")
                addr.setUrl(element.text());
            else if(element.tagName() == "company_name")
                addr.setOrganization(element.text());
            else if(element.tagName() == "job_title")
                addr.setTitle(element.text());

            // emails
            else if(element.tagName().startsWith("email"))
            {
                if(element.tagName() == "email1_address")
                    emails[ 0 ] = element.text();
                else if(element.tagName() == "email2_address")
                    emails[ 1 ] = element.text();
                else if(element.tagName() == "email3_address")
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:101,代码来源:contact.cpp

示例15:

PicAsm12bit *PicAsm12bit::self()
{
	if ( !m_self )
		picAsm12BitStaticDeleter.setObject( m_self, new PicAsm12bit() );
	return m_self;
}
开发者ID:Munrek,项目名称:ktechlab,代码行数:6,代码来源:picinfo12bit.cpp


注:本文中的KStaticDeleter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。