Index: ui/pagepalette.cpp =================================================================== --- ui/pagepalette.cpp (revision 16845) +++ ui/pagepalette.cpp (working copy) @@ -153,22 +153,35 @@ QTableWidget::mousePressEvent(e); } -void SeView::mouseReleaseEvent(QMouseEvent* e) +void SeView::mouseReleaseEvent(QMouseEvent* m) { - e->accept(); + m->accept(); Mpressed = false; -/* if (e->button() == RightButton) + if (m->button() == Qt::RightButton) { - QPopupMenu *pmen = new QPopupMenu(); - qApp->setOverrideCursor(QCursor(Qt::ArrowCursor), true); - int px = pmen->insertItem( tr("Show Master Page Names"), this, SLOT(ToggleNam())); + QMenu *pmen = new QMenu(); + // QPopupMenu *pmen = new QPopupMenu(); + qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); + QAction *px = pmen->addAction( tr("Show Master Page Names"), this, SLOT(ToggleNam())); + px->setCheckable(true); if (Namen) - pmen->setItemChecked(px, true); + px->setChecked(true); + + px = pmen->addAction( tr("Show Page Previews"), this, SLOT(toggleThumbnail())); + px->setCheckable(true); + if (Thumb) + px->setChecked(true); + + px = pmen->addAction( tr("Horizontal view"), this, SLOT(toggleViewDirection())); + px->setCheckable(true); + if (Horizontal) + px->setChecked(true); + pmen->exec(QCursor::pos()); delete pmen; - } */ - emit Click(rowAt(e->pos().y()), columnAt(e->pos().x()), e->button()); - QTableWidget::mouseReleaseEvent(e); + } + emit Click(rowAt(m->pos().y()), columnAt(m->pos().x()), m->button()); + QTableWidget::mouseReleaseEvent(m); } void SeView::ToggleNam() @@ -183,6 +196,18 @@ show(); */ } +void SeView::toggleThumbnail() +{ + Thumb = !Thumb; + emit thumbnailChanged(); +} + +void SeView::toggleViewDirection() +{ + Horizontal = !Horizontal; + emit horizontalChanged(); +} + void SeView::mouseMoveEvent(QMouseEvent* e) { if ((Mpressed) && ((Mpos - e->pos()).manhattanLength() > 4)) @@ -234,8 +259,9 @@ // Fixed at least in Qt-4.4.2 // QApplication::restoreOverrideCursor(); str = e->mimeData()->text(); + qDebug() << "str: " << str; ClearPix(); - if (str.startsWith("1")) + if (str.startsWith("1")) // apply a master page ("1Normal") { int a = rowAt(e->pos().y()); int b = columnAt(e->pos().x()); @@ -291,19 +317,24 @@ return; } } - if (str.startsWith("2")) + if (str.startsWith("2")) // move a page ("2 3 Normal" -> "2 pageno masterpagename") { int st = str.indexOf(" "); int en = str.indexOf(" ", st+1); tmp = str.mid(en+1); - int dr = str.mid(st, en-st).toInt(); - int a = rowAt(e->pos().y()); - int b = columnAt(e->pos().x()); + int dr = str.mid(st, en-st).toInt(); // page being moved + int a = rowAt(e->pos().y()); // row of the target + int b = columnAt(e->pos().x()); // column of the target + qDebug() << "en: " << en; + qDebug() << "dr: " << dr; + qDebug() << "a: " << a; + qDebug() << "b: " << b; int p; if ((a == -1) || (b == -1)) return; QTableWidgetItem* ite = item(a, b); - p = GetPage(a, b, &lastPage); + p = GetPage(a, b, &lastPage); // target page + qDebug() << "p: " << p; if (a == rowCount()-1) { emit movePage(dr, p+1); @@ -441,6 +472,32 @@ int SeView::GetPage(int r, int c, bool *last) { + if (Horizontal) + return GetPageHorizontal(r, c, last); + else + return GetPageVertical(r, c, last); +} + +int SeView::GetPageHorizontal(int r, int c, bool *last) +{ + int ret = MaxC; + *last = false; + // qDebug() << "c: " << c; + // qDebug() << "columnCount: " << columnCount(); + // qDebug() << "ret: " << ret; + if (c >= columnCount() - 1) + { + *last = true; + } else if (c % 2 == 0) + ret = c / 2; + else + ret = (c - 1) / 2; + // qDebug() << "ret: " << ret; + return ret; +} + +int SeView::GetPageVertical(int r, int c, bool *last) +{ int counter = firstP; int rowcounter = 0; int ret = MaxC; @@ -553,6 +610,7 @@ Layout2->setSpacing(5); TextLabel1 = new QLabel( privateLayoutWidget ); Layout2->addWidget( TextLabel1 ); + // master pages masterPageList = new SeList(privateLayoutWidget); masterPageList->setMinimumSize(QSize(130,70)); masterPageList->Thumb = false; @@ -564,6 +622,7 @@ Layout3->setSpacing(5); TextLabel2 = new QLabel( privateLayoutWidget_2 ); Layout3->addWidget( TextLabel2 ); + // pages pageView = new SeView(privateLayoutWidget_2); QHeaderView *Header = pageView->verticalHeader(); Header->setMovable(false); @@ -579,6 +638,10 @@ pageView->setColumnCount(1); pageView->setIconSize(QSize(60, 60)); pageView->setMinimumSize(QSize(130,120)); + pageView->Namen = false; + pageView->Thumb = false; + pageView->Horizontal = true; // @xxx: only for debugging purposes; othwerise to false or prefs (ale) + // pageView->setShowGrid(true); // @xxx: only for debugging purposes (ale) Layout3->addWidget( pageView ); PagePaletteLayout->addWidget( Splitter1 ); @@ -628,6 +691,8 @@ connect(Trash, SIGNAL(DelPage(int)), m_scMW, SLOT(DeletePage2(int))); connect(pageView, SIGNAL(DelPage(int)), m_scMW, SLOT(DeletePage2(int))); connect(this, SIGNAL(gotoPage(int)), m_scMW, SLOT(selectPagesFromOutlines(int))); + connect(pageView, SIGNAL(thumbnailChanged()), this, SLOT(rebuildPages())); + connect(pageView, SIGNAL(horizontalChanged()), this, SLOT(rebuildPages())); } void PagePalette::deleteMasterPage(QString tmp) @@ -687,9 +752,12 @@ { int p; bool dummy; + // qDebug() << "r: " << r; + // qDebug() << "c: " << c; if ((b == Qt::LeftButton) && (r != -1) && (c != -1)) { p = pageView->GetPage(r, c, &dummy); + // qDebug() << "p: " << p; emit gotoPage(p); } } @@ -754,7 +822,7 @@ disconnect(pageLayout, SIGNAL(selectedLayout(int )), this, SLOT(handlePageLayout(int ))); disconnect(pageLayout, SIGNAL(selectedFirstPage(int )), this, SLOT(handleFirstPage(int ))); pageView->clearContents(); - pageView->setRowCount(1); + pageView->setRowCount(1); // why not 0? (ale/20110916) pageView->setColumnCount(1); if (currView == 0) { @@ -766,15 +834,25 @@ pageLayout->selectItem(currView->Doc->pagePositioning()); pageLayout->firstPage->setCurrentIndex(currView->Doc->pageSets()[currView->Doc->pagePositioning()].FirstPage); pageView->MaxC = currView->Doc->DocPages.count()-1; + // counter [0] [1|0] [0|1|2] [0|1|2|3] int counter = currView->Doc->pageSets()[currView->Doc->pagePositioning()].FirstPage; + // in horizontal mode cols and rows will be used switched int cols = currView->Doc->pageSets()[currView->Doc->pagePositioning()].Columns; int rows = (currView->Doc->DocPages.count()+counter) / currView->Doc->pageSets()[currView->Doc->pagePositioning()].Columns; if (((currView->Doc->DocPages.count()+counter) % currView->Doc->pageSets()[currView->Doc->pagePositioning()].Columns) != 0) rows++; int rowcounter = 0; int colmult, rowmult, coladd, rowadd; - if (cols == 1) + if (pageView->Horizontal) { + pageView->setColumnCount((currView->Doc->DocPages.count() * 2) + 1); + pageView->setRowCount(1); + colmult = 1; + coladd = 0; + rowmult = 2; + rowadd = 1; + } else if (cols == 1) + { pageView->setColumnCount(cols); pageView->setRowCount(rows*2+1); colmult = 1; @@ -805,41 +883,80 @@ pageView->rowadd = rowadd; pageView->rowmult = rowmult; pageView->firstP = counter; + // why not "pageView->cols = cols"? (ale/20110921) pageView->cols = currView->Doc->pageSets()[currView->Doc->pagePositioning()].Columns; pageList.clear(); - for (int a = 0; a < currView->Doc->DocPages.count(); ++a) + QPixmap ppix = pix; + if (pageView->Horizontal) { - str = currView->Doc->DocPages.at(a)->MPageNam; - SeItem *it = new SeItem(str, a, CreateIcon(a, pix)); - pageList.append(it); - pageView->setItem(rowcounter*rowmult+rowadd, counter*colmult+coladd, (QTableWidgetItem *)it); - pageView->setColumnWidth(counter*colmult+coladd, pix.width()); - if (cols == 1) + // qDebug() << "firstP: " << pageView->firstP; + int spread = pageView->cols; + for (int i = 0; i < currView->Doc->DocPages.count(); ++i) { - pageView->setRowHeight(rowcounter*rowmult, 10); - pageView->setRowHeight(rowcounter*rowmult+rowadd, pix.height()); + int j = i * 2; + str = currView->Doc->DocPages.at(i)->MPageNam; + SeItem *it; + // @todo: the icons must be updated when leaving the current page (ale/20110921) + if (pageView->Thumb) + ppix = QPixmap::fromImage(currView->PageToPixmap(i, 60)); + it = new SeItem(str, i, CreateIcon(i, ppix)); + pageList.append(it); + pageView->setItem(0, j + 1, (QTableWidgetItem *)it); + pageView->setColumnWidth(j, 10); + pageView->setColumnWidth(j + 1, ppix.width()); + if (spread > 1) + { + int k = (i + pageView->firstP) % spread; + // qDebug() << "k: " << k; + if (k == 0) + { + it->setTextAlignment(Qt::AlignLeft); + pageView->setColumnWidth(j, 20); + } + else if (k == spread -1) + it->setTextAlignment(Qt::AlignRight); + else + it->setTextAlignment(Qt::AlignHCenter); + } } - else - pageView->setRowHeight(rowcounter*rowmult+rowadd, pix.height()+5); - counter++; - if (counter > currView->Doc->pageSets()[currView->Doc->pagePositioning()].Columns-1) + pageView->setColumnWidth(0, 10); // the first column is always 10px wide + pageView->setColumnWidth(currView->Doc->DocPages.count() * 2, 10); + pageView->setRowHeight(0, ppix.height()); + } else { + for (int a = 0; a < currView->Doc->DocPages.count(); ++a) { - counter = 0; - rowcounter++; - } - } - pageView->setRowHeight(pageView->rowCount()-1, 10); - counter = 0; - if (cols != 1) - { - for (int c = 0; c < pageView->columnCount(); ++c) - { - if ((counter % 2) == 0) - pageView->setColumnWidth(counter, 10); + str = currView->Doc->DocPages.at(a)->MPageNam; + SeItem *it = new SeItem(str, a, CreateIcon(a, pix)); + pageList.append(it); + pageView->setItem(rowcounter*rowmult+rowadd, counter*colmult+coladd, (QTableWidgetItem *)it); + pageView->setColumnWidth(counter*colmult+coladd, pix.width()); + if (cols == 1) + { + pageView->setRowHeight(rowcounter*rowmult, 10); + pageView->setRowHeight(rowcounter*rowmult+rowadd, pix.height()); + } else - pageView->setColumnWidth(counter, pix.width()); + pageView->setRowHeight(rowcounter*rowmult+rowadd, pix.height()+5); counter++; + if (counter > currView->Doc->pageSets()[currView->Doc->pagePositioning()].Columns-1) + { + counter = 0; + rowcounter++; + } } + pageView->setRowHeight(pageView->rowCount()-1, 10); + counter = 0; + if (cols != 1) + { + for (int c = 0; c < pageView->columnCount(); ++c) + { + if ((counter % 2) == 0) + pageView->setColumnWidth(counter, 10); + else + pageView->setColumnWidth(counter, pix.width()); + counter++; + } + } } pageView->repaint(); if (currView != 0) Index: ui/pagepalette.h =================================================================== --- ui/pagepalette.h (revision 16845) +++ ui/pagepalette.h (working copy) @@ -102,6 +102,8 @@ public slots: void ToggleNam(); + void toggleThumbnail(); + void toggleViewDirection(); signals: void UseTemp(QString, int); @@ -109,6 +111,8 @@ void movePage(int, int); void Click(int, int, int); void DelPage(int); + void thumbnailChanged(); + void horizontalChanged(); protected: virtual void dropEvent(QDropEvent * e); @@ -119,12 +123,16 @@ virtual void mousePressEvent(QMouseEvent* e); virtual void mouseMoveEvent(QMouseEvent* e); virtual void keyPressEvent(QKeyEvent* e); + int GetPageVertical(int r, int c, bool *last); + int GetPageHorizontal(int r, int c, bool *last); QPoint Mpos; bool Mpressed; + bool Thumb; + bool Namen; + bool Horizontal; bool Doppel; bool Links; - bool Namen; int MaxC; int colmult; int rowmult;