Exemple #1
0
//------------------------------------------------------------------------------
void ctkDICOMDatabase::openDatabase(const QString databaseFile, const QString& connectionName )
{
  Q_D(ctkDICOMDatabase);
  d->DatabaseFileName = databaseFile;
  d->Database = QSqlDatabase::addDatabase("QSQLITE", connectionName);
  d->Database.setDatabaseName(databaseFile);
  if ( ! (d->Database.open()) )
    {
    d->LastError = d->Database.lastError().text();
    return;
    }
  if ( d->Database.tables().empty() )
    {
    if (!initializeDatabase())
      {
      d->LastError = QString("Unable to initialize DICOM database!");
      return;
      }
    }
  if (!isInMemory())
    {
    QFileSystemWatcher* watcher = new QFileSystemWatcher(QStringList(databaseFile),this);
    connect(watcher, SIGNAL(fileChanged(QString)),this, SIGNAL (databaseChanged()) );
    }
}
Exemple #2
0
void CoreDbWatch::sendDatabaseChanged()
{
#ifdef HAVE_DBUS
    // Note: This is not dispatched by DBus!
#endif

    emit databaseChanged();
}
void SqlQueryDataSource::setDatabase(QString databaseName)
{
    if (m_databaseName != databaseName) {
        m_databaseName = databaseName;
        updateModel();
        emit databaseChanged(databaseName);
    }
}
void DatabaseWidget::replaceDatabase(Database* db)
{
    Database* oldDb = m_db;
    m_db = db;
    m_groupView->changeDatabase(m_db);
    Q_EMIT databaseChanged(m_db);
    delete oldDb;
}
Exemple #5
0
/*************************** DATABASE *******************************/
void QgsGrassNewMapset::browseDatabase()
{
    QString selectedDir = QFileDialog::getExistingDirectory( this, NULL, mDatabaseLineEdit->text() );
    if ( selectedDir.isEmpty() )
        return;

    mDatabaseLineEdit->setText( selectedDir );
    databaseChanged();
}
Exemple #6
0
void MainWindow::saveDatabase()
{
    if (!database()->isReadOnly() && database()->isModified())
    {
        Output output(Output::Pgn);
        output.output(database()->filename(), *database());
    }
    emit databaseChanged(databaseInfo());
}
void SensMessageModel::setDatabase(CommandsDatabase *db)
{
    if(p->db == db)
        return;

    p->db = db;
    refresh();
    emit databaseChanged();
}
bool CreateViewDialog::event(QEvent * e)
{
	QDialog::event(e);
	if (e->type() == QEvent::Polish)
	{
		databaseChanged(ui.databaseCombo->currentIndex());
	}
	e->accept();
	return true;
}
Applications::Applications(QString root, QString title, QIcon icon, bool flat)
    : d(new Private(this))
{
    d->root = root;
    d->title = title;
    d->icon = icon;
    d->flat = flat;

    connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)),
            d, SLOT(sycocaUpdated(QStringList)));
    d->load();
}
void DesktopCorona::init()
{
    setPreferredToolBoxPlugin(Plasma::Containment::DesktopContainment, "org.kde.desktoptoolbox");
    setPreferredToolBoxPlugin(Plasma::Containment::CustomContainment, "org.kde.desktoptoolbox");
    setPreferredToolBoxPlugin(Plasma::Containment::PanelContainment, "org.kde.paneltoolbox");
    setPreferredToolBoxPlugin(Plasma::Containment::CustomPanelContainment, "org.kde.paneltoolbox");

    kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "DesktopCorona init start" << "(line:" << __LINE__ << ")";
    Kephal::Screens *screens = Kephal::Screens::self();
    connect(screens, SIGNAL(screenAdded(Kephal::Screen*)), SLOT(screenAdded(Kephal::Screen*)));
    connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SIGNAL(availableScreenRegionChanged()));

    Plasma::ContainmentActionsPluginsConfig desktopPlugins;
    desktopPlugins.addPlugin(Qt::NoModifier, Qt::Vertical, "switchdesktop");
    desktopPlugins.addPlugin(Qt::NoModifier, Qt::MidButton, "paste");
    desktopPlugins.addPlugin(Qt::NoModifier, Qt::RightButton, "contextmenu");
    Plasma::ContainmentActionsPluginsConfig panelPlugins;
    panelPlugins.addPlugin(Qt::NoModifier, Qt::RightButton, "contextmenu");

    setContainmentActionsDefaults(Plasma::Containment::DesktopContainment, desktopPlugins);
    setContainmentActionsDefaults(Plasma::Containment::CustomContainment, desktopPlugins);
    setContainmentActionsDefaults(Plasma::Containment::PanelContainment, panelPlugins);
    setContainmentActionsDefaults(Plasma::Containment::CustomPanelContainment, panelPlugins);

    checkAddPanelAction();

    //why do these actions belong to plasmaapp?
    //because it makes the keyboard shortcuts work.
    KAction *action = new KAction(PlasmaApp::self());
    action->setText(i18n("Next Activity"));
    action->setObjectName( QLatin1String("Next Activity" )); // NO I18N
    action->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Tab));
    connect(action, SIGNAL(triggered()), this, SLOT(activateNextActivity()));

    action = new KAction(PlasmaApp::self());
    action->setText(i18n("Previous Activity"));
    action->setObjectName( QLatin1String("Previous Activity" )); // NO I18N
    action->setGlobalShortcut(KShortcut(Qt::META + Qt::SHIFT + Qt::Key_Tab));
    connect(action, SIGNAL(triggered()), this, SLOT(activatePreviousActivity()));

    connect(this, SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)),
            this, SLOT(updateImmutability(Plasma::ImmutabilityType)));
    connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), this, SLOT(checkAddPanelAction(QStringList)));

    connect(m_activityController, SIGNAL(currentActivityChanged(QString)), this, SLOT(currentActivityChanged(QString)));
    connect(m_activityController, SIGNAL(activityAdded(QString)), this, SLOT(activityAdded(QString)));
    connect(m_activityController, SIGNAL(activityRemoved(QString)), this, SLOT(activityRemoved(QString)));

    mapAnimation(Plasma::Animator::AppearAnimation, Plasma::Animator::ZoomAnimation);
    mapAnimation(Plasma::Animator::DisappearAnimation, Plasma::Animator::ZoomAnimation);
    kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "DesktopCorona init end" << "(line:" << __LINE__ << ")";
}
void CDatabaseManagerServerSession::ConstructL(QString dbPath)
    {
    iDb = new ServiceDatabase();
    iDb->setDatabasePath(dbPath);
    openDb();
    
    //initDbPath();
    iDatabaseManagerSignalHandler = new DatabaseManagerSignalHandler(*this);
        
    m_watcher = new QFileSystemWatcher();
    QObject::connect(m_watcher, SIGNAL(fileChanged(QString)),
            iDatabaseManagerSignalHandler, SLOT(databaseChanged(QString)));
    }
