Exemplo n.º 1
0
QWidgetModuleDefault::QWidgetModuleDefault(Searchable& config, QWidget* parent, const char* name, bool modal, WFlags fl)
	: QWidget(parent, name, fl),
	_qwViewer(NULL),
	_qwOutput(NULL),
	_qwRPC(NULL),
	_qwConnections(NULL){	

	Property prop;
	prop.fromString(config.toString());
	if(!prop.check("name")){
		prop.put("name", "/moduleGui");
	}

	this->setCaption("Yarp Default Module Interface");

	// main layout (vbox)
    QVBoxLayout *mainLayout = new QVBoxLayout( this, 3, 3, "QWidgetModuleDefaultBaseLayout"); 

	// add a vertical split as first entry to main layout
	QSplitter *splitMain = new QSplitter(this);
	mainLayout->addWidget(splitMain);

	// add horizontal splitter to left part of main splitter
	QSplitter *splitLeft = new QSplitter(Qt::Vertical, splitMain);
	Property propViewer; propViewer.fromString(prop.toString());
	propViewer.put("name", std::string(std::string(propViewer.find("name").asString().c_str()) + std::string("/viewer")).c_str());
	_qwViewer = new QWidgetViewer(propViewer, splitLeft); // the viewer widget
	_qwConnections = new QWidgetConnections(prop, splitLeft); // the connection widget

	// add horizontal splitter to right part of main splitter
	QSplitter *splitRight = new QSplitter(Qt::Vertical, splitMain);
	Property propOutput; propOutput.fromString(prop.toString());
	propOutput.put("name", std::string(std::string(propOutput.find("name").asString().c_str()) + std::string("/stdout")).c_str());
	_qwOutput = new QWidgetOutput(propOutput, splitRight); // the output widget
	Property propRPC; propRPC.fromString(prop.toString());
	propRPC.put("name", std::string(std::string(propRPC.find("name").asString().c_str()) + std::string("/rpc")).c_str());
	_qwRPC = new QWidgetRPC(propRPC, splitRight); // the RPC widget

	// add a frame as second entry in main layout
	QFrame *frmBottom = new QFrame(this);
	frmBottom->setMaximumHeight(35);
	mainLayout->addWidget(frmBottom);

	// add a layout to the bottom frame
	QHBoxLayout *frmBottomLayout = new QHBoxLayout(frmBottom, 0, -1, "frmBottomLayout"); 
	frmBottomLayout->setSpacing(3);
	frmBottomLayout->setMargin(3);

	// add a button to the bottom frame
	QPushButton *btnCheckAll = new QPushButton(frmBottom);
	btnCheckAll->setText("check all ports and connections");
	frmBottomLayout->addWidget(btnCheckAll);
	connect( btnCheckAll, SIGNAL( clicked() ), this, SLOT( btnCheckAll_clicked() ) );

	this->resize(850,650);
	QValueList<int> valsSplitMain;
	valsSplitMain.append(400);
	valsSplitMain.append(450);
	splitMain->setSizes(valsSplitMain);
	QValueList<int> valsSplitLeft;
	valsSplitLeft.append(400);
	valsSplitLeft.append(250);
	splitLeft->setSizes(valsSplitLeft);
	QValueList<int> valsSplitRight;
	valsSplitRight.append(400);
	valsSplitRight.append(250);
	splitRight->setSizes(valsSplitRight);

	// position screen center
    QWidget* desk = QApplication::desktop();
    this->move(desk->width()/2 - this->width()/2,desk->height()/2 - this->height()/2);

}
Exemplo n.º 2
0
void K3bVideoDVDRippingDialog::populateTitleView( const QValueList<int>& titles )
{
  m_w->m_titleView->clear();
  m_titleRipInfos.clear();

  QCheckListItem* titleItem = 0;
  for( QValueList<int>::const_iterator it = titles.begin(); it != titles.end(); ++it ) {
    titleItem = new QCheckListItem( m_w->m_titleView,
				    titleItem,
				    i18n("Title %1 (%2)")
				    .arg(*it)
				    .arg(m_dvd[*it-1].playbackTime().toString()),
				    QCheckListItem::RadioButtonController );
    titleItem->setText( 1, QString("%1x%2")
		       .arg(m_dvd[*it-1].videoStream().realPictureWidth())
		       .arg(m_dvd[*it-1].videoStream().realPictureHeight()) );
    titleItem->setText( 3, QString("%1 Title %2.avi").arg(m_dvd.volumeIdentifier()).arg(*it) );

    // now for the rip info
    K3bVideoDVDRippingJob::TitleRipInfo ri( *it );

    //
    // Determine default language selection:
    // first try the configured locale, if that fails, fall back to the first audio stream
    //
    ri.audioStream = 0;
    for( unsigned int i = 0; i < m_dvd[*it-1].numAudioStreams(); ++i ) {
      if( m_dvd[*it-1].audioStream(i).langCode() == KGlobal::locale()->language() &&
	  m_dvd[*it-1].audioStream(i).format() != K3bVideoDVD::AUDIO_FORMAT_DTS ) {
	ri.audioStream = i;
	break;
      }
    }

    QListViewItem* asI = 0;
    for( unsigned int i = 0; i < m_dvd[*it-1].numAudioStreams(); ++i ) {
      QString text = i18n("%1 %2Ch (%3%4)")
	.arg( K3bVideoDVD::audioFormatString( m_dvd[*it-1].audioStream(i).format() ) )
	.arg( m_dvd[*it-1].audioStream(i).channels() )
	.arg( m_dvd[*it-1].audioStream(i).langCode().isEmpty()
	      ? i18n("unknown language")
	      : KGlobal::locale()->twoAlphaToLanguageName( m_dvd[*it-1].audioStream(i).langCode() ) )
	.arg( m_dvd[*it-1].audioStream(i).codeExtension() != K3bVideoDVD::AUDIO_CODE_EXT_UNSPECIFIED
	      ? QString(" ") + K3bVideoDVD::audioCodeExtensionString( m_dvd[*it-1].audioStream(i).codeExtension() )
	      : QString::null );

      if( m_dvd[*it-1].audioStream(i).format() == K3bVideoDVD::AUDIO_FORMAT_DTS ) {
	// width of the radio button from QCheckListItem::paintCell
	int buttonSize = style().pixelMetric( QStyle::PM_CheckListButtonSize, m_w->m_titleView ) + 4;
	int spaceWidth = fontMetrics().width( ' ' );
	int numSpaces = buttonSize/spaceWidth;
	asI = new QListViewItem( titleItem, asI, QString().fill( ' ', numSpaces ) + text + " (" + i18n("not supported") + ")" );
      }
      else {
	asI = new AudioStreamViewItem( this, titleItem, asI, text, i );

	if( ri.audioStream == (int)i )
	  ((AudioStreamViewItem*)asI)->setState( QCheckListItem::On );
      }
    }

    titleItem->setOpen( true );

    m_titleRipInfos[titleItem] = ri;
  }
}
Exemplo n.º 3
0
void PMTextureMapEdit::displayObject( PMObject* o )
{
   QString str;

   if( o->isA( "TextureMapBase" ) )
   {
      bool readOnly = o->isReadOnly( );
      m_pDisplayedObject = ( PMTextureMapBase* ) o;
      QValueList<double> mv = m_pDisplayedObject->mapValues( );
      QValueList<double>::Iterator vit = mv.begin( );
      QPtrListIterator<PMFloatEdit> eit( m_edits );
      PMFloatEdit* edit;

      m_numValues = 0;

      for( ; vit != mv.end( ); ++vit )
      {
         if( eit.current( ) )
         {
            eit.current( )->setValue( *vit );
            eit.current( )->show( );
            eit.current( )->setReadOnly( readOnly );
            ++eit;
         }
         else
         {
            edit = new PMFloatEdit( this );
            m_pEditLayout->addWidget( edit );
            m_edits.append( edit );
            edit->setValue( *vit );
            edit->setValidation( true, 0.0, true, 1.0 );
            edit->setReadOnly( readOnly );
            connect( edit, SIGNAL( dataChanged( ) ), SIGNAL( dataChanged( ) ) );
         }
         m_numValues++;
      }
      for( ; eit.current( ); ++eit )
         eit.current( )->hide( );
      if( m_numValues == 0 )
      {
         if( o->linkedObject( ) )
         {
            m_pPureLinkLabel->show( );
            m_pNoChildLabel->hide( );
         }
         else
         {
            m_pPureLinkLabel->hide( );
            m_pNoChildLabel->show( );
         }
      }
      else
      {
         m_pNoChildLabel->hide( );
         m_pPureLinkLabel->hide( );
      }
   }
   else
      kdError( PMArea ) << "PMTextureMapEdit: Can't display object\n";
   Base::displayObject( o );
   enableLinkEdit( m_numValues == 0 );
}
Exemplo n.º 4
0
/*
   Handle Ctrl+Cursor etc better than the Qt widget, which always
   jumps to the next whitespace. This code additionally jumps to
   the next [/#?:], which makes more sense for URLs. The list of 
   chars that will stop the cursor are '/', '.', '?', '#', ':'.
*/
void KLSHistoryCombo::selectWord(QKeyEvent *e)
{
    QLineEdit* edit = lineEdit();
    QString text = edit->text();
    int pos = edit->cursorPosition();
    int pos_old = pos;
    int count = 0;

    // TODO: make these a parameter when in kdelibs/kdeui...
    QValueList<QChar> chars;
    chars << QChar('/') << QChar('.') << QChar('?') << QChar('#') << QChar(':');
    bool allow_space_break = true;

    if( e->key() == Key_Left || e->key() == Key_Backspace )
    {
        do
        {
            pos--;
            count++;
            if( allow_space_break && text[pos].isSpace() && count > 1 )
                break;
        }
        while( pos >= 0 && (chars.findIndex(text[pos]) == -1 || count <= 1) );

        if( e->state() & ShiftButton )
        {
            edit->cursorForward(true, 1-count);
        }
        else if(  e->key() == Key_Backspace )
        {
            edit->cursorForward(false, 1-count);
            QString text = edit->text();
            int pos_to_right = edit->text().length() - pos_old;
            QString cut = text.left(edit->cursorPosition()) + text.right(pos_to_right);
            edit->setText(cut);
            edit->setCursorPosition(pos_old-count+1);
        }
        else
        {
            edit->cursorForward(false, 1-count);
        }
    }
    else if( e->key() == Key_Right || e->key() == Key_Delete )
    {
        do
        {
            pos++;
            count++;
            if( allow_space_break && text[pos].isSpace() )
                break;
        }
        while( pos < (int) text.length() && chars.findIndex(text[pos]) == -1 );

        if( e->state() & ShiftButton )
        {
            edit->cursorForward(true, count+1);
        }
        else if(  e->key() == Key_Delete )
        {
            edit->cursorForward(false, -count-1);
            QString text = edit->text();
            int pos_to_right = text.length() - pos - 1;
            QString cut = text.left(pos_old) +
                          (pos_to_right > 0 ? text.right(pos_to_right) : QString() );
            edit->setText(cut);
            edit->setCursorPosition(pos_old);
        }
        else
        {
            edit->cursorForward(false, count+1);
        }
    }
}
Exemplo n.º 5
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);
}
Exemplo n.º 6
0
bool
HelixEngine::init()
{
    debug() << "Initializing HelixEngine\n";
    struct stat s;
    bool exists = false;
    stop();
    m_state = Engine::Empty;

    m_numPlayers = 2;
    m_current = 1;

    m_coredir = HelixConfig::coreDirectory();
    if (m_coredir.isEmpty())
        m_coredir = HELIX_LIBS "/common";

    m_pluginsdir = HelixConfig::pluginDirectory();
    if (m_pluginsdir.isEmpty())
        m_pluginsdir = HELIX_LIBS "/plugins";

    m_codecsdir = HelixConfig::codecsDirectory();
    if (m_codecsdir.isEmpty())
        m_codecsdir = HELIX_LIBS "/codecs";

    if (HelixConfig::outputplugin() == "oss")
        setOutputSink( HelixSimplePlayer::OSS );
    else
    {
        setOutputSink( HelixSimplePlayer::ALSA );
        if (HelixConfig::deviceenabled())
            setDevice( HelixConfig::device().utf8() );
        else
            setDevice("default");
    }


    if (!stat(m_coredir.utf8(), &s) && !stat(m_pluginsdir.utf8(), &s) && !stat(m_codecsdir.utf8(), &s))
    {
        long vol=0;
        bool eqenabled=false;
        int savedpreamp=0;
        QValueList<int> savedequalizerGains;

        if (m_inited)
        {
            vol = PlayerControl::getVolume();
            eqenabled = PlayerControl::isEQenabled();
            for (unsigned int i=0; i < m_equalizerGains.size(); i++)
                savedequalizerGains.append(m_equalizerGains[i]);
            savedpreamp = m_preamp;
            PlayerControl::tearDown();
        }

        PlayerControl::init(m_coredir.utf8(), m_pluginsdir.utf8(), m_codecsdir.utf8(), 2);
        if (PlayerControl::initDirectSS())
        {
            fallbackToOSS();

            PlayerControl::initDirectSS();
        }

        if (m_inited)
        {
            PlayerControl::setVolume(vol);
            setEqualizerEnabled(eqenabled);
            setEqualizerParameters(savedpreamp, savedequalizerGains);
        }

        m_inited = exists = true;
    }


    if (!exists || PlayerControl::getError())
    {
        KMessageBox::error( 0, i18n("The Helix Engine requires the RealPlayer(tm) or HelixPlayer libraries to be installed. Please make sure one is installed, and adjust the paths in \"Pana Settings\" -> \"Engine\"") );
        // we need to return true here so that the user has an oppportunity to change the directory
        //return false;
        return true;
    }

    // create a list of mime types and ext for use in canDecode()
    m_mimes.resize( getMimeListLen() );
    int i = 0;
    const MimeList *ml = getMimeList();
    MimeEntry *entry;
    while (ml)
    {
        QString mt = ml->mimetypes;
        QString me = ml->mimeexts;

        entry = new MimeEntry;
        entry->type = QStringList::split('|', mt);
        entry->ext = QStringList::split('|', me);
        m_mimes[i] = *entry;

        debug() << ml->mimetypes << endl;

        i++;
        ml = ml->fwd;
    }

    debug() << "Succussful init\n";

    return true;
}
Exemplo n.º 7
0
void LayoutConfig::initUI()
{
    const char *modelName = m_rules->models()[m_kxkbConfig.m_model];
    if(modelName == NULL)
        modelName = DEFAULT_MODEL;

    widget->comboModel->setCurrentText(i18n(modelName));

    QValueList< LayoutUnit > otherLayouts = m_kxkbConfig.m_layouts;
    widget->listLayoutsDst->clear();
    // to optimize we should have gone from it.end to it.begin
    QValueList< LayoutUnit >::ConstIterator it;
    for(it = otherLayouts.begin(); it != otherLayouts.end(); ++it)
    {
        QListViewItemIterator src_it(widget->listLayoutsSrc);
        LayoutUnit layoutUnit = *it;

        for(; src_it.current(); ++src_it)
        {
            QListViewItem *srcItem = src_it.current();

            if(layoutUnit.layout == src_it.current()->text(LAYOUT_COLUMN_MAP))
            { // check if current config knows about this layout
                QListViewItem *newItem = copyLVI(srcItem, widget->listLayoutsDst);

                newItem->setText(LAYOUT_COLUMN_VARIANT, layoutUnit.variant);
                newItem->setText(LAYOUT_COLUMN_INCLUDE, layoutUnit.includeGroup);
                newItem->setText(LAYOUT_COLUMN_DISPLAY_NAME, layoutUnit.displayName);
                widget->listLayoutsDst->insertItem(newItem);
                newItem->moveItem(widget->listLayoutsDst->lastItem());

                break;
            }
        }
    }

    // display KXKB switching options
    widget->chkShowSingle->setChecked(m_kxkbConfig.m_showSingle);
    widget->chkShowFlag->setChecked(m_kxkbConfig.m_showFlag);

    widget->chkEnableOptions->setChecked(m_kxkbConfig.m_enableXkbOptions);
    widget->checkResetOld->setChecked(m_kxkbConfig.m_resetOldOptions);

    switch(m_kxkbConfig.m_switchingPolicy)
    {
        default:
        case SWITCH_POLICY_GLOBAL:
            widget->grpSwitching->setButton(0);
            break;
        case SWITCH_POLICY_WIN_CLASS:
            widget->grpSwitching->setButton(1);
            break;
        case SWITCH_POLICY_WINDOW:
            widget->grpSwitching->setButton(2);
            break;
    }

    widget->chkEnableSticky->setChecked(m_kxkbConfig.m_stickySwitching);
    widget->spinStickyDepth->setEnabled(m_kxkbConfig.m_stickySwitching);
    widget->spinStickyDepth->setValue(m_kxkbConfig.m_stickySwitchingDepth);

    updateStickyLimit();

    widget->chkEnable->setChecked(m_kxkbConfig.m_useKxkb);
    widget->grpLayouts->setEnabled(m_kxkbConfig.m_useKxkb);
    widget->optionsFrame->setEnabled(m_kxkbConfig.m_useKxkb);

    // display xkb options
    QStringList options = QStringList::split(',', m_kxkbConfig.m_options);
    for(QStringList::ConstIterator it = options.begin(); it != options.end(); ++it)
    {
        QString option = *it;
        QString optionKey = option.mid(0, option.find(':'));
        QString optionName = m_rules->options()[option];
        OptionListItem *item = m_optionGroups[i18n(optionKey.latin1())];

        if(item != NULL)
        {
            OptionListItem *child = item->findChildItem(option);

            if(child)
                child->setState(QCheckListItem::On);
            else
                kdDebug() << "load: Unknown option: " << option << endl;
        }
        else
        {
            kdDebug() << "load: Unknown option group: " << optionKey << " of " << option << endl;
        }
    }

    updateOptionsCommand();
    emit KCModule::changed(false);
}
Exemplo n.º 8
0
void Layout::setup()
{
    startPoint = QPoint( 32767, 32767 );
    QValueList<QWidgetList> lists;
    QWidget *lastParent = 0;
    QWidgetList *lastList = 0;
    QWidget *w = 0;

    // Go through all widgets of the list we got. As we can only
    // layout widgets which have the same parent, we first do some
    // sorting which means create a list for each parent containing
    // its child here. After that we keep working on the list of
    // childs which has the most entries.
    // Widgets which are already laid out are thrown away here too
    for ( w = widgets.first(); w; w = widgets.next() ) {
	if ( w->parentWidget() && WidgetFactory::layoutType( w->parentWidget() ) != WidgetFactory::NoLayout )
	    continue;
	if ( lastParent != w->parentWidget() ) {
	    lastList = 0;
	    lastParent = w->parentWidget();
	    QValueList<QWidgetList>::Iterator it = lists.begin();
	    for ( ; it != lists.end(); ++it ) {
		if ( ( *it ).first()->parentWidget() == w->parentWidget() )
		    lastList = &( *it );
	    }
	    if ( !lastList ) {
		QWidgetList l;
		l.setAutoDelete( FALSE );
		lists.append( l );
		lastList = &lists.last();
	    }
	}
	lastList->append( w );
    }

    // So, now find the list with the most entries
    lastList = 0;
    QValueList<QWidgetList>::Iterator it = lists.begin();
    for ( ; it != lists.end(); ++it ) {
	if ( !lastList || ( *it ).count() > lastList->count() )
	    lastList = &( *it );
    }

    // If we found no list (because no widget did fit at all) or the
    // best list has only one entry and we do not layout a container,
    // we leave here.
    if ( !lastList || ( lastList->count() < 2 &&
			( !layoutBase ||
			  ( !WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( layoutBase ) ) ) &&
			    layoutBase != formWindow->mainContainer() ) )
			) ) {
	widgets.clear();
	startPoint = QPoint( 0, 0 );
	return;
    }

    // Now we have a new and clean widget list, which makes sense
    // to layout
    widgets = *lastList;
    // Also use the only correct parent later, so store it
    parent = WidgetFactory::widgetOfContainer( widgets.first()->parentWidget() );
    // Now calculate the position where the layout-meta-widget should
    // be placed and connect to widgetDestroyed() signals of the
    // widgets to get informed if one gets deleted to be able to
    // handle that and do not crash in this case
    for ( w = widgets.first(); w; w = widgets.next() ) {
	connect( w, SIGNAL( destroyed() ),
		 this, SLOT( widgetDestroyed() ) );
	startPoint = QPoint( QMIN( startPoint.x(), w->x() ),
			     QMIN( startPoint.y(), w->y() ) );
	geometries.insert( w, QRect( w->pos(), w->size() ) );
	// Change the Z-order, as saving/loading uses the Z-order for
	// writing/creating widgets and this has to be the same as in
	// the layout. Else saving + loading will give different results
	w->raise();
    }
}
Exemplo n.º 9
0
/******************************************************************************
*  Add all the templates to the list.
*/
void TemplateListView::populate()
{
	QValueList<KAEvent> templates = KAlarm::templateList();
	for (QValueList<KAEvent>::Iterator it = templates.begin();  it != templates.end();  ++it)
		addEntry(*it);
}
Exemplo n.º 10
0
void KWindowListMenu::init()
{
    int i, d;
    i = 0;

    int nd = kwin_module->numberOfDesktops();
    int cd = kwin_module->currentDesktop();
    WId active_window = kwin_module->activeWindow();

    // Make sure the popup is not too wide, otherwise clicking in the middle of kdesktop
    // wouldn't leave any place for the popup, and release would activate some menu entry.    
    int maxwidth = kapp->desktop()->screenGeometry( this ).width() / 2 - 100;

    clear();
    map.clear();

    int unclutter = insertItem( i18n("Unclutter Windows"),
                                this, SLOT( slotUnclutterWindows() ) );
    int cascade = insertItem( i18n("Cascade Windows"),
                              this, SLOT( slotCascadeWindows() ) );

    // if we only have one desktop we won't be showing titles, so put a separator in
    if (nd == 1)
    {
        insertSeparator();
    }


    QValueList<KWin::WindowInfo> windows;
    for (QValueList<WId>::ConstIterator it = kwin_module->windows().begin();
         it != kwin_module->windows().end(); ++it) {
         windows.append( KWin::windowInfo( *it, NET::WMDesktop ));
    }
    bool show_all_desktops_group = ( nd > 1 );
    for (d = 1; d <= nd + (show_all_desktops_group ? 1 : 0); d++) {
        bool on_all_desktops = ( d > nd );
	int items = 0;

	if (!active_window && d == cd)
	    setItemChecked(1000 + d, true);

        NameSortedInfoList list;
        list.setAutoDelete(true);

	for (QValueList<KWin::WindowInfo>::ConstIterator it = windows.begin();
             it != windows.end(); ++it) {
	    if (((*it).desktop() == d) || (on_all_desktops && (*it).onAllDesktops())
                || (!show_all_desktops_group && (*it).onAllDesktops())) {
	        list.inSort(new KWin::WindowInfo( (*it).win(),
                    NET::WMVisibleName | NET::WMState | NET::XAWMState | NET::WMWindowType,
                    NET::WM2GroupLeader | NET::WM2TransientFor ));
            }
        }

        for (KWin::WindowInfo* info = list.first(); info; info = list.next(), ++i)
        {
            QString itemText = KStringHandler::cPixelSqueeze(info->visibleNameWithState(), fontMetrics(), maxwidth);
            NET::WindowType windowType = info->windowType( NET::NormalMask | NET::DesktopMask
                | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask
                | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask );
            if ( (windowType == NET::Normal || windowType == NET::Unknown
                    || (windowType == NET::Dialog && standaloneDialog( info, list )))
                && !(info->state() & NET::SkipTaskbar) ) {
                QPixmap pm = KWin::icon(info->win(), 16, 16, true );
                items++;

                // ok, we have items on this desktop, let's show the title
                if ( items == 1 && nd > 1 )
                {
                    if( !on_all_desktops )
                        insertTitle(kwin_module->desktopName( d ), 1000 + d);
                    else
                        insertTitle(i18n("On All Desktops"), 2000 );
                }

                // Avoid creating unwanted accelerators.
                itemText.replace('&', QString::fromLatin1("&&"));
                insertItem( pm, itemText, i);
                map.insert(i, info->win());
                if (info->win() == active_window)
                    setItemChecked(i, true);
            }
        }

        if (d == cd)
        {
            setItemEnabled(unclutter, items > 0);
            setItemEnabled(cascade, items > 0);
        }
    }

    // no windows?
    if (i == 0)
    {
        if (nd > 1)
        {
            // because we don't have any titles, nor a separator
            insertSeparator();
        }

        setItemEnabled(insertItem(i18n("No Windows")), false);
    }
}
Exemplo n.º 11
0
void managementWidget::setupWidgets()
{
  QTab t;

  top = new QBoxLayout(this,QBoxLayout::TopToBottom);
  vPan  = new QSplitter(QSplitter::Horizontal, this);
  top->addWidget(vPan);

  // the left panel
  leftpanel = new QFrame(vPan);
  leftbox = new QBoxLayout(leftpanel,QBoxLayout::TopToBottom);

  QTabBar *ltab = new QTabBar(leftpanel);

  treeList = new KpTreeList(leftpanel);


  for (int i = 0; i < 4; i++) {
    QTab *t = new QTab();
    t->setText( tType[i] );
    ltab->addTab(t);
  }
  // Quick Search Bar
  searchToolBar = new KToolBar( leftpanel, "search toolbar");

  QToolButton *clearSearch = new QToolButton(searchToolBar);
  clearSearch->setTextLabel(i18n("Clear Search"), true);
  clearSearch->setIconSet(SmallIconSet(QApplication::reverseLayout() ? "clear_left"
                                            : "locationbar_erase"));
  (void) new QLabel(i18n("Search: "),searchToolBar);

  searchLine = new KpListViewSearchLine(searchToolBar, treeList);
  //  searchLine->setKeepParentsVisible(false);
  connect( clearSearch, SIGNAL( pressed() ), searchLine, SLOT( clear() ));

  QValueList<int> clist;  clist.append(0);  clist.append(2);
  searchLine->setSearchColumns(clist);

  searchToolBar->setStretchableWidget( searchLine );
  connect( treeList, SIGNAL( cleared() ), searchLine, SLOT( clear() ));

  connect(ltab,SIGNAL(selected (int)),SLOT(tabChanged(int)));
  ltab->setCurrentTab(treeList->treeType);

  leftbox->addWidget(ltab,10);
  leftbox->addWidget(searchToolBar,10);
  leftbox->addWidget(treeList,10);

  leftbox->addStretch();

  lbuttons = new QBoxLayout(QBoxLayout::LeftToRight);

  luinstButton = new QPushButton(i18n("Uninstall Marked"),leftpanel);
  luinstButton->setEnabled(FALSE);
  connect(luinstButton,SIGNAL(clicked()),
	  SLOT(uninstallMultClicked()));
  linstButton = new QPushButton(i18n("Install Marked"),leftpanel);
  linstButton->setEnabled(FALSE);
  connect(linstButton,SIGNAL(clicked()),
	  SLOT(installMultClicked()));

  leftbox->addLayout(lbuttons,0); // top level layout as child

  // Setup the `buttons' layout
  lbuttons->addWidget(linstButton,1,AlignBottom);
  lbuttons->addWidget(luinstButton,1,AlignBottom);
  lbuttons->addStretch(1);

  connect(treeList, SIGNAL(selectionChanged(QListViewItem *)),
	  SLOT(packageHighlighted(QListViewItem *)));

  // the right panel
  rightpanel = new QFrame(vPan);
  rightbox = new QBoxLayout(rightpanel,QBoxLayout::TopToBottom);

  packageDisplay = new packageDisplayWidget(rightpanel);
  //  connect(this, SIGNAL(changePackage(packageInfo *)),
  //  packageDisplay, SLOT(changePackage(packageInfo *)));

  rbuttons = new QBoxLayout(QBoxLayout::LeftToRight);

  uinstButton = new QPushButton(i18n("Uninstall"),rightpanel);
  uinstButton->setEnabled(FALSE);
  connect(uinstButton,SIGNAL(clicked()),
	  SLOT(uninstallSingleClicked()));
  instButton = new QPushButton(i18n("Install"),rightpanel);
  instButton->setEnabled(FALSE);
  connect(instButton,SIGNAL(clicked()),
	  SLOT(installSingleClicked()));


  // Setup the `right panel' layout
  rightbox->addWidget(packageDisplay,10);
  rightbox->addLayout(rbuttons,0); // top level layout as child

  // Setup the `buttons' layout
  rbuttons->addWidget(instButton,1);
  rbuttons->addWidget(uinstButton,1);
  rbuttons->addStretch(1);

}
Exemplo n.º 12
0
QVariant KConfigBase::readPropertyEntry(const char *pKey, const QVariant &aDefault) const
{
    if(!hasKey(pKey))
        return aDefault;

    QVariant tmp = aDefault;

    switch(aDefault.type())
    {
        case QVariant::Invalid:
            return QVariant();
        case QVariant::String:
            return QVariant(readEntry(pKey, aDefault.toString()));
        case QVariant::StringList:
            return QVariant(readListEntry(pKey));
        case QVariant::List:
        {
            QStringList strList = readListEntry(pKey);
            QStringList::ConstIterator it = strList.begin();
            QStringList::ConstIterator end = strList.end();
            QValueList< QVariant > list;

            for(; it != end; ++it)
            {
                tmp = *it;
                list.append(tmp);
            }
            return QVariant(list);
        }
        case QVariant::Font:
            return QVariant(readFontEntry(pKey, &tmp.asFont()));
        case QVariant::Point:
            return QVariant(readPointEntry(pKey, &tmp.asPoint()));
        case QVariant::Rect:
            return QVariant(readRectEntry(pKey, &tmp.asRect()));
        case QVariant::Size:
            return QVariant(readSizeEntry(pKey, &tmp.asSize()));
        case QVariant::Color:
            return QVariant(readColorEntry(pKey, &tmp.asColor()));
        case QVariant::Int:
            return QVariant(readNumEntry(pKey, aDefault.toInt()));
        case QVariant::UInt:
            return QVariant(readUnsignedNumEntry(pKey, aDefault.toUInt()));
        case QVariant::LongLong:
            return QVariant(readNum64Entry(pKey, aDefault.toLongLong()));
        case QVariant::ULongLong:
            return QVariant(readUnsignedNum64Entry(pKey, aDefault.toULongLong()));
        case QVariant::Bool:
            return QVariant(readBoolEntry(pKey, aDefault.toBool()), 0);
        case QVariant::Double:
            return QVariant(readDoubleNumEntry(pKey, aDefault.toDouble()));
        case QVariant::DateTime:
            return QVariant(readDateTimeEntry(pKey, &tmp.asDateTime()));
        case QVariant::Date:
            return QVariant(readDateTimeEntry(pKey, &tmp.asDateTime()).date());

        case QVariant::Pixmap:
        case QVariant::Image:
        case QVariant::Brush:
        case QVariant::Palette:
        case QVariant::ColorGroup:
        case QVariant::Map:
        case QVariant::IconSet:
        case QVariant::CString:
        case QVariant::PointArray:
        case QVariant::Region:
        case QVariant::Bitmap:
        case QVariant::Cursor:
        case QVariant::SizePolicy:
        case QVariant::Time:
        case QVariant::ByteArray:
        case QVariant::BitArray:
        case QVariant::KeySequence:
        case QVariant::Pen:
            break;
    }

    Q_ASSERT(0);
    return QVariant();
}
Exemplo n.º 13
0
void KConfigBase::writeEntry(const char *pKey, const QVariant &prop, bool bPersistent, bool bGlobal, bool bNLS)
{
    switch(prop.type())
    {
        case QVariant::Invalid:
            writeEntry(pKey, "", bPersistent, bGlobal, bNLS);
            return;
        case QVariant::String:
            writeEntry(pKey, prop.toString(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::StringList:
            writeEntry(pKey, prop.toStringList(), ',', bPersistent, bGlobal, bNLS);
            return;
        case QVariant::List:
        {
            QValueList< QVariant > list = prop.toList();
            QValueList< QVariant >::ConstIterator it = list.begin();
            QValueList< QVariant >::ConstIterator end = list.end();
            QStringList strList;

            for(; it != end; ++it)
                strList.append((*it).toString());

            writeEntry(pKey, strList, ',', bPersistent, bGlobal, bNLS);

            return;
        }
        case QVariant::Font:
            writeEntry(pKey, prop.toFont(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Point:
            writeEntry(pKey, prop.toPoint(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Rect:
            writeEntry(pKey, prop.toRect(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Size:
            writeEntry(pKey, prop.toSize(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Color:
            writeEntry(pKey, prop.toColor(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Int:
            writeEntry(pKey, prop.toInt(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::UInt:
            writeEntry(pKey, prop.toUInt(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::LongLong:
            writeEntry(pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::ULongLong:
            writeEntry(pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Bool:
            writeEntry(pKey, prop.toBool(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Double:
            writeEntry(pKey, prop.toDouble(), bPersistent, bGlobal, 'g', 6, bNLS);
            return;
        case QVariant::DateTime:
            writeEntry(pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Date:
            writeEntry(pKey, QDateTime(prop.toDate()), bPersistent, bGlobal, bNLS);
            return;

        case QVariant::Pixmap:
        case QVariant::Image:
        case QVariant::Brush:
        case QVariant::Palette:
        case QVariant::ColorGroup:
        case QVariant::Map:
        case QVariant::IconSet:
        case QVariant::CString:
        case QVariant::PointArray:
        case QVariant::Region:
        case QVariant::Bitmap:
        case QVariant::Cursor:
        case QVariant::SizePolicy:
        case QVariant::Time:
        case QVariant::ByteArray:
        case QVariant::BitArray:
        case QVariant::KeySequence:
        case QVariant::Pen:
            break;
    }

    Q_ASSERT(0);
}
Exemplo n.º 14
0
void TransactionMatcher::match(MyMoneyTransaction tm, MyMoneySplit sm, MyMoneyTransaction ti, MyMoneySplit si, bool allowImportedTransactions)
{
  const MyMoneySecurity& sec = MyMoneyFile::instance()->security(m_account.currencyId());

  // Now match the transactions.
  //
  // 'Matching' the transactions entails DELETING the end transaction,
  // and MODIFYING the start transaction as needed.
  //
  // There are a variety of ways that a transaction can conflict.
  // Post date, splits, amount are the ones that seem to matter.
  // TODO: Handle these conflicts intelligently, at least warning
  // the user, or better yet letting the user choose which to use.
  //
  // For now, we will just use the transaction details from the start
  // transaction.  The only thing we'll take from the end transaction
  // are the bank ID's.
  //
  // What we have to do here is iterate over the splits in the end
  // transaction, and find the corresponding split in the start
  // transaction.  If there is a bankID in the end split but not the
  // start split, add it to the start split.  If there is a bankID
  // in BOTH, then this transaction cannot be merged (both transactions
  // were imported!!)  If the corresponding start split cannot  be
  // found and the end split has a bankID, we should probably just fail.
  // Although we could ADD it to the transaction.

  // ipwizard: Don't know if iterating over the transactions is a good idea.
  // In case of a split transaction recorded with KMyMoney and the transaction
  // data being imported consisting only of a single category assignment, this
  // does not make much sense. The same applies for investment transactions
  // stored in KMyMoney against imported transactions. I think a better solution
  // is to just base the match on the splits referencing the same (currently
  // selected) account.

  // verify, that tm is a manually (non-matched) transaction and ti an imported one
  if(sm.isMatched() || (!allowImportedTransactions && tm.isImported()))
    throw new MYMONEYEXCEPTION(i18n("First transaction does not match requirement for matching"));
  if(!ti.isImported())
    throw new MYMONEYEXCEPTION(i18n("Second transaction does not match requirement for matching"));

  // verify that the amounts are the same, otherwise we should not be matching!
  if(sm.shares() != si.shares()) {
    throw new MYMONEYEXCEPTION(i18n("Splits for %1 have conflicting values (%2,%3)").arg(m_account.name()).arg(sm.shares().formatMoney(m_account, sec), si.shares().formatMoney(m_account, sec)));
  }

  // ipwizard: I took over the code to keep the bank id found in the endMatchTransaction
  // This might not work for QIF imports as they don't setup this information. It sure
  // makes sense for OFX and HBCI.
  const QString& bankID = si.bankID();
  if (!bankID.isEmpty()) {
    try {
      if (sm.bankID().isEmpty() ) {
        sm.setBankID( bankID );
        tm.modifySplit(sm);
      } else if(sm.bankID() != bankID) {
        throw new MYMONEYEXCEPTION(i18n("Both of these transactions have been imported into %1.  Therefore they cannot be matched.  Matching works with one imported transaction and one non-imported transaction.").arg(m_account.name()));
      }
    } catch(MyMoneyException *e) {
      QString estr = e->what();
      delete e;
      throw new MYMONEYEXCEPTION(i18n("Unable to match all splits (%1)").arg(estr));
    }
  }

#if 0 // Ace's original code
  // TODO (Ace) Add in another error to catch the case where a user
  // tries to match two hand-entered transactions.
  QValueList<MyMoneySplit> endSplits = endMatchTransaction.splits();
  QValueList<MyMoneySplit>::const_iterator it_split = endSplits.begin();
  while (it_split != endSplits.end())
  {
    // find the corresponding split in the start transaction
    MyMoneySplit startSplit;
    QString accountid = (*it_split).accountId();
    try
    {
      startSplit = startMatchTransaction.splitByAccount( accountid );
    }
      // only exception is thrown if we cannot find a split like this
    catch(MyMoneyException *e)
    {
      delete e;
      startSplit = (*it_split);
      startSplit.clearId();
      startMatchTransaction.addSplit(startSplit);
    }

    // verify that the amounts are the same, otherwise we should not be
    // matching!
    if ( (*it_split).value() != startSplit.value() )
    {
      QString accountname = MyMoneyFile::instance()->account(accountid).name();
      throw new MYMONEYEXCEPTION(i18n("Splits for %1 have conflicting values (%2,%3)").arg(accountname).arg((*it_split).value().formatMoney(),startSplit.value().formatMoney()));
    }

    QString bankID = (*it_split).bankID();
    if ( ! bankID.isEmpty() )
    {
      try
      {
        if ( startSplit.bankID().isEmpty() )
        {
          startSplit.setBankID( bankID );
          startMatchTransaction.modifySplit(startSplit);
        }
        else
        {
          QString accountname = MyMoneyFile::instance()->account(accountid).name();
          throw new MYMONEYEXCEPTION(i18n("Both of these transactions have been imported into %1.  Therefore they cannot be matched.  Matching works with one imported transaction and one non-imported transaction.").arg(accountname));
        }
      }
      catch(MyMoneyException *e)
      {
        QString estr = e->what();
        delete e;
        throw new MYMONEYEXCEPTION(i18n("Unable to match all splits (%1)").arg(estr));
      }
    }
    ++it_split;
  }
#endif

  // mark the split as cleared if it does not have a reconciliation information yet
  if(sm.reconcileFlag() == MyMoneySplit::NotReconciled) {
    sm.setReconcileFlag(MyMoneySplit::Cleared);
  }

  // if we don't have a payee assigned to the manually entered transaction
  // we use the one we found in the imported transaction
  if(sm.payeeId().isEmpty() && !si.payeeId().isEmpty()) {
    sm.setValue("kmm-orig-payee", sm.payeeId());
    sm.setPayeeId(si.payeeId());
  }

  // We use the imported postdate and keep the previous one for unmatch
  if(tm.postDate() != ti.postDate()) {
    sm.setValue("kmm-orig-postdate", tm.postDate().toString(Qt::ISODate));
    tm.setPostDate(ti.postDate());
  }

  // combine the two memos into one
  QString memo = sm.memo();
  if(!si.memo().isEmpty() && si.memo() != memo) {
    sm.setValue("kmm-orig-memo", memo);
    if(!memo.isEmpty())
      memo += "\n";
    memo += si.memo();
  }
  sm.setMemo(memo);

  // remember the split we matched
  sm.setValue("kmm-match-split", si.id());

  sm.addMatch(ti);
  tm.modifySplit(sm);

  MyMoneyFile::instance()->modifyTransaction(tm);
  // Delete the end transaction if it was stored in the engine
  if(!ti.id().isEmpty())
    MyMoneyFile::instance()->removeTransaction(ti);
}
Exemplo n.º 15
0
QValueList<int> fitsDim( fitsfile *fp, int HDU ) {
  
  QValueList<int> dims;
  
  // move to desired HDU
  int ret = 0;
  int hduType;
  if (fits_movabs_hdu(fp, HDU, &hduType, &ret)) {
    return dims;
  }
  
  // for each type of HDU, find the dimensions
  
  int maxDim;
  long rowLen;
  long nRows;
  int nCols;
  long tbCol;
  long *dimAxes = NULL;
  int nAxis;
  switch (hduType) {
    case IMAGE_HDU:
      // find the size of the image and include it in the 
      // generic name.
      maxDim = 100; // no images should have > 100 dimensions...
      dimAxes = (long*)calloc(maxDim, sizeof(long));
      
      if (fits_read_imghdr(fp, maxDim, NULL, NULL, &nAxis, dimAxes, NULL, NULL, NULL, &ret)) {
        return dims;
      }
      for (int i = 0; i < nAxis; i++) {
        dims.append((int)dimAxes[i]);
      }
      free(dimAxes);
      break;
      
    case ASCII_TBL:
      maxDim = 2147483646; // 2^32/2 - 2 (i.e. a big positive integer)
      
      // find number of columns
      if (fits_read_atblhdr(fp, maxDim, &rowLen, &nRows, &nCols, NULL, &tbCol, NULL, NULL, NULL, &ret)) {
        return dims;
      }
      
      dims.append((int)nCols);
      dims.append((int)nRows);
      
      break;
      
    case BINARY_TBL:
      maxDim = 2147483646; // 2^32/2 - 2 (i.e. a big positive integer)
      
      // find number of columns
      if (fits_read_btblhdr(fp, maxDim, &nRows, &nCols, NULL, NULL, NULL, NULL, NULL, &ret)) {
        return dims;
      }
      
      dims.append((int)nCols);
      dims.append((int)nRows);
      
      break;
      
    default:
      return dims;
      break;
  }
  
  return dims;
}
Exemplo n.º 16
0
void MakefileHandler::parse( const QString& folder, bool recursive )
{
    //look for either Makefile.am.in, Makefile.am, or Makefile.in, in that order
    AutoTools::ProjectAST* ast;
    int ret = -1;
    QString filePath = folder + "/Makefile.am.in";
    if ( QFile::exists( filePath ) )
        ret = AutoTools::Driver::parseFile( filePath, &ast );
    else
    {
        filePath = folder + "/Makefile.am";
        if ( QFile::exists( filePath ) )
            ret = AutoTools::Driver::parseFile( filePath, &ast );
        else
        {
            filePath = folder + "/Makefile.in";
            if ( QFile::exists( filePath ) )
                ret = AutoTools::Driver::parseFile( filePath, &ast );
            else
                kdDebug(9020) << k_funcinfo << "no appropriate file to parse in "
                              << folder << endl;
        }
    }

    if ( ret != 0 )
    {
        return;
    }

    kdDebug(9020) << k_funcinfo << filePath << " was parsed correctly. Adding information" << endl;
    Q_ASSERT( ast != 0 );
    d->projects[filePath] = ast;
    d->folderToFileMap[folder] = filePath;

    if ( recursive && ast && ast->hasChildren() )
    {
        QValueList<AutoTools::AST*> astChildList = ast->children();
        QValueList<AutoTools::AST*>::iterator it(astChildList.begin()), clEnd(astChildList.end());
        for ( ; it != clEnd; ++it )
        {
            if ( (*it)->nodeType() == AutoTools::AST::AssignmentAST )
            {
                AutoTools::AssignmentAST* assignment = static_cast<AutoTools::AssignmentAST*>( (*it) );
                if ( assignment->scopedID == "SUBDIRS"  )
                {
                    QString list = assignment->values.join( QString::null );
                    list.simplifyWhiteSpace();
                    kdDebug(9020) << k_funcinfo << "subdirs is " << list << endl;
                    QStringList subdirList = QStringList::split( " ",  list );
                    QStringList::iterator vit = subdirList.begin();
                    for ( ; vit != subdirList.end(); ++vit )
                    {
                        QString realDir = ( *vit );
                        if ( realDir.startsWith( "\\" ) )
                            realDir.remove( 0, 1 );

                        realDir = realDir.stripWhiteSpace();
                        if ( realDir != "." && realDir != ".." && !realDir.isEmpty() )
                        {
                            if ( isVariable( realDir ) )
                            {
                                kdDebug(9020) << k_funcinfo << "'" << realDir << "' is a variable" << endl;
                                realDir = resolveVariable( realDir, ast );
                            }

                            kdDebug(9020) << k_funcinfo << "Beginning parsing of '" << realDir << "'" << endl;
                            parse( folder + '/' + realDir, recursive );
                        }
                    }
                }
            }
        }
    }
}
Exemplo n.º 17
0
EList KalziumDataObject::readData(  QDomDocument &dataDocument )
{
	EList list;
	QDomNodeList elementNodes; //the list of all element
	QDomElement  domElement;   //a single element

	//read in all elements
	elementNodes = dataDocument.elementsByTagName( "element" );

	const uint count = elementNodes.count();

	for ( uint i = 0; i < count; ++i )
	{//iterate through all elements
		domElement = ( const QDomElement& ) elementNodes.item( i ).toElement();

		double mass = domElement.namedItem( "mass" ).toElement().text().toDouble();
		double en = domElement.namedItem( "electronegativity" ).toElement().text().toDouble();
		double ea = domElement.namedItem( "electronaffinity" ).toElement().text().toDouble();
		double mp = domElement.namedItem( "meltingpoint" ).toElement().text().toDouble();
		double bp = domElement.namedItem( "boilingpoint" ).toElement().text().toDouble();
		double density = domElement.namedItem( "density" ).toElement().text().toDouble();
		double covalent_radius = domElement.namedItem( "radius" ).namedItem( "covalent" ).toElement().text().toDouble();
		//van der Waals-Radius
		double vdw_radius = domElement.namedItem( "radius" ).namedItem( "vdw" ).toElement().text().toDouble();
		double atomic_radius = domElement.namedItem( "radius" ).namedItem( "atomic" ).toElement().text().toDouble();
		double ionic_radius = domElement.namedItem( "radius" ).namedItem( "ionic" ).toElement().text().toDouble();
		QString ionic_charge = domElement.namedItem( "radius" ).namedItem( "ionic" ).toElement().attributeNode( "charge" ).value();
		
		int bio = domElement.namedItem( "biologicalmeaning" ).toElement().text().toInt();
		int radioactive = domElement.namedItem( "radioactive" ).toElement().text().toInt();
		int period = domElement.namedItem( "period" ).toElement().text().toInt();
		int artificial = domElement.namedItem( "artificial" ).toElement().text().toInt();
		int date = domElement.namedItem( "date" ).toElement().text().toInt();
		int number = domElement.namedItem( "number" ).toElement().text().toInt();
		int abundance = domElement.namedItem( "abundance" ).toElement().text().toInt();
		
		QString scientist = domElement.namedItem( "date" ).toElement().attributeNode( "scientist" ).value();
		QString crystal = domElement.namedItem( "crystalstructure" ).toElement().text();
		
		QDomElement nameE = domElement.namedItem( "name" ).toElement();
		QString name = nameE.text();
		QString origin = i18n( nameE.attributeNode( "origin" ).value().utf8() );
		
		QString block = domElement.namedItem( "block" ).toElement().text();
		QString group = domElement.namedItem( "group" ).toElement().text();
		QString family = domElement.namedItem( "family" ).toElement().text();
		QString orbits = domElement.namedItem( "orbits" ).toElement().text();
		QString symbol = domElement.namedItem( "symbol" ).toElement().text();
		QString oxydation = domElement.namedItem( "oxydation" ).toElement().text();
		QString acidicbehaviour = domElement.namedItem( "acidicbehaviour" ).toElement().text();

		QDomNodeList elist = domElement.elementsByTagName( "energy" );
		QValueList<double> ionlist;
		for( uint i = 0; i < elist.length(); i++ )
		{
			ionlist.append(  elist.item(  i ).toElement().text().toDouble() );
		}
		
		//now read in all the date for the isotopes
		QDomNodeList isotopelist = domElement.elementsByTagName( "isotope" );
		QValueList<Isotope*> isolist;
		for( uint i = 0; i < isotopelist.length(); i++ )
		{
			QDomElement iso = isotopelist.item( i ).toElement();
			double halflife = iso.attributeNode( "halflife" ).value().toDouble();
			double weight = iso.attributeNode( "weight" ).value().toDouble();
			QString format = iso.attributeNode( "halflifeformat" ).value();
			int neutrons  = iso.attributeNode( "neutron" ).value().toInt();
			double percentage = iso.attributeNode( "percentage" ).value().toDouble();
			double alphapercentage = iso.attributeNode( "alphapercentage" ).value().toDouble();
			double betapluspercentage = iso.attributeNode( "betapluspercentage" ).value().toDouble();
			double betaminuspercentage = iso.attributeNode( "betaminuspercentage" ).value().toDouble();
			double ecpercentage = iso.attributeNode( "ecpercentage" ).value().toDouble();
			double alphadecay = iso.attributeNode( "alphadecay" ).value().toDouble();
			double betaplusdecay = iso.attributeNode( "betaplusdecay" ).value().toDouble();
			double betaminusdecay = iso.attributeNode( "betaminusdecay" ).value().toDouble();
			double ecdecay = iso.attributeNode( "ecdecay" ).value().toDouble();
			QString spin = iso.attributeNode( "spin" ).value();
			QString magmoment = iso.attributeNode( "magmoment" ).value();
			
						
			Isotope *isotope = new Isotope( neutrons, 
					number, 
					percentage, 
					weight, 
					halflife, 
					format, 
					alphadecay, 
					betaplusdecay, 
					betaminusdecay, 
					ecdecay, 
					alphapercentage, 
					betapluspercentage, 
					betaminuspercentage, 
					ecpercentage, 
					spin, 
					magmoment );
			isolist.append( isotope );
		}

		QDomNodeList spectrumList = domElement.namedItem( "spectra" ).toElement().elementsByTagName( "spectrum" );

		Element *e = new Element();
		e->setDate(date);
		e->setBiologicalMeaning(bio);
		e->setNumber( number );
		e->setName(i18n(name.utf8()));
		e->setRadius( Element::ATOMIC, atomic_radius );
		e->setRadius( Element::IONIC, ionic_radius, ionic_charge );
		e->setRadius( Element::COVALENT, covalent_radius );
		e->setRadius( Element::VDW, vdw_radius );
		e->setAbundance( abundance );

		if ( artificial == 1 )
			e->setArtificial();
		if ( radioactive == 1 )
			e->setRadioactive();
		
		e->setScientist(scientist);
		e->setPeriod( period );
		e->setCrysatalstructure( crystal );
		e->setOrigin(origin);
		e->setBlock(block);
		e->setGroup(group);
		e->setFamily(family);
		e->setOrbits(orbits);
		e->setSymbol(symbol);
		e->setOxydation(oxydation);
		e->setAcidicbehaviour(acidicbehaviour);
		e->setIonisationList( ionlist );
		e->setIsotopeList( isolist );
		
		e->setMass( mass );	
		e->setEN( en );
		e->setEA( ea );
		e->setMeltingpoint( mp );
		e->setBoilingpoint( bp );
		e->setDensity( density );

		e->setupXY();

		Spectrum *spectrum = new Spectrum();
		bool spectrum_temp = false;
		if ( spectrumList.length() > 0 )
			spectrum_temp = true;
		for( uint i = 0; i < spectrumList.length(); i++ )
		{
			Spectrum::band b;
			QDomElement spec = spectrumList.item( i ).toElement();
			
			b.intensity = spec.attributeNode( "intensity" ).value().toInt();
			b.wavelength = spec.attributeNode( "wavelength" ).value().toDouble()/10.0;
			b.aki = spec.attributeNode( "aki" ).value().toDouble();
			b.energy1 = spec.attributeNode( "energy1" ).value().toDouble();
			b.energy2 = spec.attributeNode( "energy2" ).value().toDouble();
			b.electronconfig1 = spec.attributeNode( "electronconfig1" ).value();
			b.electronconfig2 = spec.attributeNode( "electronconfig1" ).value();
			b.term1 = spec.attributeNode( "term1" ).value();
			b.term2 = spec.attributeNode( "term2" ).value();
			b.J1 = spec.attributeNode( "J1" ).value();
			b.J2 = spec.attributeNode( "J2" ).value();

			spectrum->addBand( b );
		}
		if ( spectrum_temp ) //if no spectrumdata are found don't use this object
			e->setSpectrum( spectrum );
		e->setHasSepctrum( spectrum_temp );

		list.append( e );
		coordinate point; point.x =  e->x; point.y = e->y;
		CoordinateList.append( point );
	}

	return list;
}
KstDataManagerI::KstDataManagerI(KstDoc *in_doc, QWidget* parent, const char* name, bool modal, WFlags fl)
: KstDataManager(parent, name, modal, fl) {
  doc = in_doc;

  _yesPixmap = QPixmap(locate("data", "kst/pics/yes.png"));

  connect(Edit, SIGNAL(clicked()), this, SLOT(edit_I()));
  connect(Delete, SIGNAL(clicked()), this, SLOT(delete_I()));
  connect(Purge, SIGNAL(clicked()), doc, SLOT(purge()));
  connect(DataView, SIGNAL(doubleClicked(QListViewItem *)),
      this, SLOT(edit_I()));
  connect(DataView, SIGNAL(currentChanged(QListViewItem *)),
      this, SLOT(currentChanged(QListViewItem *)));
  connect(DataView, SIGNAL(selectionChanged()),
      this, SLOT(selectionChanged()));
  connect(DataView, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)), this, SLOT(contextMenu(QListViewItem*, const QPoint&, int)));

  _searchWidget = new KListViewSearchLineWidget(DataView, SearchBox);
  QValueList<int> cols;
  cols.append(0);
  _searchWidget->createSearchLine(DataView);
  _searchWidget->searchLine()->setSearchColumns(cols);

  QMainWindow *main = static_cast<QMainWindow*>(parent);
  main->setUsesTextLabel(true);

  _primitive = new QToolBar(i18n("Create Primitive"), main, this);
  _primitive->setFrameStyle(QFrame::NoFrame);
  _primitive->setOrientation(Qt::Vertical);
  _primitive->setBackgroundMode(PaletteBase);

  _data = new QToolBar(i18n("Create Data Object"), main, this);
  _data->setFrameStyle(QFrame::NoFrame);
  _data->setOrientation(Qt::Vertical);
  _data->setBackgroundMode(PaletteBase);

  _plugins = new QToolBar(i18n("Create Plugin"), main, this);
  _plugins->setFrameStyle(QFrame::NoFrame);
  _plugins->setOrientation(Qt::Vertical);
  _plugins->setBackgroundMode(PaletteBase);

  _fits = new QToolBar(i18n("Create Fit"), main, this);
  _fits->setFrameStyle(QFrame::NoFrame);
  _fits->setOrientation(Qt::Vertical);
  _fits->setBackgroundMode(PaletteBase);

  _filters = new QToolBar(i18n("Create Filter"), main, this);
  _filters->setFrameStyle(QFrame::NoFrame);
  _filters->setOrientation(Qt::Vertical);
  _filters->setBackgroundMode(PaletteBase);

  ToolBox->setUpdatesEnabled(false);

  _primitive->setUpdatesEnabled(false);
  _primitive->clear();

  _data->setUpdatesEnabled(false);
  _data->clear();

  _plugins->setUpdatesEnabled(false);
  _plugins->clear();

  _fits->setUpdatesEnabled(false);
  _fits->clear();

  _filters->setUpdatesEnabled(false);
  _filters->clear();

  //Create canonical actions...
//   createObjectAction(i18n("Scalar"), _primitive, KstScalarDialogI::globalInstance(), SLOT(show()));
  createObjectAction(i18n("Vector"), _primitive, KstVectorDialogI::globalInstance(), SLOT(show()));
  createObjectAction(i18n("Matrix"), _primitive, KstMatrixDialogI::globalInstance(), SLOT(show()));
//   createObjectAction(i18n("String"), _primitive, KstStringDialogI::globalInstance(), SLOT(show()));

  createObjectAction(i18n("Curve"), _data, KstCurveDialogI::globalInstance(), SLOT(show()));
  createObjectAction(i18n("Equation"), _data, KstEqDialogI::globalInstance(), SLOT(show()));
  createObjectAction(i18n("Histogram"), _data, KstHsDialogI::globalInstance(), SLOT(show()));
  createObjectAction(i18n("Spectrum"), _data, KstPsdDialogI::globalInstance(), SLOT(show()));
  createObjectAction(i18n("Event Monitor"), _data, KstEventMonitorI::globalInstance(), SLOT(show()));
  createObjectAction(i18n("Image"), _data, KstImageDialogI::globalInstance(), SLOT(show()));
  createObjectAction(i18n("Spectrogram"), _data, KstCsdDialogI::globalInstance(), SLOT(show()));
  createObjectAction(i18n("Vector View"), _data, KstVvDialogI::globalInstance(), SLOT(show()));

  //Create plugin actions...
  setupPluginActions();

  //TODO sort the actions in each box alphabetically?

  QWidget *priw = new QWidget(_primitive);
  priw->setBackgroundMode(PaletteBase);
  _primitive->setStretchableWidget(priw);

  QWidget *datw = new QWidget(_data);
  datw->setBackgroundMode(PaletteBase);
  _data->setStretchableWidget(datw);

  QWidget *pluginw = new QWidget(_plugins);
  pluginw->setBackgroundMode(PaletteBase);
  _plugins->setStretchableWidget(pluginw);

  QWidget *fitw = new QWidget(_fits);
  fitw->setBackgroundMode(PaletteBase);
  _fits->setStretchableWidget(fitw);

  QWidget *filw = new QWidget(_filters);
  filw->setBackgroundMode(PaletteBase);
  _filters->setStretchableWidget(filw);

  ToolBox->setUpdatesEnabled(true);

  _primitive->setUpdatesEnabled(true);
  _data->setUpdatesEnabled(true);
  _plugins->setUpdatesEnabled(true);
  _fits->setUpdatesEnabled(true);
  _filters->setUpdatesEnabled(true);

  ToolBox->addItem(_primitive, i18n("Create Primitive"));
  ToolBox->addItem(_data, i18n("Create Data Object"));
  ToolBox->addItem(_plugins, i18n("Create Plugin"));
  ToolBox->addItem(_fits, i18n("Create Fit"));
  ToolBox->addItem(_filters, i18n("Create Filter"));
}
Exemplo n.º 19
0
QValueList<EffectiveEvent> DateBookDB::getEffectiveEvents( const QDate &from,
                                                           const QDate &to )
{
    QValueList<EffectiveEvent> tmpList;
    QValueListIterator<Event> it;

    EffectiveEvent effEv;
    QDateTime dtTmp,
              dtEnd;

    for (it = eventList.begin(); it != eventList.end(); ++it ) {
        if (!(*it).isValidUid())
            (*it).assignUid(); // FIXME: Hack to restore cleared uids

        dtTmp = (*it).start(TRUE);
        dtEnd = (*it).end(TRUE);

        if ( dtTmp.date() >= from && dtTmp.date() <= to ) {
            Event tmpEv = *it;
            effEv.setEvent(tmpEv);
            effEv.setDate( dtTmp.date() );
            effEv.setStart( dtTmp.time() );
            if ( dtTmp.date() != dtEnd.date() )
                effEv.setEnd( QTime(23, 59, 0) );
            else
                effEv.setEnd( dtEnd.time() );
            tmpList.append( effEv );
        }
        // we must also check for end date information...
        if ( dtEnd.date() != dtTmp.date() && dtEnd.date() >= from ) {
            QDateTime dt = dtTmp.addDays( 1 );
            dt.setTime( QTime(0, 0, 0) );
            QDateTime dtStop;
            if ( dtEnd > to ) {
                dtStop = to;
            } else
                dtStop = dtEnd;
            while ( dt <= dtStop ) {
                Event tmpEv = *it;
                effEv.setEvent( tmpEv );
                effEv.setDate( dt.date() );
                if ( dt >= from ) {
                    effEv.setStart( QTime(0, 0, 0) );
                    if ( dt.date() == dtEnd.date() )
                        effEv.setEnd( dtEnd.time() );
                    else
                        effEv.setEnd( QTime(23, 59, 59) );
                    tmpList.append( effEv );
                }
                dt = dt.addDays( 1 );
            }
        }
    }
    // check for repeating events...
    QDateTime repeat;
    for ( it = repeatEvents.begin(); it != repeatEvents.end(); ++it ) {
        if (!(*it).isValidUid())
            (*it).assignUid(); // FIXME: Hack to restore cleared uids

        /* create a false end date, to short circuit on hard
           MonthlyDay recurences */
        Event dummy_event = *it;
        int duration = (*it).start().date().daysTo( (*it).end().date() );
        QDate itDate = from.addDays(-duration);

        Event::RepeatPattern r = dummy_event.repeatPattern();
        if ( !r.hasEndDate || r.endDate() > to ) {
            r.setEndDate( to );
            r.hasEndDate = TRUE;
        }
        dummy_event.setRepeat(TRUE, r);

        while (nextOccurance(dummy_event, itDate, repeat)) {
            if(repeat.date() > to)
                break;
            effEv.setDate( repeat.date() );
            if ((*it).type() == Event::AllDay) {
                effEv.setStart( QTime(0,0,0) );
                effEv.setEnd( QTime(23,59,59) );
            } else {
                /* we only occur by days, not hours/minutes/seconds.  Hence
                   the actual end and start times will be the same for
                   every repeated event.  For multi day events this is
                   fixed up later if on wronge day span */
                effEv.setStart( (*it).start().time() );
                effEv.setEnd( (*it).end().time() );
            }
            if ( duration != 0 ) {
                // multi-day repeating events
                QDate sub_it = QMAX( repeat.date(), from );
                QDate startDate = repeat.date();
                QDate endDate = startDate.addDays( duration );

                while ( sub_it <= endDate && sub_it  <= to ) {
                    EffectiveEvent tmpEffEv = effEv;
                    Event tmpEv = *it;
                    tmpEffEv.setEvent( tmpEv );

                    if ( sub_it != startDate )
                        tmpEffEv.setStart( QTime(0,0,0) );
                    if ( sub_it != endDate )
                        tmpEffEv.setEnd( QTime(23,59,59) );
                    tmpEffEv.setDate( sub_it );
                    tmpEffEv.setEffectiveDates( startDate, endDate );
                    tmpList.append( tmpEffEv );
                    sub_it = sub_it.addDays( 1 );
                }
                itDate = endDate;
            } else {
                Event tmpEv = *it;
                effEv.setEvent( tmpEv );
                tmpList.append( effEv );
                itDate = repeat.date().addDays( 1 );
            }
        }
    }

    qHeapSort( tmpList );
    return tmpList;
}
Exemplo n.º 20
0
/**
  Internal method that draws one of the pies in a pie chart.

  \param painter the QPainter to draw in
  \param dataset the dataset to draw the pie for
  \param pie the pie to draw
  \param the chart to draw the pie in
  \param regions a pointer to a list of regions that will be filled
  with regions representing the data segments, if not null
  */
void KDChartPiePainter::drawOnePie( QPainter* painter,
        KDChartTableDataBase* /*data*/,
        uint dataset, uint pie, uint chart,
        uint threeDPieHeight,
        KDChartDataRegionList* regions )
{
    // Is there anything to draw at all?
    int angleLen = _angleLens[ ( int ) pie ];
    if ( angleLen ) {
        int startAngle = _startAngles[ ( int ) pie ];

        KDChartDataRegion* datReg = 0;
        QRegion* region = 0;
        bool mustDeleteRegion = false;
        if ( regions ){
            region = new QRegion();
            mustDeleteRegion = true;
        }

        QRect drawPosition = _position;
        if ( params()->explode() ) {
            // need to compute a new position for each or some of the pie
            QValueList<int> explodeList = params()->explodeValues();
            if( explodeList.count() == 0 || // nothing on list, explode all
                    explodeList.find( pie ) != explodeList.end() ) {
                double explodeAngle = ( startAngle + angleLen / 2 ) / 16;
                double explodeAngleRad = DEGTORAD( explodeAngle );
                double cosAngle = cos( explodeAngleRad );
                double sinAngle = -sin( explodeAngleRad );

                // find the explode factor for this particular pie
                double explodeFactor = 0.0;
                QMap<int,double> explodeFactors = params()->explodeFactors();
                if( !explodeFactors.contains( pie ) ) // not on factors list, use default
                    explodeFactor = params()->explodeFactor();
                else // on factors list, use segment-specific value
                    explodeFactor = explodeFactors[pie];

                double explodeX = explodeFactor * _size * cosAngle;
                double explodeY = explodeFactor * _size * sinAngle;
                drawPosition.moveBy( static_cast<int>( explodeX ), static_cast<int>( explodeY ) );
            } else
                drawPosition = _position;
        } else
            drawPosition = _position;

        // The 3D effect needs to be drawn first because it could
        // otherwise partly hide the pie itself.
        if ( params()->threeDPies() ) {
            draw3DEffect( painter, drawPosition, dataset, pie, chart,
                          threeDPieHeight,
                          params()->explode(), region );
        }

        painter->setBrush( params()->dataColor( pie ) );
        if ( angleLen == 5760 ) {
            // full circle, avoid nasty line in the middle
            painter->drawEllipse( drawPosition );
            if ( regions ) {
                QPointArray hitregion;
                hitregion.makeEllipse( drawPosition.x(), drawPosition.y(),
                                       drawPosition.width(),
                                       drawPosition.height() );
                datReg = new KDChartDataRegion( region->unite( QRegion( hitregion ) ),
                                                dataset,
                                                pie,
                                                chart );
                datReg->points[ KDChartEnums::PosCenter ]
                    = drawPosition.center();
                datReg->points[ KDChartEnums::PosCenterRight ]
                    = pointOnCircle( drawPosition,    0 );
                datReg->points[ KDChartEnums::PosTopRight ]
                    = pointOnCircle( drawPosition,  720 );
                datReg->points[ KDChartEnums::PosTopCenter ]
                    = pointOnCircle( drawPosition, 1440 );
                datReg->points[ KDChartEnums::PosTopLeft ]
                    = pointOnCircle( drawPosition, 2160 );
                datReg->points[ KDChartEnums::PosCenterLeft ]
                    = pointOnCircle( drawPosition, 2880 );
                datReg->points[ KDChartEnums::PosBottomLeft ]
                    = pointOnCircle( drawPosition, 3600 );
                datReg->points[ KDChartEnums::PosBottomCenter ]
                    = pointOnCircle( drawPosition, 4320 );
                datReg->points[ KDChartEnums::PosBottomRight ]
                    = pointOnCircle( drawPosition, 5040 );
                datReg->startAngle = 2880;
                datReg->angleLen   = 5760;
                regions->append( datReg );
            }
        } else {
            // draw the top of this piece
            // Start with getting the points for the arc.
            const int arcPoints = angleLen;
            QPointArray collect(arcPoints+2);
            int i=0;
            for ( ; i<=angleLen; ++i){
                collect.setPoint(i, pointOnCircle( drawPosition, startAngle+i ));
            }
            // Adding the center point of the piece.
            collect.setPoint(i, drawPosition.center() );



            painter->drawPolygon( collect );

//if( bHelp ){
//              painter->drawPolyline( collect );
//bHelp=false;
//}



            if ( regions ) {
                QPointArray hitregion;
                hitregion.makeArc( drawPosition.x(), drawPosition.y(),
                        drawPosition.width(),
                        drawPosition.height(),
                        ( int ) startAngle, ( int ) angleLen );
                hitregion.resize( hitregion.size() + 1 );
                hitregion.setPoint( hitregion.size() - 1,
                        drawPosition.center() );
                datReg = new KDChartDataRegion( region->unite( QRegion( hitregion ) ),
                                                dataset,
                                                pie,
                                                chart );

                datReg->points[ KDChartEnums::PosTopLeft ]
                    = pointOnCircle( drawPosition, startAngle + angleLen );
                datReg->points[ KDChartEnums::PosTopCenter ]
                    = pointOnCircle( drawPosition, startAngle + angleLen / 2 );
                datReg->points[ KDChartEnums::PosTopRight ]
                    = pointOnCircle( drawPosition, startAngle );

                datReg->points[   KDChartEnums::PosBottomLeft   ] = drawPosition.center();
                datReg->points[   KDChartEnums::PosBottomCenter ]
                    = datReg->points[ KDChartEnums::PosBottomLeft   ];
                datReg->points[   KDChartEnums::PosBottomRight  ]
                    = datReg->points[ KDChartEnums::PosBottomLeft   ];

                datReg->points[ KDChartEnums::PosCenterLeft ]
                    = QPoint( (   datReg->points[ KDChartEnums::PosTopLeft      ].x()
                                + datReg->points[ KDChartEnums::PosBottomLeft   ].x() ) / 2,
                            (   datReg->points[ KDChartEnums::PosTopLeft      ].y()
                                + datReg->points[ KDChartEnums::PosBottomLeft   ].y() ) / 2 );
                datReg->points[ KDChartEnums::PosCenter ]
                    = QPoint( (   datReg->points[ KDChartEnums::PosTopCenter    ].x()
                                + datReg->points[ KDChartEnums::PosBottomCenter ].x() ) / 2,
                            (   datReg->points[ KDChartEnums::PosTopCenter    ].y()
                                + datReg->points[ KDChartEnums::PosBottomCenter ].y() ) / 2 );
                datReg->points[ KDChartEnums::PosCenterRight ]
                    = QPoint( (   datReg->points[ KDChartEnums::PosTopRight     ].x()
                                + datReg->points[ KDChartEnums::PosBottomRight  ].x() ) / 2,
                            (   datReg->points[ KDChartEnums::PosTopRight     ].y()
                                + datReg->points[ KDChartEnums::PosBottomRight  ].y() ) / 2 );

                datReg->startAngle = startAngle;
                datReg->angleLen   = angleLen;
                regions->append( datReg );
            }
        }
        if( mustDeleteRegion )
            delete region;
    }
}
Exemplo n.º 21
0
void LayoutConfig::save()
{
    QString model = lookupLocalized(m_rules->models(), widget->comboModel->currentText());
    m_kxkbConfig.m_model = model;

    m_kxkbConfig.m_enableXkbOptions = widget->chkEnableOptions->isChecked();
    m_kxkbConfig.m_resetOldOptions = widget->checkResetOld->isChecked();
    m_kxkbConfig.m_options = createOptionString();

    QListViewItem *item = widget->listLayoutsDst->firstChild();
    QValueList< LayoutUnit > layouts;
    while(item)
    {
        QString layout = item->text(LAYOUT_COLUMN_MAP);
        QString variant = item->text(LAYOUT_COLUMN_VARIANT);
        QString includes = item->text(LAYOUT_COLUMN_INCLUDE);
        QString displayName = item->text(LAYOUT_COLUMN_DISPLAY_NAME);

        LayoutUnit layoutUnit(layout, variant);
        layoutUnit.includeGroup = includes;
        layoutUnit.displayName = displayName;
        layouts.append(layoutUnit);

        item = item->nextSibling();
        kdDebug() << "To save: layout " << layoutUnit.toPair() << ", inc: " << layoutUnit.includeGroup << ", disp: " << layoutUnit.displayName
                  << endl;
    }
    m_kxkbConfig.m_layouts = layouts;

    if(m_kxkbConfig.m_layouts.count() == 0)
    {
        m_kxkbConfig.m_layouts.append(LayoutUnit(DEFAULT_LAYOUT_UNIT));
        widget->chkEnable->setChecked(false);
    }

    m_kxkbConfig.m_useKxkb = widget->chkEnable->isChecked();
    m_kxkbConfig.m_showSingle = widget->chkShowSingle->isChecked();
    m_kxkbConfig.m_showFlag = widget->chkShowFlag->isChecked();

    int modeId = widget->grpSwitching->id(widget->grpSwitching->selected());
    switch(modeId)
    {
        default:
        case 0:
            m_kxkbConfig.m_switchingPolicy = SWITCH_POLICY_GLOBAL;
            break;
        case 1:
            m_kxkbConfig.m_switchingPolicy = SWITCH_POLICY_WIN_CLASS;
            break;
        case 2:
            m_kxkbConfig.m_switchingPolicy = SWITCH_POLICY_WINDOW;
            break;
    }

    m_kxkbConfig.m_stickySwitching = widget->chkEnableSticky->isChecked();
    m_kxkbConfig.m_stickySwitchingDepth = widget->spinStickyDepth->value();

    m_kxkbConfig.save();

    kapp->kdeinitExec("kxkb");
    emit KCModule::changed(false);
}
Exemplo n.º 22
0
/**
  Paints the actual data area.

  \param painter the QPainter onto which the chart should be painted
  \param data the data that will be displayed as a chart
  \param paint2nd specifies whether the main chart or the additional chart is to be drawn now
  \param regions a pointer to a list of regions that will be filled
  with regions representing the data segments, if not null
  */
void KDChartPiePainter::paintData( QPainter* painter,
        KDChartTableDataBase* data,
        bool paint2nd,
        KDChartDataRegionList* regions )
{
//bHelp=true;
    uint chart = paint2nd ? 1 : 0;

    QRect ourClipRect( _dataRect );
    ourClipRect.addCoords( -1,-1,1,1 );

    const QWMatrix & world = painter->worldMatrix();
    ourClipRect =
#if COMPAT_QT_VERSION >= 0x030000
        world.mapRect( ourClipRect );
#else
    world.map( ourClipRect );
#endif

    painter->setClipRect( ourClipRect );

    // find which dataset to paint
    uint dataset;
    if ( !params()->findDataset( KDChartParams::DataEntry
                ,
                dataset, dataset ) ) {
        return ; // nothing to draw
    }

    if ( dataset == KDCHART_ALL_DATASETS )
        // setChartSourceMode() has not been used (or all datasets have been
        // configured to be used); use the first dataset by
        // default
        dataset = 0;


    // Number of values: If -1, use all values, otherwise use the
    // specified number of values.
    if ( params()->numValues() != -1 )
        _numValues = params()->numValues();
    else
        _numValues = data->usedCols();

    _startAngles.resize( _numValues );
    _angleLens.resize( _numValues );

    // compute position
    _size = QMIN( _dataRect.width(), _dataRect.height() ); // initial size
    // if the pies explode, we need to give them additional space =>
    // make the basic size smaller
    if ( params()->explode() ) {
        double doubleSize = ( double ) _size;
        doubleSize /= ( 1.0 + params()->explodeFactor() * 2 );
        _size = ( int ) doubleSize;
    }

    int sizeFor3DEffect = 0;
    if ( !params()->threeDPies() ) {

        int x = ( _dataRect.width() == _size ) ? 0 : ( ( _dataRect.width() - _size ) / 2 );
        int y = ( _dataRect.height() == _size ) ? 0 : ( ( _dataRect.height() - _size ) / 2 );
        _position = QRect( x, y, _size, _size );
        _position.moveBy( _dataRect.left(), _dataRect.top() );
    } else {
        // threeD: width is the maximum possible width; height is 1/2 of that
        int x = ( _dataRect.width() == _size ) ? 0 : ( ( _dataRect.width() - _size ) / 2 );
        int height = _size;
        // make sure that the height plus the threeDheight is not more than the
        // available size
        if ( params()->threeDPieHeight() >= 0 ) {
            // positive pie height: absolute value
            sizeFor3DEffect = params()->threeDPieHeight();
            height = _size - sizeFor3DEffect;
        } else {
            // negative pie height: relative value
            sizeFor3DEffect = -( int ) ( ( ( double ) params()->threeDPieHeight() / 100.0 ) * ( double ) height );
            height = _size - sizeFor3DEffect;
        }
        int y = ( _dataRect.height() == height ) ? 0 : ( ( _dataRect.height() - height - sizeFor3DEffect ) / 2 );

        _position = QRect( _dataRect.left() + x, _dataRect.top() + y,
                _size, height );
        //  _position.moveBy( _dataRect.left(), _dataRect.top() );
    }

    double sum = data->rowAbsSum( dataset );
    if( sum==0 ) //nothing to draw
        return;
    double sectorsPerValue = 5760.0 / sum; // 5760 == 16*360, number of sections in Qt circle

    int currentValue = params()->pieStart() * 16;
    bool atLeastOneValue = false; // guard against completely empty tables
    QVariant vValY;
    for ( int value = 0; value < _numValues; value++ ) {
        // is there anything at all at this value
        /* see above for meaning of 16 */

        if( data->cellCoord( dataset, value, vValY, 1 ) &&
            QVariant::Double == vValY.type() ){
            _startAngles[ value ] = currentValue;
            const double cellValue = fabs( vValY.toDouble() );
            _angleLens[ value ] = ( int ) floor( cellValue * sectorsPerValue + 0.5 );
            atLeastOneValue = true;
        } else { // mark as non-existent
            _angleLens[ value ] = 0;
            if ( value > 0 )
                _startAngles[ value ] = _startAngles[ value - 1 ];
            else
                _startAngles[ value ] = currentValue;
        }

        currentValue = _startAngles[ value ] + _angleLens[ value ];
    }

    // If there was no value at all, bail out, to avoid endless loops
    // later on (e.g. in findPieAt()).
    if( !atLeastOneValue )
        return;


    // Find the backmost pie which is at +90° and needs to be drawn
    // first
    int backmostpie = findPieAt( 90 * 16 );
    // Find the frontmost pie (at -90°/+270°) that should be drawn last
    int frontmostpie = findPieAt( 270 * 16 );
    // and put the backmost pie on the TODO stack to initialize it,
    // but only if it is not the frontmostpie
    QValueStack < int > todostack;
    if ( backmostpie != frontmostpie )
        todostack.push( backmostpie );
    else {
        // Otherwise, try to find something else
        int leftOfCurrent = findLeftPie( backmostpie );
        if ( leftOfCurrent != frontmostpie ) {
            todostack.push( leftOfCurrent );
        } else {
            int rightOfCurrent = findRightPie( backmostpie );
            if ( rightOfCurrent != frontmostpie ) {
                todostack.push( rightOfCurrent );
            }
        }
        // If we get here, there was nothing else, and we will bail
        // out of the while loop below.
    }

    // The list with pies that have already been drawn

    QValueList < int > donelist;

    // Draw pies until the todostack is empty or only the frontmost
    // pie is there
    while ( !todostack.isEmpty() &&
            !( ( todostack.count() == 1 ) &&
                ( ( todostack.top() == frontmostpie ) ) ) ) {
        // The while loop cannot be cancelled if frontmostpie is on
        // top of the stack, but this is also backmostpie (can happen
        // when one of the pies covers more than 1/2 of the circle. In
        // this case, we need to find something else to put on the
        // stack to get things going.

        // take one pie from the stack
        int currentpie = todostack.pop();
        // if this pie was already drawn, ignore it
        if ( donelist.find( currentpie ) != donelist.end() )
            continue;

        // If this pie is the frontmost pie, put it back, but at the
        // second position (otherwise, there would be an endless
        // loop). If this pie is the frontmost pie, there must be at
        // least one other pie, otherwise the loop would already have
        // been terminated by the loop condition.
        if ( currentpie == frontmostpie ) {
            Q_ASSERT( !todostack.isEmpty() );
            // QValueStack::exchange() would be nice here...
            int secondpie = todostack.pop();
            if ( currentpie == secondpie )
                // no need to have the second pie twice on the stack,
                // forget about one instance and take the third
                // instead
                if ( todostack.isEmpty() )
                    break; // done anyway
                else
                    secondpie = todostack.pop();
            todostack.push( currentpie );
            todostack.push( secondpie );
            continue;
        }

        // When we get here, we can just draw the pie and proceed.
        drawOnePie( painter, data, dataset, currentpie, chart,
                sizeFor3DEffect,
                regions );

        // Mark the pie just drawn as done.
        donelist.append( currentpie );

        // Now take the pie to the left and to the right, check
        // whether these have not been painted already, and put them
        // on the stack.
        int leftOfCurrent = findLeftPie( currentpie );
        if ( donelist.find( leftOfCurrent ) == donelist.end() )
            todostack.push( leftOfCurrent );
        int rightOfCurrent = findRightPie( currentpie );
        if ( donelist.find( rightOfCurrent ) == donelist.end() )
            todostack.push( rightOfCurrent );
    }

    // now only the frontmost pie is left to draw
    drawOnePie( painter, data, dataset, frontmostpie, chart,
            sizeFor3DEffect,
            regions );
}
CSSValueImpl *CSSComputedStyleDeclarationImpl::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const
{
    NodeImpl *node = m_node.handle();
    if (!node)
        return 0;

    // Make sure our layout is up to date before we allow a query on these attributes.
    DocumentImpl* docimpl = node->getDocument();
    if (docimpl && updateLayout)
        docimpl->updateLayout();

    RenderObject *renderer = node->renderer();
    if (!renderer)
        return 0;
    RenderStyle *style = renderer->style();
    if (!style)
        return 0;

    switch (propertyID)
    {
    case CSS_PROP_BACKGROUND_COLOR:
        return new CSSPrimitiveValueImpl(style->backgroundColor().rgb());
    case CSS_PROP_BACKGROUND_IMAGE:
        if (style->backgroundImage())
            return new CSSPrimitiveValueImpl(style->backgroundImage()->url(), CSSPrimitiveValue::CSS_URI);
        return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
    case CSS_PROP_BACKGROUND_REPEAT:
        switch (style->backgroundRepeat()) {
            case khtml::REPEAT:
                return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT);
            case khtml::REPEAT_X:
                return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT_X);
            case khtml::REPEAT_Y:
                return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT_Y);
            case khtml::NO_REPEAT:
                return new CSSPrimitiveValueImpl(CSS_VAL_NO_REPEAT);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_BACKGROUND_ATTACHMENT:
        if (style->backgroundAttachment())
            return new CSSPrimitiveValueImpl(CSS_VAL_SCROLL);
        else
            return new CSSPrimitiveValueImpl(CSS_VAL_FIXED);
    case CSS_PROP_BACKGROUND_POSITION:
    {
        DOMString string;
        Length length(style->backgroundXPosition());
        if (length.isPercent())
            string = numberAsString(length.length()) + "%";
        else
            string = numberAsString(length.minWidth(renderer->contentWidth()));
        string += " ";
        length = style->backgroundYPosition();
        if (length.isPercent())
            string += numberAsString(length.length()) + "%";
        else
            string += numberAsString(length.minWidth(renderer->contentWidth()));
        return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
    }
    case CSS_PROP_BACKGROUND_POSITION_X:
        return valueForLength(style->backgroundXPosition());
    case CSS_PROP_BACKGROUND_POSITION_Y:
        return valueForLength(style->backgroundYPosition());
#ifndef KHTML_NO_XBL
    case CSS_PROP__KHTML_BINDING:
        // FIXME: unimplemented
        break;
#endif
    case CSS_PROP_BORDER_COLLAPSE:
        if (style->borderCollapse())
            return new CSSPrimitiveValueImpl(CSS_VAL_COLLAPSE);
        else
            return new CSSPrimitiveValueImpl(CSS_VAL_SEPARATE);
    case CSS_PROP_BORDER_SPACING:
    {
        QString string(numberAsString(style->horizontalBorderSpacing()) + 
            "px " + 
            numberAsString(style->verticalBorderSpacing()) +
            "px");
        return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
    }
    case CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING:
        return new CSSPrimitiveValueImpl(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
    case CSS_PROP__KHTML_BORDER_VERTICAL_SPACING:
        return new CSSPrimitiveValueImpl(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
    case CSS_PROP_BORDER_TOP_COLOR:
        return new CSSPrimitiveValueImpl(style->borderLeftColor().rgb());
    case CSS_PROP_BORDER_RIGHT_COLOR:
        return new CSSPrimitiveValueImpl(style->borderRightColor().rgb());
    case CSS_PROP_BORDER_BOTTOM_COLOR:
        return new CSSPrimitiveValueImpl(style->borderBottomColor().rgb());
    case CSS_PROP_BORDER_LEFT_COLOR:
        return new CSSPrimitiveValueImpl(style->borderLeftColor().rgb());
    case CSS_PROP_BORDER_TOP_STYLE:
        return valueForBorderStyle(style->borderTopStyle());
    case CSS_PROP_BORDER_RIGHT_STYLE:
        return valueForBorderStyle(style->borderRightStyle());
    case CSS_PROP_BORDER_BOTTOM_STYLE:
        return valueForBorderStyle(style->borderBottomStyle());
    case CSS_PROP_BORDER_LEFT_STYLE:
        return valueForBorderStyle(style->borderLeftStyle());
    case CSS_PROP_BORDER_TOP_WIDTH:
        return new CSSPrimitiveValueImpl(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX);
    case CSS_PROP_BORDER_RIGHT_WIDTH:
        return new CSSPrimitiveValueImpl(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX);
    case CSS_PROP_BORDER_BOTTOM_WIDTH:
        return new CSSPrimitiveValueImpl(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX);
    case CSS_PROP_BORDER_LEFT_WIDTH:
        return new CSSPrimitiveValueImpl(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX);
    case CSS_PROP_BOTTOM:
        return getPositionOffsetValue(renderer, CSS_PROP_BOTTOM);
    case CSS_PROP__KHTML_BOX_ALIGN:
        switch (style->boxAlign()) {
            case khtml::BSTRETCH:
                return new CSSPrimitiveValueImpl(CSS_VAL_STRETCH);
            case khtml::BSTART:
                return new CSSPrimitiveValueImpl(CSS_VAL_START);
            case khtml::BCENTER:
                return new CSSPrimitiveValueImpl(CSS_VAL_CENTER);
            case khtml::BEND:
                return new CSSPrimitiveValueImpl(CSS_VAL_END);
            case khtml::BBASELINE:
                return new CSSPrimitiveValueImpl(CSS_VAL_BASELINE);
            case khtml::BJUSTIFY:
                break; // not allowed
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP__KHTML_BOX_DIRECTION:
        switch (style->boxDirection()) {
            case khtml::BNORMAL:
                return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
            case khtml::BREVERSE:
                return new CSSPrimitiveValueImpl(CSS_VAL_REVERSE);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP__KHTML_BOX_FLEX:
        return new CSSPrimitiveValueImpl(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
    case CSS_PROP__KHTML_BOX_FLEX_GROUP:
        return new CSSPrimitiveValueImpl(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
    case CSS_PROP__KHTML_BOX_LINES:
        switch (style->boxLines()) {
            case khtml::SINGLE:
                return new CSSPrimitiveValueImpl(CSS_VAL_SINGLE);
            case khtml::MULTIPLE:
                return new CSSPrimitiveValueImpl(CSS_VAL_MULTIPLE);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP__KHTML_BOX_ORDINAL_GROUP:
        return new CSSPrimitiveValueImpl(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
    case CSS_PROP__KHTML_BOX_ORIENT:
        switch (style->boxOrient()) {
            case khtml::HORIZONTAL:
                return new CSSPrimitiveValueImpl(CSS_VAL_HORIZONTAL);
            case khtml::VERTICAL:
                return new CSSPrimitiveValueImpl(CSS_VAL_VERTICAL);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP__KHTML_BOX_PACK:
        switch (style->boxPack()) {
            case khtml::BSTART:
                return new CSSPrimitiveValueImpl(CSS_VAL_START);
            case khtml::BEND:
                return new CSSPrimitiveValueImpl(CSS_VAL_END);
            case khtml::BCENTER:
                return new CSSPrimitiveValueImpl(CSS_VAL_CENTER);
            case khtml::BJUSTIFY:
                return new CSSPrimitiveValueImpl(CSS_VAL_JUSTIFY);
            case khtml::BSTRETCH:
            case khtml::BBASELINE:
                break; // not allowed
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_CAPTION_SIDE:
        switch (style->captionSide()) {
            case khtml::CAPLEFT:
                return new CSSPrimitiveValueImpl(CSS_VAL_LEFT);
            case khtml::CAPRIGHT:
                return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT);
            case khtml::CAPTOP:
                return new CSSPrimitiveValueImpl(CSS_VAL_TOP);
            case khtml::CAPBOTTOM:
                return new CSSPrimitiveValueImpl(CSS_VAL_BOTTOM);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_CLEAR:
        switch (style->clear()) {
            case khtml::CNONE:
                return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
            case khtml::CLEFT:
                return new CSSPrimitiveValueImpl(CSS_VAL_LEFT);
            case khtml::CRIGHT:
                return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT);
            case khtml::CBOTH:
                return new CSSPrimitiveValueImpl(CSS_VAL_BOTH);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_CLIP:
        // FIXME: unimplemented
        break;
    case CSS_PROP_COLOR:
        return new CSSPrimitiveValueImpl(style->color().rgb());
    case CSS_PROP_CONTENT:
        // FIXME: unimplemented
        break;
    case CSS_PROP_COUNTER_INCREMENT:
        // FIXME: unimplemented
        break;
    case CSS_PROP_COUNTER_RESET:
        // FIXME: unimplemented
        break;
    case CSS_PROP_CURSOR:
        switch (style->cursor()) {
            case khtml::CURSOR_AUTO:
                return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
            case khtml::CURSOR_CROSS:
                return new CSSPrimitiveValueImpl(CSS_VAL_CROSSHAIR);
            case khtml::CURSOR_DEFAULT:
                return new CSSPrimitiveValueImpl(CSS_VAL_DEFAULT);
            case khtml::CURSOR_POINTER:
                return new CSSPrimitiveValueImpl(CSS_VAL_POINTER);
            case khtml::CURSOR_MOVE:
                return new CSSPrimitiveValueImpl(CSS_VAL_MOVE);
            case khtml::CURSOR_E_RESIZE:
                return new CSSPrimitiveValueImpl(CSS_VAL_E_RESIZE);
            case khtml::CURSOR_NE_RESIZE:
                return new CSSPrimitiveValueImpl(CSS_VAL_NE_RESIZE);
            case khtml::CURSOR_NW_RESIZE:
                return new CSSPrimitiveValueImpl(CSS_VAL_NW_RESIZE);
            case khtml::CURSOR_N_RESIZE:
                return new CSSPrimitiveValueImpl(CSS_VAL_N_RESIZE);
            case khtml::CURSOR_SE_RESIZE:
                return new CSSPrimitiveValueImpl(CSS_VAL_SE_RESIZE);
            case khtml::CURSOR_SW_RESIZE:
                return new CSSPrimitiveValueImpl(CSS_VAL_SW_RESIZE);
            case khtml::CURSOR_S_RESIZE:
                return new CSSPrimitiveValueImpl(CSS_VAL_S_RESIZE);
            case khtml::CURSOR_W_RESIZE:
                return new CSSPrimitiveValueImpl(CSS_VAL_W_RESIZE);
            case khtml::CURSOR_TEXT:
                return new CSSPrimitiveValueImpl(CSS_VAL_TEXT);
            case khtml::CURSOR_WAIT:
                return new CSSPrimitiveValueImpl(CSS_VAL_WAIT);
            case khtml::CURSOR_HELP:
                return new CSSPrimitiveValueImpl(CSS_VAL_HELP);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_DIRECTION:
        switch (style->direction()) {
            case khtml::LTR:
                return new CSSPrimitiveValueImpl(CSS_VAL_LTR);
            case khtml::RTL:
                return new CSSPrimitiveValueImpl(CSS_VAL_RTL);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_DISPLAY:
        switch (style->display()) {
            case khtml::INLINE:
                return new CSSPrimitiveValueImpl(CSS_VAL_INLINE);
            case khtml::BLOCK:
                return new CSSPrimitiveValueImpl(CSS_VAL_BLOCK);
            case khtml::LIST_ITEM:
                return new CSSPrimitiveValueImpl(CSS_VAL_LIST_ITEM);
            case khtml::RUN_IN:
                return new CSSPrimitiveValueImpl(CSS_VAL_RUN_IN);
            case khtml::COMPACT:
                return new CSSPrimitiveValueImpl(CSS_VAL_COMPACT);
            case khtml::INLINE_BLOCK:
                return new CSSPrimitiveValueImpl(CSS_VAL_INLINE_BLOCK);
            case khtml::TABLE:
                return new CSSPrimitiveValueImpl(CSS_VAL_TABLE);
            case khtml::INLINE_TABLE:
                return new CSSPrimitiveValueImpl(CSS_VAL_INLINE_TABLE);
            case khtml::TABLE_ROW_GROUP:
                return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_ROW_GROUP);
            case khtml::TABLE_HEADER_GROUP:
                return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_HEADER_GROUP);
            case khtml::TABLE_FOOTER_GROUP:
                return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_FOOTER_GROUP);
            case khtml::TABLE_ROW:
                return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_ROW);
            case khtml::TABLE_COLUMN_GROUP:
                return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_COLUMN_GROUP);
            case khtml::TABLE_COLUMN:
                return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_COLUMN);
            case khtml::TABLE_CELL:
                return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_CELL);
            case khtml::TABLE_CAPTION:
                return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_CAPTION);
            case khtml::BOX:
                return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_BOX);
            case khtml::INLINE_BOX:
                return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_INLINE_BOX);
            case khtml::NONE:
                return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_EMPTY_CELLS:
        switch (style->emptyCells()) {
            case khtml::SHOW:
                return new CSSPrimitiveValueImpl(CSS_VAL_SHOW);
            case khtml::HIDE:
                return new CSSPrimitiveValueImpl(CSS_VAL_HIDE);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_FLOAT:
        switch (style->floating()) {
            case khtml::FNONE:
                return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
            case khtml::FLEFT:
                return new CSSPrimitiveValueImpl(CSS_VAL_LEFT);
            case khtml::FRIGHT:
                return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_FONT_FAMILY:
    {
        FontDef def = style->htmlFont().getFontDef();
        return new CSSPrimitiveValueImpl(def.firstFamily().family().domString(), CSSPrimitiveValue::CSS_STRING);
    }
    case CSS_PROP_FONT_SIZE:
    {
        FontDef def = style->htmlFont().getFontDef();
        return new CSSPrimitiveValueImpl(def.specifiedSize, CSSPrimitiveValue::CSS_PX);
    }
    case CSS_PROP_FONT_STRETCH:
        // FIXME: unimplemented
        break;
    case CSS_PROP_FONT_STYLE:
    {
        // FIXME: handle oblique?
        FontDef def = style->htmlFont().getFontDef();
        if (def.italic)
            return new CSSPrimitiveValueImpl(CSS_VAL_ITALIC);
        else
            return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
    }
    case CSS_PROP_FONT_VARIANT:
    {
        FontDef def = style->htmlFont().getFontDef();
        if (def.smallCaps)
            return new CSSPrimitiveValueImpl(CSS_VAL_SMALL_CAPS);
        else
            return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
    }
    case CSS_PROP_FONT_WEIGHT:
    {
        // FIXME: this does not reflect the full range of weights
        // that can be expressed with CSS
        FontDef def = style->htmlFont().getFontDef();
        if (def.weight == QFont::Bold)
            return new CSSPrimitiveValueImpl(CSS_VAL_BOLD);
        else
            return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
    }
    case CSS_PROP_HEIGHT:
        return new CSSPrimitiveValueImpl(renderer->contentHeight(), CSSPrimitiveValue::CSS_PX);
    case CSS_PROP_LEFT:
        return getPositionOffsetValue(renderer, CSS_PROP_LEFT);
    case CSS_PROP_LETTER_SPACING:
        if (style->letterSpacing() == 0)
            return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
        return new CSSPrimitiveValueImpl(style->letterSpacing(), CSSPrimitiveValue::CSS_PX);
    case CSS_PROP__APPLE_LINE_CLAMP:
        return new CSSPrimitiveValueImpl(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE);
    case CSS_PROP_LINE_HEIGHT: {
        Length length(style->lineHeight());
	if (length.value < 0)
            return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
        if (length.isPercent()) {
            // This is imperfect, because it doesn't include the zoom factor and the real computation
            // for how high to be in pixels does include things like minimum font size and the zoom factor.
            // On the other hand, since font-size doesn't include the zoom factor, we really can't do
            // that here either.
            float fontSize = style->htmlFont().getFontDef().specifiedSize;
            return new CSSPrimitiveValueImpl((int)(length.length() * fontSize) / 100, CSSPrimitiveValue::CSS_PX);
        }
        else {
            return new CSSPrimitiveValueImpl(length.length(), CSSPrimitiveValue::CSS_PX);
        }
    }
    case CSS_PROP_LIST_STYLE_IMAGE:
        if (style->listStyleImage())
            return new CSSPrimitiveValueImpl(style->listStyleImage()->url(), CSSPrimitiveValue::CSS_URI);
        return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
    case CSS_PROP_LIST_STYLE_POSITION:
        switch (style->listStylePosition()) {
            case khtml::OUTSIDE:
                return new CSSPrimitiveValueImpl(CSS_VAL_OUTSIDE);
            case khtml::INSIDE:
                return new CSSPrimitiveValueImpl(CSS_VAL_INSIDE);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_LIST_STYLE_TYPE:
        switch (style->listStyleType()) {
            case khtml::LNONE:
                return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
            case khtml::DISC:
                return new CSSPrimitiveValueImpl(CSS_VAL_DISC);
            case khtml::CIRCLE:
                return new CSSPrimitiveValueImpl(CSS_VAL_CIRCLE);
            case khtml::SQUARE:
                return new CSSPrimitiveValueImpl(CSS_VAL_SQUARE);
            case khtml::LDECIMAL:
                return new CSSPrimitiveValueImpl(CSS_VAL_DECIMAL);
            case khtml::DECIMAL_LEADING_ZERO:
                return new CSSPrimitiveValueImpl(CSS_VAL_DECIMAL_LEADING_ZERO);
            case khtml::LOWER_ROMAN:
                return new CSSPrimitiveValueImpl(CSS_VAL_LOWER_ROMAN);
            case khtml::UPPER_ROMAN:
                return new CSSPrimitiveValueImpl(CSS_VAL_UPPER_ROMAN);
            case khtml::LOWER_GREEK:
                return new CSSPrimitiveValueImpl(CSS_VAL_LOWER_GREEK);
            case khtml::LOWER_ALPHA:
                return new CSSPrimitiveValueImpl(CSS_VAL_LOWER_ALPHA);
            case khtml::LOWER_LATIN:
                return new CSSPrimitiveValueImpl(CSS_VAL_LOWER_LATIN);
            case khtml::UPPER_ALPHA:
                return new CSSPrimitiveValueImpl(CSS_VAL_UPPER_ALPHA);
            case khtml::UPPER_LATIN:
                return new CSSPrimitiveValueImpl(CSS_VAL_UPPER_LATIN);
            case khtml::HEBREW:
                return new CSSPrimitiveValueImpl(CSS_VAL_HEBREW);
            case khtml::ARMENIAN:
                return new CSSPrimitiveValueImpl(CSS_VAL_ARMENIAN);
            case khtml::GEORGIAN:
                return new CSSPrimitiveValueImpl(CSS_VAL_GEORGIAN);
            case khtml::CJK_IDEOGRAPHIC:
                return new CSSPrimitiveValueImpl(CSS_VAL_CJK_IDEOGRAPHIC);
            case khtml::HIRAGANA:
                return new CSSPrimitiveValueImpl(CSS_VAL_HIRAGANA);
            case khtml::KATAKANA:
                return new CSSPrimitiveValueImpl(CSS_VAL_KATAKANA);
            case khtml::HIRAGANA_IROHA:
                return new CSSPrimitiveValueImpl(CSS_VAL_HIRAGANA_IROHA);
            case khtml::KATAKANA_IROHA:
                return new CSSPrimitiveValueImpl(CSS_VAL_KATAKANA_IROHA);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_MARGIN_TOP:
        return valueForLength(style->marginTop());
    case CSS_PROP_MARGIN_RIGHT:
        return valueForLength(style->marginRight());
    case CSS_PROP_MARGIN_BOTTOM:
        return valueForLength(style->marginBottom());
    case CSS_PROP_MARGIN_LEFT:
        return valueForLength(style->marginLeft());
    case CSS_PROP__KHTML_MARQUEE:
        // FIXME: unimplemented
        break;
    case CSS_PROP__KHTML_MARQUEE_DIRECTION:
        switch (style->marqueeDirection()) {
            case khtml::MFORWARD:
                return new CSSPrimitiveValueImpl(CSS_VAL_FORWARDS);
            case khtml::MBACKWARD:
                return new CSSPrimitiveValueImpl(CSS_VAL_BACKWARDS);
            case khtml::MAUTO:
                return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
            case khtml::MUP:
                return new CSSPrimitiveValueImpl(CSS_VAL_UP);
            case khtml::MDOWN:
                return new CSSPrimitiveValueImpl(CSS_VAL_DOWN);
            case khtml::MLEFT:
                return new CSSPrimitiveValueImpl(CSS_VAL_LEFT);
            case khtml::MRIGHT:
                return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP__KHTML_MARQUEE_INCREMENT:
        return valueForLength(style->marqueeIncrement());
    case CSS_PROP__KHTML_MARQUEE_REPETITION:
        if (style->marqueeLoopCount() < 0)
            return new CSSPrimitiveValueImpl(CSS_VAL_INFINITE);
        return new CSSPrimitiveValueImpl(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
    case CSS_PROP__KHTML_MARQUEE_SPEED:
        // FIXME: unimplemented
        break;
    case CSS_PROP__KHTML_MARQUEE_STYLE:
        switch (style->marqueeBehavior()) {
            case khtml::MNONE:
                return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
            case khtml::MSCROLL:
                return new CSSPrimitiveValueImpl(CSS_VAL_SCROLL);
            case khtml::MSLIDE:
                return new CSSPrimitiveValueImpl(CSS_VAL_SLIDE);
            case khtml::MALTERNATE:
                return new CSSPrimitiveValueImpl(CSS_VAL_ALTERNATE);
            case khtml::MUNFURL:
                return new CSSPrimitiveValueImpl(CSS_VAL_UNFURL);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP__KHTML_USER_MODIFY:
        switch (style->userModify()) {
            case khtml::READ_ONLY:
                return new CSSPrimitiveValueImpl(CSS_VAL_READ_ONLY);
            case khtml::READ_WRITE:
                return new CSSPrimitiveValueImpl(CSS_VAL_READ_WRITE);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_MAX_HEIGHT:
        return valueForLength(style->maxHeight());
    case CSS_PROP_MAX_WIDTH:
        return valueForLength(style->maxWidth());
    case CSS_PROP_MIN_HEIGHT:
        return valueForLength(style->minHeight());
    case CSS_PROP_MIN_WIDTH:
        return valueForLength(style->minWidth());
    case CSS_PROP_OPACITY:
        return new CSSPrimitiveValueImpl(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
    case CSS_PROP_ORPHANS:
        return new CSSPrimitiveValueImpl(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
    case CSS_PROP_OUTLINE_COLOR:
        // FIXME: unimplemented
        break;
    case CSS_PROP_OUTLINE_OFFSET:
        // FIXME: unimplemented
        break;
    case CSS_PROP_OUTLINE_STYLE:
        if (style->outlineStyleIsAuto())
            return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
        return valueForBorderStyle(style->outlineStyle());
    case CSS_PROP_OUTLINE_WIDTH:
        // FIXME: unimplemented
        break;
    case CSS_PROP_OVERFLOW:
        switch (style->overflow()) {
            case khtml::OVISIBLE:
                return new CSSPrimitiveValueImpl(CSS_VAL_VISIBLE);
            case khtml::OHIDDEN:
                return new CSSPrimitiveValueImpl(CSS_VAL_HIDDEN);
            case khtml::OSCROLL:
                return new CSSPrimitiveValueImpl(CSS_VAL_SCROLL);
            case khtml::OAUTO:
                return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
            case khtml::OMARQUEE:
                return new CSSPrimitiveValueImpl(CSS_VAL_MARQUEE);
            case khtml::OOVERLAY:
                return new CSSPrimitiveValueImpl(CSS_VAL_OVERLAY);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_PADDING_TOP:
        return valueForLength(style->paddingTop());
    case CSS_PROP_PADDING_RIGHT:
        return valueForLength(style->paddingRight());
    case CSS_PROP_PADDING_BOTTOM:
        return valueForLength(style->paddingBottom());
    case CSS_PROP_PADDING_LEFT:
        return valueForLength(style->paddingLeft());
    case CSS_PROP_PAGE:
        // FIXME: unimplemented
        break;
    case CSS_PROP_PAGE_BREAK_AFTER:
        switch (style->pageBreakAfter()) {
            case khtml::PBAUTO:
                return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
            case khtml::PBALWAYS:
                return new CSSPrimitiveValueImpl(CSS_VAL_ALWAYS);
            case khtml::PBAVOID:
                return new CSSPrimitiveValueImpl(CSS_VAL_AVOID);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_PAGE_BREAK_BEFORE:
        switch (style->pageBreakBefore()) {
            case khtml::PBAUTO:
                return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
            case khtml::PBALWAYS:
                return new CSSPrimitiveValueImpl(CSS_VAL_ALWAYS);
            case khtml::PBAVOID:
                return new CSSPrimitiveValueImpl(CSS_VAL_AVOID);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_PAGE_BREAK_INSIDE:
        switch (style->pageBreakInside()) {
            case khtml::PBAUTO:
                return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
            case khtml::PBAVOID:
                return new CSSPrimitiveValueImpl(CSS_VAL_AVOID);
            case khtml::PBALWAYS:
                break; // not allowed
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_POSITION:
        switch (style->position()) {
            case khtml::STATIC:
                return new CSSPrimitiveValueImpl(CSS_VAL_STATIC);
            case khtml::RELATIVE:
                return new CSSPrimitiveValueImpl(CSS_VAL_RELATIVE);
            case khtml::ABSOLUTE:
                return new CSSPrimitiveValueImpl(CSS_VAL_ABSOLUTE);
            case khtml::FIXED:
                return new CSSPrimitiveValueImpl(CSS_VAL_FIXED);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_QUOTES:
        // FIXME: unimplemented
        break;
    case CSS_PROP_RIGHT:
        return getPositionOffsetValue(renderer, CSS_PROP_RIGHT);
    case CSS_PROP_SIZE:
        // FIXME: unimplemented
        break;
    case CSS_PROP_TABLE_LAYOUT:
        switch (style->tableLayout()) {
            case khtml::TAUTO:
                return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
            case khtml::TFIXED:
                return new CSSPrimitiveValueImpl(CSS_VAL_FIXED);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_TEXT_ALIGN:
        return valueForTextAlign(style->textAlign());
    case CSS_PROP_TEXT_DECORATION:
    {
        QString string;
        if (style->textDecoration() & khtml::UNDERLINE)
            string += "underline";
        if (style->textDecoration() & khtml::OVERLINE) {
            if (string.length() > 0)
                string += " ";
            string += "overline";
        }
        if (style->textDecoration() & khtml::LINE_THROUGH) {
            if (string.length() > 0)
                string += " ";
            string += "line-through";
        }
        if (style->textDecoration() & khtml::BLINK) {
            if (string.length() > 0)
                string += " ";
            string += "blink";
        }
        if (string.length() == 0)
            return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
        return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
    }
    case CSS_PROP__KHTML_TEXT_DECORATIONS_IN_EFFECT:
    {
        QString string;
        if (style->textDecorationsInEffect() & khtml::UNDERLINE)
            string += "underline";
        if (style->textDecorationsInEffect() & khtml::OVERLINE) {
            if (string.length() > 0)
                string += " ";
            string += "overline";
        }
        if (style->textDecorationsInEffect() & khtml::LINE_THROUGH) {
            if (string.length() > 0)
                string += " ";
            string += "line-through";
        }
        if (style->textDecorationsInEffect() & khtml::BLINK) {
            if (string.length() > 0)
                string += " ";
            string += "blink";
        }
        if (string.length() == 0)
            return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
        return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
    }
    case CSS_PROP_TEXT_INDENT:
        return valueForLength(style->textIndent());
    case CSS_PROP_TEXT_SHADOW:
        return valueForShadow(style->textShadow());
    case CSS_PROP__APPLE_TEXT_SIZE_ADJUST:
        if (style->textSizeAdjust()) 
            return new CSSPrimitiveValueImpl(CSS_VAL_AUTO);
        else
            return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
    case CSS_PROP_TEXT_TRANSFORM:
        switch (style->textTransform()) {
            case khtml::CAPITALIZE:
                return new CSSPrimitiveValueImpl(CSS_VAL_CAPITALIZE);
            case khtml::UPPERCASE:
                return new CSSPrimitiveValueImpl(CSS_VAL_UPPERCASE);
            case khtml::LOWERCASE:
                return new CSSPrimitiveValueImpl(CSS_VAL_LOWERCASE);
            case khtml::TTNONE:
                return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_TOP:
        return getPositionOffsetValue(renderer, CSS_PROP_TOP);
    case CSS_PROP_UNICODE_BIDI:
        switch (style->unicodeBidi()) {
            case khtml::UBNormal:
                return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
            case khtml::Embed:
                return new CSSPrimitiveValueImpl(CSS_VAL_EMBED);
            case khtml::Override:
                return new CSSPrimitiveValueImpl(CSS_VAL_BIDI_OVERRIDE);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_VERTICAL_ALIGN:
        switch (style->verticalAlign()) {
            case khtml::BASELINE:
                return new CSSPrimitiveValueImpl(CSS_VAL_BASELINE);
            case khtml::MIDDLE:
                return new CSSPrimitiveValueImpl(CSS_VAL_MIDDLE);
            case khtml::SUB:
                return new CSSPrimitiveValueImpl(CSS_VAL_SUB);
            case khtml::SUPER:
                return new CSSPrimitiveValueImpl(CSS_VAL_SUPER);
            case khtml::TEXT_TOP:
                return new CSSPrimitiveValueImpl(CSS_VAL_TEXT_TOP);
            case khtml::TEXT_BOTTOM:
                return new CSSPrimitiveValueImpl(CSS_VAL_TEXT_BOTTOM);
            case khtml::TOP:
                return new CSSPrimitiveValueImpl(CSS_VAL_TOP);
            case khtml::BOTTOM:
                return new CSSPrimitiveValueImpl(CSS_VAL_BOTTOM);
            case khtml::BASELINE_MIDDLE:
                return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_BASELINE_MIDDLE);
            case khtml::LENGTH:
                return valueForLength(style->verticalAlignLength());
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_VISIBILITY:
        switch (style->visibility()) {
            case khtml::VISIBLE:
                return new CSSPrimitiveValueImpl(CSS_VAL_VISIBLE);
            case khtml::HIDDEN:
                return new CSSPrimitiveValueImpl(CSS_VAL_HIDDEN);
            case khtml::COLLAPSE:
                return new CSSPrimitiveValueImpl(CSS_VAL_COLLAPSE);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_WHITE_SPACE:
        switch (style->whiteSpace()) {
            case khtml::NORMAL:
                return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
            case khtml::PRE:
                return new CSSPrimitiveValueImpl(CSS_VAL_PRE);
            case khtml::NOWRAP:
                return new CSSPrimitiveValueImpl(CSS_VAL_NOWRAP);
            case khtml::KHTML_NOWRAP:
                return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_NOWRAP);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_WIDOWS:
        return new CSSPrimitiveValueImpl(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
    case CSS_PROP_WIDTH:
        return new CSSPrimitiveValueImpl(renderer->contentWidth(), CSSPrimitiveValue::CSS_PX);
    case CSS_PROP_WORD_SPACING:
        return new CSSPrimitiveValueImpl(style->wordSpacing(), CSSPrimitiveValue::CSS_PX);
    case CSS_PROP_WORD_WRAP:
        switch (style->wordWrap()) {
            case khtml::WBNORMAL:
                return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
            case khtml::BREAK_WORD:
                return new CSSPrimitiveValueImpl(CSS_VAL_BREAK_WORD);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP__KHTML_LINE_BREAK:
        switch (style->khtmlLineBreak()) {
            case khtml::LBNORMAL:
                return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
            case khtml::AFTER_WHITE_SPACE:
                return new CSSPrimitiveValueImpl(CSS_VAL_AFTER_WHITE_SPACE);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP__KHTML_NBSP_MODE:
        switch (style->nbspMode()) {
            case khtml::NBNORMAL:
                return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
            case khtml::SPACE:
                return new CSSPrimitiveValueImpl(CSS_VAL_SPACE);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP__KHTML_MATCH_NEAREST_MAIL_BLOCKQUOTE_COLOR:
        switch (style->matchNearestMailBlockquoteColor()) {
            case khtml::BCNORMAL:
                return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
            case khtml::MATCH:
                return new CSSPrimitiveValueImpl(CSS_VAL_MATCH);
        }
        ASSERT_NOT_REACHED();
        return 0;
    case CSS_PROP_Z_INDEX:
        if (style->hasAutoZIndex())
            return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
        return new CSSPrimitiveValueImpl(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
    case CSS_PROP_BACKGROUND:
        // FIXME: unimplemented
        break;
    case CSS_PROP_BORDER:
        // FIXME: unimplemented
        break;
    case CSS_PROP_BORDER_COLOR:
        // FIXME: unimplemented
        break;
    case CSS_PROP_BORDER_STYLE:
        // FIXME: unimplemented
        break;
    case CSS_PROP_BORDER_TOP:
        // FIXME: unimplemented
        break;
    case CSS_PROP_BORDER_RIGHT:
        // FIXME: unimplemented
        break;
    case CSS_PROP_BORDER_BOTTOM:
        // FIXME: unimplemented
        break;
    case CSS_PROP_BORDER_LEFT:
        // FIXME: unimplemented
        break;
    case CSS_PROP_BORDER_WIDTH:
        // FIXME: unimplemented
        break;
    case CSS_PROP_FONT:
        // FIXME: unimplemented
        break;
    case CSS_PROP_LIST_STYLE:
        // FIXME: unimplemented
        break;
    case CSS_PROP_MARGIN:
        // FIXME: unimplemented
        break;
    case CSS_PROP_OUTLINE:
        // FIXME: unimplemented
        break;
    case CSS_PROP_PADDING:
        // FIXME: unimplemented
        break;
#if !APPLE_CHANGES
    case CSS_PROP_SCROLLBAR_FACE_COLOR:
        // FIXME: unimplemented
        break;
    case CSS_PROP_SCROLLBAR_SHADOW_COLOR:
        // FIXME: unimplemented
        break;
    case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:
        // FIXME: unimplemented
        break;
    case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR:
        // FIXME: unimplemented
        break;
    case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR:
        // FIXME: unimplemented
        break;
    case CSS_PROP_SCROLLBAR_TRACK_COLOR:
        // FIXME: unimplemented
        break;
    case CSS_PROP_SCROLLBAR_ARROW_COLOR:
        // FIXME: unimplemented
        break;
#endif
#if APPLE_CHANGES
        case CSS_PROP__APPLE_DASHBOARD_REGION: {
            QValueList<StyleDashboardRegion> regions = style->dashboardRegions();
            uint i, count = regions.count();
            if (count == 1 && regions[0].type == StyleDashboardRegion::None)
                return new CSSPrimitiveValueImpl (CSS_VAL_NONE);
                
            DashboardRegionImpl *firstRegion = new DashboardRegionImpl(), *region;
            region = firstRegion;
            for (i = 0; i < count; i++) {
                StyleDashboardRegion styleRegion = regions[i];
                region->m_label = styleRegion.label;
                LengthBox offset = styleRegion.offset;
                region->setTop (new CSSPrimitiveValueImpl(offset.top.value, CSSPrimitiveValue::CSS_PX));
                region->setRight (new CSSPrimitiveValueImpl(offset.right.value, CSSPrimitiveValue::CSS_PX));
                region->setBottom (new CSSPrimitiveValueImpl(offset.bottom.value, CSSPrimitiveValue::CSS_PX));
                region->setLeft (new CSSPrimitiveValueImpl(offset.left.value, CSSPrimitiveValue::CSS_PX));
                region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle); 
                region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
                if (i != count-1) {
                    DashboardRegionImpl *newRegion = new DashboardRegionImpl();
                    region->setNext (newRegion);
                    region = newRegion;
                }
            }
            return new CSSPrimitiveValueImpl(firstRegion);
        }
#endif
    }

    ERROR("unimplemented propertyID: %d", propertyID);
    return 0;
}
Exemplo n.º 24
0
	void ChunkManager::downloadPriorityChanged(TorrentFile* tf,Priority newpriority,Priority oldpriority)
	{
		if (newpriority == EXCLUDED)
		{
			downloadStatusChanged(tf, false);
			return;
		}
		if (oldpriority == EXCLUDED)
		{
			downloadStatusChanged(tf, true);
			return;
		}

		savePriorityInfo();
		
		Uint32 first = tf->getFirstChunk();
		Uint32 last = tf->getLastChunk();
		
		// first and last chunk may be part of multiple files
		// so we can't just exclude them
		QValueList<Uint32> files;

		// get list of files where first chunk lies in
		tor.calcChunkPos(first,files);
		
		Chunk* c = chunks[first];
		// if one file in the list needs to be downloaded,increment first
		for (QValueList<Uint32>::iterator i = files.begin();i != files.end();i++)
		{
			Priority np = tor.getFile(*i).getPriority();
			if (np > newpriority && *i != tf->getIndex())
			{
				// make sure we don't go past last
				if (first == last)
					return;
					
				first++;
				break;
			}
		}
		
		files.clear();
		// get list of files where last chunk lies in
		tor.calcChunkPos(last,files);
		c = chunks[last];
		// if one file in the list needs to be downloaded,decrement last
		for (QValueList<Uint32>::iterator i = files.begin();i != files.end();i++)
		{
			Priority np = tor.getFile(*i).getPriority();
			if (np > newpriority && *i != tf->getIndex())
			{
				// make sure we don't wrap around
				if (last == 0 || last == first)
					return;
					
				last--;
				break;
			}
		}
		
		// last smaller then first is not normal, so just return
		if (last < first)
		{
			return;
		}
		

		prioritise(first,last,newpriority);
		if (newpriority == ONLY_SEED_PRIORITY)
			excluded(first,last);
	}
Exemplo n.º 25
0
void KNewAccountDlg::okClicked()
{
  MyMoneyFile* file = MyMoneyFile::instance();

  QString accountNameText = accountNameEdit->text();
  if (accountNameText.isEmpty())
  {
    KMessageBox::error(this, i18n("You have not specified a name.\nPlease fill in this field."));
    accountNameEdit->setFocus();
    return;
  }

  MyMoneyAccount parent = parentAccount();
  if (parent.name().length() == 0)
  {
    KMessageBox::error(this, i18n("Please select a parent account."));
    return;
  }

  if (!m_categoryEditor)
  {
    QString institutionNameText = m_qcomboboxInstitutions->currentText();
    if (institutionNameText != i18n("<No Institution>"))
    {
      try
      {
        MyMoneyFile *file = MyMoneyFile::instance();

        QValueList<MyMoneyInstitution> list = file->institutionList();
        QValueList<MyMoneyInstitution>::ConstIterator institutionIterator;
        for (institutionIterator = list.begin(); institutionIterator != list.end(); ++institutionIterator)
        {
          if ((*institutionIterator).name() == institutionNameText)
            m_account.setInstitutionId((*institutionIterator).id());
        }
      }
      catch (MyMoneyException *e)
      {
        qDebug("Exception in account institution set: %s", e->what().latin1());
        delete e;
      }
    }
    else
    {
      m_account.setInstitutionId(QString());
    }
  }

  m_account.setName(accountNameText);
  m_account.setNumber(accountNoEdit->text());
  storeKVP("iban", ibanEdit);
  storeKVP("minBalanceAbsolute", m_minBalanceAbsoluteEdit);
  storeKVP("minBalanceEarly", m_minBalanceEarlyEdit);

  // the figures for credit line with reversed sign
  if(!m_maxCreditAbsoluteEdit->lineedit()->text().isEmpty())
    m_maxCreditAbsoluteEdit->setValue(m_maxCreditAbsoluteEdit->value()*MyMoneyMoney(-1,1));
  if(!m_maxCreditEarlyEdit->lineedit()->text().isEmpty())
    m_maxCreditEarlyEdit->setValue(m_maxCreditEarlyEdit->value()*MyMoneyMoney(-1,1));
  storeKVP("maxCreditAbsolute", m_maxCreditAbsoluteEdit);
  storeKVP("maxCreditEarly", m_maxCreditEarlyEdit);
  if(!m_maxCreditAbsoluteEdit->lineedit()->text().isEmpty())
    m_maxCreditAbsoluteEdit->setValue(m_maxCreditAbsoluteEdit->value()*MyMoneyMoney(-1,1));
  if(!m_maxCreditEarlyEdit->lineedit()->text().isEmpty())
    m_maxCreditEarlyEdit->setValue(m_maxCreditEarlyEdit->value()*MyMoneyMoney(-1,1));

  storeKVP("lastNumberUsed", m_lastCheckNumberUsed);
  // delete a previous version of the minimumbalance information
  storeKVP("minimumBalance", QString(), QString());

  MyMoneyAccount::accountTypeE acctype;
  if (!m_categoryEditor)
  {
    acctype = KMyMoneyUtils::stringToAccountType(typeCombo->currentText());
    // If it's a loan, check if the parent is asset or liability. In
    // case of asset, we change the account type to be AssetLoan
    if(acctype == MyMoneyAccount::Loan
    && parent.accountGroup() == MyMoneyAccount::Asset)
      acctype = MyMoneyAccount::AssetLoan;

#if 0
    // we do allow the same name for different accounts, so
    // we don't need this check anymore.
    if(!file->nameToAccount(accountNameText).isEmpty()
    && (file->nameToAccount(accountNameText) != m_account.id())) {
      KMessageBox::error(this, QString("<qt>")+i18n("An account named <b>%1</b> already exists. You cannot create a second account with the same name.").arg(accountNameText)+QString("</qt>"));
      return;
    }
#endif
  }
  else
  {
    acctype = parent.accountGroup();
    QString newName;
    if(!MyMoneyFile::instance()->isStandardAccount(parent.id())) {
      newName = MyMoneyFile::instance()->accountToCategory(parent.id()) + MyMoneyFile::AccountSeperator;
    }
    newName += accountNameText;
    if(!file->categoryToAccount(newName, acctype).isEmpty()
    && (file->categoryToAccount(newName, acctype) != m_account.id())) {
      KMessageBox::error(this, QString("<qt>")+i18n("A category named <b>%1</b> already exists. You cannot create a second category with the same name.").arg(newName)+QString("</qt>"));
      return;
    }
  }
  m_account.setAccountType(acctype);

  m_account.setDescription(descriptionEdit->text());

  if (!m_categoryEditor)
  {
    m_account.setOpeningDate(startDateEdit->date());
    m_account.setCurrencyId(m_currency->security().id());

    if(m_qcheckboxPreferred->isChecked())
      m_account.setValue("PreferredAccount", "Yes");
    else
      m_account.deletePair("PreferredAccount");
    if(m_qcheckboxNoVat->isChecked())
      m_account.setValue("NoVat", "Yes");
    else
      m_account.deletePair("NoVat");

    if(m_minBalanceAbsoluteEdit->isVisible()) {
      m_account.setValue("minimumBalance", m_minBalanceAbsoluteEdit->value().toString());
    }
  }
  else
  {
    if(KMyMoneyGlobalSettings::hideUnusedCategory() && !m_isEditing) {
      KMessageBox::information(this, i18n("You have selected to suppress the display of unused categories in the KMyMoney configuration dialog. The category you just created will therefore only be shown if it is used. Otherwise, it will be hidden in the accounts/categories view."), i18n("Hidden categories"), "NewHiddenCategory");
    }
  }

  if ( m_qcheckboxTax->isChecked())
    m_account.setValue("Tax", "Yes");
  else
    m_account.deletePair("Tax");

  m_account.deletePair("VatAccount");
  m_account.deletePair("VatAmount");
  m_account.deletePair("VatRate");

  if(m_vatCategory->isChecked()) {
    m_account.setValue("VatRate", (m_vatRate->value().abs() / MyMoneyMoney(100,1)).toString());
  } else {
    if(m_vatAssignment->isChecked()) {
      m_account.setValue("VatAccount", m_vatAccount->selectedItems().first());
      if(m_netAmount->isChecked())
        m_account.setValue("VatAmount", "Net");
    }
  }

  accept();
}
Exemplo n.º 26
0
/*!
    Constructs a single key from the string \str.
 */
int QKeySequence::decodeString( const QString& str )
{
    int ret = 0;
    QString accel = str;

    QValueList<ModifKeyName> modifs;
#ifdef QMAC_CTRL
    modifs << ModifKeyName( CTRL, QMAC_CTRL );
#endif
#ifdef QMAC_ALT
    modifs << ModifKeyName( ALT, QMAC_ALT );
#endif
#ifdef QMAC_META
    modifs << ModifKeyName( META, QMAC_META );
#endif
#ifdef QMAC_SHIFT
    modifs << ModifKeyName( SHIFT, QMAC_SHIFT );
#endif
    modifs << ModifKeyName( CTRL, "ctrl+" ) << ModifKeyName( CTRL, QAccel::tr("Ctrl").lower().append('+') );
    modifs << ModifKeyName( SHIFT, "shift+" ) << ModifKeyName( SHIFT, QAccel::tr("Shift").lower().append('+') );
    modifs << ModifKeyName( ALT, "alt+" ) << ModifKeyName( ALT, QAccel::tr("Alt").lower().append('+') );
    modifs << ModifKeyName( META, "meta+" ) << ModifKeyName( ALT, QAccel::tr("Meta").lower().append('+') );
    QString sl = accel.lower();
    for( QValueList<ModifKeyName>::iterator it = modifs.begin(); it != modifs.end(); ++it ) {
        if ( sl.contains( (*it).name ) ) {
            ret |= (*it).qt_key;
#ifndef QT_NO_REGEXP
            accel.remove( QRegExp(QRegExp::escape((*it).name), FALSE) );
#else
            accel.remove( (*it).name );
#endif
            sl = accel.lower();
        }
    }

    int p = accel.findRev( '+', str.length() - 2 ); // -2 so that Ctrl++ works
    if( p > 0 )
        accel = accel.mid( p + 1 );

    int fnum = 0;
    if ( accel.length() == 1 ) {
        char ltr = accel[0].upper().latin1();
        // We can only upper A-Z without problems.
        if ( ltr < (char)Key_A || ltr > (char)Key_Z )
            ret |= accel[0].unicode();
        else
            ret |= accel[0].upper().unicode();
        ret |= UNICODE_ACCEL;
    } else if ( accel[0] == 'F' && (fnum = accel.mid(1).toInt()) && (fnum >= 1) && (fnum <= 35) ) {
        ret |= Key_F1 + fnum - 1;
    } else {
        // Check through translation table for the correct key name
        // ...or fall back on english table.
        bool found = FALSE;
        for ( int tran = 0; tran < 2; tran++ ) {
            for ( int i = 0; keyname[i].name; i++ ) {
                if ( tran ? accel == QAccel::tr(keyname[i].name)
                        : accel == keyname[i].name ) {
                    ret |= keyname[i].key;
                    found = TRUE;
                    break;
                }
            }
            if(found)
                break;
        }
    }
    return ret;
}
Exemplo n.º 27
0
static void createDescription( const QValueList<Widget> &l, QTextStream &ts )
{
    int indent = 0;
    ts << "<!DOCTYPE CW><CW>" << endl;
    ts << makeIndent( indent ) << "<customwidgets>" << endl;
    indent++;

    for ( QValueList<Widget>::ConstIterator it = l.begin(); it != l.end(); ++it ) {
	Widget w = *it;
	ts << makeIndent( indent ) << "<customwidget>" << endl;
	indent++;
	ts << makeIndent( indent ) << "<class>" << w.w->className() << "</class>" << endl;
	ts << makeIndent( indent ) << "<header location=\"" << w.location << "\">" << w.include << "</header>" << endl;
	ts << makeIndent( indent ) << "<sizehint>" << endl;
	indent++;
	ts << makeIndent( indent ) << "<width>" << w.w->sizeHint().width() << "</width>" << endl;
	ts << makeIndent( indent ) << "<height>" << w.w->sizeHint().height() << "</height>" << endl;
	indent--;
	ts << makeIndent( indent ) << "</sizehint>" << endl;
	ts << makeIndent( indent ) << "<container>" << ( w.w->inherits( "QGroupBox" ) || w.w->inherits( "QWidgetStack" ) ) << "</container>" << endl;
	ts << makeIndent( indent ) << "<sizepolicy>" << endl;
	indent++;
	ts << makeIndent( indent ) << "<hordata>" << (int)w.w->sizePolicy().horData() << "</hordata>" << endl;
	ts << makeIndent( indent ) << "<verdata>" << (int)w.w->sizePolicy().verData() << "</verdata>" << endl;
	indent--;
	ts << makeIndent( indent ) << "</sizepolicy>" << endl;
	
	QStrList sigs = w.w->metaObject()->signalNames( TRUE );
	if ( !sigs.isEmpty() ) {
	    for ( int i = 0; i < (int)sigs.count(); ++i )
		ts << makeIndent( indent ) << "<signal>" << entitize( sigs.at( i ) ) << "</signal>" << endl;
	}
	QStrList slts = w.w->metaObject()->slotNames( TRUE );
	if ( !slts.isEmpty() ) {
	    for ( int i = 0; i < (int)slts.count(); ++i ) {
		QMetaData::Access data = w.w->metaObject()->slot( i, TRUE )->access;
		if ( data == QMetaData::Private )
		    continue;
		ts << makeIndent( indent ) << "<slot access=\""
		   << ( data == QMetaData::Protected ? "protected" : "public" )
		   << "\">" << entitize( slts.at( i ) ) << "</slot>" << endl;
	    }
	}	
	QStrList props = w.w->metaObject()->propertyNames( TRUE );
	if ( !props.isEmpty() ) {
	    for ( int i = 0; i < (int)props.count(); ++i ) {
		const QMetaProperty *p = w.w->metaObject()->
					 property( w.w->metaObject()->
						   findProperty( props.at( i ), TRUE ), TRUE );
		if ( !p )
		    continue;
		if ( !p->writable() || !p->designable( w.w ) )
		    continue;
		ts << makeIndent( indent ) << "<property type=\"" << convert_type( p->type() ) << "\">" << entitize( p->name() ) << "</property>" << endl;
	    }
	}
	indent--;
	ts << makeIndent( indent ) << "</customwidget>" << endl;
    }

    indent--;
    ts << makeIndent( indent ) << "</customwidgets>" << endl;
    ts << "</CW>" << endl;
}
Exemplo n.º 28
0
void Incidence::setRecurrence(KCal::Recurrence *recur)
{
    mRecurrence.interval = recur->frequency();
    switch(recur->recurrenceType())
    {
    case KCal::Recurrence::rMinutely: // Not handled by the kolab XML
        mRecurrence.cycle = "minutely";
        break;
    case KCal::Recurrence::rHourly:  // Not handled by the kolab XML
        mRecurrence.cycle = "hourly";
        break;
    case KCal::Recurrence::rDaily:
        mRecurrence.cycle = "daily";
        break;
    case KCal::Recurrence::rWeekly: // every X weeks
        mRecurrence.cycle = "weekly";
        {
            QBitArray arr = recur->days();
            for(uint idx = 0 ; idx < 7 ; ++idx)
                if(arr.testBit(idx))
                    mRecurrence.days.append(s_weekDayName[idx]);
        }
        break;
    case KCal::Recurrence::rMonthlyPos:
    {
        mRecurrence.cycle = "monthly";
        mRecurrence.type = "weekday";
        QValueList<KCal::RecurrenceRule::WDayPos> monthPositions = recur->monthPositions();
        if(!monthPositions.isEmpty())
        {
            KCal::RecurrenceRule::WDayPos monthPos = monthPositions.first();
            // TODO: Handle multiple days in the same week
            mRecurrence.dayNumber = QString::number(monthPos.pos());
            mRecurrence.days.append(s_weekDayName[ monthPos.day() - 1 ]);
            // Not (properly) handled(?): monthPos.negative (nth days before end of month)
        }
        break;
    }
    case KCal::Recurrence::rMonthlyDay:
    {
        mRecurrence.cycle = "monthly";
        mRecurrence.type = "daynumber";
        QValueList<int> monthDays = recur->monthDays();
        // ####### Kolab XML limitation: only the first month day is used
        if(!monthDays.isEmpty())
            mRecurrence.dayNumber = QString::number(monthDays.first());
        break;
    }
    case KCal::Recurrence::rYearlyMonth: // (day n of Month Y)
    {
        mRecurrence.cycle = "yearly";
        mRecurrence.type = "monthday";
        QValueList<int> rmd = recur->yearDates();
        int day = !rmd.isEmpty() ? rmd.first() : recur->startDate().day();
        mRecurrence.dayNumber = QString::number(day);
        QValueList<int> months = recur->yearMonths();
        if(!months.isEmpty())
            mRecurrence.month = s_monthName[ months.first() - 1 ]; // #### Kolab XML limitation: only one month specified
        break;
    }
    case KCal::Recurrence::rYearlyDay: // YearlyDay (day N of the year). Not supported by Outlook
        mRecurrence.cycle = "yearly";
        mRecurrence.type = "yearday";
        mRecurrence.dayNumber = QString::number(recur->yearDays().first());
        break;
    case KCal::Recurrence::rYearlyPos: // (weekday X of week N of month Y)
        mRecurrence.cycle = "yearly";
        mRecurrence.type = "weekday";
        QValueList<int> months = recur->yearMonths();
        if(!months.isEmpty())
            mRecurrence.month = s_monthName[ months.first() - 1 ]; // #### Kolab XML limitation: only one month specified
        QValueList<KCal::RecurrenceRule::WDayPos> monthPositions = recur->yearPositions();
        if(!monthPositions.isEmpty())
        {
            KCal::RecurrenceRule::WDayPos monthPos = monthPositions.first();
            // TODO: Handle multiple days in the same week
            mRecurrence.dayNumber = QString::number(monthPos.pos());
            mRecurrence.days.append(s_weekDayName[ monthPos.day() - 1 ]);

            //mRecurrence.dayNumber = QString::number( *recur->yearNums().getFirst() );
            // Not handled: monthPos.negative (nth days before end of month)
        }
        break;
    }
    int howMany = recur->duration();
    if(howMany > 0)
    {
        mRecurrence.rangeType = "number";
        mRecurrence.range = QString::number(howMany);
    }
    else if(howMany == 0)
    {
        mRecurrence.rangeType = "date";
        mRecurrence.range = dateToString(recur->endDate());
    }
    else
    {
        mRecurrence.rangeType = "none";
    }
}
Exemplo n.º 29
0
void IRCUserContact::updateStatus()
{
	//kdDebug(14120) << k_funcinfo << endl;

        Kopete::OnlineStatus newStatus;

	switch (kircEngine()->status())
	{
		case KIRC::Engine::Idle:
			newStatus = m_protocol->m_UserStatusOffline;
			break;

		case KIRC::Engine::Connecting:
		case KIRC::Engine::Authentifying:
			if (this == ircAccount()->mySelf())
				newStatus = m_protocol->m_UserStatusConnecting;
			else
				newStatus = m_protocol->m_UserStatusOffline;
			break;

		case KIRC::Engine::Connected:
		case KIRC::Engine::Closing:
			if (mInfo.away)
				newStatus = m_protocol->m_UserStatusAway;
			else if (mInfo.online)
				newStatus = m_protocol->m_UserStatusOnline;
			break;

		default:
			newStatus = m_protocol->m_StatusUnknown;
	}

	// Try hard not to emit several onlineStatusChanged() signals.
	bool onlineStatusChanged = false;


	/* The away status is global, so if the user goes away, we must set
	 * the new status on all channels.
	 */


	// This may not be created yet ( for myself() on startup )
	if( ircAccount()->contactManager() )
	{
		QValueList<IRCChannelContact*> channels = ircAccount()->contactManager()->findChannelsByMember(this);

		for( QValueList<IRCChannelContact*>::iterator it = channels.begin(); it != channels.end(); ++it )
		{
			IRCChannelContact *channel = *it;
			Kopete::OnlineStatus currentStatus = channel->manager()->contactOnlineStatus(this);

			//kdDebug(14120) << k_funcinfo << "iterating channel " << channel->nickName() << " internal status: " << currentStatus.internalStatus() << endl;

			if( currentStatus.internalStatus() >= IRCProtocol::Online )
			{
				onlineStatusChanged = true;

				if( !(currentStatus.internalStatus() & IRCProtocol::Away) && newStatus == m_protocol->m_UserStatusAway )
				{
					setOnlineStatus( newStatus );
					//kdDebug(14120) << k_funcinfo << "was NOT away, but is now, channel " << channel->nickName() << endl;
					adjustInternalOnlineStatusBits(channel, IRCProtocol::Away, AddBits);
				}
				else if( (currentStatus.internalStatus() & IRCProtocol::Away) && newStatus == m_protocol->m_UserStatusOnline )
				{
					setOnlineStatus( newStatus );
					//kdDebug(14120) << k_funcinfo << "was away, but not anymore, channel " << channel->nickName() << endl;
					adjustInternalOnlineStatusBits(channel, IRCProtocol::Away, RemoveBits);

				}
				else if( newStatus.internalStatus() < IRCProtocol::Away )
				{
					//kdDebug(14120) << k_funcinfo << "offline or connecting?" << endl;
					channel->manager()->setContactOnlineStatus( this, newStatus );
				}
			}
		}
	}

	if (!onlineStatusChanged) {
		//kdDebug(14120) << k_funcinfo << "setting status at last" << endl;
		setOnlineStatus( newStatus );
	}
}
Exemplo n.º 30
0
/*!
   Reset color and fonts of a plot
   \sa apply()
*/
void QwtPlotPrintFilter::reset(QwtPlot *plot) const
{
    if ( d_data->cache == 0 )
        return;

    const bool doAutoReplot = plot->autoReplot();
    plot->setAutoReplot(false);

    const PrivateData::Cache &cache = *d_data->cache;

    if ( plot->titleLabel() )
    {
        QwtTextLabel* title = plot->titleLabel();
        if ( title->text().testPaintAttribute(QwtText::PaintUsingTextFont) )
        {
            QwtText text = title->text();
            text.setColor(cache.titleColor);
            title->setText(text);
        }
        else
        {
            QPalette palette = title->palette();
            palette.setColor(
                QPalette::Active, Palette::Text, cache.titleColor);
            title->setPalette(palette);
        }

        if ( title->text().testPaintAttribute(QwtText::PaintUsingTextFont) )
        {
            QwtText text = title->text();
            text.setFont(cache.titleFont);
            title->setText(text);
        }
        else
        {
            title->setFont(cache.titleFont);
        }
    }

    if ( plot->legend() )
    {
#if QT_VERSION < 0x040000
        QValueList<QWidget *> list = plot->legend()->legendItems();
        for ( QValueListIterator<QWidget *> it = list.begin();
                it != list.end(); ++it )
#else
        QList<QWidget *> list = plot->legend()->legendItems();
        for ( QList<QWidget*>::iterator it = list.begin();
                it != list.end(); ++it )
#endif
        {
            QWidget *w = *it;

            if ( cache.legendFonts.contains(w) )
                w->setFont(cache.legendFonts[w]);

            if ( w->inherits("QwtLegendItem") )
            {
                QwtLegendItem *label = (QwtLegendItem *)w;
                const QwtPlotItem *plotItem =
                    (const QwtPlotItem*)plot->legend()->find(label);

                QwtSymbol symbol = label->symbol();
                if ( cache.curveSymbolPenColors.contains(plotItem) )
                {
                    QPen pen = symbol.pen();
                    pen.setColor(cache.curveSymbolPenColors[plotItem]);
                    symbol.setPen(pen);
                }

                if ( cache.curveSymbolBrushColors.contains(plotItem) )
                {
                    QBrush brush = symbol.brush();
                    brush.setColor(cache.curveSymbolBrushColors[plotItem]);
                    symbol.setBrush(brush);
                }
                label->setSymbol(symbol);

                if ( cache.curveColors.contains(plotItem) )
                {
                    QPen pen = label->curvePen();
                    pen.setColor(cache.curveColors[plotItem]);
                    label->setCurvePen(pen);
                }
            }
        }
    }
    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
    {
        QwtScaleWidget *scaleWidget = plot->axisWidget(axis);
        if ( scaleWidget )
        {
            QPalette palette = scaleWidget->palette();
            palette.setColor(QPalette::Active, Palette::Foreground,
                             cache.scaleColor[axis]);
            scaleWidget->setPalette(palette);

            scaleWidget->setFont(cache.scaleFont[axis]);
            scaleWidget->setTitle(cache.scaleTitle[axis]);

            int startDist, endDist;
            scaleWidget->getBorderDistHint(startDist, endDist);
            scaleWidget->setBorderDist(startDist, endDist);
        }
    }

    QPalette p = plot->palette();
    p.setColor(QPalette::Active, Palette::Background, cache.widgetBackground);
    plot->setPalette(p);

    plot->setCanvasBackground(cache.canvasBackground);

    const QwtPlotItemList& itmList = plot->itemList();
    for ( QwtPlotItemIterator it = itmList.begin();
            it != itmList.end(); ++it )
    {
        reset(*it);
    }

    delete d_data->cache;
    d_data->cache = 0;

    plot->setAutoReplot(doAutoReplot);
}