diff --git a/src/SeerEditorWidget.cpp b/src/SeerEditorWidget.cpp
index b96f7af..c587427 100644
--- a/src/SeerEditorWidget.cpp
+++ b/src/SeerEditorWidget.cpp
@@ -38,6 +38,7 @@ SeerEditorWidget::SeerEditorWidget(QWidget *parent) : QWidget(parent) {
QObject::connect(searchCloseToolButton, &QToolButton::clicked, this, &SeerEditorWidget::handleSearchCloseToolButton);
QObject::connect(alternateCloseToolButton, &QToolButton::clicked, this, &SeerEditorWidget::handleAlternateCloseToolButton);
QObject::connect(alternateFileOpenToolButton, &QToolButton::clicked, this, &SeerEditorWidget::handleAlternateFileOpenToolButton);
+ QObject::connect(alternateAcceptToolButton, &QToolButton::clicked, this, &SeerEditorWidget::handleAlternateAcceptToolButton);
QObject::connect(sourceWidget, &SeerEditorWidgetSourceArea::showSearchBar, this, &SeerEditorWidget::showSearchBar);
QObject::connect(sourceWidget, &SeerEditorWidgetSourceArea::showAlternateBar, this, &SeerEditorWidget::showAlternateBar);
}
@@ -183,12 +184,29 @@ void SeerEditorWidget::handleAlternateCloseToolButton () {
void SeerEditorWidget::handleAlternateFileOpenToolButton () {
- qDebug() << "fullname=" << sourceArea()->fullname();
- qDebug() << "file =" << sourceArea()->file();
+ //qDebug() << "fullname =" << sourceArea()->fullname();
+ //qDebug() << "file =" << sourceArea()->file();
- QString fileName = QFileDialog::getOpenFileName(this, "Locate File", sourceArea()->fullname(), QString("File (%1)").arg(sourceArea()->file()), nullptr, QFileDialog::DontUseNativeDialog);
+ QString filename = QFileDialog::getOpenFileName(this, "Locate File", sourceArea()->fullname(), QString("File (%1)").arg(sourceArea()->file()), nullptr, QFileDialog::DontUseNativeDialog);
- qDebug() << "location=" << fileName;
- qDebug() << "path =" << QFileInfo(fileName).absolutePath();
+ //qDebug() << "location =" << filename;
+ //qDebug() << "directory=" << QFileInfo(filename).absolutePath();
+
+ if (filename != "") {
+ alternateLineEdit->setText(QFileInfo(filename).absolutePath());
+ }
+}
+
+void SeerEditorWidget::handleAlternateAcceptToolButton () {
+
+ showAlternateBar(false);
+
+ QString dirname = alternateLineEdit->text();
+
+ //qDebug() << "alternate dirname=" << dirname;
+
+ if (dirname != "") {
+ sourceArea()->open(sourceArea()->fullname(), sourceArea()->file(), dirname);
+ }
}
diff --git a/src/SeerEditorWidget.h b/src/SeerEditorWidget.h
index 355ee22..2fadd69 100644
--- a/src/SeerEditorWidget.h
+++ b/src/SeerEditorWidget.h
@@ -42,11 +42,14 @@ class SeerEditorWidgetSourceArea : public QPlainTextEdit {
int miniMapAreaWidth ();
bool isOpen () const;
- void open (const QString& fullname, const QString& file);
+ void open (const QString& fullname, const QString& file, const QString& alternateDirectory="");
void openText (const QString& text, const QString& file);
const QString& fullname () const;
const QString& file () const;
void close ();
+ void setAlternateDirectory (const QString& alternateDirectory);
+ const QString& alternateDirectory () const;
+
void setCurrentLine (int lineno);
void scrollToLine (int lineno);
@@ -115,6 +118,8 @@ class SeerEditorWidgetSourceArea : public QPlainTextEdit {
private:
QString _fullname;
QString _file;
+ QString _alternateDirectory;
+
bool _enableLineNumberArea;
bool _enableBreakPointArea;
bool _enableMiniMapArea;
@@ -209,18 +214,21 @@ class SeerEditorWidget : public QWidget, protected Ui::SeerEditorWidgetForm {
explicit SeerEditorWidget (QWidget* parent = 0);
~SeerEditorWidget ();
- SeerEditorWidgetSourceArea* sourceArea ();
+ SeerEditorWidgetSourceArea* sourceArea ();
- void handleLineNumberLineEdit ();
- void handleSearchTextLineEdit ();
- void handleSearchDownToolButton ();
- void handleSearchUpToolButton ();
- void handleCloseToolButton ();
+ void handleSearchLineNumberLineEdit ();
+ void handleSearchTextLineEdit ();
+ void handleSearchDownToolButton ();
+ void handleSearchUpToolButton ();
+ void handleSearchCloseToolButton ();
+ void handleAlternateCloseToolButton ();
+ void handleAlternateFileOpenToolButton ();
+ void handleAlternateAcceptToolButton ();
public slots:
- void showSearchBar (bool flag);
- bool isSearchBarShown () const;
- void showAlternateBar (bool flag);
- bool isAlternateBarShown () const;
+ void showSearchBar (bool flag);
+ bool isSearchBarShown () const;
+ void showAlternateBar (bool flag);
+ bool isAlternateBarShown () const;
};
diff --git a/src/SeerEditorWidget.ui b/src/SeerEditorWidget.ui
index abded08..9e01c45 100644
--- a/src/SeerEditorWidget.ui
+++ b/src/SeerEditorWidget.ui
@@ -154,7 +154,7 @@
-
-
+
20
@@ -177,7 +177,7 @@
-
-
+
Close the search bar. CTRL+F to reshow it.
diff --git a/src/SeerEditorWidgetSourceArea.cpp b/src/SeerEditorWidgetSourceArea.cpp
index 123df88..0eea417 100644
--- a/src/SeerEditorWidgetSourceArea.cpp
+++ b/src/SeerEditorWidgetSourceArea.cpp
@@ -581,7 +581,7 @@ bool SeerEditorWidgetSourceArea::isOpen () const {
return false;
}
-void SeerEditorWidgetSourceArea::open (const QString& fullname, const QString& file) {
+void SeerEditorWidgetSourceArea::open (const QString& fullname, const QString& file, const QString& alternateDirectory) {
// Close the previous file, if any.
if (isOpen()) {
@@ -589,8 +589,9 @@ void SeerEditorWidgetSourceArea::open (const QString& fullname, const QString& f
}
// Save the filename.
- _fullname = fullname;
- _file = file;
+ _fullname = fullname;
+ _file = file;
+ _alternateDirectory = alternateDirectory;
setDocumentTitle(_fullname);
@@ -599,14 +600,37 @@ void SeerEditorWidgetSourceArea::open (const QString& fullname, const QString& f
return;
}
+ // If the file is null, don't do anything.
+ if (_file == "") {
+ qDebug() << "'file' is null. Skipping.";
+ return;
+ }
+
+ //
// Open the file.
- QFile inputFile(_fullname);
+ //
+ // Build the filename to open. If there is no alternateDirectory,
+ // use fullname. If alternateDirectory is provided, then use
+ //
+ // alternateDirectory/file
+ //
+ QString filename;
+
+ if (alternateDirectory == "") {
+ filename = _fullname;
+ }else{
+ filename = _alternateDirectory + "/" + _file;
+ }
+
+ //qDebug() << "Loading" << _file << "from" << filename;
+
+ QFile inputFile(filename);
inputFile.open(QIODevice::ReadOnly);
if (!inputFile.isOpen()) {
- QMessageBox::critical(this, "Can't open source file.", "Can't open : " + _fullname + "\nIts location may have changed.");
+ QMessageBox::critical(this, "Can't open source file.", "Can't open : " + filename + "\nIts location may have changed.");
emit showAlternateBar(true);
@@ -679,6 +703,17 @@ void SeerEditorWidgetSourceArea::close () {
clearExpression();
}
+void SeerEditorWidgetSourceArea::setAlternateDirectory (const QString& alternateDirectory) {
+
+ _alternateDirectory = alternateDirectory;
+}
+
+const QString& SeerEditorWidgetSourceArea::alternateDirectory () const {
+
+ return _alternateDirectory;
+}
+
+
void SeerEditorWidgetSourceArea::setCurrentLine (int lineno) {
//qDebug() << lineno << file();