コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: sglass68/paperman
void Mainwindow::init ()
{
   connect (_main->getPage (), SIGNAL (newContents (QString)),
            this, SLOT (statusUpdate (QString)));
   connect (_main, SIGNAL (newContents (QString)),
            this, SLOT (statusUpdate (QString)));
   connect (_main->getDesktop (), SIGNAL (newContents (QString)),
            this, SLOT (statusUpdate (QString)));
}
コード例 #2
0
ファイル: mainwindow.cpp プロジェクト: ABBAPOH/imagedocument
void MainWindow::convertToProjection()
{
    Q_D(MainWindow);
    const auto contents = d->_document->toContents();
    if (contents.header().type() != ImageResource::Type::CubeTexture) {
        QMessageBox::warning(this,
                             tr("Convert to projection"),
                             tr("Can't convert to projection, not a cube texture"));
    }

    QVector<QImage> images;
    images.reserve(contents.header().imageCount() * contents.header().mipmapCount());
    for (int index = 0; index < contents.header().imageCount(); ++index) {
        for (int level = 0; level < contents.header().mipmapCount(); ++level) {
            auto texture = contents.resource(index, level).cubeTexture();
            auto image = texture.toProjection(CubeTexture::Projection::HorizonalCross);
            images.append(image);
        }
    }
    if (images.empty())
        return;
    ImageHeader header(contents.header());
    header.setType(ImageResource::Type::Image);
    header.setSize(images.at(0).size());
    ImageContents newContents(header);
    auto it = images.begin();
    for (int index = 0; index < contents.header().imageCount(); ++index) {
        for (int level = 0; level < contents.header().mipmapCount(); ++level) {
            newContents.setResource(*it++);
        }
    }

    d->_document->setContents(newContents);
}
コード例 #3
0
void StringMultilinePropertyWidgetQt::updateFromProperty() {
    QString text(textEdit_->toPlainText());
    QString newContents(QString::fromStdString(property_->get()));
    if (text != newContents) {
        textEdit_->setPlainText(newContents);
        textEdit_->moveCursor(QTextCursor::Start);

        textEdit_->adjustHeight();
    }
}
コード例 #4
0
ファイル: desktopwidget.cpp プロジェクト: sglass68/paperman
void Desktopwidget::createPage(void)
   {
   _page = new Pagewidget (_modelconv, "desktopwidget/", this);
   _page->setSmoothing (false);

   // allow top level to see our preview messages
   connect (_page, SIGNAL (newContents (QString)), this, SIGNAL (newContents (QString)));

   connect (_page, SIGNAL (modeChanging (int, int)),
      this, SLOT (slotModeChanging (int, int)));

   _page->init ();

   // alert the page widget whenever a new page is finished scanning
   connect (_contents, SIGNAL (newScannedPage (const QString &, bool)),
      _page, SLOT (slotNewScannedPage (const QString &, bool)));

   // alert the page widget whenever we start to scan a new page
   connect (_contents, SIGNAL (beginningPage ()),
      _page, SLOT (slotBeginningPage ()));

   // and when we have a new preview image fragment for the page being scanned
   connect (_contents, SIGNAL (newScaledImage (const QImage &, int)),
      _page, SLOT (slotNewScaledImage (const QImage &, int)));

   // and when we change a stack
   connect (_contents, SIGNAL (dataChanged (const QModelIndex &, const QModelIndex &)),
      _page, SLOT (slotStackChanged (const QModelIndex &, const QModelIndex &)));

   // and when we delete any stacks
   connect (_contents, SIGNAL (rowsRemoved (const QModelIndex &, int, int)),
      _page, SLOT (slotReset ()));

   // and when we want to commit the stack
   connect (_contents, SIGNAL (commitScanStack ()),
      _page, SLOT (slotCommitScanStack ()));
   }
コード例 #5
0
ファイル: desktopwidget.cpp プロジェクト: sglass68/paperman
void Desktopwidget::slotItemClicked (const QModelIndex &index, int which)
   {
   QAbstractItemModel *model = (QAbstractItemModel *)index.model ();
   bool changed = false;

   if (index != QModelIndex ())
      {
      switch (which)
         {
         case Desktopdelegate::Point_left : // left
            pageLeft (index);
            changed = true;
            break;

         case Desktopdelegate::Point_right : // right
            pageRight (index);
            changed = true;
            break;

         case Desktopdelegate::Point_page : // page button
            {
            int pagenum = model->data (index, Desktopmodel::Role_pagenum).toInt ();
            int pagecount = model->data (index, Desktopmodel::Role_pagecount).toInt ();
            int num;
            bool ok;

            num = QInputDialog::getInt (this, "Select page number", "Page",
                       pagenum + 1, 1, pagecount, 1, &ok);
            if (ok)
               {
               QVariant v = num - 1;

               model->setData (index, v, Desktopmodel::Role_pagenum);
               changed = true;
               }
            break;
            }

         default :
            break;
         }

      if (changed)
         {
         QString str = index.model ()->data (index, Desktopmodel::Role_message).toString ();
         emit newContents (str);
         }
      }
   }
