]> Some of my projects - localmylist.git/commitdiff
Make MyListModel reloadable
authorAPTX <marek321@gmail.com>
Fri, 15 Jun 2012 18:48:21 +0000 (20:48 +0200)
committerAPTX <marek321@gmail.com>
Fri, 15 Jun 2012 18:48:21 +0000 (20:48 +0200)
localmylist/mylistmodel.cpp
localmylist/mylistmodel.h
management-gui/mainwindow.cpp
management-gui/mainwindow.h
management-gui/mainwindow.ui

index 8730d6ba27a5af0b21f27f3e0a36b04675725879..d8c7362fc74ac120e15ffa0b68c545f79ffe75d5 100644 (file)
@@ -149,4 +149,12 @@ int MyListModel::id(const QModelIndex &idx) const
        return static_cast<MyListNode *>(idx.internalPointer())->id();
 }
 
+void MyListModel::reload()
+{
+       beginResetModel();
+       delete rootItem;
+       rootItem = new MyListNode();
+       endResetModel();
+}
+
 } // namespace LocalMyList
index 4c599dbe30f54978cc29a7f1e8c1ec11120beb50..99d9bc51bf566bb6308408b7c3ee0b687106abde 100644 (file)
@@ -42,6 +42,7 @@ public slots:
        NodeType type(const QModelIndex &idx) const;
        int id(const QModelIndex &idx) const;
 
+       void reload();
 private:
        MyListNode *rootItem;
 };
index 7aefa9184607781e7a1aa4d46e36b1b7609b66f0..949251a3abbab3cd7da1ad409042464eb5dba4ca 100644 (file)
@@ -41,6 +41,7 @@ MainWindow::MainWindow(QWidget *parent) :
 
        animeModel = new MyListModel(this);
        ui->myListView->setModel(animeModel);
+       ui->myListView->setColumnWidth(0, 450);
 }
 
 MainWindow::~MainWindow()
@@ -262,3 +263,8 @@ void MainWindow::on_actionRemoveKnownUnknownFiles_triggered()
 {
        LocalMyList::instance()->executeTask(new UnknownFileLookupTask());
 }
+
+void MainWindow::on_refreshButton_clicked()
+{
+       animeModel->reload();
+}
index 34d3c74f685fc5158a7f95f5b770189f2871e813..c3e8b1ea1cc55a110166aaa0c33428f95a285e1a 100644 (file)
@@ -50,6 +50,7 @@ private slots:
        void on_actionClearStartedMyListUpdates_triggered();
        void on_actionAddFiles_triggered();
        void on_actionRemoveKnownUnknownFiles_triggered();
+       void on_refreshButton_clicked();
 
 private:
        Ui::MainWindow *ui;
index 3c9204c492c4cfecace27ca3fb8a2c2a08a64feb..89742de4ecc8dbd132dc7afcad176f776e578b3a 100644 (file)
@@ -6,18 +6,42 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>400</width>
-    <height>300</height>
+    <width>912</width>
+    <height>690</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>LocalMyList Management</string>
   </property>
   <widget class="QWidget" name="centralWidget">
-   <layout class="QHBoxLayout" name="horizontalLayout">
+   <layout class="QVBoxLayout" name="verticalLayout">
     <item>
      <widget class="MyListView" name="myListView"/>
     </item>
+    <item>
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <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>
   <widget class="QMenuBar" name="menuBar">
@@ -25,7 +49,7 @@
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>400</width>
+     <width>912</width>
      <height>21</height>
     </rect>
    </property>