GitBrowser::GitBrowser(QString localRepoFolder, QWidget *parent) : QWidget(parent), newDocumentDialog(0) { Q_INIT_RESOURCE(gitbrowser); ui = new Ui::GitBrowser; ui->setupUi(this); repoParams = new RepoParams(); model = new QFileSystemModel; model->setNameFilters(QStringList()<<"*.lyx"); model->setNameFilterDisables(false); repoFolder = localRepoFolder; model->setRootPath(repoFolder); model->setReadOnly(false); ui->listView->setModel(model); ui->listView->setEditTriggers(QAbstractItemView::SelectedClicked|QAbstractItemView::EditKeyPressed); connect(model, SIGNAL(fileRenamed(QString,QString,QString)), this, SLOT(onFileRenamed(QString,QString,QString))); syncWidget = new SyncDialog(this); repoSettingsDialog = new RepoSettings(this); connect(repoSettingsDialog, SIGNAL(changed()), this, SLOT(updateRepoParams())); git = new GitManager(repoFolder); actUpdate = new QAction(QIcon(":/images/refresh.png"), "Обновить", this); connect(actUpdate, SIGNAL(triggered()), this, SLOT(callUpdate())); actUp = new QAction(QIcon(":/images/arrow-up.png"), "Перейти на каталог выше", this); connect(actUp, SIGNAL(triggered()), this, SLOT(up())); actGo = new QAction(QIcon(":/images/go.png"), "Перейти", this); connect(actGo, SIGNAL(triggered()), this, SLOT(onGoBtn_clicked())); actOpen = new QAction("Открыть", this); connect(actOpen, SIGNAL(triggered()), this, SLOT(callOpen())); actVersions = new QAction("Версии...", this); connect(actVersions, SIGNAL(triggered()), this, SLOT(callVersions())); actRename = new QAction("Переименовать", this); connect(actRename, SIGNAL(triggered()), this, SLOT(callRename())); actRemove = new QAction("Удалить", this); connect(actRemove, SIGNAL(triggered()), this, SLOT(callRemove())); actNewDir = new QAction("Новая папка", this); connect(actNewDir, SIGNAL(triggered()), this, SLOT(callNewDir())); actNewDocument = new QAction(QIcon(":/images/new-document.png"), "Новый документ", this); connect(actNewDocument, SIGNAL(triggered()), this, SLOT(callNewDocument())); actCopy = new QAction("Копировать", this); connect(actCopy, SIGNAL(triggered()), this, SLOT(callCopy())); actCut = new QAction("Вырезать", this); connect(actCut, SIGNAL(triggered()), this, SLOT(callCut())); actPaste = new QAction("Вставить", this); connect(actPaste, SIGNAL(triggered()), this, SLOT(callPaste())); actRepoSettings = new QAction(QIcon(":/images/settings.png"), "Настройки репозитория", this); connect(actRepoSettings, SIGNAL(triggered(bool)), SLOT(callRepoSettings())); ui->listView->setContextMenuPolicy(Qt::CustomContextMenu); registerAction("settings", actRepoSettings); registerAction("new-document", actNewDocument); ui->navigationPanel->addActions(QList<QAction* >()<<actUpdate<<actUp); pathLE = new QLineEdit(); connect(pathLE, SIGNAL(returnPressed()), this, SLOT(onLineEdit_returnPressed())); ui->navigationPanel->addWidget(pathLE); ui->navigationPanel->addActions(QList<QAction* >()<<actGo); QList<int> list= ui->splitter->sizes(); list.replace(0,200); list.replace(1,this->width()-200); ui->splitter->setSizes(list); QJS rootItem; rootItem["name"] = "Хранилища"; QJS n1; n1["name"] = "Отчеты"; n1["type"] = "folder"; QJS n2; n2["name"] = "Карточки"; n2["type"] = "folder"; QJS n3; n3["name"] = "Инструкции"; n3["type"] = "folder"; QJS n4; n4["name"] = "Генетические отчеты"; n4["type"] = "folder"; QJS n5; n5["name"] = "Прочие отчеты"; n5["type"] = "folder"; n1["children"][0] = n4; n1["children"][1] = n5; rootItem["children"][0] = n1; rootItem["children"][1] = n2; rootItem["children"][2] = n3; QJSModel *rm = new QJSModel(rootItem); rm->setIcon("folder", "://images/folder.png"); ui->treeView->setModel(rm); go("/"); connect(syncWidget, SIGNAL(retry()), this, SLOT(retry())); }
void FileItem::fileRenamed(const QString& old_path, const QString& new_path) { if (old_path == path_) { path_ = new_path; emit onFileRenamed(old_path, new_path); } }