コード例 #6
0
ファイル: desktopwidget.cpp プロジェクト: sglass68/paperman
Desktopwidget::Desktopwidget (QWidget *parent)
      : QSplitter (parent)
   {
   _model = new Dirmodel ();
//    _model->setLazyChildCount (true);
   _dir = new Dirview (this);
   _dir->setModel (_model);

   _contents = new Desktopmodel (this);

   QWidget *group = createToolbar();

   _view = new Desktopview (group);
   QVBoxLayout *lay = new QVBoxLayout (group);
   lay->setContentsMargins (0, 0, 0, 0);
   lay->setSpacing (2);
   lay->addWidget (_toolbar);
   lay->addWidget (_view);

   connect (_view, SIGNAL (itemPreview (const QModelIndex &, int, bool)),
         this, SLOT (slotItemPreview (const QModelIndex &, int, bool)));

#ifdef USE_PROXY
   _proxy = new Desktopproxy (this);
   _proxy->setSourceModel (_contents);
   _view->setModel (_proxy);
//    printf ("contents=%p, proxy=%p\n", _contents, _proxy);

   // set up the model converter
   _modelconv = new Desktopmodelconv (_contents, _proxy);

   // setup another one for Desktopmodel, which only allows assertions
   _modelconv_assert = new Desktopmodelconv (_contents, _proxy, false);
#else
   _proxy = 0;
   _view->setModel (_contents);
   _modelconv = new Desktopmodelconv (_contents);

   // setup another one for Desktopmodel, which only allows assertions
   _modelconv_assert = new Desktopmodelconv (_contents, false);
#endif

   _view->setModelConv (_modelconv);

   _contents->setModelConv (_modelconv_assert);

   _delegate = new Desktopdelegate (_modelconv, this);
   _view->setItemDelegate (_delegate);
   connect (_delegate, SIGNAL (itemClicked (const QModelIndex &, int)),
         this, SLOT (slotItemClicked (const QModelIndex &, int)));
   connect (_delegate, SIGNAL (itemPreview (const QModelIndex &, int, bool)),
         this, SLOT (slotItemPreview (const QModelIndex &, int, bool)));
   connect (_delegate, SIGNAL (itemDoubleClicked (const QModelIndex &)),
      this, SLOT (openStack (const QModelIndex &)));

   connect (_contents, SIGNAL (undoChanged ()),
      this, SIGNAL (undoChanged ()));
   connect (_contents, SIGNAL (dirChanged (QString&, QModelIndex&)),
      this, SLOT (slotDirChanged (QString&, QModelIndex&)));
   connect (_contents, SIGNAL (beginningScan (const QModelIndex &)),
      this, SLOT (slotBeginningScan (const QModelIndex &)));
   connect (_contents, SIGNAL (endingScan (bool)),
      this, SLOT (slotEndingScan (bool)));
   connect (_contents, SIGNAL(updateRepositoryList (QString &, bool)),
            this, SLOT(slotUpdateRepositoryList (QString &, bool)));

    // position the items when the model is reset, otherwise things
    // move and look ugly for a while
    connect (_contents, SIGNAL (modelReset ()), _view, SLOT (setPositions ()));

   createPage();

   // and when there are no selected items
   connect (_view, SIGNAL (pageLost()), _page, SLOT (slotReset ()));

   _parent = parent;
   _pendingMatch = QString::null;
   _updating = false;

   // setup the preview timer
   _timer = new QTimer ();
   _timer->setSingleShot (true);
   connect (_timer, SIGNAL(timeout()), this, SLOT(updatePreview()));

   connect (_dir, SIGNAL (clicked (const QModelIndex&)),
            this, SLOT (dirSelected (const QModelIndex&)));
   connect (_dir, SIGNAL (activated (const QModelIndex&)),
            this, SLOT (dirSelected (const QModelIndex&)));
   connect (_model, SIGNAL(droppedOnFolder(const QMimeData *, QString &)),
            this, SLOT(slotDroppedOnFolder(const QMimeData *, QString &)));

   /* notice when the current directory is fully displayed so we can handle
      any pending action */
   connect (_contents, SIGNAL (updateDone()), this, SLOT (slotUpdateDone()));

   // connect signals from the directory tree
   connect (_dir->_new, SIGNAL (triggered ()), this, SLOT (newDir ()));
   connect (_dir->_rename, SIGNAL (triggered ()), this, SLOT (renameDir ()));
   connect (_dir->_delete, SIGNAL (triggered ()), this, SLOT (deleteDir ()));
   connect (_dir->_refresh, SIGNAL (triggered ()), this, SLOT (refreshDir ()));
   connect (_dir->_add_recent, SIGNAL (triggered ()), this,
            SLOT (addToRecent ()));
   connect (_dir->_add_repository, SIGNAL (triggered ()), this,
            SLOT (slotAddRepository ()));
   connect (_dir->_remove_repository, SIGNAL (triggered ()), this,
            SLOT (slotRemoveRepository ()));

   setStretchFactor(indexOf(_dir), 0);

   QList<int> size;

   if (!getSettingsSizes ("desktopwidget/", size))
      {
      size.append (200);
      size.append (1000);
      size.append (400);
      }
   setSizes (size);

   connect (_view, SIGNAL (popupMenu (QModelIndex &)),
         this, SLOT (slotPopupMenu (QModelIndex &)));

   // allow top level to see our view messages
   connect (_view, SIGNAL (newContents (QString)), this, SIGNAL (newContents (QString)));

   addActions();

   /* unfortunately when we first run maxview it starts with the main window
      un-maximised. This means that scrollToLast() doesn't quite scroll far
      enough for the maximised view which appears soon afterwards. As a hack
      for the moment, we do another scroll 1 second after starting up */
   QTimer::singleShot(1000, _view, SLOT (scrollToLast()));
   }