Exemple #1
0
void Editor::idleDebugStatusChange(eDebuggerChangeStatus st)
    {
    if(st == DCS_RunState)
        {
        getEditFiles().updateDebugMenu();
        if(mDebugger.getChildState() == DCS_ChildPaused)
            {
            auto const &loc = mDebugger.getStoppedLocation();
            mEditFiles.viewModule(loc.getFilename(), loc.getLine());
            mDebugger.startGetStack();
            }
        }
    else if(st == DCS_Stack)
        {
        GtkTextView *view = GTK_TEXT_VIEW(ControlWindow::getTabView(
            ControlWindow::CT_Stack));
        Gui::setText(view, mDebugger.getStack());
        }
    else if(st == DCS_Value)
        {
//        mVarView.appendText(GuiTreeItem(), mDebugger.getVarValue().getAsString());
        GuiTreeItem item;
        appendTree(mVarView, item, mDebugger.getVarValue());

        GuiTreeItem root;
        int numChildren = mVarView.getNumChildren(root);
        OovString numPathStr;
        numPathStr.appendInt(numChildren-1);
        GuiTreePath path(numPathStr);
        mVarView.scrollToPath(path);
        }
    }
/**
 * Appends the given directory to the given list view item. Called recursively until all
 * library directories are appended.
 *
 * @author Rallaz
 */
void QG_LibraryWidget::appendTree(QStandardItem* item, QString directory) {
//    QStringList::Iterator it;
    QDir dir(directory);

	if (!dir.exists()) return;

    // read subdirectories of this directory:
    QStringList lDirectoryList = dir.entryList(QDir::Dirs|QDir::NoDotAndDotDot, QDir::Name);


	if (!item) item = dirModel->invisibleRootItem();

    for (int i = 0; i < lDirectoryList.size(); ++i) {
		QStandardItem* newItem=nullptr;

        // Look for an item already existing and take this
        //   instead of making a new one:
        for (int j = 0; j < item->rowCount(); ++j) {
			QStandardItem* const searchItem = item->child (j);
            if (searchItem->text() == lDirectoryList.at(i)) {
                newItem=searchItem;
                break;
            }
        }

        // Create new item if no existing was found:
		if (!newItem) {
                newItem = new QStandardItem(QIcon(":/ui/folderclosed.png"), lDirectoryList.at(i));
                item->setChild(item->rowCount(), newItem);
        }
        appendTree(newItem, directory+QDir::separator()+lDirectoryList.at(i));
    }
    item->sortChildren ( 0, Qt::AscendingOrder );
}
Exemple #3
0
// This is recursive.
// This adds items if they does not exist.  It preserves the tree
// so that the state of expanded items will not be destroyed.
// childIndex of -1 is special since the name is used to find the item.
static void appendTree(GuiTree &varView, GuiTreeItem &parentItem,
    DebugResult const &debResult, int childIndex = -1)
    {
    OovString varPrefix = debResult.getVarName();
    OovString str = varPrefix;
    if(debResult.getValue().length() > 0)
        {
        varPrefix += " : ";
        str = varPrefix;
        str += debResult.getValue();
        }

    GuiTreeItem item;
    bool foundItem = false;
    if(childIndex == -1)
        {
        if(varView.findImmediateChildPartialMatch(varPrefix, parentItem, item))
            {
            foundItem = true;
            }
        }
    else
        {
        foundItem = varView.getNthChild(parentItem, childIndex, item);
        }
    if(foundItem)
        {
        varView.setText(item, str);
        }
    else
        {
        item = varView.appendText(parentItem, str);
        }

    /// Remove items that no longer are available for the variable name.
        {
        int numDataChildren = debResult.getChildResults().size();
        int numTreeChildren = varView.getNumChildren(item);
        for(int childI=numDataChildren; childI<numTreeChildren; childI++)
            {
            varView.removeNthChild(item, childI);
            }
        }

    int callerChildIndex = 0;
    for(auto const &childRes : debResult.getChildResults())
        {
        appendTree(varView, item, *childRes.get(), callerChildIndex++);
        }
    /// @TODO - should only expand added item at parent level?
    GuiTreeItem root;
    int lastChild = varView.getNumChildren(root) - 1;
    OovString numPathStr;
    numPathStr.appendInt(lastChild);
    GuiTreePath path(numPathStr);
    varView.expandRow(path);
    }
/*
 *  Constructs a QG_LibraryWidget as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 *
 * @author Rallaz
 */
QG_LibraryWidget::QG_LibraryWidget(QWidget* parent, const char* name, Qt::WindowFlags fl)
    : QWidget(parent, fl)
{
    setObjectName(name);
	actionHandler = nullptr;

    QVBoxLayout *vboxLayout = new QVBoxLayout(this);
    vboxLayout->setSpacing(2);
    vboxLayout->setContentsMargins(2, 2, 2, 2);
    dirView = new QTreeView(this);
    dirView->setRootIsDecorated(true);
    dirView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    vboxLayout->addWidget(dirView);
    ivPreview = new QListView(this);
    ivPreview->setViewMode(QListView::IconMode);
    vboxLayout->addWidget(ivPreview);
    bInsert = new QPushButton(tr("Insert"), this);
    vboxLayout->addWidget(bInsert);

    dirModel = new QStandardItemModel;
    iconModel = new QStandardItemModel;
    QStringList directoryList = RS_SYSTEM->getDirectoryList("library");
    for (int i = 0; i < directoryList.size(); ++i) {
		appendTree(nullptr, directoryList.at(i));
     }

    RS_SETTINGS->beginGroup("/Paths");
    QString customPath=RS_SETTINGS->readEntry("/Library", "");
    RS_SETTINGS->endGroup();
    if(customPath.size()>0){
            //todo: make the custom path more flexible
			appendTree(nullptr,customPath);
    }
    dirView->setModel(dirModel);
    ivPreview->setModel(iconModel);
    dirModel->setHorizontalHeaderLabels ( QStringList(tr("Directories")));

    connect(dirView, SIGNAL(expanded(QModelIndex)), this, SLOT(expandView(QModelIndex)));
    connect(dirView, SIGNAL(collapsed(QModelIndex)), this, SLOT(collapseView(QModelIndex)));
    connect(dirView, SIGNAL(clicked(QModelIndex)), this, SLOT(updatePreview(QModelIndex)));
    connect(bInsert, SIGNAL(clicked()), this, SLOT(insert()));
}