Exemple #1
0
QString DesignerProjectImpl::formFileName( const QString &form ) const
{
    for ( QPtrListIterator<FormFile> forms = project->formFiles();
	  forms.current(); ++forms ) {
	if ( QString( forms.current()->formName() ) == form )
	    return forms.current()->fileName();
    }
    return QString::null;
}
Exemple #2
0
QStringList DesignerProjectImpl::formNames() const
{
    QStringList l;
    for ( QPtrListIterator<FormFile> forms = project->formFiles();
	  forms.current(); ++forms ) {
	FormFile* f = forms.current();
	if ( f->isFake() )
	    continue;
	l << f->formName();
    }
    return l;
}
Exemple #3
0
void UIListTreeType::RefreshCurrentLevel(void)
{
    if (currentlevel)
    {
        QPtrListIterator<UIListBtnTypeItem> it = currentlevel->GetIterator();

        UIListBtnTypeItem *item;
        while ((item = it.current()))
        {
            UIListGenericTree *ui = (UIListGenericTree *)item->getData();
            ui->setActive(ui->getActive());
            ++it;
        }
    }
}
QString Project::locationOfObject( QObject *o )
{
    if ( !o )
	return QString::null;

    if ( MainWindow::self ) {
	QWidgetList windows = MainWindow::self->qWorkspace()->windowList();
	for ( QWidget *w = windows.first(); w; w = windows.next() ) {
	    FormWindow *fw = ::qt_cast<FormWindow*>(w);
	    SourceEditor *se = ::qt_cast<SourceEditor*>(w);
	    if ( fw ) {
		if ( fw->isFake() )
		    return objectForFakeForm( fw )->name() + QString( " [Source]" );
		else
		    return fw->name() + QString( " [Source]" );
	    } else if ( se ) {
		if ( !se->object() )
		    continue;
		if ( se->formWindow() )
		    return se->formWindow()->name() + QString( " [Source]" );
		else
		    return makeRelative( se->sourceFile()->fileName() );
	    }
	}
    }

    if ( ::qt_cast<SourceFile*>(o) ) {
	for ( QPtrListIterator<SourceFile> sources = sourceFiles();
	      sources.current(); ++sources ) {
	    SourceFile* f = sources.current();
	    if ( f == o )
		return makeRelative( f->fileName() );
	}
    }

    extern QMap<QWidget*, QString> *qwf_forms;
    if ( !qwf_forms ) {
	qWarning( "Project::locationOfObject: qwf_forms is NULL!" );
	return QString::null;
    }

    QString s = makeRelative( *qwf_forms->find( (QWidget*)o ) );
    s += " [Source]";
    return s;
}
Exemple #5
0
void KonqSidebarTree::followURL( const KURL &url )
{
    // Maybe we're there already ?
    KonqSidebarTreeItem *selection = static_cast<KonqSidebarTreeItem *>( selectedItem() );
    if (selection && selection->externalURL().equals( url, true ))
    {
        ensureItemVisible( selection );
        return;
    }

    kdDebug(1201) << "KonqDirTree::followURL: " << url.url() << endl;
    QPtrListIterator<KonqSidebarTreeTopLevelItem> topItem ( m_topLevelItems );
    for (; topItem.current(); ++topItem )
    {
        if ( topItem.current()->externalURL().isParentOf( url ) )
        {
            topItem.current()->module()->followURL( url );
            return; // done
        }
    }
    kdDebug(1201) << "KonqDirTree::followURL: Not found" << endl;
}
Exemple #6
0
void Workspace::setCurrentProject( Project *pro )
{
    if ( project == pro )
	return;
    if ( project ) {
	disconnect( project, SIGNAL( sourceFileAdded(SourceFile*) ), this, SLOT( sourceFileAdded(SourceFile*) ) );
	disconnect( project, SIGNAL( sourceFileRemoved(SourceFile*) ), this, SLOT( sourceFileRemoved(SourceFile*) ) );
	disconnect( project, SIGNAL( formFileAdded(FormFile*) ), this, SLOT( formFileAdded(FormFile*) ) );
	disconnect( project, SIGNAL( formFileRemoved(FormFile*) ), this, SLOT( formFileRemoved(FormFile*) ) );
	disconnect( project, SIGNAL( objectAdded(QObject*) ), this, SLOT( objectAdded(QObject*) ) );
	disconnect( project, SIGNAL( objectRemoved(QObject*) ), this, SLOT( objectRemoved(QObject*) ) );
	disconnect( project, SIGNAL( projectModified() ), this, SLOT( update() ) );
    }
    project = pro;
    connect( project, SIGNAL( sourceFileAdded(SourceFile*) ), this, SLOT( sourceFileAdded(SourceFile*) ) );
    connect( project, SIGNAL( sourceFileRemoved(SourceFile*) ), this, SLOT( sourceFileRemoved(SourceFile*) ) );
    connect( project, SIGNAL( formFileAdded(FormFile*) ), this, SLOT( formFileAdded(FormFile*) ) );
    connect( project, SIGNAL( formFileRemoved(FormFile*) ), this, SLOT( formFileRemoved(FormFile*) ) );
    connect( project, SIGNAL( destroyed(QObject*) ), this, SLOT( projectDestroyed(QObject*) ) );
    connect( project, SIGNAL( objectAdded(QObject*) ), this, SLOT( objectAdded(QObject*) ) );
    connect( project, SIGNAL( objectRemoved(QObject*) ), this, SLOT( objectRemoved(QObject*) ) );
    connect( project, SIGNAL( projectModified() ), this, SLOT( update() ) );
    clear();

    if ( bufferEdit )
	bufferEdit->clear();

    projectItem = new WorkspaceItem( this, project );

    projectItem->setOpen( TRUE );

    for ( QPtrListIterator<SourceFile> sources = project->sourceFiles();
	  sources.current(); ++sources ) {
	SourceFile* f = sources.current();
	(void) new WorkspaceItem( projectItem, f );
    }

    for ( QPtrListIterator<FormFile> forms = project->formFiles();
	  forms.current(); ++forms ) {
	FormFile* f = forms.current();
	if ( f->isFake() )
	    continue;

	(void) new WorkspaceItem( projectItem, f );
    }

    QObjectList l = project->objects();
    QObjectListIt objs( l );
    for ( ;objs.current(); ++objs ) {
	QObject* o = objs.current();
	(void) new WorkspaceItem( projectItem, o, project );
    }

    updateColors();
    completionDirty = TRUE;
}
Exemple #7
0
void DesignerProjectImpl::breakPoints( QMap<QString, QValueList<uint> > &bps ) const
{
    MainWindow::self->saveAllBreakPoints();
    for ( QPtrListIterator<SourceFile> sources = project->sourceFiles();
	  sources.current(); ++sources ) {
	SourceFile* f = sources.current();
	bps.insert( project->makeRelative( f->fileName() ) + " <Source-File>", MetaDataBase::breakPoints( f ) );
    }
    for ( QPtrListIterator<FormFile> forms = project->formFiles();
	  forms.current(); ++forms ) {
	if ( forms.current()->formWindow() )
	    bps.insert( QString( forms.current()->formWindow()->name() ) + " <Form>", MetaDataBase::breakPoints( forms.current()->formWindow() ) );
    }
}
Exemple #8
0
void DesignerProjectImpl::clearAllBreakpoints() const
{
    QValueList<uint> empty;
    for ( QPtrListIterator<SourceFile> sources = project->sourceFiles();
	  sources.current(); ++sources ) {
	SourceFile* f = sources.current();
	MetaDataBase::setBreakPoints( f, empty );
    }
    for ( QPtrListIterator<FormFile> forms = project->formFiles();
	  forms.current(); ++forms ) {
	if ( forms.current()->formWindow() )
	    MetaDataBase::setBreakPoints( forms.current()->formWindow(), empty );
	MainWindow::self->resetBreakPoints();
    }
}
Exemple #9
0
    }

    if (minNextFrame == FrameAnalyzer::ANYFRAME)
        minNextFrame = FrameAnalyzer::NEXTFRAME;

    if (minNextFrame == FrameAnalyzer::NEXTFRAME)
        minNextFrame = frameno + 1;

    return minNextFrame;
}

