]> Some of my projects - localmylist.git/commitdiff
Remove all reload buttons from tabs and replace them with a generic reload action.
authorAPTX <marek321@gmail.com>
Fri, 3 May 2013 14:44:02 +0000 (16:44 +0200)
committerAPTX <marek321@gmail.com>
Fri, 3 May 2013 14:44:02 +0000 (16:44 +0200)
12 files changed:
localmylist-management/abstracttab.cpp
localmylist-management/abstracttab.h
localmylist-management/mainwindow.cpp
localmylist-management/mainwindow.ui
localmylist-management/tabs/mylisttab.cpp
localmylist-management/tabs/mylisttab.h
localmylist-management/tabs/mylisttab.ui
localmylist-management/tabs/reportstab.cpp
localmylist-management/tabs/reportstab.h
localmylist-management/tabs/reportstab.ui
localmylist-management/tabwidget.cpp
localmylist-management/tabwidget.h

index 3b7adf28ab1ad5c6b139393c2bb33fdb2ce732e8..0f9f11c0016f0d3055b2554eb2ffdb94d1455def 100644 (file)
@@ -45,6 +45,10 @@ void AbstractTab::deactivate()
 {
 }
 
+void AbstractTab::reload()
+{
+}
+
 void AbstractTab::loadSettings(QSettings *settings)
 {
        Q_UNUSED(settings);
index 051c9fd1921a43fe17b3233e8970899138ea653f..989e88688eb2f5c5112df8161c0bcea432457822 100644 (file)
@@ -28,6 +28,8 @@ public:
        virtual void activate();
        virtual void deactivate();
 
+       virtual void reload();
+
        virtual void loadSettings(QSettings *settings);
        virtual void saveSettings(QSettings *settings);
 
index 7f42ec79b646210a192a7c627570e3c3bbfd8746..4c6990168f0d2480fe334833c60a13c8bae3cf8d 100644 (file)
@@ -77,6 +77,7 @@ MainWindow::MainWindow(QWidget *parent) :
                ui->actionRenameFiles->setDisabled(true);
        }
 
+       connect(ui->actionReload, SIGNAL(triggered()), ui->tabWidget, SLOT(reloadCurrentTab()));
        registerTabs();
 
        ui->tabWidget->setMainWindow(this);
index a3d45b8b2c9743499839948edc2e7af7048b7976..00b4df010bfefcad019b5edf42021c609f9a8c36 100644 (file)
    <attribute name="toolBarBreak">
     <bool>false</bool>
    </attribute>
+   <addaction name="actionReload"/>
   </widget>
   <widget class="QStatusBar" name="statusBar"/>
   <action name="actionConnect">
     <string>Check File Locations</string>
    </property>
   </action>
+  <action name="actionReload">
+   <property name="text">
+    <string>Reload</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>
index c119de3c87bf1e89d7a6f069c42a12856e5a566a..133a9f0d380a976ea184b6f8c5ca8f78b36b888b 100644 (file)
@@ -74,6 +74,12 @@ void MyListTab::activate()
        ui->filterInput->setFocus();
 }
 
+void MyListTab::reload()
+{
+       myListModel()->reload();
+       selectedRow = -1;
+}
+
 void MyListTab::loadSettings(QSettings *settings)
 {
        ui->filterType->setCurrentIndex(settings->value("filterType", 0).toInt());
@@ -84,12 +90,6 @@ void MyListTab::saveSettings(QSettings *settings)
        settings->setValue("filterType", ui->filterType->currentIndex());
 }
 
