Ver código fonte

Scrolling in configuration tree view. Fixes #19

Neal Wilson 11 anos atrás
pai
commit
9ac838efce
2 arquivos alterados com 334 adições e 298 exclusões
  1. 314
    298
      src/typica.cpp
  2. 20
    0
      src/typica.w

+ 314
- 298
src/typica.cpp
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 20
- 0
src/typica.w Ver arquivo

@@ -14862,6 +14862,8 @@ class DeviceConfigurationWindow : public QMainWindow
14862 14862
 		void addDevice();
14863 14863
 		void removeNode();
14864 14864
 		void newSelection(const QModelIndex &index);
14865
+	@[private slots@]:@/
14866
+		void resizeColumn();
14865 14867
 	private:@/
14866 14868
 		QDomDocument document;
14867 14869
 		DeviceTreeModel *model;
@@ -14896,7 +14898,9 @@ DeviceConfigurationWindow::DeviceConfigurationWindow() : QMainWindow(NULL),
14896 14898
 	document = AppInstance->deviceConfiguration();
14897 14899
 	model = new DeviceTreeModel;
14898 14900
 	view->setModel(model);
14901
+	view->setTextElideMode(Qt::ElideNone);
14899 14902
 	view->expandAll();
14903
+	view->resizeColumnToContents(0);
14900 14904
 	connect(model, SIGNAL(modelReset()), view, SLOT(expandAll()));
14901 14905
 	QHBoxLayout *treeButtons = new QHBoxLayout;
14902 14906
 	QToolButton *addDeviceButton = new QToolButton;
@@ -14924,6 +14928,10 @@ DeviceConfigurationWindow::DeviceConfigurationWindow() : QMainWindow(NULL),
14924 14928
 	        this, SLOT(newSelection(QModelIndex)));
14925 14929
 	connect(model, SIGNAL(rowsInserted(QModelIndex, int, int)),
14926 14930
 	        view, SLOT(expand(QModelIndex)));
14931
+	connect(model, SIGNAL(rowsInserted(QModelIndex, int, int)),
14932
+	        this, SLOT(resizeColumn()));
14933
+	connect(model, SIGNAL(rowsRemoved(QModelIndex, int, int)),
14934
+	        this, SLOT(resizeColumn()));
14927 14935
 }
14928 14936
 
14929 14937
 @ Adding a new top level node to the model is just a matter of extracting the
@@ -14964,6 +14972,18 @@ void DeviceConfigurationWindow::newSelection(const QModelIndex &index)
14964 14972
 	}
14965 14973
 }
14966 14974
 
14975
+@ As nodes are added deeper in the device hierarchy or as nodes obtain longer
14976
+names, the nodes names may be elided by default rather than indicate that the
14977
+view can be scrolled horizontally. There has been feedback that this behavior
14978
+is not preferred so instead as the model data changes we expand the column
14979
+instead.
14980
+
14981
+@<DeviceConfigurationWindow implementation@>=
14982
+void DeviceConfigurationWindow::resizeColumn()
14983
+{
14984
+	view->resizeColumnToContents(0);
14985
+}
14986
+
14967 14987
 @ At least for the initial testing of this feature it will be useful if we can
14968 14988
 instantiate this from the host environment. For this we at least require a
14969 14989
 constructor.

Carregando…
Cancelar
Salvar