int passFinished(QPtrList<FrameAnalyzer> *pass, long long nframes, bool final)
{
    FrameAnalyzer       *fa;

    for (QPtrListIterator<FrameAnalyzer> iifa(*pass);
            (fa = iifa.current()); ++iifa)
        (void)fa->finished(nframes, final);

    return 0;
}

int passReportTime(QPtrList<FrameAnalyzer> *pass)
{
    FrameAnalyzer       *fa;

    for (QPtrListIterator<FrameAnalyzer> iifa(*pass);
            (fa = iifa.current()); ++iifa)
        (void)fa->reportTime();

    return 0;
void Project::save( bool onlyProjectFile )
{
    bool anythingModified = FALSE;

    //  save sources and forms
    if ( !onlyProjectFile ) {

	saveConnections();

	for ( SourceFile *sf = sourcefiles.first(); sf; sf = sourcefiles.next() ) {
	    anythingModified = anythingModified || sf->isModified();
	    if ( !sf->save() )
		return;
	}

	for ( FormFile *ff = formfiles.first(); ff; ff = formfiles.next() ) {
	    anythingModified = anythingModified || ff->isModified();
	    if ( !ff->save() )
		return;
	}
    }

    if ( isDummy() || filename.isEmpty() )
	return;

    if ( !modified ) {
	if ( singleProjectMode() ) {
	    LanguageInterface *iface = MetaDataBase::languageInterface( language() );
	    if ( iface && iface->supports( LanguageInterface::CompressProject ) )
		iface->compressProject( makeAbsolute( filename ), singleProFileName, anythingModified );
	}
 	return;
    }

    QFile f( filename );
    QString original = "";

    // read the existing file
    bool hasPreviousContents = FALSE;
    if ( f.open( IO_ReadOnly ) ) {
	QTextStream ts( &f );
	original = ts.read();
	f.close();
        hasPreviousContents = TRUE;
	remove_contents( original, "{SOURCES+=" ); // ### compatibility with early 3.0 betas
	remove_contents( original, "DBFILE" );
	remove_contents( original, "LANGUAGE" );
	remove_contents( original, "TEMPLATE" );
	removePlatformSettings( original, "CONFIG" );
	removePlatformSettings( original, "DEFINES" );
	removePlatformSettings( original, "LIBS" );
	removePlatformSettings( original, "INCLUDEPATH" );
	removePlatformSettings( original, "SOURCES" );
	removePlatformSettings( original, "HEADERS" );
	remove_multiline_contents( original, "FORMS" );
	remove_multiline_contents( original, "INTERFACES" ); // compatibility
	remove_multiline_contents( original, "IMAGES" );
	for ( QStringList::Iterator it = csList.begin(); it != csList.end(); ++it )
	    remove_contents( original, *it );
    }

    if (!original.isEmpty()) {
	// Removes any new lines at the beginning of the file
	while (original.startsWith("\n"))
	    original.remove(0, 1);
    }

    // the contents of the saved file
    QString contents;

    // template
    contents += "TEMPLATE\t= " + templ + "\n";

    // language
    contents += "LANGUAGE\t= " + lang + "\n";
    contents += "\n";

    // config
    writePlatformSettings( contents, "CONFIG", cfg );
    LanguageInterface *iface = MetaDataBase::languageInterface( lang );
    if ( iface ) {
	QStringList sourceKeys;
	iface->sourceProjectKeys( sourceKeys );
	for ( QStringList::Iterator spit = sourceKeys.begin(); spit != sourceKeys.end(); ++spit )
	    remove_multiline_contents( contents, *spit );
    }

    // libs, defines, includes
    writePlatformSettings( contents, "LIBS", lbs );
    writePlatformSettings( contents, "DEFINES", defs );
    writePlatformSettings( contents, "INCLUDEPATH", inclPath );
    writePlatformSettings( contents, "SOURCES", sources );
    writePlatformSettings( contents, "HEADERS", headers );

    // unix
    if ( !hasPreviousContents ) {
 	contents +=
 	    "unix|os2 {\n"
 	    "  UI_DIR = .ui\n"
 	    "  MOC_DIR = .moc\n"
 	    "  OBJECTS_DIR = .obj\n"
 	    "}\n\n";
    }

    // sources
    if ( !sourcefiles.isEmpty() && iface ) {
	QMap<QString, QStringList> sourceToKey;
	for ( SourceFile *f = sourcefiles.first(); f; f = sourcefiles.next() ) {
	    QString key = iface->projectKeyForExtension( QFileInfo( f->fileName() ).extension() );
	    QStringList lst = sourceToKey[ key ];
	    lst << makeRelative( f->fileName() );
	    sourceToKey.replace( key, lst );
	}

	for ( QMap<QString, QStringList>::Iterator skit = sourceToKey.begin();
	      skit != sourceToKey.end(); ++skit ) {
	    QString part = skit.key() + "\t+= ";
	    QStringList lst = *skit;
	    for ( QStringList::Iterator sit = lst.begin(); sit != lst.end(); ++sit ) {
		part += *sit;
		part += ++sit != lst.end() ? " \\\n\t" : "";
		--sit;
	    }
	    part += "\n\n";
	    contents += part;
	}
    }

    // forms and interfaces
    if ( !formfiles.isEmpty() ) {
	contents += "FORMS\t= ";
	for ( QPtrListIterator<FormFile> fit = formfiles; fit.current(); ++fit ) {
	    contents += fit.current()->fileName() +
		 (fit != formfiles.last() ? " \\\n\t" : "");
	}
	contents += "\n\n";
    }

    // images
     if ( !pixCollection->isEmpty() ) {
	contents += "IMAGES\t= ";
	QValueList<PixmapCollection::Pixmap> pixmaps = pixCollection->pixmaps();
	for ( QValueList<PixmapCollection::Pixmap>::Iterator it = pixmaps.begin();
	      it != pixmaps.end(); ++it ) {
		  contents += makeRelative( (*it).absname );
		  contents += ++it != pixmaps.end() ? " \\\n\t" : "";
		  --it;
	}
	contents += "\n\n";
    }

    // database
    if ( !dbFile.isEmpty() )
	contents += "DBFILE\t= " + dbFile + "\n";

    // custom settings
    for ( QStringList::Iterator it = csList.begin(); it != csList.end(); ++it ) {
	QString val = *customSettings.find( *it );
	if ( !val.isEmpty() )
	    contents += *it + "\t= " + val + "\n";
    }

    if ( !f.open( IO_WriteOnly | IO_Translate ) ) {
	QMessageBox::warning( messageBoxParent(),
			      "Save Project Failed", "Couldn't write project file " + filename );
	return;
    }

    QTextStream os( &f );
    os << contents;
    if (hasPreviousContents)
        os << original;

    f.close();

    setModified( FALSE );

    if ( singleProjectMode() ) {
	LanguageInterface *iface = MetaDataBase::languageInterface( language() );
	if ( iface && iface->supports( LanguageInterface::CompressProject ) )
	    iface->compressProject( makeAbsolute( filename ), singleProFileName, TRUE );
    }
}
StyleSheetListImpl::~StyleSheetListImpl()
{
    for ( QPtrListIterator<StyleSheetImpl> it ( styleSheets ); it.current(); ++it )
        it.current()->deref();
}
Exemple #12
0
int PMInsertRuleSystem::canInsert( const PMObject* parentObject,
                                   const QStringList& list,
                                   const PMObject* after )
{
   if( list.size( ) == 1 )
   {
      // more efficient
      if( canInsert( parentObject, list.first( ), after ) )
         return 1;
      else
         return 0;
   }

   // find rules for target class
   QPtrList<PMRuleTargetClass> targetClassList;
   PMMetaObject* meta = parentObject->metaObject( );
   for( ; meta; meta = meta->superClass( ) )
   {
      PMRuleTargetClass* tc = m_rulesDict.find( meta->className( ) );
      if( tc )
         targetClassList.append( tc );
   }
   if( targetClassList.isEmpty( ) )
      return 0; // not rules found

   // count already inserted children
   QPtrListIterator<PMRuleTargetClass> tit( targetClassList );
   for( ; tit.current( ); ++tit ) // ... for all target classes
   {
      QPtrListIterator<PMRule> rit = tit.current( )->rules( );
      for( ; rit.current( ); ++rit ) // ... and all rules
      {
         rit.current( )->reset( );
         bool afterInsertPoint = false;
         PMObject* o = parentObject->firstChild( );
         if( !after )
            afterInsertPoint = true;
         for( ; o; o = o->nextSibling( ) )
         {
            rit.current( )->countChild( o->className( ), afterInsertPoint );
            if( o == after )
               afterInsertPoint = true;
         }
      }
   }

   int number = 0;
   QStringList::const_iterator oit;

   for( oit = list.begin( ); oit != list.end( ); ++oit )
   {
      bool possible = false;
      for( tit.toFirst( ); tit.current( ) && !possible; ++tit )
      {
         QPtrListIterator<PMRule> rit = tit.current( )->rules( );

         for( ; rit.current( ) && !possible; ++rit )
         {
            PMRule* rule = rit.current( );
            if( rule->matches( *oit ) )
               possible = rule->evaluate( parentObject );
         }
      }
      if( possible )
      {
         // object can be inserted, count it
         for( ; tit.current( ); ++tit )
         {
            QPtrListIterator<PMRule> rit = tit.current( )->rules( );
            for( ; rit.current( ); ++rit )
               rit.current( )->countChild( *oit, false );
         }
			number++;
      }
   }

   return number;
}
Exemple #13
0
bool PMInsertRuleSystem::canInsert( const PMObject* parentObject,
                                    const QString& className,
                                    const PMObject* after,
                                    const PMObjectList* objectsBetween )
{
   bool possible = false;

   // find rules for target class
   PMMetaObject* meta = parentObject->metaObject( );
   for( ; meta && !possible; meta = meta->superClass( ) )
   {
      PMRuleTargetClass* tc = m_rulesDict.find( meta->className( ) );
      if( tc )
      {
         // check the exception list
         QStringList exceptions = tc->exceptions( );
         bool exceptionFound = false;
         QStringList::ConstIterator it;
         for( it = exceptions.begin( );
              it != exceptions.end( ) && !exceptionFound; ++it )
            if( parentObject->isA( *it ) )
               exceptionFound = true;

         if( !exceptionFound )
         {
            QPtrListIterator<PMRule> rit = tc->rules( );
            // find matching rules for class name
            for( ; rit.current( ) && !possible; ++rit )
            {
               PMRule* rule = rit.current( );
               if( rule->matches( className ) )
               {
                  // matching rule found
                  // reset the rule
                  rit.current( )->reset( );

                  // count already inserted child objects
                  bool afterInsertPoint = false;
                  PMObject* o = parentObject->firstChild( );
                  if( !after )
                     afterInsertPoint = true;
                  for( ; o; o = o->nextSibling( ) )
                  {
                     rule->countChild( o->className( ), afterInsertPoint );
                     if( o == after )
                        afterInsertPoint = true;
                  }
                  if( objectsBetween )
                  {
                     PMObjectListIterator it( *objectsBetween );
                     for( ; it.current( ); ++it )
                        rule->countChild( it.current( )->type( ), false );
                  }

                  // evaluate condition value
                  possible = rule->evaluate( parentObject );
               }
            }
         }
      }
   }

   return possible;
}
Exemple #14
0
void UIListBtnType::Draw(QPainter *p, int order, int context, bool active_on)
{
    if (!m_visible || hidden)
        return;

    if (!m_initialized)
        Init();

    if (m_order != order)
        return;

    if (m_context != -1 && m_context != context)
        return;

    //  Put something on the LCD device (if one exists)
    if (class LCD *lcddev = LCD::Get())
    {
        if (m_active)
        {
            // add max of lcd height menu items either side of the selected item
            // let the lcdserver figure out which ones to display

            QPtrList<LCDMenuItem> menuItems;
            menuItems.setAutoDelete(true);

            QPtrListIterator<UIListBtnTypeItem> it = (*m_selIterator);
            uint count = 0;

            // move back up the list a little
            while (it.current() && count < lcddev->getLCDHeight())
            {
                --it;
                ++count;
            }

            if (!it.current())
                it.toFirst();
            count = 0;
            while (it.current() && count < lcddev->getLCDHeight() * 2)
            {
                UIListBtnTypeItem *curItem = it.current();
                QString msg = curItem->text();
                bool selected;
                CHECKED_STATE checkState = NOTCHECKABLE;
                if (curItem->checkable())
                {
                    if (curItem->state() == UIListBtnTypeItem::HalfChecked || 
                        curItem->state() == UIListBtnTypeItem::FullChecked)
                        checkState = CHECKED;
                    else
                        checkState = UNCHECKED;
                }

                if (curItem == m_selItem)
                    selected = true;
                else
                    selected = false;

                menuItems.append(new LCDMenuItem(selected, checkState, msg));
                ++it;
                ++count;
            }

            QString title = "";

            if (m_parentListTree && m_parentListTree->getDepth() > 0)
                title = "<< ";
            else
                title = "   ";

            if ((m_selItem && m_selItem->getDrawArrow()) || m_showArrow)
                title += " >>";
            else
                title += "   ";

            if (!menuItems.isEmpty())
            {
                lcddev->switchToMenu(&menuItems, title);
            }
        }
    }

    fontProp* font = m_active ? m_fontActive : m_fontInactive;

    if (!active_on)
    {
        font = m_fontInactive;
    }
    
    p->setFont(font->face);
    p->setPen(font->color);

    int x = m_rect.x() + m_xdrawoffset;

    int y = m_rect.y();
    QPtrListIterator<UIListBtnTypeItem> it = (*m_topIterator);
    while (it.current() && 
           (y - m_rect.y()) <= (m_contentsRect.height() - m_itemHeight)) 
    {
        if (active_on && it.current()->getOverrideInactive())
        {
            font = m_fontInactive;
            p->setFont(font->face);
            p->setPen(font->color);
            it.current()->setJustification(m_justify);
            it.current()->paint(p, font, x, y, active_on);
            font = m_active ? m_fontActive : m_fontInactive;;
            p->setFont(font->face);
            p->setPen(font->color);
        }
        else
        {
            it.current()->setJustification(m_justify);
            it.current()->paint(p, font, x, y, active_on);
        }

        y += m_itemHeight + m_itemSpacing;

        ++it;
    }

    if (m_showScrollArrows) 
    {
        if (m_showUpArrow)
            p->drawPixmap(x + m_arrowsRect.x(),
                          m_rect.y() + m_arrowsRect.y(),
                          m_upArrowActPix);
        else
            p->drawPixmap(x + m_arrowsRect.x(),
                          m_rect.y() + m_arrowsRect.y(),
                          m_upArrowRegPix);
        if (m_showDnArrow)
            p->drawPixmap(x + m_arrowsRect.x() +
                          m_upArrowRegPix.width() + m_itemMargin,
                          m_rect.y() + m_arrowsRect.y(),
                          m_dnArrowActPix);
        else
            p->drawPixmap(x + m_arrowsRect.x() +
                          m_upArrowRegPix.width() + m_itemMargin,
                          m_rect.y() + m_arrowsRect.y(),
                          m_dnArrowRegPix);
    }
    
}
Exemple #15
0
bool UIListBtnType::incSearchNext(void)
{
    if (!m_selItem)
    {
        return false;
    }

    //
    //  Move the active node to the node whose string value
    //  starts or contains the search text
    //

    QPtrListIterator<UIListBtnTypeItem> it = (*m_selIterator);
    ++it;

    while (it.current())
    {
        if (m_bIncSearchContains)
        {
            if (it.current()->text().find(m_incSearch, 0, false) != -1)
                break;
        }
        else
        {
            if (it.current()->text().startsWith(m_incSearch, false))
                break;
        }

        ++it;
    }

    // if it is NULL, we reached the end of the list. wrap to the
    // beginning and try again
    if (!it.current())
    {
        it.toFirst();

        while (it.current())
        {
            // we're back at the current_node, which means there are no
            // matching nodes
            if (it.current() == m_selItem)
            {
                break;
            }

            if (m_bIncSearchContains)
            {
                if (it.current()->text().find(m_incSearch, 0, false) != -1)
                    break;
            }
            else
            {
                if (it.current()->text().startsWith(m_incSearch, false))
                    break;
            }

            ++it;
        }
    }

    if (it.current())
    {
        SetItemCurrent(it.current());
        return true;
    }

    return false;
}