21 #include <QListWidgetItem>
22 #include <QTextStream>
24 #include <kfiledialog.h>
25 #include <kactioncollection.h>
26 #include <kconfigdialog.h>
43 m_ConfigDialog = KConfigDialog::exists(
"settings" );
46 populateInbuiltCatalogs();
57 m_StarDensity = kcfg_StarDensity->value();
63 kcfg_MagLimitDrawDeepSky->setMaximum( 16.0 );
64 kcfg_MagLimitDrawDeepSkyZoomOut->setMaximum( 16.0 );
67 if ( ! kcfg_ShowStars->isChecked() ) slotStarWidgets(
false);
76 populateCustomCatalogs();
78 connect( CatalogList, SIGNAL( itemClicked( QListWidgetItem* ) ),
this, SLOT( updateCustomCatalogs() ) );
79 connect( CatalogList, SIGNAL( itemSelectionChanged() ),
this, SLOT( selectCatalog() ) );
80 connect( AddCatalog, SIGNAL( clicked() ),
this, SLOT( slotAddCatalog() ) );
81 connect( LoadCatalog, SIGNAL( clicked() ),
this, SLOT( slotLoadCatalog() ) );
82 connect( RemoveCatalog, SIGNAL( clicked() ),
this, SLOT( slotRemoveCatalog() ) );
90 connect( kcfg_ShowStars, SIGNAL( toggled(
bool) ), SLOT( slotStarWidgets(
bool) ) );
91 connect( kcfg_ShowDeepSky, SIGNAL( toggled(
bool) ), SLOT( slotDeepSkyWidgets(
bool) ) );
92 connect( kcfg_ShowDeepSkyNames, SIGNAL( toggled(
bool) ), kcfg_DeepSkyLongLabels, SLOT( setEnabled(
bool) ) );
93 connect( m_ConfigDialog, SIGNAL( applyClicked() ), SLOT( slotApply() ) );
94 connect( m_ConfigDialog, SIGNAL( okClicked() ), SLOT( slotApply() ) );
95 connect( m_ConfigDialog, SIGNAL( cancelClicked() ), SLOT( slotCancel() ) );
102 void OpsCatalog::updateCustomCatalogs() {
103 m_ShowMessier = showMessier->checkState();
104 m_ShowMessImages = showMessImages->checkState();
105 m_ShowNGC = showNGC->checkState();
106 m_ShowIC = showIC->checkState();
108 int limit = m_CustomCatalogFile->size();
109 for (
int i=0; i < limit; ++i ) {
110 QString name = m_CustomCatalogFile->at(i);
121 if (l.count() == 0)
continue;
122 if ( l[0]->checkState()==Qt::Checked ) {
123 if (!m_CheckedCatalogNames.contains(name))
124 m_CheckedCatalogNames.append(name);
125 }
else if ( l[0]->checkState()==Qt::Unchecked ){
126 if (m_CheckedCatalogNames.contains(name))
127 m_CheckedCatalogNames.removeAll(name);
131 m_ConfigDialog->enableButtonApply(
false );
135 void OpsCatalog::selectCatalog() {
137 RemoveCatalog->setEnabled(
false );
139 if ( ! CatalogList->currentItem() )
return;
141 foreach (
SkyComponent *sc, ksw->data()->skyComposite()->customCatalogs() ) {
143 if ( CatalogList->currentItem()->text() == cc->
name() ) {
144 RemoveCatalog->setEnabled(
true );
151 void OpsCatalog::slotAddCatalog() {
152 QPointer<AddCatDialog> ac =
new AddCatDialog( ksw );
153 if ( ac->exec()==QDialog::Accepted )
154 ksw->data()->catalogdb()->AddCatalogContents( ac->filename() );
155 refreshCatalogList();
160 void OpsCatalog::slotLoadCatalog() {
162 QString filename = KFileDialog::getOpenFileName( QDir::homePath(),
"*");
163 if ( ! filename.isEmpty() ) {
164 ksw->data()->catalogdb()->AddCatalogContents(filename);
165 refreshCatalogList();
167 m_ConfigDialog->enableButtonApply(
false );
171 void OpsCatalog::refreshCatalogList() {
172 ksw->data()->catalogdb()->Catalogs();
173 populateCustomCatalogs();
177 void OpsCatalog::slotRemoveCatalog() {
178 if (KMessageBox::warningYesNo(0,
179 i18n(
"The selected database will be removed. "
180 "This action cannot be reversed! Delete Catalog?"),
181 i18n(
"Delete Catalog?") )
182 == KMessageBox::No) {
183 KMessageBox::information(0,
"Catalog deletion cancelled.");
187 ksw->data()->catalogdb()->RemoveCatalog( CatalogList->currentItem()->text() );
192 if (checkedlist.contains(CatalogList->currentItem()->text())) {
193 checkedlist.removeAll(CatalogList->currentItem()->text());
198 QListWidgetItem *todelete = CatalogList->takeItem( CatalogList->row( CatalogList->currentItem() ) );
200 refreshCatalogList();
201 m_ConfigDialog->enableButtonApply(
false );
219 void OpsCatalog::slotApply() {
220 refreshCatalogList();
233 updateCustomCatalogs();
244 ksw->data()->setFullTimeUpdate();
246 ksw->map()->forceUpdate();
250 void OpsCatalog::slotCancel() {
266 void OpsCatalog::slotStarWidgets(
bool on) {
268 LabelStarDensity->setEnabled(on);
270 LabelDensity->setEnabled(on);
274 kcfg_StarDensity->setEnabled(on);
275 LabelStarDensity->setEnabled( on );
277 kcfg_StarLabelDensity->setEnabled(on);
278 kcfg_ShowStarNames->setEnabled(on);
279 kcfg_ShowStarMagnitudes->setEnabled(on);
283 void OpsCatalog::slotDeepSkyWidgets(
bool on) {
284 CatalogList->setEnabled( on );
285 AddCatalog->setEnabled( on );
286 LoadCatalog->setEnabled( on );
287 LabelMagDeepSky->setEnabled( on );
288 LabelMagDeepSkyZoomOut->setEnabled( on );
289 kcfg_MagLimitDrawDeepSky->setEnabled( on );
290 kcfg_MagLimitDrawDeepSkyZoomOut->setEnabled( on );
291 kcfg_ShowDeepSkyNames->setEnabled( on );
292 kcfg_ShowDeepSkyMagnitudes->setEnabled( on );
293 kcfg_DeepSkyLabelDensity->setEnabled( on );
294 kcfg_DeepSkyLongLabels->setEnabled( on );
295 LabelMag3->setEnabled( on );
296 LabelMag4->setEnabled( on );
301 RemoveCatalog->setEnabled( on );
306 void OpsCatalog::populateInbuiltCatalogs() {
307 showIC =
new QListWidgetItem( i18n(
"Index Catalog (IC)" ), CatalogList );
308 showIC->setFlags( Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
309 showIC->setCheckState(
Options::showIC() ? Qt::Checked : Qt::Unchecked );
311 showNGC =
new QListWidgetItem( i18n(
"New General Catalog (NGC)" ), CatalogList );
312 showNGC->setFlags( Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
315 showMessImages =
new QListWidgetItem( i18n(
"Messier Catalog (images)" ), CatalogList );
316 showMessImages->setFlags( Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
319 showMessier =
new QListWidgetItem( i18n(
"Messier Catalog (symbols)" ), CatalogList );
320 showMessier->setFlags( Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
325 void OpsCatalog::populateCustomCatalogs() {
327 QStringList customList = *m_CustomCatalogFile;
328 QStringListIterator catalogIter(customList);
330 while ( catalogIter.hasNext() ) {
331 QString catalogname = catalogIter.next();
333 if (CatalogList->findItems( catalogname, Qt::MatchExactly ).length() > 0)
337 QListWidgetItem *newItem =
new QListWidgetItem( catalogname, CatalogList );
338 newItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
340 if ( toggleNames.contains( catalogname ) ) {
341 newItem->setCheckState( Qt::Checked );
343 newItem->setCheckState( Qt::Unchecked );
350 #include "opscatalog.moc"
static void setStarDensity(int v)
Set Density of stars in the field of view.
static void setShowMessier(bool v)
Set Draw Messier objects in the sky map?
static QList< int > showCatalog()
Get List of toggles for displaying custom object catalogs.
static KStars * Instance()
SkyComponent represents an object on the sky map.
static int starDensity()
Get Density of stars in the field of view.
This is the main window for KStars.
QStringList * Catalogs()
Accessor for list of all available catalogs in db.
Represents a custom user-defined catalog.
static void setShowIC(bool v)
Set Draw IC objects in the sky map?
static void setShowCatalogNames(const QStringList &v)
Set List for displaying custom object catalogs.
SkyMapComposite * skyComposite()
static bool showMessierImages()
Get Draw Messier object images in the sky map?
static QStringList showCatalogNames()
Get List for displaying custom object catalogs.
static void setShowMessierImages(bool v)
Set Draw Messier object images in the sky map?
static bool showNGC()
Get Draw NGC objects in the sky map?
KStarsData * data() const
static void setShowNGC(bool v)
Set Draw NGC objects in the sky map?
static void setShowDeepSky(bool v)
Set Draw "deep sky" objects in the sky map?
static bool showIC()
Get Draw IC objects in the sky map?
static bool showMessier()
Get Draw Messier objects in the sky map?