
--- GScribo/GScribo.pro.user | 45 +++++++++++++++++++++++++++++++++- GScribo/PagesWidget/listmodel.cpp | 20 ++++++--------- GScribo/PagesWidget/pageswidget.cpp | 10 +++++++ GScribo/PagesWidget/pageswidget.h | 5 +--- GScribo/XmlWidget/regionwidget.cpp | 5 ---- GScribo/mainwindow.cpp | 9 ++++--- 6 files changed, 67 insertions(+), 27 deletions(-) delete mode 100644 GScribo/XmlWidget/regionwidget.cpp diff --git a/GScribo/GScribo.pro.user b/GScribo/GScribo.pro.user index 77c6b9f..98084bd 100644 --- a/GScribo/GScribo.pro.user +++ b/GScribo/GScribo.pro.user @@ -87,7 +87,7 @@ <value type="QString">LANG=fr_FR.UTF-8</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt/GScribo/XmlWidget</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/games</value> <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> @@ -136,7 +136,7 @@ <value type="QString">LANG=fr_FR.UTF-8</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt/GScribo/XmlWidget</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/games</value> <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> @@ -170,6 +170,47 @@ <variable>buildconfiguration-Debug-cleanstep0</variable> <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> + <valuelist key="abstractProcess.Environment" type="QVariantList"> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-8HhQV0Db3w,guid=820a1dac27c5f8287b84357100000031</value> + <value type="QString">DESKTOP_SESSION=fluxbox</value> + <value type="QString">DISPLAY=:0.0</value> + <value type="QString">GDMSESSION=fluxbox</value> + <value type="QString">GDM_LANG=fr_FR.UTF-8</value> + <value type="QString">GDM_XSERVER_LOCATION=local</value> + <value type="QString">GTK_MODULES=canberra-gtk-module</value> + <value type="QString">HOME=/lrde/home/stage/froger_a</value> + <value type="QString">LANG=fr_FR.UTF-8</value> + <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> + <value type="QString">LOGNAME=froger_a</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt/GScribo/XmlWidget</value> + <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/games</value> + <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> + <value type="QString">QTDIR=/usr/share/qt4</value> + <value type="QString">SHELL=/bin/bash</value> + <value type="QString">SHLVL=2</value> + <value type="QString">SSH_AGENT_PID=2149</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-vKpzBP2096/agent.2096</value> + <value type="QString">TERM=xterm</value> + <value type="QString">USER=froger_a</value> + <value type="QString">USERNAME=froger_a</value> + <value type="QString">WINDOWID=16777252</value> + <value type="QString">WINDOWPATH=7</value> + <value type="QString">XAUTHORITY=/tmp/.gdmYQPASW</value> + <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> + <value type="QString">XDG_SESSION_COOKIE=9a5c41ad78622411b8e25b00459a554f-1360245257.460868-2058632410</value> + <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> + <value type="QString">XTERM_SHELL=/bin/bash</value> + <value type="QString">XTERM_VERSION=XTerm(261)</value> + <value type="QString">_=/usr/bin/qtcreator</value> + </valuelist> + <value key="abstractProcess.IgnoreReturnValue" type="bool">true</value> + <valuelist key="abstractProcess.arguments" type="QVariantList"> + <value type="QString">clean</value> + <value type="QString">-w</value> + </valuelist> + <value key="abstractProcess.command" type="QString">/usr/bin/make</value> + <value key="abstractProcess.enabled" type="bool">true</value> + <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/GScribo</value> <value key="cleanConfig" type="bool">true</value> <valuelist key="makeargs" type="QVariantList"> <value type="QString">clean</value> diff --git a/GScribo/PagesWidget/listmodel.cpp b/GScribo/PagesWidget/listmodel.cpp index 35a86e4..4426087 100644 --- a/GScribo/PagesWidget/listmodel.cpp +++ b/GScribo/PagesWidget/listmodel.cpp @@ -3,7 +3,7 @@ ListModel::ListModel(QObject *parent): QAbstractListModel(parent) { - currentRow_ = -1; + currentRow_ = 0; } QVariant ListModel::data(const QModelIndex& index, int role) const @@ -25,14 +25,14 @@ QVariant ListModel::data(const QModelIndex& index, int role) const void ListModel::addPicture(const QString& filename, const QPixmap& pixmap) { - int row = rowCount(); + beginInsertRows(QModelIndex(), 0, 0); + beginResetModel(); - beginInsertRows(QModelIndex(), row, row); - - pixmaps_.insert(row, pixmap.scaled(QSize(200, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation)); - filenames_.insert(row, filename); + pixmaps_.prepend(pixmap.scaled(QSize(200, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation)); + filenames_.prepend(filename); endInsertRows(); + //endResetModel(); } void ListModel::removePixmap(const QModelIndex &parent) @@ -49,11 +49,7 @@ void ListModel::removePixmap(const QModelIndex &parent) void ListModel::setCurrentRow(int currentRow) { - int precRow = currentRow_; + beginResetModel(); currentRow_ = currentRow; - - QModelIndex i = index(precRow, 0, QModelIndex()); - emit dataChanged(i, i); - i = index(currentRow_, 0, QModelIndex()); - emit dataChanged(i, i); + endResetModel(); } diff --git a/GScribo/PagesWidget/pageswidget.cpp b/GScribo/PagesWidget/pageswidget.cpp index b7d2ac8..9fad1a3 100644 --- a/GScribo/PagesWidget/pageswidget.cpp +++ b/GScribo/PagesWidget/pageswidget.cpp @@ -33,5 +33,15 @@ void PagesWidget::removeSelection() // Draw new pixmap on the scene. getPicture(model_.index(indexes[0].row())); clearSelection(); + + model_.setCurrentRow(indexes[0].row()); } } + +void PagesWidget::getPicture(const QModelIndex& index) +{ + QString filename = index.data(Qt::UserRole).toString(); + model_.setCurrentRow(index.row()); + + emit imageSelectionned(filename); +} diff --git a/GScribo/PagesWidget/pageswidget.h b/GScribo/PagesWidget/pageswidget.h index 3e2c443..f802728 100644 --- a/GScribo/PagesWidget/pageswidget.h +++ b/GScribo/PagesWidget/pageswidget.h @@ -28,7 +28,7 @@ class PagesWidget: void removeSelection(); private slots: - inline void getPicture(const QModelIndex& index); + void getPicture(const QModelIndex& index); signals: void imageSelectionned(const QString& filename); @@ -43,9 +43,6 @@ inline int PagesWidget::currentRow() const inline void PagesWidget::setCurrentRow(int currentRow) { model_.setCurrentRow(currentRow); } -void PagesWidget::getPicture(const QModelIndex& index) -{ QString filename = index.data(Qt::UserRole).toString(); emit imageSelectionned(filename); } - inline void PagesWidget::addPicture(const QString& filename, const QPixmap& pixmap) { model_.addPicture(filename, pixmap); } diff --git a/GScribo/XmlWidget/regionwidget.cpp b/GScribo/XmlWidget/regionwidget.cpp deleted file mode 100644 index 70b021f..0000000 --- a/GScribo/XmlWidget/regionwidget.cpp +++ /dev/null @@ -1,5 +0,0 @@ -nclude "regionwidget.h" - -RegionWidget::RegionWidget() -{ -} diff --git a/GScribo/mainwindow.cpp b/GScribo/mainwindow.cpp index 13902e4..55a8f00 100644 --- a/GScribo/mainwindow.cpp +++ b/GScribo/mainwindow.cpp @@ -115,25 +115,26 @@ void MainWindow::onOpen() { path = paths[counter]; counter++; - isContained = filenames.contains(path, Qt::CaseSensitive); + isContained = filenames.contains(path); } while(isContained && counter < paths.count()); if(!isContained) { - onFileChanged(path); - pagesWidget.setCurrentRow(filenames.count()+counter-1); pagesWidget.addPicture(path, QPixmap(path)); // If more than one file, we store it in the page widget. for(int i = counter; i < paths.count(); i++) { // Check if the page widget contains the image. - if(!filenames.contains(paths[i], Qt::CaseSensitive)) + if(!filenames.contains(paths[i])) { path = paths[i]; pagesWidget.addPicture(path, QPixmap(path)); } } + + pagesWidget.setCurrentRow(0); + onFileChanged(path); } else onFileChanged(path); -- 1.7.2.5