Esempio n. 1
0
// DoBuild
//------------------------------------------------------------------------------
/*virtual*/ Node::BuildResult SLNNode::DoBuild( Job * UNUSED( job ) )
{
    SLNGenerator sg;

    // projects
    Array< VCXProjectNode * > projects( m_StaticDependencies.GetSize(), false );
    const Dependency * const end = m_StaticDependencies.End();
    for ( const Dependency * it = m_StaticDependencies.Begin() ; it != end ; ++it )
    {
        projects.Append( it->GetNode()->CastTo< VCXProjectNode >() );
    }

    // .sln solution file
    const AString & sln = sg.GenerateSLN(   m_Name,
                                            m_SolutionBuildProject,
                                            m_SolutionVisualStudioVersion,
                                            m_SolutionMinimumVisualStudioVersion,
                                            m_Configs,
                                            projects,
                                            m_Folders );
    if ( Save( sln, m_Name ) == false )
    {
        return NODE_RESULT_FAILED; // Save will have emitted an error
    }

    return NODE_RESULT_OK;
}
Esempio n. 2
0
// Load
//------------------------------------------------------------------------------
/*static*/ Node * SLNNode::Load( IOStream & stream )
{
    NODE_LOAD( AStackString<>,  name );
    NODE_LOAD( AStackString<>,  buildProject );
    NODE_LOAD( AStackString<>,  visualStudioVersion );
    NODE_LOAD( AStackString<>,  minimumVisualStudioVersion );
    NODE_LOAD_DEPS( 1,          staticDeps );

    Array< VSProjectConfig > configs;
    VSProjectConfig::Load( stream, configs );

    Array< SLNSolutionFolder > folders;
    SLNSolutionFolder::Load( stream, folders );

    Array< VCXProjectNode * > projects( staticDeps.GetSize(), false );
    const Dependency * const end = staticDeps.End();
    for ( const Dependency * it = staticDeps.Begin() ; it != end ; ++it )
    {
        projects.Append( it->GetNode()->CastTo< VCXProjectNode >() );
    }

    NodeGraph & ng = FBuild::Get().GetDependencyGraph();
    SLNNode * n = ng.CreateSLNNode( name,
                                    buildProject,
                                    visualStudioVersion,
                                    minimumVisualStudioVersion,
                                    configs,
                                    projects,
                                    folders );
    return n;
}
void	ProjectTableTest::testProject() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testProject() begin");
	unlink("projecttest.db");
	Database	database = DatabaseFactory::get("projecttest.db");
	ProjectTable	projects(database);
	ProjectRecord	project1;
	project1.name = "project1";
	project1.description = "Description of project1";
	project1.started = time(NULL) - 86400;
	long	id1 = projects.add(project1);
	ProjectRecord	project2;
	project2.name = "project2";
	project2.description = "Description of project2";
	project2.started = time(NULL) - 10 * 86400;
	long	id2 = projects.add(project2);
	ProjectRecord	project3 = projects.byid(id1);
	CPPUNIT_ASSERT(project1.name == project3.name);
	CPPUNIT_ASSERT(project1.description == project3.description);
	CPPUNIT_ASSERT(project1.started == project3.started);
	ProjectRecord	project4 = projects.byid(id2);
	CPPUNIT_ASSERT(project2.name == project4.name);
	CPPUNIT_ASSERT(project2.description == project4.description);
	debug(LOG_DEBUG, DEBUG_LOG, 0, "%d - %d = %d",
		project2.started, project4.started,
		project2.started - project4.started);
	CPPUNIT_ASSERT(project2.started == project4.started);
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testProject() end");
}
void KexiWelcomeAssistant::emitOpenProject(KexiProjectData *data)
{
    bool opened = false;
    emit openProject(*data, projects()->shortcutPath(*data), &opened);
    if (opened) { // update recent projects view
        data->setLastOpened(QDateTime::currentDateTime());
        d->m_mainWelcomePage->updateRecentProjects();
    }
}
Esempio n. 5
0
Model::Node* Project::navigateTo(Model::Node* source, QString path)
{
	QString symbol = extractFrontSymbol(path);
	Model::Node* found = nullptr;

	// Is the target symbol name the module's name
	if (isAncestorOf(source) && symbol == symbolName()) found = this;

	if (!found) found = projects()->findFirstSymbolDefinition(symbol);
	if (!found) found = libraries()->findFirstSymbolDefinition(symbol);
	if (!found) found = modules()->findFirstSymbolDefinition(symbol);
	if (!found) found = classes()->findFirstSymbolDefinition(symbol);
	if (!found) return ExtendableNode::navigateTo(source, path);

	QString rest = extractSecondaryPath(path);
	if (!rest.isEmpty()) return found->navigateTo(this, rest);
	else return found;
}
Esempio n. 6
0
void SmartNameCacheTests::testCache()
{
    SmartNameCache cache;
    Task projects( 1, QStringLiteral("Projects") );
    Task charm( 2, QStringLiteral("Charm") );
    charm.setParent( projects.id() );
    Task charmDevelopment( 3, QStringLiteral("Development") );
    charmDevelopment.setParent( charm.id() );
    Task charmOverhead( 4, QStringLiteral("Overhead") );
    charmOverhead.setParent( charm.id() );
    Task lotsofcake( 5, QStringLiteral("Lotsofcake") );
    lotsofcake.setParent( projects.id() );
    Task lotsofcakeDevelopment( 6, QStringLiteral("Development") );
    lotsofcakeDevelopment.setParent( lotsofcake.id() );
    const TaskList tasks = TaskList() << projects << charm << charmDevelopment << charmOverhead << lotsofcake << lotsofcakeDevelopment;
    cache.setAllTasks( tasks );
    QCOMPARE( cache.smartName( charmDevelopment.id() ), QLatin1String("Charm/Development") );
    QCOMPARE( cache.smartName( charmOverhead.id() ), QLatin1String("Charm/Overhead") );
    QCOMPARE( cache.smartName( projects.id() ), QLatin1String("Projects") );
    QCOMPARE( cache.smartName( lotsofcakeDevelopment.id() ), QLatin1String("Lotsofcake/Development") );
}
Esempio n. 7
0
// Commit
//------------------------------------------------------------------------------
/*virtual*/ bool FunctionSLN::Commit( const BFFIterator & funcStartIter ) const
{
    AStackString<> solutionOutput;
    Array< AString > solutionProjects( 8, true );
    if ( !GetString( funcStartIter, solutionOutput,     ".SolutionOutput", true ) ||
         !GetStrings( funcStartIter, solutionProjects,  ".SolutionProjects", false ) )
    {
        return false;
    }

    // optional inputs
    AString solutionBuildProject;
    AString solutionVisualStudioVersion;
    AString solutionMinimumVisualStudioVersion;
    if ( !GetString( funcStartIter, solutionBuildProject,                 ".SolutionBuildProject", false ) ||
         !GetString( funcStartIter, solutionVisualStudioVersion,          ".SolutionVisualStudioVersion", false ) ||
         !GetString( funcStartIter, solutionMinimumVisualStudioVersion,   ".SolutionMinimumVisualStudioVersion", false ) )
    {
        return false;
    }

    // base config
    VSProjectConfig baseConfig;

    // create configs
    Array< VSProjectConfig > configs( 16, true );

    const BFFVariable * solutionConfigs = BFFStackFrame::GetVar( ".SolutionConfigs" );
    if ( solutionConfigs )
    {
        if ( solutionConfigs->IsArrayOfStructs() == false )
        {
            Error::Error_1050_PropertyMustBeOfType( funcStartIter, this, ".SolutionConfigs", solutionConfigs->GetType(), BFFVariable::VAR_ARRAY_OF_STRUCTS );
            return false;
        }

        const Array< const BFFVariable * > & structs = solutionConfigs->GetArrayOfStructs();
        const BFFVariable * const * end = structs.End();
        for ( const BFFVariable ** it = structs.Begin(); it != end; ++it )
        {
            const BFFVariable * s = *it;

            // start with the base configuration
            VSProjectConfig newConfig( baseConfig );

            // .Platform must be provided
            if ( !GetStringFromStruct( s, ".Platform",  newConfig.m_Platform ) )
            {
                // TODO:B custom error
                Error::Error_1101_MissingProperty( funcStartIter, this, AStackString<>( ".Platform" ) );
                return false;
            }

            // .Config must be provided
            if ( !GetStringFromStruct( s, ".Config",    newConfig.m_Config ) )
            {
                // TODO:B custom error
                Error::Error_1101_MissingProperty( funcStartIter, this, AStackString<>( ".Config" ) );
                return false;
            }

            configs.Append( newConfig );
        }
    }
    else
    {
        // no user specified configs, make some defaults

        // start from the default
        VSProjectConfig config( baseConfig );

        // make the configs
        config.m_Platform   = "Win32";
        config.m_Config     = "Debug";
        configs.Append( config );
        config.m_Config     = "Release";
        configs.Append( config );
        config.m_Platform   = "x64";
        configs.Append( config );
        config.m_Config     = "Debug";
        configs.Append( config );
    }

    // sort project configs by config and by platform (like visual)
    configs.Sort( VSProjectConfigComp() );

    // create solution folders
    Array< SLNSolutionFolder > folders( 16, true );

    const BFFVariable * solutionFolders = BFFStackFrame::GetVar( ".SolutionFolders" );
    if ( solutionFolders )
    {
        if ( solutionFolders->IsArrayOfStructs() == false )
        {
            Error::Error_1050_PropertyMustBeOfType( funcStartIter, this, ".SolutionFolders", solutionFolders->GetType(), BFFVariable::VAR_ARRAY_OF_STRUCTS );
            return false;
        }

        const Array< const BFFVariable * > & structs = solutionFolders->GetArrayOfStructs();
        const BFFVariable * const * end = structs.End();
        for ( const BFFVariable ** it = structs.Begin(); it != end; ++it )
        {
            const BFFVariable * s = *it;

            // start with the base configuration
            SLNSolutionFolder newFolder;

            // .Path must be provided
            if ( !GetStringFromStruct( s, ".Path", newFolder.m_Path ) )
            {
                // TODO:B custom error
                Error::Error_1101_MissingProperty( funcStartIter, this, AStackString<>( ".Path" ) );
                return false;
            }

            newFolder.m_Path.Replace( OTHER_SLASH, NATIVE_SLASH );

            // check if this path was already defined
            {
                const SLNSolutionFolder * const end2 = folders.End();
                for ( const SLNSolutionFolder * it2 = folders.Begin() ; it2 != end2 ; ++it2 )
                {
                    if ( it2->m_Path == newFolder.m_Path  )
                    {
                        // TODO:B custom error
                        Error::Error_1100_AlreadyDefined( funcStartIter, this, it2->m_Path );
                        return false;
                    }
                }
            }

            // .Projects must be provided
            if ( !GetStringOrArrayOfStringsFromStruct( funcStartIter, s, ".Projects", newFolder.m_ProjectNames ) )
            {
                return false; // GetStringOrArrayOfStringsFromStruct has emitted an error
            }

            // check if this project is included in the solution
            for ( const AString & projectName : newFolder.m_ProjectNames )
            {
                if ( solutionProjects.Find( projectName ) == nullptr )
                {
					solutionProjects.Append( projectName );
                }
            }

            folders.Append( newFolder );
        }
    }

    NodeGraph & ng = FBuild::Get().GetDependencyGraph();

    // Check for existing node
    if ( ng.FindNode( solutionOutput ) )
    {
        Error::Error_1100_AlreadyDefined( funcStartIter, this, solutionOutput );
        return false;
    }

    // resolves VCXProject nodes associated to solutionProjects
    Array< VCXProjectNode * > projects( solutionProjects.GetSize(), false );
    {
        const AString * const end = solutionProjects.End();
        for ( const AString * it = solutionProjects.Begin(); it != end; ++it )
        {
            VCXProjectNode * project = ResolveVCXProject( funcStartIter, *it );
            if ( project == nullptr )
            {
                return false; // ResolveVCXProject will have emitted error
            }

            // check that this project contains all .SolutionConfigs
            const Array< VSProjectConfig > & projectConfigs = project->GetConfigs();

            const size_t configsSize = configs.GetSize();
            for ( size_t i = 0 ; i < configsSize ; ++i )
            {
                bool containsConfig = false;

                const VSProjectConfig * const config = &configs[i];
                const VSProjectConfig * const end2 = projectConfigs.End();
                for ( const VSProjectConfig * it2 = projectConfigs.Begin(); it2 != end2; ++it2 )
                {
                    if ( it2->m_Platform == config->m_Platform &&
                         it2->m_Config   == config->m_Config )
                    {
                        containsConfig = true;
                        break;
                    }
                }

                if ( containsConfig == false )
                {
                    // TODO: specific error message "ProjectConfigNotFound"
                    AStackString<> configName;
                    configName.Format( "%s|%s", config->m_Platform.Get(), config->m_Config.Get() );
                    Error::Error_1104_TargetNotDefined( funcStartIter, this, configName.Get(), project->GetName() );
                    return false;
                }
            }

            // append vcxproject node to solution
            projects.Append( project );
        }
    }

    // sort projects by name (like visual)
    projects.Sort( VCXProjectNodeComp() );

    // resolves VCXProject nodes associated to solutionFolders
    {
        SLNSolutionFolder * const end = folders.End();
        for ( SLNSolutionFolder * it = folders.Begin(); it != end; ++it )
        {
            // retrieves full path of contained vcxprojects

            AString * const end2 = it->m_ProjectNames.End();
            for ( AString * it2 = it->m_ProjectNames.Begin(); it2 != end2; ++it2 )
            {
				// Get associate project file
				VCXProjectNode * project = ResolveVCXProject( funcStartIter, *it2 );
				if ( project == nullptr )
				{
					return false; // ResolveVCXProjectRecurse will have emitted error
				}

                ASSERT( projects.Find( project ) ); // Sanity check in global list

				// fixup name to be to final project
                *it2 = project->GetName();
            }
        }
    }

    // resolves VCXProject node referenced by solutionBuildProject
    if ( solutionBuildProject.GetLength() > 0 )
    {
		// Get associate project file
		const VCXProjectNode * project = ResolveVCXProject( funcStartIter, solutionBuildProject );
		if ( project == nullptr )
		{
			return false; // ResolveVCXProject will have emitted error
		}

        if ( projects.Find( project ) == nullptr )
        {
            // project referenced in .SolutionBuildProject is not referenced in .SolutionProjects
            Error::Error_1104_TargetNotDefined( funcStartIter, this, ".SolutionBuildProject", project->GetName() );
            return false;
        }

        solutionBuildProject = project->GetName();
    }

    // Project Dependencies
    Array< SLNDependency > slnDeps( 0, true );
    const BFFVariable * projectDepsVar = BFFStackFrame::GetVar( ".SolutionDependencies" );
    if ( projectDepsVar )
    {
        if ( projectDepsVar->IsArrayOfStructs() == false )
        {
            Error::Error_1050_PropertyMustBeOfType( funcStartIter, this, ".SolutionDependencies", projectDepsVar->GetType(), BFFVariable::VAR_ARRAY_OF_STRUCTS );
            return false;
        }
	
		slnDeps.SetCapacity( projectDepsVar->GetArrayOfStructs().GetSize() );
		for ( const BFFVariable * s : projectDepsVar->GetArrayOfStructs() )
		{
            // .Projects must be provided
            // .Dependencies must be provided
			SLNDependency deps;
            if ( !GetStringOrArrayOfStringsFromStruct( funcStartIter, s, ".Projects", deps.m_Projects ) ||
				 !GetStringOrArrayOfStringsFromStruct( funcStartIter, s, ".Dependencies", deps.m_Dependencies ) )
            {
                return false; // GetStringOrArrayOfStringsFromStruct has emitted an error
            }

			// fixup
			for ( AString & projectName : deps.m_Projects )
			{
				// Get associated project file
				const VCXProjectNode * project = ResolveVCXProject( funcStartIter, projectName );
				if ( project == nullptr )
				{
					return false; // ResolveVCXProject will have emitted error
				}
				projectName = project->GetName();
			}
			for ( AString & projectName : deps.m_Dependencies )
			{
				// Get associated project file
				const VCXProjectNode * project = ResolveVCXProject( funcStartIter, projectName );
				if ( project == nullptr )
				{
					return false; // ResolveVCXProject will have emitted error
				}
				projectName = project->GetName();
			}

			slnDeps.Append( deps );
		}
	}

    SLNNode * sln = ng.CreateSLNNode(   solutionOutput,
                                        solutionBuildProject,
                                        solutionVisualStudioVersion,
                                        solutionMinimumVisualStudioVersion,
                                        configs,
                                        projects,
										slnDeps,
                                        folders );

    ASSERT( sln );

    return ProcessAlias( funcStartIter, sln );
}
Esempio n. 8
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    this->tracking_status=FALSE;

    QIcon* icon =new QIcon((QString)APATH+"clock.png");
    ui->pushHour->setEnabled(FALSE);
    ui->pushHour->setIcon(*icon);
    ui->pushHour->setIconSize(QSize( ui->pushHour->size().width()-5,ui->pushHour->size().height()-5 ));
    QIcon* icon1 =new QIcon((QString)APATH+"add.png");
    ui->pushAddEarlier->setIcon(*icon1);
    ui->pushAddEarlier->setIconSize(QSize( ui->pushAddEarlier->size().width()-5,ui->pushAddEarlier->size().height()-5 ));
    QIcon* icon3 =new QIcon((QString)APATH+"delete.png");
    ui->pushDelete->setIcon(*icon3);
    ui->pushDelete->setIconSize(QSize( ui->pushDelete->size().width()-5,ui->pushDelete->size().height()-5 ));
    ui->pushDelete->setFocusPolicy(Qt::NoFocus);
    ui->pushAddEarlier->setFocusPolicy(Qt::NoFocus);
    ui->pushDelete->setEnabled(FALSE);
    QIcon* icon2 =new QIcon((QString)APATH+"hourglass.png");
    this->setWindowIcon(*icon2);
    db1=QSqlDatabase::addDatabase("QMYSQL","hourglass");
    db1.setDatabaseName("hourglass");
    db1.setHostName(g_HOST);
    db1.setUserName(g_USER);
    db1.setPassword(g_PASS);
    db1=QSqlDatabase::database("hourglass");
   // QPluginLoader *thePlugin = new QPluginLoader("/home/jim/qt/qt-4.6.3/plugins/sqldrivers/libqsqlmysql.so");
    //qDebug() << thePlugin->load();
    //qDebug() << thePlugin->isLoaded();
    //qDebug() << thePlugin->errorString();

    if (!db1.open())
    {
        qDebug()<<"Απέτυχε η σύνδεση με τη βάση";
        exit(0);
    }
    db2=QSqlDatabase::addDatabase("QMYSQL","asterisk");
    db2.setDatabaseName("asterisk");
    db2.setHostName(g_ASTERISK_SERVER);
    db2.setUserName(g_AST_MYSQL_USER);
    db2.setPassword(g_AST_MYSQL_PASS);
    db2=QSqlDatabase::database("asterisk");
    if (!db2.open())
    {
        qDebug()<<"Απέτυχε η σύνδεση με τη βάση";
        //exit(0);
    }
    this->customer_model=new QSqlQueryModel();
    this->project_model=new QSqlQueryModel();
    this->places_model=new QSqlQueryModel();
    this->tasks_model=new QSqlQueryModel();
    this->tasks_full_model=new QSqlQueryModel();
    this->daily_calls_model=new QSqlQueryModel();
    this->full_calls_model=new QSqlQueryModel();
    refresh_customers();
    refresh_tasks();
    refresh_full_tasks();
    refresh_daily_calls();
    refresh_full_calls();
    this->timer=new QTimer;
    this->timer_asterisk=new QTimer;
    timer_asterisk->start(60000);
    QStringList sl;
    ui->comboGraph->insertItem(0,trUtf8("ΕΒΔΟΜΑΔΑ"));
    ui->comboGraph->insertItem(1,trUtf8("ΕΤΟΣ"));
    ui->comboGraph->insertItem(2,trUtf8("ΔΙΑΧΡΟΝΙΚΟ"));
    /*
    QDate simera;
    simera=QDate::currentDate();
    int dayno=simera.dayOfWeek();

    QList <int> minut;
    for (int i=0;i<dayno;++i)
    {
        QSqlQuery query(db1);
        query.exec("select sum(TIMESTAMPDIFF(MINUTE,t.start_time,t.end_time)) from tasks t where date(start_time)='"+simera.addDays(-i).toString("yy/M/d")+"'");
        query.next();
        minut.prepend(query.value(0).toInt());
        qDebug()<<"MINUT:"<<minut;
    }


    WeekGraph *drb=new WeekGraph(this);
    drb->set_list(minut);
    drb->setFixedWidth(921);
    drb->setFixedHeight(181);
    drb->repaint();
    */
    drb=new WeekGraph(this);
    drb->setGeometry(180,10,611,151);
    //drb->setFixedWidth(621);
    //drb->setFixedHeight(161);

    connect(timer_asterisk,SIGNAL(timeout()),this,SLOT(refresh_calls()));
    connect(timer, SIGNAL(timeout()),this, SLOT(refresh_time()));
    connect(ui->action,SIGNAL(triggered()),this,SLOT(new_customer()));
    connect(ui->tableCustomers,SIGNAL(clicked(QModelIndex)),this,SLOT(customer_selection_changed()));
    connect(ui->tableCustomers,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(edit_customer()));
    connect(ui->pushHour,SIGNAL(released()),this,SLOT(tracking_pressed()));
    connect(ui->textEdit,SIGNAL(textChanged()),this,SLOT(remove_invalid_chars()));
    connect(ui->tableView,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(edit_task()));
    connect(ui->tableView_2,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(edit_task_full()));
    connect(ui->pushAddEarlier,SIGNAL(released()),this,SLOT(add_earlier_task()));
    connect(ui->actionMigration,SIGNAL(triggered()),this,SLOT(do_migration()));
    connect(ui->action_2,SIGNAL(triggered()),this,SLOT(invoicing()));
    connect(ui->actionEmail,SIGNAL(triggered()),this,SLOT(email_tasks()));
    connect(ui->comboGraph,SIGNAL(currentIndexChanged(int)),this,SLOT(change_graph(int)));
    connect(ui->actionProjects,SIGNAL(triggered()),this,SLOT(projects()));
    connect(ui->actionReview,SIGNAL(triggered()),this,SLOT(invoice_review()));
    connect(ui->tableView,SIGNAL(clicked(QModelIndex)),this,SLOT(table_clicked()));
    connect(ui->tableView_2,SIGNAL(clicked(QModelIndex)),this,SLOT(table2_clicked()));
    connect(ui->pushDelete,SIGNAL(released()),this,SLOT(delete_clicked()));
    connect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(tab_changed(int)));

    ui->comboGraph->setCurrentIndex(-1);
    ui->comboGraph->setCurrentIndex(0);
    ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu);
    ui->tableTodayCalls->setContextMenuPolicy(Qt::CustomContextMenu);
    ui->tableAllCalls->setContextMenuPolicy(Qt::CustomContextMenu);
    ui->tableCustomers->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->tableView,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(context_menu(const QPoint&)));
    connect(ui->tableView_2->horizontalHeader(),SIGNAL(sectionClicked(int)),this,SLOT(sortbycolumn(int)));
    connect(ui->tableCustomers,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(dial_customer(const QPoint&)));
    connect(ui->tableTodayCalls,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(context_menu_daily_calls(QPoint)));
    connect(ui->tableAllCalls,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(context_menu_full_calls(QPoint)));

    Asterisk_CallerID_Monitor *ast_monitor=new Asterisk_CallerID_Monitor(this);
    connect (ast_monitor,SIGNAL(incoming_call(QString)),this,SLOT(incoming_call(QString)));
    ast_monitor->start_monitor();

}