Ejemplo n.º 1
0
KstCurveDialogI *KstCurveDialogI::globalInstance() {
  if (!_inst) {
    _inst = _cuInst.setObject(new KstCurveDialogI);
  }
return _inst;
}
Ejemplo n.º 2
0
KstVectorDialogI *KstVectorDialogI::globalInstance() {
  if (!_inst) {
    _inst = _vInst.setObject(new KstVectorDialogI);
  }
return _inst;
}
Ejemplo n.º 3
0
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);
    const KURL newURL(kbaseURL, codebase);
    if(kapp->authorizeURLAction("redirect", KURL(baseurl), newURL))
        applet->setCodeBase(newURL.url());
    applet->setAppletClass(classname);
    KJavaAppletContext *const cxt = serverMaintainer->getContext(parent, baseurl);
    applet->setAppletContext(cxt);

    KJavaAppletServer *const server = cxt->getServer();

    serverMaintainer->setServer(server);

    if(!server->usingKIO())
    {
        /* if this page needs authentication */
        KIO::AuthInfo info;
        QString errorMsg;
        QCString replyType;
        QByteArray params;
        QByteArray reply;
        KIO::AuthInfo authResult;

        //(void) dcopClient(); // Make sure to have a dcop client.
        info.url = baseurl;
        info.verifyPath = true;

        QDataStream stream(params, IO_WriteOnly);
        stream << info << m_view->topLevelWidget()->winId();

        if(!kapp->dcopClient()->call("kded", "kpasswdserver", "checkAuthInfo(KIO::AuthInfo, long int)", params, replyType, reply))
        {
            kdWarning() << "Can't communicate with kded_kpasswdserver!" << endl;
        }
        else if(replyType == "KIO::AuthInfo")
        {
            QDataStream stream2(reply, IO_ReadOnly);
            stream2 >> authResult;
            applet->setUser(authResult.username);
            applet->setPassword(authResult.password);
            applet->setAuthName(authResult.realmValue);
        }
Ejemplo n.º 4
0
KFileSharePrivate *KFileSharePrivate::self()
{
    if(!_self)
        _self = kstFileShare.setObject(_self, new KFileSharePrivate());
    return _self;
}
Ejemplo n.º 5
0
ArticleInterceptorManager* ArticleInterceptorManager::self()
{
    if (!m_self)
        interceptormanagersd.setObject(m_self, new ArticleInterceptorManager);
    return m_self;
}
Ejemplo n.º 6
0
KURIFilter *KURIFilter::self()
{
    if (!s_self)
        s_self = kurifiltersd.setObject(s_self, new KURIFilter);
    return s_self;
}
Ejemplo n.º 7
0
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;
            }
        }
    }
}
Ejemplo n.º 8
0
KstDialogs *KstDialogs::self() {
  if (!_self) {
    _self = sdDialogs.setObject(_self, new KstDialogs);
  }
  return _self;
}
Ejemplo n.º 9
0
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;
        currentChar = m_buffer[ m_currentPosition ];
    }

    if ( shouldBeSkipped( allUppercase, runTogether, foundWord ) )
        return nextWord();

    return Word( foundWord, start );
}

Word Filter::previousWord() const
{
    while ( !m_buffer[ m_currentPosition ].isLetter() &&
            m_currentPosition != 0) {
        --m_currentPosition;
    }

    if ( m_currentPosition == 0 ) {
        return Filter::end();
    }

    QString foundWord;
    int start = m_currentPosition;
    while ( m_buffer[ start ].isLetter() ) {
        foundWord.prepend( m_buffer[ m_currentPosition ] );
        --start;
    }

    return Word( foundWord, start );
}

Word Filter::wordAtPosition( unsigned int pos ) const
{
    if ( pos > m_buffer.length() )
        return Filter::end();

    int currentPosition = pos - 1;
    QString foundWord;
    while ( currentPosition >= 0 &&
            m_buffer[ currentPosition ].isLetter() ) {
        foundWord.prepend( m_buffer[ currentPosition ] );
        --currentPosition;
    }

    // currentPosition == 0 means the first char is not letter
    // currentPosition == -1 means we reached the beginning
    int start = (currentPosition < 0) ? 0 : ++currentPosition;
    currentPosition = pos ;
    if ( m_buffer[ currentPosition ].isLetter() ) {
        while ( m_buffer[ currentPosition ].isLetter() ) {
            foundWord.append( m_buffer[ currentPosition ] );
            ++currentPosition;
        }
    }

    return Word( foundWord, start );
}


