⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 projectmanager.cpp

📁 用Qt4编写的linux IDE开发环境
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                    if ( itTemplate->child(nbTemplate)->text(0) == "subdirs" )                    {                        ajouter = false;                        break;                    }                }            }        }        if ( ajouter )        {            //window->comboProjects->addItem( projectName,  QVariant(reinterpret_cast<uint>(projectsList.at(nbProjects))));            window->comboProjects->addItem( projectName,  addressToVariant(projectsList.at(nbProjects)));            if ( projectsList.at(nbProjects) == it )                window->comboProjects->setCurrentIndex( window->comboProjects->count()-1);            QList<QTreeWidgetItem *> listeScope;            childsList(projectsList.at(nbProjects), "SCOPE", listeScope);            for (int nbScope=0; nbScope < listeScope.count(); nbScope++)            {                QString nomScope;                QTreeWidgetItem *tmp = listeScope.at(nbScope);                int nbSpace = 0;                while ( tmp )                {                    QString cleTmp = toKey( tmp->data(0,Qt::UserRole) );                    QString indent;                    for (int i=0; i<nbSpace; i++)                        indent += "  ";                    if ( cleTmp == "SCOPE" || cleTmp == "PROJECT" )                        nomScope = indent + tmp->text(0) + ":" + nomScope.simplified();                    if ( cleTmp == "PROJECT" )                        break;                    tmp = tmp->parent();                    nbSpace++;                }                //window->comboProjects->addItem( nomScope, QVariant(reinterpret_cast<uint>(listeScope.at(nbScope))));                window->comboProjects->addItem( nomScope, addressToVariant(listeScope.at(nbScope)));                if ( listeScope.at(nbScope) == it )                    window->comboProjects->setCurrentIndex( window->comboProjects->count()-1);            }        }    }    //    if ( window->comboProjects->count() == 1 )        window->comboProjects->setEnabled( false );    QVariant variant;    QString scopeName;    if ( window->exec() == QDialog::Accepted )    {        if ( window->win32->isChecked() )            scopeName = "win32";        else if ( window->Unix->isChecked() )            scopeName = "unix";        else if ( window->mac->isChecked() )            scopeName = "mac";        else if ( window->debug->isChecked() )            scopeName = "debug";        else if ( window->release->isChecked() )            scopeName = "release";        else            scopeName = window->scopeName->text();        variant = window->comboProjects->itemData( window->comboProjects->currentIndex() );        delete window;    }    else    {        delete window;        return;    }    //QTreeWidgetItem *item = reinterpret_cast<QTreeWidgetItem*>(variant.toUInt());    QTreeWidgetItem *item = (QTreeWidgetItem*)variantToItem(variant);    insertItem(item, "SCOPE", scopeName);    setQmake( projectFilename(item) );}//void ProjectManager::setQmake(QString projectName){    QTreeWidgetItem *itProjet = item(m_treeFiles->topLevelItem ( 0 ), projectName, Data);    QTreeWidgetItem *itModifie = item(itProjet, "qmake", Key);    itModifie->setText(0, "1");    m_isModifiedProject = true;}//bool ProjectManager::qmake(QString projectName){    bool retour = true;    if ( !projectName.isEmpty() )    {        retour = findData(projectName, "qmake") == "1";        QTreeWidgetItem *itProjet = item(m_treeFiles->topLevelItem ( 0 ), projectName, Data);        //if( itProjet )        QTreeWidgetItem *itModifie = item(itProjet, "qmake", Key);        if ( itModifie )            itModifie->setText(0, "0");    }    else    {        QList<QTreeWidgetItem *> list;        childsList(m_treeFiles->topLevelItem ( 0 ), "PROJECT", list);        for (int i=0; i<list.count(); i++)        {            QTreeWidgetItem *itModifie = item(list.at( i ), "qmake", Key);            if ( itModifie )            {                retour = itModifie->text(0) == "1";                itModifie->setText(0, "0");            }        }    }    return retour;}//void ProjectManager::slotlupdate(QTreeWidgetItem *it){    if ( m_parent->saveBeforeBuild() )        slotSaveProject();    if ( isModifiedProject() )    {        // Proposer sauvegarde        int rep = QMessageBox::question(0, "QDevelop",                                        tr("Save project changes ?"), tr("Yes"), tr("No"), tr("Cancel"), 0, 2 );        if ( rep == 2 )            return;        if ( rep == 0 )        {            slotSaveProject();        }    }    QApplication::setOverrideCursor(Qt::WaitCursor);    QString projectDir = projectDirectory( it );    QString name = projectName( projectDir );    QProcess process;    process.setWorkingDirectory( projectDir );    process.start(m_parent->lupdateName(), QStringList() << "-noobsolete" << name);    process.waitForFinished();    QApplication::restoreOverrideCursor();}//void ProjectManager::slotlrelease(QTreeWidgetItem *it){    if ( m_parent->saveBeforeBuild() )        slotSaveProject();    if ( isModifiedProject() )    {        // Proposer sauvegarde        int rep = QMessageBox::question(0, "QDevelop",                                        tr("Save project changes ?"), tr("Yes"), tr("No"), tr("Cancel"), 0, 2 );        if ( rep == 2 )            return;        if ( rep == 0 )        {            slotSaveProject();        }    }    QApplication::setOverrideCursor(Qt::WaitCursor);    QString projectDir = projectDirectory( it );    QString name = projectName( projectDir );    QProcess process;    process.setWorkingDirectory( projectDir );    process.start(m_parent->lreleaseName(), QStringList(name));    process.waitForFinished();    setQmake( projectFilename(it) );    QApplication::restoreOverrideCursor();}//void ProjectManager::slotPreviewForm(QTreeWidgetItem *it){    if ( m_previewForm )    {        delete m_previewForm;        m_previewForm = 0;    }    QString projectDir = projectDirectory(it);    QString filename = it->text(0);    QString uiName = QDir(projectDir+"/"+filename).absolutePath();    QUiLoader builder;    QFile file(uiName);    file.open(QFile::ReadOnly);    m_previewForm = builder.load(&file, 0);    m_previewForm->setWhatsThis( filename );    file.close();    //    if ( m_previewForm )    {        // Set tooltip for all widgets in form        QString name = m_previewForm->objectName();        QString className = m_previewForm->metaObject()->className();        m_previewForm->setToolTip( name+" ("+className+")" );        QRect rect = QDesktopWidget().screenGeometry();        m_previewForm->setGeometry((rect.width()-m_previewForm->width())/2, (rect.height()-m_previewForm->height())/2, m_previewForm->width(), m_previewForm->height());        QList<QWidget *> widgets;        widgets += m_previewForm->findChildren<QWidget *>();        foreach(QWidget *w, widgets)        {            w->installEventFilter( this );            name = w->objectName();            className = w->metaObject()->className();            w->setToolTip( name+" ("+className+")" );            w->setWhatsThis( filename );        }        //        m_previewForm->installEventFilter( this );        QDialog *dlg =  dynamic_cast<QDialog*>(m_previewForm);        QMainWindow *win = dynamic_cast<QMainWindow*>(m_previewForm);        if ( win )        {            win->setAttribute(Qt::WA_QuitOnClose, false);            win->show();        }        else if ( dlg )        {            dlg->show();        }        else        {            m_previewForm->show();        }    }    else    {        QString error = tr("The file  \"%1\" ").arg(uiName);        QMessageBox::warning(0,                             "QDevelop", error,                             tr("Cancel") );    }}//void ProjectManager::slotSubclassing(QTreeWidgetItem *it){    QString projectDir = projectDirectory(it);    QString projectName = projectFilename( it );    QString srcDir = srcDirectory( itemProject(projectName) );    QString filename = it->text(0);    QString uiName = QDir(projectDir+"/"+filename).absolutePath();    QStringList listeHeaders;    headers( itemProject(projectName), listeHeaders);    SubclassingImpl *dialog = new SubclassingImpl(0, m_parent, srcDir, uiName, listeHeaders);    if ( dialog->exec() == QDialog::Accepted )    {        while ( toKey( it->data(0, Qt::UserRole) ) != "PROJECT" )            it = it->parent();        projectDir = projectDirectory( itemProject(projectName) );        setQmake( projectFilename(it) );        QString filename = QDir(projectDir).relativeFilePath(dialog->newFile()+".h").replace("\\", "/");        insertFile(it, filename, true);        filename = QDir(projectDir).relativeFilePath(dialog->newFile()+".cpp").replace("\\", "/");        insertFile(it, filename, true);    }    delete dialog;    m_parent->configureCompletion( projectDirectory(m_treeFiles->topLevelItem( 0 ) ) );}//void ProjectManager::slotRenameItem(QTreeWidgetItem *it){    if ( !it )        return;    QTreeWidgetItem *itProject = itemProject( projectFilename(it) );    QString projectDir = projectDirectory(it);    QString oldAbsolutePath = QDir(projectDir+"/"+it->text(0)).absolutePath();    QString path = it->text(0).section("/", 0, -2);    QString filename = it->text(0).section("/", -1, -1);    bool ok;    filename = QInputDialog::getText(0, "QDevelop", tr("New name:"), QLineEdit::Normal, filename, &ok);    if ( !ok )        return;    if ( oldAbsolutePath.section(".", -1, -1) != filename.section(".", -1, -1) )    {        int rep = QMessageBox::question(0, "QDevelop",                                        tr("The kind of the new and the old filename is different !"),                                        tr("Rename"), tr("Cancel") );        if ( rep == 1 )            return;    }    if (!filename.isEmpty())    {        QString newName;        if ( !path.isEmpty() )            newName  = path + "/" + filename;        else            newName  = filename;        QString newAbsolutePath = QDir(projectDir+"/"+newName).absolutePath();        QFile file( oldAbsolutePath );        if ( file.rename( newAbsolutePath ) )        {            slotDeleteItem(it, true);            insertFile(itProject, newName);            m_parent->renameEditor(oldAbsolutePath, newAbsolutePath);            m_isModifiedProject = true;    		foreach(Editor *editor, m_parent->allEditors() )            {                editor->setNameOtherFile(oldAbsolutePath, newAbsolutePath);            }        }        else        {            QMessageBox::warning(0,"QDevelop", tr("Unable to rename the file to \"%1\"").arg(newAbsolutePath), tr("Cancel"));            return;        }    }    m_parent->configureCompletion( projectDirectory(m_treeFiles->topLevelItem( 0 ) ) );}//void ProjectManager::slotDeleteItem(QTreeWidgetItem *it, bool silentMode){    if ( !it )        return;    if ( it == m_treeFiles->topLevelItem ( 0 ) )    {        QMessageBox::warning(0,                             "QDevelop", tr("Cannot remove the main project."),                             tr("Ok") );        return;    }    int rep = 0;    if ( !silentMode )    {        rep = QMessageBox::question(0, "QDevelop",                                    tr("Do you want to remove \"%1\" from the project ?").arg(it->text(0)),                                    tr("Yes"), tr("No") );    }    if ( rep == 1 )        return;    //    /*QString filename = it->text(0);    QString projectName = projectFilename( it );    QString projectDir = projectDirectory(it);    QString absoluteName = QDir(projectDir+"/"+filename).absolutePath();    if( filename.section(".", -1, -1).toLower() == "h" || filename.section(".", -1, -1).toLower() == "cpp")    	m_treeClasses->clearFile( absoluteName );*/    setQmake( projectFilename( it ) );    QTreeWidgetItem *parent = it->parent();    delete it;    while ( !parent->childCount() )    {        it = parent->parent();        delete parent;        parent = it;    }    //    m_treeClasses->clear();    parseTreeClasses();    //    // Le parent est de type PROJECT. S'il a un TEMPLATE subdirs mais qu'il n'a plus de sous-projets,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -