work save: open project file ok
This commit is contained in:
parent
85e9b4d697
commit
6266a8adbf
|
@ -102,7 +102,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
|||
}
|
||||
|
||||
if (inProject) {
|
||||
//todo:
|
||||
mParser = pMainWindow->project()->cppParser();
|
||||
} else {
|
||||
initParser();
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ Editor::~Editor() {
|
|||
int index = mParentPageControl->indexOf(this);
|
||||
mParentPageControl->removeTab(index);
|
||||
}
|
||||
this->setParent(0);
|
||||
this->setParent(nullptr);
|
||||
}
|
||||
|
||||
void Editor::loadFile() {
|
||||
|
|
|
@ -6,11 +6,13 @@
|
|||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include "settings.h"
|
||||
#include "project.h"
|
||||
|
||||
EditorList::EditorList(QTabWidget* leftPageWidget,
|
||||
QTabWidget* rightPageWidget,
|
||||
QSplitter* splitter,
|
||||
QWidget* panel):
|
||||
mLayout(LayoutShowType::lstLeft),
|
||||
mLeftPageWidget(leftPageWidget),
|
||||
mRightPageWidget(rightPageWidget),
|
||||
mSplitter(splitter),
|
||||
|
@ -31,8 +33,9 @@ Editor* EditorList::newEditor(const QString& filename, const QByteArray& encodin
|
|||
if (!filename.isEmpty() && QFile(filename).exists()) {
|
||||
pMainWindow->fileSystemWatcher()->addPath(filename);
|
||||
}
|
||||
return new Editor(parentPageControl,filename,encoding,inProject,newFile,parentPageControl);
|
||||
Editor * e = new Editor(parentPageControl,filename,encoding,inProject,newFile,parentPageControl);
|
||||
updateLayout();
|
||||
return e;
|
||||
}
|
||||
|
||||
QTabWidget* EditorList::getNewEditorPageControl() const {
|
||||
|
@ -56,17 +59,14 @@ void EditorList::showLayout(LayoutShowType layout)
|
|||
case LayoutShowType::lstNone:
|
||||
mLeftPageWidget->setVisible(true);
|
||||
mRightPageWidget->setVisible(false);
|
||||
mSplitter->setVisible(false);
|
||||
break;
|
||||
case LayoutShowType::lstRight:
|
||||
mLeftPageWidget->setVisible(false);
|
||||
mRightPageWidget->setVisible(true);
|
||||
mSplitter->setVisible(false);
|
||||
break;
|
||||
case LayoutShowType::lstBoth:
|
||||
mLeftPageWidget->setVisible(true);
|
||||
mRightPageWidget->setVisible(true);
|
||||
mSplitter->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,17 +114,22 @@ bool EditorList::closeEditor(Editor* editor, bool transferFocus, bool force) {
|
|||
//todo: activate & focus the previous editor
|
||||
}
|
||||
|
||||
if (editor->inProject() && pMainWindow->project()) {
|
||||
int projIndex = pMainWindow->project()->indexInUnits(editor);
|
||||
if (projIndex>=0) {
|
||||
pMainWindow->project()->closeUnit(projIndex);
|
||||
}
|
||||
} else {
|
||||
if (pSettings->history().addToOpenedFiles(editor->filename())) {
|
||||
pMainWindow->rebuildOpenedFileHisotryMenu();
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
pMainWindow->fileSystemWatcher()->removePath(editor->filename());
|
||||
delete editor;
|
||||
|
||||
}
|
||||
updateLayout();
|
||||
if (!force) {
|
||||
editor = getEditor();
|
||||
if (!force)
|
||||
pMainWindow->updateClassBrowserForEditor(editor);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -317,6 +322,8 @@ void EditorList::getVisibleEditors(Editor *&left, Editor *&right)
|
|||
|
||||
void EditorList::updateLayout()
|
||||
{
|
||||
qDebug()<<mLeftPageWidget->count();
|
||||
qDebug()<<mRightPageWidget->count();
|
||||
if (mLeftPageWidget->count() ==0 && mRightPageWidget->count() == 0)
|
||||
showLayout(LayoutShowType::lstNone);
|
||||
else if (mLeftPageWidget->count() > 0 && mRightPageWidget->count() == 0)
|
||||
|
|
|
@ -2815,3 +2815,16 @@ std::shared_ptr<Project> MainWindow::project()
|
|||
return mProject;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_projectView_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
FolderNode * node = static_cast<FolderNode*>(index.internalPointer());
|
||||
if (!node)
|
||||
return;
|
||||
if (node->unitIndex>=0) {
|
||||
mProject->openUnit(node->unitIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -303,6 +303,8 @@ private slots:
|
|||
|
||||
void on_tblBreakpoints_doubleClicked(const QModelIndex &index);
|
||||
|
||||
void on_projectView_doubleClicked(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
EditorList *mEditorList;
|
||||
|
|
|
@ -108,7 +108,11 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeView" name="projectView"/>
|
||||
<widget class="QTreeView" name="projectView">
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -789,7 +793,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>946</width>
|
||||
<height>22</height>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
|
@ -124,8 +124,8 @@ void Project::open()
|
|||
QDir dir(directory());
|
||||
for (int i=0;i<uCount;i++) {
|
||||
PProjectUnit newUnit = std::make_shared<ProjectUnit>(this);
|
||||
mIniFile->beginGroup(QString("Unit%1").arg(i));
|
||||
newUnit->setFileName(dir.filePath(mIniFile->value("FileName","").toString()));
|
||||
mIniFile->beginGroup(QString("Unit%1").arg(i+1));
|
||||
newUnit->setFileName(dir.absoluteFilePath(mIniFile->value("FileName","").toString()));
|
||||
if (!QFileInfo(newUnit->fileName()).exists()) {
|
||||
QMessageBox::critical(pMainWindow,
|
||||
tr("File Not Found"),
|
||||
|
|
|
@ -183,6 +183,8 @@ public:
|
|||
QString getFolderPath(PFolderNode node);
|
||||
int getUnitFromString(const QString& s);
|
||||
void incrementBuildNumber();
|
||||
int indexInUnits(const QString& fileName) const;
|
||||
int indexInUnits(const Editor* editor) const;
|
||||
QString listUnitStr(const QChar& separator);
|
||||
void loadLayout(); // load all [UnitX]
|
||||
void loadOptions();
|
||||
|
@ -236,8 +238,6 @@ signals:
|
|||
void modifyChanged(bool value);
|
||||
private:
|
||||
void open();
|
||||
int indexInUnits(const QString& fileName) const;
|
||||
int indexInUnits(const Editor* editor) const;
|
||||
void removeFolderRecurse(PFolderNode node);
|
||||
void updateFolderNode(PFolderNode node);
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue