Тема: Jentos.Code
Показать сообщение отдельно
Старый 19.06.2014, 12:50   #30
Жека
Дэвелопер
 
Регистрация: 04.09.2005
Адрес: Красноярск
Сообщений: 1,376
Написано 491 полезных сообщений
(для 886 пользователей)
Ответ: Jentos IDE

Сделал переименование. Пора делать промо: скрины, новое описание на сайт и на форумы.
Просто для прикола функция замены:
void MainWindow::onUsagesRename() {
    QString newIdent = _ui->editUsagesRename->text();
    if(newIdent == "") {
        QMessageBox::information(this,"Rename","Field 'Rename with' is empty! Enter correct value.");
        return;
    }
    QWidget *w = _ui->usagesTabWidget->currentWidget();
    w = w->layout()->itemAt(0)->widget();
    QTreeWidget *tree = dynamic_cast<QTreeWidget*>(w);
    if(!tree)
        return;
    int newLen = newIdent.length();
    bool selOnly = _ui->chbUsageSelectedOnly->isChecked();
    QTreeWidgetItem *root = tree->invisibleRootItem();
    for(int k = 0; k < root->childCount(); ++k) {
        QTreeWidgetItem *item = root->child(k);
        bool first = true;
        int delta = 0;
        for(int j = 0; j < item->childCount(); ++j) {
            QTreeWidgetItem *sub = item->child(j);
            if(selOnly && sub->checkState(0) != Qt::Checked) {
                continue;
            }
            UsagesResult *u = UsagesResult::item(sub);
            if(u) {
                if(first) {
                    openFile(u->path, true);
                    first = false;
                }
                if(_codeEditor) {
                    int from = u->positionStart+delta;
                    int to = u->positionEnd+delta;
                    _codeEditor->replaceInRange(from, to, newIdent);
                    delta += (newLen - u->ident.length());
                }
            }
        }
    }
}
(Offline)
 
Ответить с цитированием
Сообщение было полезно следующим пользователям:
Randomize (09.02.2015)