diff options
| author | deva <deva> | 2011-02-08 09:19:14 +0000 | 
|---|---|---|
| committer | deva <deva> | 2011-02-08 09:19:14 +0000 | 
| commit | a65a5d1594d09d575d9e835d684eb52675341054 (patch) | |
| tree | 8829f4ffbb14b7f667fa054758e607b09fff0121 | |
| parent | 9d1dc91e1e2c11ea6df8e163b0e43f1dd43655d5 (diff) | |
Scroll into view when a new macro is expanded.
| -rw-r--r-- | client/collapser.cc | 10 | ||||
| -rw-r--r-- | client/collapser.h | 6 | ||||
| -rw-r--r-- | client/macro.cc | 7 | ||||
| -rw-r--r-- | client/macro.h | 5 | ||||
| -rw-r--r-- | client/macrowindow.cc | 5 | ||||
| -rw-r--r-- | client/macrowindow.h | 3 | ||||
| -rw-r--r-- | client/mainwindow.cc | 10 | ||||
| -rw-r--r-- | client/mainwindow.h | 1 | 
8 files changed, 34 insertions, 13 deletions
| diff --git a/client/collapser.cc b/client/collapser.cc index 1d77c09..cbbd84e 100644 --- a/client/collapser.cc +++ b/client/collapser.cc @@ -31,11 +31,14 @@  #define ANIM_TIME 100  #define ANIM_INTERVAL 20 -Collapser::Collapser(QWidget *collapsed, QWidget *expanded, bool setcollapsed) +Collapser::Collapser(QWidget *collapsed, QWidget *expanded, bool setcollapsed, +                     QScrollArea *scrollarea)  {    this->collapsed = NULL;    this->expanded = NULL; +  this->scrollarea = scrollarea; +    timer = new QTimer(this);    timer->setSingleShot(true);    timer->setInterval(ANIM_INTERVAL); @@ -203,6 +206,11 @@ void Collapser::anim()        setFixedHeight(e_height);        emit doneExpanding(); + +      if(scrollarea && expanded) { +        scrollarea->ensureWidgetVisible(expanded); +      } +      }    } diff --git a/client/collapser.h b/client/collapser.h index 03d74d7..8b38359 100644 --- a/client/collapser.h +++ b/client/collapser.h @@ -30,11 +30,13 @@  #include <QWidget>  #include <QTime>  #include <QTimer> +#include <QScrollArea>  class Collapser : public QWidget {  Q_OBJECT  public: -  Collapser(QWidget *collapsed = NULL, QWidget *expanded = NULL, bool setcollapsed = true); +  Collapser(QWidget *collapsed = NULL, QWidget *expanded = NULL, +            bool setcollapsed = true, QScrollArea *scrollarea = NULL);    bool isCollapsed();    void setCollapsed(bool setcollapsed); @@ -66,6 +68,8 @@ private:    QWidget *collapsed;    QWidget *expanded; +  QScrollArea *scrollarea; +    bool is_collapsed;    QTime t_anim; diff --git a/client/macro.cc b/client/macro.cc index 4ac56f6..6e58a5c 100644 --- a/client/macro.cc +++ b/client/macro.cc @@ -35,11 +35,13 @@  #include "macrodrawer.h"  #include "macrowindow.h" -Macro::Macro(QDomNode &n) +Macro::Macro(QDomNode &n, QScrollArea *scrollarea)  {    window = NULL;    drawer = NULL; +  this->scrollarea = scrollarea; +    update(n);  } @@ -95,7 +97,8 @@ void Macro::init(QBoxLayout *layout, Macros ¯os,    //  if(macros.find(name) == macros.end()) {    if(window == NULL && drawer == NULL) { -    window = new MacroWindow(netcom, node, templ, isstatic, iscompact); +    window = new MacroWindow(netcom, node, templ, isstatic, iscompact, +                             scrollarea);      /*      QWidget *edge = new QWidget(); diff --git a/client/macro.h b/client/macro.h index b1b8032..37f706e 100644 --- a/client/macro.h +++ b/client/macro.h @@ -34,6 +34,8 @@  #include <QDomNode>  #include <QBoxLayout> +#include <QScrollArea> +  #include "netcom.h"  class Macro; @@ -45,7 +47,7 @@ class MacroDrawer;  class Macro {  public:    Macro() {} -  Macro(QDomNode &node); +  Macro(QDomNode &node, QScrollArea *scrollarea);    void init(QBoxLayout *layout, Macros ¯os, bool initialising,              NetCom &netcom, QString templ); @@ -70,6 +72,7 @@ public:  private:    QDomNode node; +  QScrollArea *scrollarea;  };  #endif/*__PRACRO_MACRO_H__*/ diff --git a/client/macrowindow.cc b/client/macrowindow.cc index 369f71f..4ee5404 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -46,8 +46,9 @@ extern QString host;  extern quint16 port;  MacroWindow::MacroWindow(NetCom &n, QDomNode &xml_doc, QString templ, -                         bool is_static, bool compact) -  : Collapser(), netcom(n) +                         bool is_static, bool compact, +                         QScrollArea *scrollarea) +  : Collapser(NULL, NULL, true, compact?NULL:scrollarea), netcom(n)  {    this->is_static = is_static; diff --git a/client/macrowindow.h b/client/macrowindow.h index 8aedd1e..a41af01 100644 --- a/client/macrowindow.h +++ b/client/macrowindow.h @@ -41,7 +41,8 @@ class MacroWindow : public Collapser  Q_OBJECT  public:    MacroWindow(NetCom &netcom, QDomNode &xml_doc, QString templ, -              bool is_static = false, bool compact = false); +              bool is_static = false, bool compact = false, +              QScrollArea *scrollarea = NULL);    ~MacroWindow();    LUA *lua; diff --git a/client/mainwindow.cc b/client/mainwindow.cc index 03087ad..31039d4 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -103,11 +103,11 @@ MainWindow::MainWindow(QString cpr, QString templ, QString host,    connect(close_no_commit, SIGNAL(triggered()), this, SLOT(closeNoCommit()));    //  connect(show_sessions, SIGNAL(triggered()), this, SLOT(showSessions())); -  QScrollArea *s = new QScrollArea(); -  setCentralWidget(s); +  scrollarea = new QScrollArea(); +  setCentralWidget(scrollarea);    w = new QWidget(); -  s->setWidget(w); -  s->setWidgetResizable(true); +  scrollarea->setWidget(w); +  scrollarea->setWidgetResizable(true);    w->setLayout(new QVBoxLayout()); @@ -289,7 +289,7 @@ void MainWindow::update()      if(found == false || macroelement.tagName() == "header") {        QString num;        num.sprintf("%04d", j); -      Macro macro(macronode); +      Macro macro(macronode, scrollarea);        macros[num + macro.name] = macro;      } diff --git a/client/mainwindow.h b/client/mainwindow.h index 03abf09..9da8ff2 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -72,6 +72,7 @@ private:    bool initialising;    //  Sessions sessions; +  QScrollArea *scrollarea;    void init(); | 