-void MyListTab::on_refreshButton_clicked()
-{
-       myListModel()->reload();
-       selectedRow = -1;
-}
-
 void MyListTab::on_myListView_openFileRequested(const QModelIndex &index)
 {
        MyListNode *node = myListFilterModel->node(index);
index 9ff1538544373b11be66bf39e61ecc40d7a062e3..f71394f3a0da11b8d584ac39892279b4ab5c917f 100644 (file)
@@ -29,11 +29,12 @@ public:
        void init();
        void activate();
 
+       void reload();
+
        void loadSettings(QSettings *settings);
        void saveSettings(QSettings *settings);
 
 private slots:
-       void on_refreshButton_clicked();
        void on_myListView_openFileRequested(const QModelIndex &index);
        void on_myListView_renameFilesRequested(const QModelIndex &index);
        void on_myListView_dataRequested(const QModelIndex &index);
index 16b6144692603b4c54b798a016379ff7108617b5..1d9aa83883b07a1ec1e67abeb9478be72037e3b5 100644 (file)
    <item>
     <widget class="MyListView" name="myListView"/>
    </item>
-   <item>
-    <layout class="QHBoxLayout" name="refreshButtonLayout">
-     <item>
-      <spacer name="horizontalSpacer">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QPushButton" name="refreshButton">
-       <property name="text">
-        <string>Refresh</string>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
   </layout>
  </widget>
  <customwidgets>
-  <customwidget>
-   <class>MyListView</class>
-   <extends>QTreeView</extends>
-   <header>mylistview.h</header>
-  </customwidget>
   <customwidget>
    <class>FilterLineEdit</class>
    <extends>QLineEdit</extends>
    <header>filterlineedit.h</header>
   </customwidget>
+  <customwidget>
+   <class>MyListView</class>
+   <extends>QTreeView</extends>
+   <header>mylistview.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>
index 571a9b97c45e9e266d24fe2d2db8025b398ee90d..f981b2671f07852a9316bc6ac40d274c9413264c 100644 (file)
@@ -47,10 +47,10 @@ void ReportsTab::activate()
        if (ui->reports->count())
                return;
 
-       on_reloadReports_clicked();
+       reload();
 }
 
-void ReportsTab::on_reloadReports_clicked()
+void ReportsTab::reload()
 {
        ui->reports->clear();
 
index 57a92beef1c0779e214678d2da2d646c75c05fdc..9fee45d29eef5db8f7cf8d0ce54c86e9ae4d3eeb 100644 (file)
@@ -23,8 +23,9 @@ public:
        void init();
        void activate();
 
+       void reload();
+
 private slots:
-       void on_reloadReports_clicked();
        void on_reports_currentIndexChanged(int index);
        void on_runReport_clicked();
        void on_editReport_clicked();
index 493ddb1215f3a6bcce9b47c9aa466b87574885e7..29f427c366b1757edbe798daa41c60f63eec2a9f 100644 (file)
        </property>
       </widget>
      </item>
-     <item>
-      <widget class="QPushButton" name="reloadReports">
-       <property name="text">
-        <string>Reload</string>
-       </property>
-      </widget>
-     </item>
     </layout>
    </item>
    <item>
index b2eec8fb9b299a181deb0387dd9a098928f78023..3d180259624c064cc61834593c75ddd228401ffd 100644 (file)
@@ -151,6 +151,16 @@ AbstractTab *TabWidget::tab(int index) const
        return qobject_cast<AbstractTab *>(QTabWidget::widget(index));
 }
 
+void TabWidget::reloadCurrentTab()
+{
+       AbstractTab *t = tab(currentIndex());
+
+       if (!t)
+               return;
+
+       t->reload();
+}
+
 void TabWidget::tabNameChanged(const QString &newName)
 {
        AbstractTab *tab = qobject_cast<AbstractTab *>(sender());
index 6816e7e0c45246bda2e3505a3f3588f9c24d7e5d..f0b1aa226acdc16cf669e15371d479d2363611a1 100644 (file)
@@ -45,6 +45,7 @@ public slots:
 
        AbstractTab *tab(int index) const;
 
+       void reloadCurrentTab();
        void setMainWindow(MainWindow *mainWindow);
        void setLockLayout(bool locked);