void Filter::setCurrentPosition( int i )
{
    m_currentPosition = i;

    //go back to the last word so that next word returns something
    //useful
    while ( m_buffer[m_currentPosition].isLetter() && m_currentPosition > 0 )
        --m_currentPosition;
}

int Filter::currentPosition() const
{
    return m_currentPosition;
}

void Filter::replace( const Word& w, const QString& newWord)
{
    int oldLen = w.word.length();
    int newLen = newWord.length();

    if ( oldLen != newLen && m_currentPosition > w.start ) {
        if ( m_currentPosition > w.start ) {
            int len = newLen - oldLen;
            m_currentPosition += len;
        }
    }
    m_buffer = m_buffer.replace( w.start, oldLen, newWord );
}

QString Filter::context() const
{
    int len = 60;
    //we don't want the expression underneath casted to an unsigned int
    //which would cause it to always evaluate to false
    int signedPosition = m_currentPosition;
    bool begin = ( (signedPosition - len/2)<=0 ) ? true : false;


    QString buffer = m_buffer;
    Word word = wordAtPosition( m_currentPosition );
    buffer = buffer.replace( word.start, word.word.length(),
                             QString( "<b>%1</b>" ).arg( word.word ) );

    QString context;
    if ( begin )
        context = QString( "%1...")
                  .arg( buffer.mid(  0, len ) );
    else
        context = QString( "...%1..." )
                  .arg( buffer.mid(  m_currentPosition - 20, len ) );

    context = context.replace( '\n', ' ' );

    return context;
}

bool Filter::trySkipLinks() const
{
    QChar currentChar = m_buffer[ m_currentPosition ];

    uint length = m_buffer.length();
    //URL - if so skip
    if ( currentChar == ':' &&
         ( m_buffer[ ++m_currentPosition] == '/' || ( m_currentPosition + 1 ) >= length ) ) {
        //in both cases url is considered finished at the first whitespace occurence
        while ( !m_buffer[ m_currentPosition++ ].isSpace() && m_currentPosition < length )
            ;
        return true;
    }

    //Email - if so skip
    if ( currentChar == '@' ) {
        while ( !m_buffer[ ++m_currentPosition ].isSpace() && m_currentPosition < length )
            ;
        return true;
    }

    return false;
}

bool Filter::ignore( const QString& word ) const
{
    if ( d->settings ) {
        return d->settings->ignore( word );
    }
    return false;
}

QChar Filter::skipToLetter( uint &fromPosition ) const
{

    QChar currentChar = m_buffer[ fromPosition ];
    while ( !currentChar.isLetter() &&
            ++fromPosition < m_buffer.length() ) {
        currentChar = m_buffer[ fromPosition ];
    }
    return currentChar;
}

