//-------------------------------------------------------------------------------------------------
void BachKeywordView::loadState()
{
	IniConfig & cfg = userConfig();
	cfg.pushSection( "BachKeywordView" );
	setupTreeView( cfg, KeywordColumns );
	cfg.popSection();
}
Esempio n. 2
0
// Populate the tree view with models
void ModelSelector::populateModels()
{
    // Clear the treestore first
    _treeStore->Clear();
    _treeStoreWithSkins->Clear();

    // Create a VFSTreePopulator for the treestore
    wxutil::VFSTreePopulator pop(_treeStore);
    wxutil::VFSTreePopulator popSkins(_treeStoreWithSkins);

    // Use a ModelFileFunctor to add paths to the populator
    ModelFileFunctor functor(pop, popSkins);
    GlobalFileSystem().forEachFile(MODELS_FOLDER,
                                   "*",
                                   [&](const std::string& filename) { functor(filename); },
                                   0);

    // Fill in the column data (TRUE = including skins)
    ModelDataInserter inserterSkins(_columns, true);
    popSkins.forEachNode(inserterSkins);

    // Insert data into second model (FALSE = without skins)
    ModelDataInserter inserter(_columns, false);
    pop.forEachNode(inserter);

	// Sort the models
	_treeStore->SortModelFoldersFirst(_columns.filename, _columns.isFolder);
	_treeStoreWithSkins->SortModelFoldersFirst(_columns.filename, _columns.isFolder);

    // Setup the tree view
    setupTreeView();

    // Set the flag, we're done
    _populated = true;
}
AddPropertyDialog::AddPropertyDialog(Entity* entity) :
	wxutil::DialogBase(_(ADDPROPERTY_TITLE)),
    _entity(entity)
{
	Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(AddPropertyDialog::_onDeleteEvent), NULL, this);

	wxPanel* mainPanel = loadNamedPanel(this, "AddPropertyDialogPanel");

	_treeView = wxutil::TreeView::Create(mainPanel, wxBORDER_STATIC | wxDV_MULTIPLE | wxDV_NO_HEADER);
	mainPanel->GetSizer()->Prepend(_treeView, 1, wxEXPAND | wxALL, 6);

	wxButton* okButton = findNamedObject<wxButton>(mainPanel, "OkButton");
	okButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(AddPropertyDialog::_onOK), NULL, this);

	wxButton* cancelButton = findNamedObject<wxButton>(mainPanel, "CancelButton");
	cancelButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(AddPropertyDialog::_onCancel), NULL, this);

	FitToScreen(0.5f, 0.6f);

    // Populate the tree view with properties
    setupTreeView();
    populateTreeView();

	updateUsagePanel();
}
Esempio n. 4
0
IScriptEditor::IScriptEditor(QWidget *parent, QString script, config *cfg) :
    QDialog(parent),
    ui(new Ui::IScriptEditor),
    scriptFile(script),
    editor(this, cfg),
    conf(cfg),
    current(script),
    selection(NULL),
    ignoreNextTextChange(false),
    ignoreNextRowChange(false)
{
    ui->setupUi(this);
    setWindowFlags(Qt::Window);

    ui->splitter->addWidget(&editor);

    QFont font("Courier New");
    font.setPixelSize(12);
    editor.setFont(font);

    QList<int> size;
    size << 150 << 600;
    ui->splitter->setSizes(size);

    highlight = new TScriptEditorHighlighter(editor.document(), conf);

    connect(&editor, SIGNAL(textChanged()),
            this, SLOT(textChanged()));

    setupTreeView();

}
void JobHistoryView::setupModel()
{
    if( !mModel ) {
        mModel = new RecordSuperModel(this);
        RecordDataTranslator * rdt = new RecordDataTranslator(mModel->treeBuilder());
        rdt->setRecordColumnList(QStringList() << "key" << "fkeyjob" << "fkeyhost" << "message" << "fkeyuser" << "created");
        setModel( mModel );
        IniConfig & ini = userConfig();
        ini.pushSection( "JobHistoryView" );
        setupTreeView( ini, job_history_columns );
        ini.popSection();
    }
}
Esempio n. 6
0
void IScriptEditor::saveAll()
{
    QHashIterator<QString,file_t> i(files);
    while (i.hasNext()) {
        i.next();
        QString file = i.key();
        file_t ft = i.value();

        if (ft.modified == true) {
            saveFile(file);
            ft.modified = false;
        }

        files.insert(file, ft); // Update entry
    }

    setupTreeView(); // Reload in case meta-includes are changed.
}
Esempio n. 7
0
void IScriptEditor::setupTreeView()
{
    ignoreNextTextChange = true;

    disconnect(selection);

    treeModel.clear();
    treeModel.setHorizontalHeaderLabels(QStringList()<<"Included files");

    firstItem = new QStandardItem(scriptFile);
    setupTreeView(firstItem);

    treeModel.appendRow(firstItem);

    ui->treeView->setModel(&treeModel);
    ui->treeView->expandAll();

    selection = ui->treeView->selectionModel();

    connect(selection, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
            this, SLOT(currentRowChanged(QModelIndex,QModelIndex)));

    load(current, true);
}
/**
 * Constructor.
 * @param parent   the parent (wizard) of this wizard page
 */
