void FileManager::addFile(const KURL& url, const KURL& newURL) { if (getMFI(newURL) == 0) { // Add new file to list of managed files. ManagedFileInfo* mfi = new ManagedFileInfo(this, url); files.push_back(mfi); // First show the file with the old name so it get's loaded. showInEditor(url); mfi->saveAs(newURL); // Insert the file into the browser and update the directory hierachy if // necessary. updateFileBrowser(); QListViewItem* lvi = mfi->getBrowserEntry(); browser->clearSelection(); browser->setCurrentItem(lvi); lvi->setSelected(true); browser->ensureItemVisible(lvi); } // Open new file in editor. showInEditor(newURL); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { QSettings settings ("binaervarianz.de", "FollowMe"); restoreGeometry(settings.value("geometry", saveGeometry()).toByteArray()); restoreState(settings.value("windowState", saveState()).toByteArray()); mfilelist= new FMFileList(parent); model = new QFileSystemModel; QString extPath = settings.value("extPath",QDir::homePath()).toString(); model->setRootPath(extPath ); list = new QTreeView(this); updateFileBrowser(extPath); setCentralWidget(list); QAction *prefAct = new QAction(tr("&Preferences..."), this); prefAct->setShortcuts(QKeySequence::Preferences); prefAct->setStatusTip(tr("Open preference pane")); connect(prefAct, SIGNAL(triggered()), this, SLOT(openPreferences())); QMenuBar* menu = menuBar(); QMenu* fileMenu = menu->addMenu(tr("&File")); fileMenu->addAction(prefAct); ui = new PreferenceDialog2(this); }
void FileManager::updateFileList(const QStringList& fl, const KURL& url) { if (fl.isEmpty()) return; // First we mark all files as no longer part of the project. for (std::list<ManagedFileInfo*>::iterator fli = files.begin(); fli != files.end(); ++fli) (*fli)->setPartOfProject(false); /* Then we add the new ones and mark the existing ones as part of the * project again. */ for (QStringList::ConstIterator sli = fl.begin(); sli != fl.end(); ++sli) { KURL url; url.setPath(*sli); bool newFile = true; // Is this file being managed already? for (std::list<ManagedFileInfo*>::iterator mfi = files.begin(); mfi != files.end(); ++mfi) { if ((*mfi)->getFileURL() == url) { (*mfi)->setPartOfProject(true); newFile = false; break; } } if (newFile) { // No, so let's add it to our internal list. ManagedFileInfo* mfi = new ManagedFileInfo(this, KURL::fromPathOrURL(*sli)); mfi->setPartOfProject(true); files.push_back(mfi); } } setMasterFile(url); updateFileBrowser(); if (browser->currentItem()) showInEditor(getCurrentFileURL()); else showInEditor(files.front()->getFileURL()); }