Browse Source

sort of bug squashing

master
hex 5 years ago
parent
commit
b8150f6f06
  1. 1
      include/window.h
  2. 6
      src/pane.cpp
  3. 1
      src/pane.h
  4. 12
      src/window.cpp

1
include/window.h

@ -18,6 +18,7 @@ public: @@ -18,6 +18,7 @@ public:
public slots:
void switchActivePane(hex::Pane* newPane);
void switchActiveTab(int newTab);
void changeFolder(const QString& newFolder);
private:
QPushButton *mButton;

6
src/pane.cpp

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
#include <QListView>
#include <QVBoxLayout>
#include <QFileSystemModel>
#include <iostream>
namespace hex {
@ -36,17 +37,18 @@ void Pane::changeIndex(const QModelIndex& index) { @@ -36,17 +37,18 @@ void Pane::changeIndex(const QModelIndex& index) {
mView->setRootIndex(index);
emit pathChanged(mModel->filePath(index));
emit folderChanged(mModel->fileName(index));
} else {
//open file
}
}
void Pane::moveUp() {
changeIndex(mView->currentIndex().parent());
changeIndex(mView->rootIndex().parent());
}
QString Pane::getPath() {
return mModel->filePath(mView->currentIndex());
return mModel->filePath(mView->rootIndex());
}
}

1
src/pane.h

@ -21,6 +21,7 @@ public slots: @@ -21,6 +21,7 @@ public slots:
signals:
void pathChanged(const QString& newPath);
void folderChanged(const QString& newFolder);
private:
QListView* mView;

12
src/window.cpp

@ -36,12 +36,16 @@ Window::Window(QWidget *parent) : @@ -36,12 +36,16 @@ Window::Window(QWidget *parent) :
QObject::connect(mTabWidget, &QTabWidget::currentChanged,
this, &Window::switchActiveTab);
mTabWidget->setCurrentIndex(0);
switchActiveTab(0);
this->setLayout(body);
}
void Window::switchActivePane(hex::Pane* newPane) {
//TODO: Replace this garbage. It's broken.
mPathBar->setText(newPane->getPath());
QObject::connect(mButton, &QPushButton::clicked,
newPane, &hex::Pane::moveUp);
@ -49,9 +53,15 @@ void Window::switchActivePane(hex::Pane* newPane) { @@ -49,9 +53,15 @@ void Window::switchActivePane(hex::Pane* newPane) {
// newPane, &hex::Pane::setPath);
QObject::connect(newPane, &hex::Pane::pathChanged,
mPathBar, &QLineEdit::setText);
QObject::connect(newPane, &hex::Pane::folderChanged,
this, &Window::changeFolder);
}
void Window::switchActiveTab(int newTab) {
std::cout << newTab;
switchActivePane(dynamic_cast<hex::Pane*>(mTabWidget->widget(newTab)));
}
void Window::changeFolder(const QString& newFolder) {
mTabWidget->setTabText(mTabWidget->currentIndex(), newFolder);
}

Loading…
Cancel
Save