CodeImpSelectPage::CodeImpSelectPage(QWidget *parent)
  : QWizardPage(parent),
    m_fileList(),
    m_fileExtensions()
{
    setTitle(i18n("Code Importing Path"));
    setSubTitle(i18n("Select the code importing path."));

    setupUi(this);

    setupLanguageBox();
    connect(ui_languageBox, SIGNAL(activated(int)), this, SLOT(languageChanged(int)));
    connect(this, SIGNAL(languageChanged()), this, SLOT(changeLanguage()));

    setupTreeView();
    connect(ui_treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(treeClicked(QModelIndex)));

    setupFileExtEdit();
    connect(ui_fileExtLineEdit, SIGNAL(editingFinished()), this, SLOT(fileExtChanged()));

    setupToolTips();
    // update file extensions
    changeLanguage();
}
Esempio n. 9
0
void IScriptEditor::on_btnSave_clicked()
{
    // save current
    saveFile(current);
    setupTreeView();
}
Esempio n. 10
0
void IScriptEditor::setupTreeView(QStandardItem *parent)
{
    QFile file(setRelativePath(scriptFile, parent->text()));
    QByteArray data;

    QTextCursor cursor = editor.textCursor();
    cursor.movePosition(QTextCursor::Start);
    int def = cursor.position();
    QPoint scroll = editor.verticalScrollBar()->pos();

    if (! file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        int q = QMessageBox::question(this, tr("Unable to open file"),
                                      tr("Unable to open '%1'\r\nAttempt to create it?")
                                       .arg(parent->text()),
                                      QMessageBox::Yes | QMessageBox::No);

        if (q == QMessageBox::Yes) {

            if (! file.open(QIODevice::WriteOnly | QIODevice::Text)) {
                QMessageBox::question(this, tr("Unable to create file"),
                                      tr("Unable to create file '%1'")
                                        .arg(parent->text()));
                file_t ft;
                ft.modified = false;
                ft.item = parent;
                ft.text = new QByteArray();
                ft.textCursor = def;
                ft.scrollPos = scroll;
                files.insert(parent->text(), ft);
                return;
            }
            else if (files.contains(parent->text())) {
                file.write( *files.value(parent->text()).text );
                file.close();
            }
        }

        file_t ft;
        ft.modified = false;
        ft.item = parent;
        ft.textCursor = def;
        ft.scrollPos = scroll;
        if (files.contains(parent->text())) {
            file_t f = files.value(parent->text());
            ft.text = f.text;
            ft.textCursor = f.textCursor;
            ft.scrollPos = f.scrollPos;
        }
        else
            ft.text = new QByteArray();
        files.insert(parent->text(), ft);
    }
    else {
        data = file.readAll();
        file.close();

        file_t ft;
        ft.modified = false;
        ft.item = parent;
        ft.text = new QByteArray(data);
        ft.textCursor = def;
        ft.scrollPos = scroll;
        if (files.contains(current)) {
            file_t f = files.value(current);
            ft.textCursor = f.textCursor;
            ft.scrollPos = f.scrollPos;
        }
        files.insert(parent->text(), ft);
    }

    enum { st_find=0, st_meta, st_include };
    /* States:
     * * Find: Finding the meta block
     * * Meta: We found meta, now find include keywords until next }.
     * * Include: Reading the include path until newline
     */
    bool comment = false; // If this is set to true, everything is ignored until newline
    int state = st_find;
    QString keyword;
    for (int i = 0; i <= data.length()-1; i++) {
        QChar c(data[i]);

        if (c == ';')
            comment = true;

        if ((comment) && (c == '\n')) {
            comment = false;
            keyword.clear(); // Make sure it's empty for next line.
            continue;
        }

        if (comment)
            continue;

        if (state == st_find) {
            if (((c == ' ') || c == '\n') && (! keyword.isEmpty())) {
                if ((keyword.toUpper() == "SCRIPT") ||
                   (keyword.toUpper() == "META")) {
                    // This should be the first keyword the script contains.

                    // skip until the {
                    for (; i <= data.length()-1; i++) {
                        if (data[i] == '{') {
                            keyword.clear();
                            state = st_meta;
                            break;
                        }
                    }
                }
                else
                    return; // No meta in this script.
            }
            else if ((c == '\n') && (keyword.isEmpty()))
                continue;
            else
                keyword += c;

            continue;
        }

        if (state == st_meta) {
            if (c == ' ') {
                if (keyword.isEmpty())
                    continue;

                if (keyword.toUpper() == "INCLUDE") {
                    // Found include file...
                    state = st_include;
                    keyword.clear();
                    continue;
                }
                else
                    keyword.clear();
            }
            else if (c == '}')
                return;
            else if (c == '\n')
                continue;
            else
                keyword += c;
        }

        if (state == st_include) {
            if (c == '\n') {
                if (keyword.isEmpty()) // empty include set, just ignore this.
                    state = st_meta;
                else {
                    QStandardItem *item = new QStandardItem(keyword);
                    parent->appendRow(item);
                    setupTreeView(item);

                    keyword.clear();
                    state = st_meta;
                }
            }
            else
                keyword += c;
        }
    }
}
Esempio n. 11
0
PrefabSelector::PrefabSelector() :
	DialogBase(_(PREFABSELECTOR_TITLE)),
	_treeStore(new wxutil::TreeModel(_columns)),
	_treeView(NULL),
	_lastPrefab(""),
	_populated(false),
    _description(NULL),
    _customPath(NULL)
{
	SetSizer(new wxBoxSizer(wxVERTICAL));

	wxBoxSizer* vbox = new wxBoxSizer(wxVERTICAL);
	GetSizer()->Add(vbox, 1, wxEXPAND | wxALL, 12);

    setupPathSelector(vbox);

	wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY,
		wxDefaultPosition, wxDefaultSize, wxSP_3D | wxSP_LIVE_UPDATE);
    splitter->SetMinimumPaneSize(10); // disallow unsplitting

	setupTreeView(splitter);
	
	wxPanel* previewPanel = new wxPanel(splitter, wxID_ANY);
	previewPanel->SetSizer(new wxBoxSizer(wxVERTICAL));

	_preview.reset(new ui::MapPreview(previewPanel));

	_description = new wxTextCtrl(previewPanel, wxID_ANY, "",
		wxDefaultPosition, wxDefaultSize, wxTE_LEFT | wxTE_MULTILINE | wxTE_READONLY | wxTE_WORDWRAP);
	_description->SetMinClientSize(wxSize(-1, 60));

	previewPanel->GetSizer()->Add(_description, 0, wxEXPAND | wxBOTTOM, 6);
	previewPanel->GetSizer()->Add(_preview->getWidget(), 1, wxEXPAND);

	splitter->SplitVertically(_treeView, previewPanel);

	vbox->Add(splitter, 1, wxEXPAND);

	wxStdDialogButtonSizer* buttonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL);
	wxButton* reloadButton = new wxButton(this, wxID_ANY, _("Rescan Prefab Folders"));
	reloadButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(PrefabSelector::onRescanPrefabs), NULL, this);

	buttonSizer->Prepend(reloadButton, 0, wxRIGHT, 32);
	vbox->Add(buttonSizer, 0, wxALIGN_RIGHT | wxTOP, 12);

	// Set the default size of the window
	_position.connect(this);
	_position.readPosition();

	// The model preview is half the width and 20% of the parent's height (to
	// allow vertical shrinking)
	_preview->setSize(static_cast<int>(_position.getSize()[0] * 0.4f),
		static_cast<int>(_position.getSize()[1] * 0.2f));

	FitToScreen(0.8f, 0.8f);

	splitter->SetSashPosition(static_cast<int>(GetSize().GetWidth() * 0.2f));

	_panedPosition.connect(splitter);
	_panedPosition.loadFromPath(RKEY_SPLIT_POS);

	Connect(wxutil::EV_TREEMODEL_POPULATION_FINISHED,
		TreeModelPopulationFinishedHandler(PrefabSelector::onTreeStorePopulationFinished), NULL, this);
}