bool Filter::shouldBeSkipped( bool wordWasUppercase, bool wordWasRunTogether,
                             const QString& foundWord ) const
{
    bool checkUpper = ( d->settings ) ?
                      d->settings->checkUppercase () : true;
    bool skipRunTogether = ( d->settings ) ?
                           d->settings->skipRunTogether() : true;

    if ( trySkipLinks() )
        return true;

    if ( wordWasUppercase && !checkUpper )
        return true;

    if ( wordWasRunTogether && skipRunTogether )
        return true;

    return ignore( foundWord );
}

}
Ejemplo n.º 10
0
Filter* Filter::defaultFilter()
{
    if ( !defFilter )
        sd.setObject( defFilter, new Filter() );
    return defFilter;
}
Ejemplo n.º 11
0
void ArgExtractor::setArgExpressions( QStringList* list )
{
    sdAL.setObject( _argList, new QStringList );
    for( QStringList::Iterator it = list->begin() ; it != list->end() ; ++it )
        _argList->append(*it);
}
Ejemplo n.º 12
0
KstPluginDialogI *KstPluginDialogI::globalInstance() {
  if (!_inst) {
    _inst = _plInst.setObject(new KstPluginDialogI);
  }
return _inst;
}
Ejemplo n.º 13
0
KDialogQueue* KDialogQueue::self()
{
   if (!_self)
      _self = ksdkdq.setObject(_self, new KDialogQueue);
   return _self;
}
Ejemplo n.º 14
0
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;
}
Ejemplo n.º 15
0
KStandardDirsSingleton *KStandardDirsSingleton::self()
{
    if(!s_self)
        kstds_sd.setObject(s_self, new KStandardDirsSingleton);
    return s_self;
}
Ejemplo n.º 16
0
XineCfg::~XineCfg()
{
  if ( mSelf == this )
    staticXineCfgDeleter.setObject( mSelf, 0, false );
}
Ejemplo n.º 17
0
KDCOPServiceStarter* KDCOPServiceStarter::self()
{
    if ( !s_self )
        dss_sd.setObject( s_self, new KDCOPServiceStarter );
    return s_self;
}
Ejemplo n.º 18
0
void KstDialogs::replaceSelf(KstDialogs *newInstance) {
  delete _self;
  _self = 0L;
  _self = sdDialogs.setObject(_self, newInstance);
}
Ejemplo n.º 19
0
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);

    m_prbNone = new QRadioButton(i18n("no key", "&None"), d->fCArea);
    d->kbGroup->insert(m_prbNone, NoKey);
    m_prbNone->setEnabled(false);
    // grid->addMultiCellWidget( rb, 1, 1, 1, 2 );
    grid->addWidget(m_prbNone, 1, 0);
    QWhatsThis::add(m_prbNone, i18n("The selected action will not be associated with any key."));
    connect(m_prbNone, SIGNAL(clicked()), SLOT(slotNoKey()));

    m_prbDef = new QRadioButton(i18n("default key", "De&fault"), d->fCArea);
    d->kbGroup->insert(m_prbDef, DefaultKey);
    m_prbDef->setEnabled(false);
    // grid->addMultiCellWidget( rb, 2, 2, 1, 2 );
    grid->addWidget(m_prbDef, 1, 1);
    QWhatsThis::add(m_prbDef, i18n("This will bind the default key to the selected action. Usually a reasonable choice."));
    connect(m_prbDef, SIGNAL(clicked()), SLOT(slotDefaultKey()));

    m_prbCustom = new QRadioButton(i18n("C&ustom"), d->fCArea);
    d->kbGroup->insert(m_prbCustom, CustomKey);
    m_prbCustom->setEnabled(false);
    // grid->addMultiCellWidget( rb, 3, 3, 1, 2 );
    grid->addWidget(m_prbCustom, 1, 2);
    QWhatsThis::add(m_prbCustom, i18n("If this option is selected you can create a customized key binding for the"
                                      " selected action using the buttons below."));
    connect(m_prbCustom, SIGNAL(clicked()), SLOT(slotCustomKey()));

    // connect( d->kbGroup, SIGNAL( clicked( int ) ), SLOT( keyMode( int ) ) );

    QBoxLayout *pushLayout = new QHBoxLayout(KDialog::spacingHint());
    grid->addLayout(pushLayout, 1, 3);

    d->pbtnShortcut = new KKeyButton(d->fCArea, "key");
    d->pbtnShortcut->setEnabled(false);
    connect(d->pbtnShortcut, SIGNAL(capturedShortcut(const KShortcut &)), SLOT(capturedShortcut(const KShortcut &)));
    grid->addRowSpacing(1, d->pbtnShortcut->sizeHint().height() + 5);

    wtstr = i18n(
        "Use this button to choose a new shortcut key. Once you click it, "
        "you can press the key-combination which you would like to be assigned "
        "to the currently selected action.");
    QWhatsThis::add(d->pbtnShortcut, wtstr);

    //
    // Add widgets to the geometry manager
    //
    pushLayout->addSpacing(KDialog::spacingHint() * 2);
    pushLayout->addWidget(d->pbtnShortcut);
    pushLayout->addStretch(10);

    d->lInfo = new QLabel(d->fCArea);
    // resize(0,0);
    // d->lInfo->setAlignment( AlignCenter );
    // d->lInfo->setEnabled( false );
    // d->lInfo->hide();
    grid->addMultiCellWidget(d->lInfo, 2, 2, 0, 3);

    // d->globalDict = new QDict<int> ( 100, false );
    // d->globalDict->setAutoDelete( true );
    readGlobalKeys();
    // d->stdDict = new QDict<int> ( 100, false );
    // d->stdDict->setAutoDelete( true );
    // if (type == Application || type == ApplicationGlobal)
    //  readStdKeys();
    connect(kapp, SIGNAL(settingsChanged(int)), SLOT(slotSettingsChanged(int)));
    if(allChoosers == NULL)
        allChoosers = allChoosersDeleter.setObject(allChoosers, new QValueList< KKeyChooser * >);
    allChoosers->append(this);
}
Ejemplo n.º 20
0
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")
                    emails[ 2 ] = element.text();
                else
                    setCustom(element.tagName(), element.text(), addr);
            }

            // phone numbers
            else if(element.tagName() == "home_phone_number")
                addr.insertPhoneNumber(KABC::PhoneNumber(element.text(), KABC::PhoneNumber::Home));
            else if(element.tagName() == "work_phone_number")
                addr.insertPhoneNumber(KABC::PhoneNumber(element.text(), KABC::PhoneNumber::Work));
            else if(element.tagName() == "work_fax_number")
                addr.insertPhoneNumber(KABC::PhoneNumber(element.text(), KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax));
            else if(element.tagName() == "mobile_phone_number")
                addr.insertPhoneNumber(KABC::PhoneNumber(element.text(), KABC::PhoneNumber::Cell));

            // address (work)
            else if(element.tagName() == "work_address_street")
                workAddress.setStreet(element.text());
            else if(element.tagName() == "work_address_zip")
                workAddress.setPostalCode(element.text());
            else if(element.tagName() == "work_address_city")
                workAddress.setLocality(element.text());
            else if(element.tagName() == "work_address_state")
                workAddress.setRegion(element.text());
            else if(element.tagName() == "work_address_country")
                workAddress.setCountry(element.text());

            // address (home)
            else if(element.tagName() == "home_address_street")
                homeAddress.setStreet(element.text());
            else if(element.tagName() == "home_address_zip")
                homeAddress.setPostalCode(element.text());
            else if(element.tagName() == "home_address_city")
                homeAddress.setLocality(element.text());
            else if(element.tagName() == "home_address_state")
                homeAddress.setRegion(element.text());
            else if(element.tagName() == "home_address_country")
                homeAddress.setCountry(element.text());

            // address (other)
            else if(element.tagName() == "other_address_street")
                otherAddress.setStreet(element.text());
            else if(element.tagName() == "other_address_zip")
                otherAddress.setPostalCode(element.text());
            else if(element.tagName() == "other_address_city")
                otherAddress.setLocality(element.text());
            else if(element.tagName() == "other_address_state")
                otherAddress.setRegion(element.text());
            else if(element.tagName() == "other_address_country")
                otherAddress.setCountry(element.text());

            else if(element.tagName() == "selected_mailing_address")
                switch(element.text().toInt())
                {
                    case 1:
                        homeAddress.setType(homeAddress.type() | KABC::Address::Pref);
                        break;
                    case 2:
                        workAddress.setType(workAddress.type() | KABC::Address::Pref);
                        break;
                    case 3:
                        otherAddress.setType(otherAddress.type() | KABC::Address::Pref);
                        break;
                    default:
                        Q_ASSERT(!"Unknown selected_mailing_address enum");
                        break;
                }

            // misc
            else if(element.tagName() == "im_address")
                addr.insertCustom("KADDRESSBOOK", "X-IMAddress", element.text());
            else if(element.tagName() == "manager")
                addr.insertCustom("KADDRESSBOOK", "X-ManagersName", element.text());
            else if(element.tagName() == "department")
                addr.insertCustom("KADDRESSBOOK", "X-Department", element.text());
            else if(element.tagName() == "assistant")
                addr.insertCustom("KADDRESSBOOK", "X-AssistantsName", element.text());
            else if(element.tagName() == "profession")
                addr.insertCustom("KADDRESSBOOK", "X-Profession", element.text());
            else if(element.tagName() == "office_location")
                addr.insertCustom("KADDRESSBOOK", "X-Office", element.text());
            else if(element.tagName() == "spouse")
                addr.insertCustom("KADDRESSBOOK", "X-SpousesName", element.text());

            else if(element.tagName() == "bday")
                addr.setBirthday(QDateTime::fromString(element.text(), Qt::ISODate));
            else if(element.tagName() == "anniversary")
                addr.insertCustom("KADDRESSBOOK", "X-Anniversary", element.text());
            else
                setCustom(element.tagName(), element.text(), addr);
        }

        node = node.nextSibling();
    }

    for(int i = 0; i < 3; ++i)
        if(!emails[ i ].isEmpty())
            addr.insertEmail(emails[ i ]);

    if(!homeAddress.isEmpty())
        addr.insertAddress(homeAddress);
    if(!workAddress.isEmpty())
        addr.insertAddress(workAddress);
    if(!otherAddress.isEmpty())
        addr.insertAddress(otherAddress);

    return addr;
}
Ejemplo n.º 21
0
PicAsm12bit *PicAsm12bit::self()
{
	if ( !m_self )
		picAsm12BitStaticDeleter.setObject( m_self, new PicAsm12bit() );
	return m_self;
}
Ejemplo n.º 22
0
KSaveIOConfigPrivate::KSaveIOConfigPrivate (): config(0), http_config(0)
{
  ksiocp.setObject (ksiocpref, this);
}
Ejemplo n.º 23
0
Settings::~Settings()
{
  if ( mSelf == this )
    staticDeleter.setObject( mSelf, 0, false );
}