void WeatherEngine::init()
{
    // Get the list of available plugins but don't load them
    Solid::Networking::Status status = Solid::Networking::status();
    m_networkAvailable = (status == Solid::Networking::Connected ||
                             status == Solid::Networking::Unknown);
    connect(Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)),
            this, SLOT(networkStatusChanged(Solid::Networking::Status)));
    connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), this, SLOT(updateIonList()));

    updateIonList();
    kDebug() << "init()";
}
Exemple #13
0
void QLandmarkManagerEngineSqlite::setChangeNotificationsEnabled(bool enabled)
{
    if (!m_dbWatcher) {
        m_dbWatcher = new DatabaseFileWatcher(m_dbFilename);
        connect(m_dbWatcher, SIGNAL(notifyChange()),this,SLOT(databaseChanged()));
    }
    m_dbWatcher->setEnabled(enabled);
    if (enabled) {
        QDateTime dateTime= QDateTime::currentDateTime();
        m_latestLandmarkTimestamp = (qint64)dateTime.toTime_t() *1000 + dateTime.time().msec();
        m_latestCategoryTimestamp = (qint64)dateTime.toTime_t() *1000 + dateTime.time().msec();
    }
}
Exemple #14
0
ChangeNotifier::ChangeNotifier(QObject *parent)
: QObject(parent)
, mTimer(new QTimer(this))
{
    // Use a timer to aggregate multiple KSycoca changes
    mTimer->setInterval(100);
    mTimer->setSingleShot(true);
    connect(mTimer, SIGNAL(timeout()), SLOT(timeout()));

    connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), SLOT(checkSycocaChanges(QStringList)));

    mWatchedProps << "appletContainmentId" << "appletContainmentMutable"
        << "desktopContainmentId" << "desktopContainmentMutable";
    qApp->installEventFilter(this);
}
ExportInfoPage::ExportInfoPage(const QMap<QString, QString> &str, QWidget *parent)
    : QWizardPage(parent), strMap(str)
{
    setTitle(tr("Source Information"));
    setSubTitle(tr("Specify source information about the source type for which you "
                   "want to export."));

    sourceDatabaseLabel = new QLabel(tr("Source Database:"));
    sourceDatabaseComcoBox = new QComboBox;
//    sourceTableLabel = new QLabel(tr("Source Table:"));
//    sourceTableComcoBox = new QComboBox;
    listView = new QListView;
    model = new MyStringListModel;
    listView->setModel(model);
    selectAllButton = new QPushButton(tr("Select All"));
    unSelectAllButton = new QPushButton(tr("Unselect All"));

    QHBoxLayout *topLayout = new QHBoxLayout;
    topLayout->addWidget(sourceDatabaseLabel);
    topLayout->addWidget(sourceDatabaseComcoBox);
    topLayout->addStretch();

    QVBoxLayout *rightLayout = new QVBoxLayout;
    rightLayout->addWidget(selectAllButton);
    rightLayout->addWidget(unSelectAllButton);
    rightLayout->addStretch();

    QHBoxLayout *bottomLayout = new QHBoxLayout;
    bottomLayout->addWidget(listView);
    bottomLayout->addLayout(rightLayout);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(topLayout);
    mainLayout->addLayout(bottomLayout);

    setLayout(mainLayout);

    connect(selectAllButton, SIGNAL(clicked()), this, SLOT(selectAllClicked()));
    connect(unSelectAllButton, SIGNAL(clicked()), this, SLOT(unselectAllClicked()));
    connect(sourceDatabaseComcoBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(databaseChanged(QString)));
    sourceDatabaseComcoBox->addItems(str.keys());
//    sourceDatabaseComcoBox->setCurrentIndex(-1);
//    sourceTableComcoBox->setCurrentIndex(-1);

//    registerField("sourceName*", sourceDatabaseComcoBox);
}
void KBuildSycocaProgressDialog::rebuildKSycoca(QWidget *parent)
{
  KBuildSycocaProgressDialog dlg(parent,
                                 i18n("Updating System Configuration"),
                                 i18n("Updating system configuration."));

  QDBusInterface kbuildsycoca("org.kde.kded", "/kbuildsycoca",
                              "org.kde.kbuildsycoca");
  if (kbuildsycoca.isValid()) {
     kbuildsycoca.callWithCallback("recreate", QVariantList(), &dlg, SLOT(_k_slotFinished()));
  } else {
      // kded not running, e.g. when using keditfiletype out of a KDE session
      QObject::connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), &dlg, SLOT(_k_slotFinished()));
      KProcess* proc = new KProcess(&dlg);
      (*proc) << KStandardDirs::findExe(KBUILDSYCOCA_EXENAME);
      proc->start();
  }
  dlg.exec();
}
Exemple #17
0
void DatabaseFileWatcher::setEnabled(bool enabled)
{
    if (!m_watcher) {
        m_watcher = new QFileSystemWatcher(this);
        connect(m_watcher, SIGNAL(fileChanged(QString)),
            SLOT(databaseChanged(QString)));
        connect(m_watcher, SIGNAL(directoryChanged(QString)),
            SLOT(databaseDirectoryChanged(QString)));
    }

    if (enabled) {
        if (QFile::exists(m_databasePath)) {
            if (!m_watcher->files().contains(m_databasePath))
                    m_watcher->addPath(m_databasePath);
        } else {
            restartDirMonitoring(QString());
        }
    } else {
        m_watcher->removePath(m_databasePath);
    }
}
Exemple #18
0
void SearchDialog::readSettings(){

    this->resize(settings->value("SearchDialog/size", QSize(700, 600)).toSize());
    this->move( settings->value("SearchDialog/pos", QPoint(200, 200)).toPoint() );
    coverFormat->setText( settings->value("SearchDialog/coverFormat","%artist% - %album%").toString() );
    coverFormatCheckBox->setChecked( settings->value("SearchDialog/coverFormatCheckBox",true).toBool() );
    saveCoverCheckBox->setChecked( settings->value("SearchDialog/saveCover",false).toBool() );
    saveAllCoversCheckBox->setChecked( settings->value("SearchDialog/saveAllCovers",true).toBool() );
    artistLabel->setChecked( settings->value("SearchDialog/artistLabel",true).toBool() );
    albumLabel->setChecked( settings->value("SearchDialog/albumLabel",true).toBool() );
    genreLabel->setChecked( settings->value("SearchDialog/genreLabel",true).toBool() );
    yearLabel->setChecked( settings->value("SearchDialog/yearLabel",true).toBool() );
    rolesLabel->setChecked( settings->value("SearchDialog/rolesLabel",false).toBool() );
    formatLabel->setChecked( settings->value("SearchDialog/formatLabel",false).toBool() );
    countryLabel->setChecked( settings->value("SearchDialog/countryLabel",false).toBool() );
    labelLabel->setChecked( settings->value("SearchDialog/labelLabel",false).toBool() );
    notesLabel->setChecked( settings->value("SearchDialog/notesLabel",false).toBool() );
    clearPreviousComentsCheckBox->setChecked( settings->value("SearchDialog/clearPreviousComents",false).toBool() );
    downloadImmediately->setChecked( settings->value("SearchDialog/downloadImmediately",true).toBool() );

    databaseComboBox->setCurrentIndex( settings->value("SearchDialog/databaseComboBox",0).toInt() );
    databaseChanged( databaseComboBox->currentIndex() );
}
Exemple #19
0
void DatabaseFileWatcher::setEnabled(ServiceDatabase *database, bool enabled)
{
    if (!m_watcher) {
        m_watcher = new QFileSystemWatcher(this);
        connect(m_watcher, SIGNAL(fileChanged(QString)),
            SLOT(databaseChanged(QString)));
        connect(m_watcher, SIGNAL(directoryChanged(QString)),
            SLOT(databaseDirectoryChanged(QString)));
    }

    QString path = database->databasePath();
    if (enabled) {
        if (QFile::exists(path)) {
            m_knownServices[path] = database->getServiceNames(QString());
            m_watcher->addPath(path);
        } else {
            restartDirMonitoring(path, QString());
        }
    } else {
        m_watcher->removePath(path);
        m_knownServices.remove(path);
    }
}
Exemple #20
0
void DatabaseWidget::openDatabase(bool accepted)
{
    if (accepted) {
        Database* oldDb = m_db;
        m_db = static_cast<DatabaseOpenWidget*>(sender())->database();
        m_groupView->changeDatabase(m_db);
        Q_EMIT databaseChanged(m_db);
        delete oldDb;
        setCurrentWidget(m_mainWidget);

        // We won't need those anymore and KeePass1OpenWidget closes
        // the file in its dtor.
        delete m_databaseOpenWidget;
        m_databaseOpenWidget = Q_NULLPTR;
        delete m_keepass1OpenWidget;
        m_keepass1OpenWidget = Q_NULLPTR;
    }
    else {
        if (m_databaseOpenWidget->database()) {
            delete m_databaseOpenWidget->database();
        }
        Q_EMIT closeRequest();
    }
}
Exemple #21
0
void IconApplet::setUrl(const KUrl& url, bool fromConfigDialog)
{
    if (!fromConfigDialog) {
        delete m_dialog.data();
    }

    m_url = url;
    if (!m_url.protocol().isEmpty()) {
        m_url = KIO::NetAccess::mostLocalUrl(url, 0);
    }

    m_service = 0;
    disconnect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)),
               this, SLOT(checkService(QStringList)));

    m_hasDesktopFile = false;
    delete m_watcher;
    m_watcher = 0;

    // if local
    //   if not a directory and executable
    //     make desktop file
    //    desktop file
    if (m_url.isLocalFile()) {
        m_watcher = new KDirWatch;
        m_watcher->addFile(m_url.toLocalFile());
        connect(m_watcher, SIGNAL(deleted(QString)), this, SLOT(delayedDestroy()));

        QFileInfo fi(m_url.toLocalFile());
        if (KDesktopFile::isDesktopFile(m_url.toLocalFile())) {
            m_hasDesktopFile = true;
        } else if (!fi.isDir() && fi.isExecutable()) {
            const QString suggestedName = fi.baseName();
            const QString file = KService::newServicePath(false, suggestedName);
            KDesktopFile df(file);
            KConfigGroup desktopGroup = df.desktopGroup();
            desktopGroup.writeEntry("Name", suggestedName);
            QString entryType;
            desktopGroup.writeEntry("Exec", m_url.toLocalFile());
            desktopGroup.writeEntry("Icon", KMimeType::iconNameForUrl(url));
            desktopGroup.writeEntry("Type", "Application");
            df.sync();
            m_url.setPath(file);
            m_hasDesktopFile = true;
        }
    }

    if (m_hasDesktopFile) {
        KDesktopFile f(m_url.toLocalFile());
        m_text = f.readName();
        //corrupted desktop file?
        if (m_text.isNull()) {
            m_text = m_url.fileName();
        }
        m_icon->setIcon(f.readIcon());

        m_genericName = f.readGenericName();

        connect(m_watcher, SIGNAL(dirty(QString)), this, SLOT(updateDesktopFile()));
    } else {
        m_text = m_url.fileName();
        m_service = KService::serviceByStorageId(m_text);
        connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)),
                this, SLOT(checkService(QStringList)));

        if (m_service) {
            m_text = m_service->name();
            m_icon->setIcon(m_service->icon());
        } else {
            if (m_text.isEmpty() && m_url.isLocalFile()) {
                //handle special case like the / folder
                m_text = m_url.directory();
            } else if (m_url.protocol().contains("http")) {
                m_text = m_url.prettyUrl();
                m_text.remove(QRegExp("http://(www.)*"));
            } else if (m_text.isEmpty()) {
                m_text = m_url.prettyUrl();

                if (m_text.endsWith(QLatin1String(":/"))) {
                    m_text = m_url.protocol();
                }
            }

            m_icon->setIcon(KMimeType::iconNameForUrl(url));
        }
    }

    if (m_icon->icon().isNull()) {
        m_icon->setIcon("unknown");
    }

    //Update the icon text (if the icon is not on a panel)
    if (formFactor() == Plasma::Planar || formFactor() == Plasma::MediaCenter) {
        m_icon->setText(m_text);
    } else {
        //Update the tooltip (if the icon is on a panel)
        Plasma::ToolTipContent data(m_text, m_genericName, m_icon->icon());
        Plasma::ToolTipManager::self()->setContent(m_icon, data);
    }

    //kDebug() << "url was" << url << "and is" << m_url;
}
Exemple #22
0
QgsGrassNewMapset::QgsGrassNewMapset( QgisInterface *iface,
                                      QgsGrassPlugin *plugin, QWidget *parent,
                                      Qt::WindowFlags f )
  : QWizard( parent, f )
  , QgsGrassNewMapsetBase()
{
  QgsDebugMsg( "QgsGrassNewMapset()" );

  setupUi( this );
  connect( mDatabaseButton, &QPushButton::clicked, this, &QgsGrassNewMapset::mDatabaseButton_clicked );
  connect( mDatabaseLineEdit, &QLineEdit::returnPressed, this, &QgsGrassNewMapset::mDatabaseLineEdit_returnPressed );
  connect( mDatabaseLineEdit, &QLineEdit::textChanged, this, &QgsGrassNewMapset::mDatabaseLineEdit_textChanged );
  connect( mCreateLocationRadioButton, &QRadioButton::clicked, this, &QgsGrassNewMapset::mCreateLocationRadioButton_clicked );
  connect( mSelectLocationRadioButton, &QRadioButton::clicked, this, &QgsGrassNewMapset::mSelectLocationRadioButton_clicked );
  connect( mLocationComboBox, &QComboBox::editTextChanged, this, &QgsGrassNewMapset::mLocationComboBox_textChanged );
  connect( mLocationLineEdit, &QLineEdit::returnPressed, this, &QgsGrassNewMapset::mLocationLineEdit_returnPressed );
  connect( mLocationLineEdit, &QLineEdit::textChanged, this, &QgsGrassNewMapset::mLocationLineEdit_textChanged );
  connect( mNoProjRadioButton, &QRadioButton::clicked, this, &QgsGrassNewMapset::mNoProjRadioButton_clicked );
  connect( mProjRadioButton, &QRadioButton::clicked, this, &QgsGrassNewMapset::mProjRadioButton_clicked );
  connect( mNorthLineEdit, &QLineEdit::returnPressed, this, &QgsGrassNewMapset::mNorthLineEdit_returnPressed );
  connect( mNorthLineEdit, &QLineEdit::textChanged, this, &QgsGrassNewMapset::mNorthLineEdit_textChanged );
  connect( mSouthLineEdit, &QLineEdit::returnPressed, this, &QgsGrassNewMapset::mSouthLineEdit_returnPressed );
  connect( mSouthLineEdit, &QLineEdit::textChanged, this, &QgsGrassNewMapset::mSouthLineEdit_textChanged );
  connect( mEastLineEdit, &QLineEdit::returnPressed, this, &QgsGrassNewMapset::mEastLineEdit_returnPressed );
  connect( mEastLineEdit, &QLineEdit::textChanged, this, &QgsGrassNewMapset::mEastLineEdit_textChanged );
  connect( mWestLineEdit, &QLineEdit::returnPressed, this, &QgsGrassNewMapset::mWestLineEdit_returnPressed );
  connect( mWestLineEdit, &QLineEdit::textChanged, this, &QgsGrassNewMapset::mWestLineEdit_textChanged );
  connect( mCurrentRegionButton, &QPushButton::clicked, this, &QgsGrassNewMapset::mCurrentRegionButton_clicked );
  connect( mRegionButton, &QPushButton::clicked, this, &QgsGrassNewMapset::mRegionButton_clicked );
  connect( mMapsetLineEdit, &QLineEdit::returnPressed, this, &QgsGrassNewMapset::mMapsetLineEdit_returnPressed );
  connect( mMapsetLineEdit, &QLineEdit::textChanged, this, &QgsGrassNewMapset::mMapsetLineEdit_textChanged );
  connect( mOpenNewMapsetCheckBox, &QCheckBox::stateChanged, this, &QgsGrassNewMapset::mOpenNewMapsetCheckBox_stateChanged );
#ifdef Q_OS_MAC
  setWizardStyle( QWizard::ClassicStyle );
#endif

  sRunning = true;
  mIface = iface;
  mProjectionSelector = nullptr;
  mPreviousPage = -1;
  mRegionModified = false;

  QString mapPath = QStringLiteral( ":/images/grass/world.png" );
  QgsDebugMsg( QString( "mapPath = %1" ).arg( mapPath ) );

  //mPixmap = QPixmap( *(mRegionMap->pixmap()) );
  mPixmap.load( mapPath );
  QgsDebugMsg( QString( "mPixmap.isNull() = %1" ).arg( mPixmap.isNull() ) );

  mRegionsInited = false;
  mPlugin = plugin;

  setError( mDatabaseErrorLabel );
  setError( mLocationErrorLabel );
  setError( mProjErrorLabel );
  setError( mRegionErrorLabel );
  setError( mMapsetErrorLabel );

  // DATABASE
  QgsSettings settings;
  QString gisdbase = settings.value( QStringLiteral( "GRASS/lastGisdbase" ) ).toString();
  if ( gisdbase.isEmpty() )
  {
    gisdbase = QDir::homePath() + QDir::separator() + "grassdata";
  }
  mDatabaseLineEdit->setText( gisdbase );
  databaseChanged();

  // LOCATION
  QRegExp rx( "[A-Za-z0-9_.]+" );
  mLocationLineEdit->setValidator( new QRegExpValidator( rx, mLocationLineEdit ) );

  // CRS

  // MAPSET
  mMapsetsListView->clear();
  mMapsetLineEdit->setValidator( new QRegExpValidator( rx, mMapsetLineEdit ) );

  mMapsetsListView->header()->setSectionResizeMode( QHeaderView::ResizeToContents );

  // FINISH
  mOpenNewMapsetCheckBox->setChecked( settings.value( QStringLiteral( "GRASS/newMapsetWizard/openMapset" ), true ).toBool() );
  connect( this, &QWizard::currentIdChanged, this, &QgsGrassNewMapset::pageSelected );

  restoreGeometry( settings.value( QStringLiteral( "Windows/QgsGrassNewMapset/geometry" ) ).toByteArray() );
}
Exemple #23
0
QgsGrassNewMapset::QgsGrassNewMapset( QgisInterface *iface,
                                      QgsGrassPlugin *plugin, QWidget * parent,
                                      Qt::WindowFlags f ) :
    QWizard( parent, f ),
    QgsGrassNewMapsetBase( )
{
    QgsDebugMsg( "QgsGrassNewMapset()" );

    setupUi( this );
#ifdef Q_WS_MAC
    setWizardStyle( QWizard::ClassicStyle );
#endif

    mRunning = true;
    mIface = iface;
    mProjectionSelector = 0;
    mPreviousPage = -1;
    mRegionModified = false;

    QString mapPath = ":/images/grass/world.png";
    QgsDebugMsg( QString( "mapPath = %1" ).arg( mapPath ) );

    //mPixmap = QPixmap( *(mRegionMap->pixmap()) );
    mPixmap.load( mapPath );
    QgsDebugMsg( QString( "mPixmap.isNull() = %1" ).arg( mPixmap.isNull() ) );

    mRegionsInited = false;
    mPlugin = plugin;

    setError( mDatabaseErrorLabel, "" );
    setError( mLocationErrorLabel, "" );
    setError( mProjErrorLabel, "" );
    setError( mRegionErrorLabel, "" );
    setError( mMapsetErrorLabel, "" );

    const QColor& paletteBackgroundColor = palette().color( backgroundRole() );
    QPalette palette = mDatabaseText->palette();
    palette.setColor( mDatabaseText->backgroundRole(), paletteBackgroundColor );
    mDatabaseText->setPalette( palette );
    palette = mLocationText->palette();
    palette.setColor( mLocationText->backgroundRole(), paletteBackgroundColor );
    mLocationText->setPalette( palette );
    palette = mRegionText->palette();
    palette.setColor( mRegionText->backgroundRole(), paletteBackgroundColor );
    mRegionText->setPalette( palette );
    palette = mMapsetText->palette();
    palette.setColor( mMapsetText->backgroundRole(), paletteBackgroundColor );
    mMapsetText->setPalette( palette );

    // DATABASE
    QSettings settings;
    QString db = settings.value( "/GRASS/lastGisdbase" ).toString();
    if ( !db.isNull() )
    {
        mDatabaseLineEdit->setText( db );
    }
    else
    {
        mDatabaseLineEdit->setText( QDir::currentPath() );
    }
    databaseChanged();

    // Create example tree structure
    mTreeListView->clear();
    QTreeWidgetItem *dbi = new QTreeWidgetItem( mTreeListView, QStringList() << "OurDatabase" << tr( "Database" ) );
    dbi->setExpanded( true );

    QTreeWidgetItem *l = new QTreeWidgetItem( dbi, QStringList() << "Mexico" << tr( "Location 1" ) );
    l->setExpanded( true );
    QTreeWidgetItem *m = new QTreeWidgetItem( l, QStringList() << "PERMANENT" << tr( "System mapset" ) );
    m->setExpanded( true );
    m = new QTreeWidgetItem( l, QStringList() << "Alejandra" << tr( "User's mapset" ) );
    m->setExpanded( true );
    m = new QTreeWidgetItem( l, QStringList() << "Juan" << tr( "User's mapset" ) );
    m->setExpanded( true );

    l = new QTreeWidgetItem( dbi, QStringList() << "New Zealand" << tr( "Location 2" ) );
    l->setExpanded( true );
    m = new QTreeWidgetItem( l, QStringList() << "PERMANENT" << tr( "System mapset" ) );
    m->setExpanded( true );
    m = new QTreeWidgetItem( l, QStringList() << "Cimrman" << tr( "User's mapset" ) );
    m->setExpanded( true );

    // LOCATION
    QRegExp rx;
    rx.setPattern( "[A-Za-z0-9_.]+" );
    mLocationLineEdit->setValidator( new QRegExpValidator( rx, mLocationLineEdit ) );

    // CRS

    // MAPSET
    mMapsetsListView->clear();
    mMapsetLineEdit->setValidator( new QRegExpValidator( rx, mMapsetLineEdit ) );

    // FINISH

    connect( this, SIGNAL( currentIdChanged( int ) ),
             this, SLOT( pageSelected( int ) ) );
}
Exemple #24
0
//----------------------------------------------------------------------------
ctkDICOMAppWidget::ctkDICOMAppWidget(QWidget* _parent):Superclass(_parent), 
  d_ptr(new ctkDICOMAppWidgetPrivate)
{
  Q_D(ctkDICOMAppWidget);  

  d->setupUi(this);

  //Hide image previewer buttons
  d->nextImageButton->hide();
  d->prevImageButton->hide();
  d->nextSeriesButton->hide();
  d->prevSeriesButton->hide();
  d->nextStudyButton->hide();
  d->prevStudyButton->hide();

  //Enable sorting in tree view
  d->treeView->setSortingEnabled(true);
  d->treeView->setSelectionBehavior(QAbstractItemView::SelectRows);

  connect(d->treeView, SIGNAL(collapsed(QModelIndex)), this, SLOT(onTreeCollapsed(QModelIndex)));
  connect(d->treeView, SIGNAL(expanded(QModelIndex)), this, SLOT(onTreeExpanded(QModelIndex)));

  //Set toolbar button style
  d->toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);

  //Initialize Q/R widget
  d->QueryRetrieveWidget = new ctkDICOMQueryRetrieveWidget();
  d->QueryRetrieveWidget->setWindowModality ( Qt::ApplicationModal );

  //initialize directory from settings, then listen for changes
  QSettings settings;
  if ( settings.value("DatabaseDirectory", "") == "" )
    {
    QString directory = QString("./ctkDICOM-Database");
    settings.setValue("DatabaseDirectory", directory);
    settings.sync();
    }
  QString databaseDirectory = settings.value("DatabaseDirectory").toString();
  this->setDatabaseDirectory(databaseDirectory);
  d->directoryButton->setDirectory(databaseDirectory);

  connect(d->directoryButton, SIGNAL(directoryChanged(const QString&)), this, SLOT(setDatabaseDirectory(const QString&)));

  //Initialize import widget
  d->ImportDialog = new ctkFileDialog();
  QCheckBox* importCheckbox = new QCheckBox("Copy on import", d->ImportDialog);
  d->ImportDialog->setBottomWidget(importCheckbox);
  d->ImportDialog->setFileMode(QFileDialog::Directory);
  d->ImportDialog->setLabelText(QFileDialog::Accept,"Import");
  d->ImportDialog->setWindowTitle("Import DICOM files from directory ...");
  d->ImportDialog->setWindowModality(Qt::ApplicationModal);

  //connect signal and slots
  connect(d->treeView, SIGNAL(clicked(const QModelIndex&)), d->thumbnailsWidget, SLOT(onModelSelected(const QModelIndex &)));
  connect(d->treeView, SIGNAL(clicked(const QModelIndex&)), d->imagePreview, SLOT(onModelSelected(const QModelIndex &)));
  connect(d->treeView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(onModelSelected(const QModelIndex &)));

  connect(d->thumbnailsWidget, SIGNAL(selected(const ctkDICOMThumbnailWidget&)), this, SLOT(onThumbnailSelected(const ctkDICOMThumbnailWidget&)));
  connect(d->ImportDialog, SIGNAL(fileSelected(QString)),this,SLOT(onImportDirectory(QString)));

  connect(d->DICOMDatabase.data(), SIGNAL( databaseChanged() ), &(d->DICOMModel), SLOT( reset() ) );
  connect(d->QueryRetrieveWidget, SIGNAL( canceled() ), d->QueryRetrieveWidget, SLOT( hide() ) );

  connect(d->imagePreview, SIGNAL(requestNextImage()), this, SLOT(onNextImage()));
  connect(d->imagePreview, SIGNAL(requestPreviousImage()), this, SLOT(onPreviousImage()));

}
Exemple #25
0
//------------------------------------------------------------------------------
void ctkDICOMDatabase::insert ( DcmDataset *dataset, bool storeFile, bool generateThumbnail)
{
  Q_D(ctkDICOMDatabase);

  if (!dataset)
    {
    return;
    }
  // Check to see if the file has already been loaded
  OFString sopInstanceUID ;
  dataset->findAndGetOFString(DCM_SOPInstanceUID, sopInstanceUID);

  QSqlQuery fileExists ( d->Database );
  fileExists.prepare("SELECT InsertTimestamp,Filename FROM Images WHERE SOPInstanceUID == ?");
  fileExists.bindValue(0,QString(sopInstanceUID.c_str()));
  fileExists.exec();
  if ( fileExists.next() && QFileInfo(fileExists.value(1).toString()).lastModified() < QDateTime::fromString(fileExists.value(0).toString(),Qt::ISODate) )
    {
    logger.debug ( "File " + fileExists.value(1).toString() + " already added" );
    return;
    }

  OFString patientsName, patientID, patientsBirthDate, patientsBirthTime, patientsSex,
    patientComments, patientsAge;

  OFString studyInstanceUID, studyID, studyDate, studyTime,
    accessionNumber, modalitiesInStudy, institutionName, performingPhysiciansName, referringPhysician, studyDescription;

  OFString seriesInstanceUID, seriesDate, seriesTime,
    seriesDescription, bodyPartExamined, frameOfReferenceUID,
    contrastAgent, scanningSequence;
  OFString instanceNumber;

  Sint32 seriesNumber = 0, acquisitionNumber = 0, echoNumber = 0, temporalPosition = 0;

  //If the following fields can not be evaluated, cancel evaluation of the DICOM file
  dataset->findAndGetOFString(DCM_PatientName, patientsName);
  dataset->findAndGetOFString(DCM_StudyInstanceUID, studyInstanceUID);
  dataset->findAndGetOFString(DCM_SeriesInstanceUID, seriesInstanceUID);
  dataset->findAndGetOFString(DCM_PatientID, patientID);


  dataset->findAndGetOFString(DCM_PatientBirthDate, patientsBirthDate);
  dataset->findAndGetOFString(DCM_PatientBirthTime, patientsBirthTime);
  dataset->findAndGetOFString(DCM_PatientSex, patientsSex);
  dataset->findAndGetOFString(DCM_PatientAge, patientsAge);
  dataset->findAndGetOFString(DCM_PatientComments, patientComments);
  dataset->findAndGetOFString(DCM_StudyID, studyID);
  dataset->findAndGetOFString(DCM_StudyDate, studyDate);
  dataset->findAndGetOFString(DCM_StudyTime, studyTime);
  dataset->findAndGetOFString(DCM_AccessionNumber, accessionNumber);
  dataset->findAndGetOFString(DCM_ModalitiesInStudy, modalitiesInStudy);
  dataset->findAndGetOFString(DCM_InstitutionName, institutionName);
  dataset->findAndGetOFString(DCM_PerformingPhysicianName, performingPhysiciansName);
  dataset->findAndGetOFString(DCM_ReferringPhysicianName, referringPhysician);
  dataset->findAndGetOFString(DCM_StudyDescription, studyDescription);

  dataset->findAndGetOFString(DCM_SeriesDate, seriesDate);
  dataset->findAndGetOFString(DCM_SeriesTime, seriesTime);
  dataset->findAndGetOFString(DCM_SeriesDescription, seriesDescription);
  dataset->findAndGetOFString(DCM_BodyPartExamined, bodyPartExamined);
  dataset->findAndGetOFString(DCM_FrameOfReferenceUID, frameOfReferenceUID);
  dataset->findAndGetOFString(DCM_ContrastBolusAgent, contrastAgent);
  dataset->findAndGetOFString(DCM_ScanningSequence, scanningSequence);

  dataset->findAndGetSint32(DCM_SeriesNumber, seriesNumber);
  dataset->findAndGetSint32(DCM_AcquisitionNumber, acquisitionNumber);
  dataset->findAndGetSint32(DCM_EchoNumbers, echoNumber);
  dataset->findAndGetSint32(DCM_TemporalPositionIdentifier, temporalPosition);

  // store the file if the database is not in memomry
  QString filename;
  if ( storeFile && !this->isInMemory() )
  {
    DcmFileFormat* fileformat = new DcmFileFormat ( dataset );

    QString destinationDirectoryName = databaseDirectory() + "/dicom/";
    QDir destinationDir(destinationDirectoryName);
    QString studySeriesDirectory = QString(studyInstanceUID.c_str()) + "/" + seriesInstanceUID.c_str();
    destinationDir.mkpath(studySeriesDirectory);

    filename = databaseDirectory() + "/dicom/" + pathForDataset(dataset);
    logger.debug ( "Saving file: " + filename );
    OFCondition status = fileformat->saveFile ( filename.toAscii() );
    if ( !status.good() )
      {
      logger.error ( "Error saving file: " + filename + "\nError is " + status.text() );
      delete fileformat;
      return;
      }
    delete fileformat;
  }


  QSqlQuery check_exists_query(d->Database);
  //The patient UID is a unique number within the database, generated by the sqlite autoincrement
  int patientUID = -1;
  if ( patientID != "" && patientsName != "" )
    {
    //Check if patient is already present in the db
    check_exists_query.prepare ( "SELECT * FROM Patients WHERE PatientID = ? AND PatientsName = ?" );
    check_exists_query.bindValue ( 0, QString ( patientID.c_str() ) );
    check_exists_query.bindValue ( 1, QString ( patientsName.c_str() ) );
    check_exists_query.exec();
    
    if (check_exists_query.next())
      {
      patientUID = check_exists_query.value(check_exists_query.record().indexOf("UID")).toInt();
      }
    else
      {
      // Insert it
      QSqlQuery statement ( d->Database );
      statement.prepare ( "INSERT INTO Patients ('UID', 'PatientsName', 'PatientID', 'PatientsBirthDate', 'PatientsBirthTime', 'PatientsSex', 'PatientsAge', 'PatientsComments' ) values ( NULL, ?, ?, ?, ?, ?, ?, ? )" );
      statement.bindValue ( 0, QString ( patientsName.c_str() ) );
      statement.bindValue ( 1, QString ( patientID.c_str() ) );
      statement.bindValue ( 2, QString ( patientsBirthDate.c_str() ) );
      statement.bindValue ( 3, QString ( patientsBirthTime.c_str() ) );
      statement.bindValue ( 4, QString ( patientsSex.c_str() ) );
      // TODO: shift patient's age to study, since this is not a patient level attribute in images
      // statement.bindValue ( 5, QString ( patientsAge.c_str() ) );
      statement.bindValue ( 6, QString ( patientComments.c_str() ) );
      statement.exec ();
      patientUID = statement.lastInsertId().toInt();
      logger.debug ( "New patient inserted: " + QString().setNum ( patientUID ) );
      }
    }

  if ( studyInstanceUID != "" )
    {
    check_exists_query.prepare ( "SELECT * FROM Studies WHERE StudyInstanceUID = ?" );
    check_exists_query.bindValue ( 0, QString ( studyInstanceUID.c_str() ) );
    check_exists_query.exec();
    if(!check_exists_query.next())
      {
      QSqlQuery statement ( d->Database );
      statement.prepare ( "INSERT INTO Studies ( 'StudyInstanceUID', 'PatientsUID', 'StudyID', 'StudyDate', 'StudyTime', 'AccessionNumber', 'ModalitiesInStudy', 'InstitutionName', 'ReferringPhysician', 'PerformingPhysiciansName', 'StudyDescription' ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" );
      statement.bindValue ( 0, QString ( studyInstanceUID.c_str() ) );
      statement.bindValue ( 1, patientUID );
      statement.bindValue ( 2, QString ( studyID.c_str() ) );
      statement.bindValue ( 3, QDate::fromString ( studyDate.c_str(), "yyyyMMdd" ) );
      statement.bindValue ( 4, QString ( studyTime.c_str() ) );
      statement.bindValue ( 5, QString ( accessionNumber.c_str() ) );
      statement.bindValue ( 6, QString ( modalitiesInStudy.c_str() ) );
      statement.bindValue ( 7, QString ( institutionName.c_str() ) );
      statement.bindValue ( 8, QString ( referringPhysician.c_str() ) );
      statement.bindValue ( 9, QString ( performingPhysiciansName.c_str() ) );
      statement.bindValue ( 10, QString ( studyDescription.c_str() ) );
      if ( !statement.exec() )
        {
        logger.error ( "Error executing statament: " + statement.lastQuery() + " Error: " + statement.lastError().text() );
        }
      }
    }

  if ( seriesInstanceUID != "" )
    {
    check_exists_query.prepare ( "SELECT * FROM Series WHERE SeriesInstanceUID = ?" );
    check_exists_query.bindValue ( 0, QString ( seriesInstanceUID.c_str() ) );
    logger.warn ( "Statement: " + check_exists_query.lastQuery() );
    check_exists_query.exec();
    if(!check_exists_query.next())
      {
      QSqlQuery statement ( d->Database );
      statement.prepare ( "INSERT INTO Series ( 'SeriesInstanceUID', 'StudyInstanceUID', 'SeriesNumber', 'SeriesDate', 'SeriesTime', 'SeriesDescription', 'BodyPartExamined', 'FrameOfReferenceUID', 'AcquisitionNumber', 'ContrastAgent', 'ScanningSequence', 'EchoNumber', 'TemporalPosition' ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" );
      statement.bindValue ( 0, QString ( seriesInstanceUID.c_str() ) );
      statement.bindValue ( 1, QString ( studyInstanceUID.c_str() ) );
      statement.bindValue ( 2, static_cast<int>(seriesNumber) );
      statement.bindValue ( 3, QString ( seriesDate.c_str() ) );
      statement.bindValue ( 4, QDate::fromString ( seriesTime.c_str(), "yyyyMMdd" ) );
      statement.bindValue ( 5, QString ( seriesDescription.c_str() ) );
      statement.bindValue ( 6, QString ( bodyPartExamined.c_str() ) );
      statement.bindValue ( 7, QString ( frameOfReferenceUID.c_str() ) );
      statement.bindValue ( 8, static_cast<int>(acquisitionNumber) );
      statement.bindValue ( 9, QString ( contrastAgent.c_str() ) );
      statement.bindValue ( 10, QString ( scanningSequence.c_str() ) );
      statement.bindValue ( 11, static_cast<int>(echoNumber) );
      statement.bindValue ( 12, static_cast<int>(temporalPosition) );
      if ( !statement.exec() )
        {
        logger.error ( "Error executing statament: " + statement.lastQuery() + " Error: " + statement.lastError().text() );
        }
      }
    }
  if ( !filename.isEmpty() )
    {
    check_exists_query.prepare ( "SELECT * FROM Images WHERE Filename = ?" );
    check_exists_query.bindValue ( 0, filename );
    check_exists_query.exec();
    if(!check_exists_query.next())
      {
      QSqlQuery statement ( d->Database );
      statement.prepare ( "INSERT INTO Images ( 'SOPInstanceUID', 'Filename', 'SeriesInstanceUID', 'InsertTimestamp' ) VALUES ( ?, ?, ?, ? )" );
      statement.bindValue ( 0, QString ( sopInstanceUID.c_str() ) );
      statement.bindValue ( 1, filename );
      statement.bindValue ( 2, QString ( seriesInstanceUID.c_str() ) );
      statement.bindValue ( 3, QDateTime::currentDateTime() );
      statement.exec();
      }
    }

  if(generateThumbnail){
      if(d->thumbnailGenerator){
        QString studySeriesDirectory = QString(studyInstanceUID.c_str()) + "/" + QString(seriesInstanceUID.c_str());
        //Create thumbnail here
        QString thumbnailPath = databaseDirectory() +
                            "/thumbs/" + this->pathForDataset(dataset) + ".png";
                            //QString(studyInstanceUID.c_str()) + "/" +
                            //QString(seriesInstanceUID.c_str()) + "/" +
                            //QString(sopInstanceUID.c_str()) + ".png";
        QFileInfo thumbnailInfo(thumbnailPath);
        if(!(thumbnailInfo.exists() && (thumbnailInfo.lastModified() > QFileInfo(filename).lastModified()))){
            QDir(databaseDirectory() + "/thumbs/").mkpath(studySeriesDirectory);
            DicomImage dcmImage(QDir::toNativeSeparators(filename).toAscii());
            d->thumbnailGenerator->generateThumbnail(&dcmImage, thumbnailPath);
        }
      }
  }

  if (isInMemory())
    {
      emit databaseChanged();
    }
}
void ShareEngine::init()
{
    connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)),
            this, SLOT(updatePlugins(QStringList)));
    updatePlugins(QStringList() << "services");
}
QgsGrassNewMapset::QgsGrassNewMapset( QgisInterface *iface,
                                      QgsGrassPlugin *plugin, QWidget * parent,
                                      Qt::WindowFlags f ) :
    QWizard( parent, f ),
    QgsGrassNewMapsetBase()
{
  QgsDebugMsg( "QgsGrassNewMapset()" );

  setupUi( this );
#ifdef Q_OS_MAC
  setWizardStyle( QWizard::ClassicStyle );
#endif

  mRunning = true;
  mIface = iface;
  mProjectionSelector = 0;
  mPreviousPage = -1;
  mRegionModified = false;

  QString mapPath = ":/images/grass/world.png";
  QgsDebugMsg( QString( "mapPath = %1" ).arg( mapPath ) );

  //mPixmap = QPixmap( *(mRegionMap->pixmap()) );
  mPixmap.load( mapPath );
  QgsDebugMsg( QString( "mPixmap.isNull() = %1" ).arg( mPixmap.isNull() ) );

  mRegionsInited = false;
  mPlugin = plugin;

  setError( mDatabaseErrorLabel );
  setError( mLocationErrorLabel );
  setError( mProjErrorLabel );
  setError( mRegionErrorLabel );
  setError( mMapsetErrorLabel );

  // DATABASE
  QSettings settings;
  QString gisdbase = settings.value( "/GRASS/lastGisdbase" ).toString();
  if ( gisdbase.isEmpty() )
  {
    gisdbase = QDir::homePath() + QDir::separator() + "grassdata";
  }
  mDatabaseLineEdit->setText( gisdbase );
  databaseChanged();

  // LOCATION
  QRegExp rx( "[A-Za-z0-9_.]+" );
  mLocationLineEdit->setValidator( new QRegExpValidator( rx, mLocationLineEdit ) );

  // CRS

  // MAPSET
  mMapsetsListView->clear();
  mMapsetLineEdit->setValidator( new QRegExpValidator( rx, mMapsetLineEdit ) );

  mMapsetsListView->header()->setResizeMode( QHeaderView::ResizeToContents );

  // FINISH
  mOpenNewMapsetCheckBox->setChecked( settings.value( "/GRASS/newMapsetWizard/openMapset", true ).toBool() );
  connect( this, SIGNAL( currentIdChanged( int ) ), SLOT( pageSelected( int ) ) );

  restoreGeometry( settings.value( "/Windows/QgsGrassNewMapset/geometry" ).toByteArray() );
}