Mercurial > hg > octave-lojdl
changeset 16478:079ec7ce60e0
delete useless connection; style fixes
* main-window.cc (main_window::construct): Delete connection from
_workspace_model::model_changed to nonexistent slot
workspace_window::model_changed.
* workspace-model.cc, workspace-model.h, workspace-view.cc,
workspace-view.h: Style fixes.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 09 Apr 2013 03:40:28 -0400 |
parents | 64727ed135cb |
children | 7a71ea0b7ae9 |
files | libgui/src/main-window.cc libgui/src/workspace-model.cc libgui/src/workspace-model.h libgui/src/workspace-view.cc libgui/src/workspace-view.h |
diffstat | 5 files changed, 47 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -524,9 +524,6 @@ workspace_window->setModel (_workspace_model); - connect (_workspace_model, SIGNAL (model_changed ()), - workspace_window, SLOT (model_changed ())); - // Create and set the central widget. QMainWindow takes ownership of // the widget (pointer) so there is no need to delete the object upon // destroying this main_window.
--- a/libgui/src/workspace-model.cc +++ b/libgui/src/workspace-model.cc @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 John W. Eaton @@ -27,79 +26,77 @@ #endif #include <QTreeWidget> -#include <QTime> #include "symtab.h" #include "variables.h" #include "workspace-model.h" -#include "octave-link.h" -workspace_model::workspace_model(QObject *p) +workspace_model::workspace_model (QObject *p) : QAbstractTableModel (p) { - _columnNames.append(tr("Name")); - _columnNames.append(tr("Class")); - _columnNames.append(tr("Dimension")); - _columnNames.append(tr("Value")); -} - -workspace_model::~workspace_model() -{ + _columnNames.append (tr ("Name")); + _columnNames.append (tr ("Class")); + _columnNames.append (tr ("Dimension")); + _columnNames.append (tr ("Value")); } int -workspace_model::rowCount(const QModelIndex &p) const +workspace_model::rowCount(const QModelIndex& p) const { - return _symbols.size(); + return _symbols.size (); } int -workspace_model::columnCount(const QModelIndex &p) const +workspace_model::columnCount (const QModelIndex& p) const { - return _columnNames.size(); + return _columnNames.size (); } Qt::ItemFlags -workspace_model::flags(const QModelIndex &idx) const +workspace_model::flags (const QModelIndex& idx) const { - if (!idx.isValid()) + if (! idx.isValid ()) return 0; return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } QVariant -workspace_model::headerData(int section, Qt::Orientation orientation, int role) const +workspace_model::headerData (int section, Qt::Orientation orientation, + int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - { - return _columnNames[section]; - } - - return QVariant(); + return _columnNames[section]; + else + return QVariant(); } QVariant -workspace_model::data(const QModelIndex &idx, int role) const +workspace_model::data (const QModelIndex& idx, int role) const { if (!idx.isValid()) return QVariant(); + if (role != Qt::DisplayRole) - return QVariant(); + return QVariant (); + + switch (idx.column ()) + { + case 0: + return QVariant(_symbols[idx.row()]); - switch(idx.column()) - { - case 0: - return QVariant(_symbols[idx.row()]); - case 1: - return QVariant(_class_names[idx.row()]); - case 2: - return QVariant(_dimensions[idx.row()]); - case 3: - return QVariant(_values[idx.row()]); - } - return QVariant(); + case 1: + return QVariant(_class_names[idx.row()]); + + case 2: + return QVariant(_dimensions[idx.row()]); + + case 3: + return QVariant(_values[idx.row()]); + } + + return QVariant (); } void @@ -109,7 +106,6 @@ const QStringList& dimensions, const QStringList& values) { - _scopes = scopes; _symbols = symbols; _class_names = class_names; @@ -145,10 +141,9 @@ { beginResetModel(); - // nothing to do except tell the world to recalc + // Nothing to do except tell the world to recalc. endResetModel (); emit model_changed (); } -
--- a/libgui/src/workspace-model.h +++ b/libgui/src/workspace-model.h @@ -38,18 +38,18 @@ workspace_model (QObject *parent = 0); - ~workspace_model (void); + ~workspace_model (void) { } - QVariant data (const QModelIndex &index, int role) const; + QVariant data (const QModelIndex& index, int role) const; - Qt::ItemFlags flags (const QModelIndex &index) const; + Qt::ItemFlags flags (const QModelIndex& index) const; QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - int rowCount (const QModelIndex &parent = QModelIndex ()) const; + int rowCount (const QModelIndex& parent = QModelIndex ()) const; - int columnCount (const QModelIndex &parent = QModelIndex ()) const; + int columnCount (const QModelIndex& parent = QModelIndex ()) const; public slots: @@ -79,4 +79,4 @@ QStringList _columnNames; }; -#endif // WORKSPACEMODEL_H +#endif
--- a/libgui/src/workspace-view.cc +++ b/libgui/src/workspace-view.cc @@ -37,7 +37,7 @@ : octave_dock_widget (p) { setObjectName ("WorkspaceView"); - setWindowIcon (QIcon(":/actions/icons/logo.png")); + setWindowIcon (QIcon (":/actions/icons/logo.png")); setWindowTitle (tr ("Workspace")); setStatusTip (tr ("View the variables in the active workspace.")); @@ -72,11 +72,11 @@ connect (view, SIGNAL (doubleClicked (QModelIndex)), this, SLOT (item_double_clicked (QModelIndex))); - connect (view, SIGNAL (customContextMenuRequested(const QPoint&)), + connect (view, SIGNAL (customContextMenuRequested (const QPoint&)), this, SLOT(contextmenu_requested (const QPoint&))); connect (this, SIGNAL (command_requested (const QString&)), - p, SLOT (handle_command_double_clicked(const QString&))); + p, SLOT (handle_command_double_clicked (const QString&))); } workspace_view::~workspace_view (void) @@ -114,7 +114,7 @@ // if it isnt Local, Glocal etc, allow the ctx menu if (index.isValid()) { - index = index.sibling(index.row(), 0); + index = index.sibling (index.row(), 0); QMap<int, QVariant> item_data = m->itemData (index);