r15527 by fschmid - Scrapbook directorys are now under supervision by the filewatcher, extended this for the directorys themselfs.
scribus-commit
scribus-commit at lists.scribus.net
Tue Oct 12 23:48:09 CEST 2010
Author: fschmid
Date: Tue Oct 12 21:48:08 2010
New Revision: 15527
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15527
Log:
Scrapbook directorys are now under supervision by the filewatcher, extended this for the directorys themselfs.
Fixed the non working dirDeleted() signal of the filewatcher.
Modified:
trunk/Scribus/scribus/filewatcher.cpp
trunk/Scribus/scribus/filewatcher.h
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/ui/scrapbookpalette.cpp
trunk/Scribus/scribus/ui/scrapbookpalette.h
Modified: trunk/Scribus/scribus/filewatcher.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15527&path=/trunk/Scribus/scribus/filewatcher.cpp
==============================================================================
--- trunk/Scribus/scribus/filewatcher.cpp (original)
+++ trunk/Scribus/scribus/filewatcher.cpp Tue Oct 12 21:48:08 2010
@@ -53,7 +53,7 @@
return m_timeOut;
}
-void FileWatcher::addFile(QString fileName)
+void FileWatcher::addFile(QString fileName, bool fast)
{
watchTimer->stop();
if (!watchedFiles.contains(fileName))
@@ -64,6 +64,8 @@
fi.pendingCount = 0;
fi.pending = false;
fi.refCount = 1;
+ fi.isDir = fi.info.isDir();
+ fi.fast = fast;
watchedFiles.insert(fileName, fi);
}
else
@@ -85,9 +87,9 @@
watchTimer->start(m_timeOut);
}
-void FileWatcher::addDir(QString fileName)
-{
- addFile(fileName);
+void FileWatcher::addDir(QString fileName, bool fast)
+{
+ addFile(fileName, fast);
}
void FileWatcher::removeDir(QString fileName)
@@ -146,22 +148,9 @@
break;
if (!it.value().pending)
{
- it.value().pendingCount = 5;
- it.value().pending = true;
- emit statePending(it.key());
- continue;
- }
- else
- {
- if (it.value().pendingCount != 0)
- {
- it.value().pendingCount--;
- continue;
- }
- else
- {
- it.value().pending = false;
- if (it.value().info.isDir())
+ if (it.value().fast)
+ {
+ if (it.value().isDir)
emit dirDeleted(it.key());
else
emit fileDeleted(it.key());
@@ -172,6 +161,35 @@
toRemove.append(it.key());
continue;
}
+ else
+ {
+ it.value().pendingCount = 5;
+ it.value().pending = true;
+ emit statePending(it.key());
+ continue;
+ }
+ }
+ else
+ {
+ if (it.value().pendingCount != 0)
+ {
+ it.value().pendingCount--;
+ continue;
+ }
+ else
+ {
+ it.value().pending = false;
+ if (it.value().isDir)
+ emit dirDeleted(it.key());
+ else
+ emit fileDeleted(it.key());
+ if (m_stateFlags & FileCheckMustStop)
+ break;
+ it.value().refCount--;
+ if (it.value().refCount == 0)
+ toRemove.append(it.key());
+ continue;
+ }
}
}
else
@@ -180,7 +198,7 @@
time = it.value().info.lastModified();
if (time != it.value().timeInfo)
{
- if (it.value().info.isDir())
+ if (it.value().isDir)
{
it.value().timeInfo = time;
if (!(m_stateFlags & FileCheckMustStop))
Modified: trunk/Scribus/scribus/filewatcher.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15527&path=/trunk/Scribus/scribus/filewatcher.h
==============================================================================
--- trunk/Scribus/scribus/filewatcher.h (original)
+++ trunk/Scribus/scribus/filewatcher.h Tue Oct 12 21:48:08 2010
@@ -34,11 +34,11 @@
public slots:
//Add a file to the watch list for monitoring
- void addFile(QString fileName);
+ void addFile(QString fileName, bool fast = false);
//Remove a file from the watch list
void removeFile(QString fileName);
//Add a directory to the watch list for monitoring
- void addDir(QString fileName);
+ void addDir(QString fileName, bool fast = false);
//Remove a directory from the watch list
void removeDir(QString fileName);
//Start the watcher's timer for file monitoring
@@ -56,6 +56,8 @@
int pendingCount;
bool pending;
int refCount;
+ bool isDir;
+ bool fast;
};
typedef enum
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15527&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Tue Oct 12 21:48:08 2010
@@ -602,11 +602,12 @@
if (scrapbookFileInfo.exists())
scrapbookPalette->readContents(scrapbookFile);
scrapbookPalette->setScrapbookFileName(scrapbookFile);
- ScCore->fileWatcher->addDir(scrapbookFile);
+ ScCore->fileWatcher->addDir(scrapbookFile, true);
scrapbookPalette->setOpenScrapbooks(prefsManager->appPrefs.scrapbookPrefs.RecentScrapbooks);
rebuildRecentPasteMenu();
connect(scrapbookPalette, SIGNAL(updateRecentMenue()), this, SLOT(rebuildRecentPasteMenu()));
connect(ScCore->fileWatcher, SIGNAL(dirChanged(QString )), scrapbookPalette, SLOT(reloadLib(QString )));
+ connect(ScCore->fileWatcher, SIGNAL(dirDeleted(QString )), scrapbookPalette, SLOT(closeOnDel(QString )));
}
Modified: trunk/Scribus/scribus/ui/scrapbookpalette.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15527&path=/trunk/Scribus/scribus/ui/scrapbookpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scrapbookpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/scrapbookpalette.cpp Tue Oct 12 21:48:08 2010
@@ -185,9 +185,11 @@
e->ignore();
}
-void BibView::AddObj(QString name, QString daten, QPixmap Bild)
+void BibView::AddObj(QString name, QString daten, QPixmap Bild, bool isDir, bool isRaster)
{
struct Elem DrElem;
+ DrElem.isDir = false;
+ DrElem.isRaster = false;
DrElem.Data = daten;
DrElem.Preview = Bild;
objectMap.insert(name, DrElem);
@@ -435,9 +437,9 @@
fil.close();
QPixmap pm;
QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(name + "/" + d4[dc])));
- QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
+ QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.fileName()+".png")));
if (fi2.exists())
- pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
+ pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.fileName()+".png")));
else
{
FileLoader *fileLoader = new FileLoader(QDir::cleanPath(QDir::convertSeparators(name + "/" + d4[dc])));
@@ -455,8 +457,8 @@
}
}
QFileInfo fi3(QDir::cleanPath(QDir::convertSeparators(name + "/" + d4[dc])));
- if (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews)
- pm.save(QDir::cleanPath(QDir::convertSeparators(fi3.path()+"/.ScribusThumbs/"+fi3.baseName()+".png")), "PNG");
+ if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
+ pm.save(QDir::cleanPath(QDir::convertSeparators(fi3.path()+"/.ScribusThumbs/"+fi3.fileName()+".png")), "PNG");
}
}
}
@@ -481,9 +483,9 @@
fil.close();
QPixmap pm;
QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(name + "/" + d5[dc])));
- QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
+ QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.fileName()+".png")));
if (fi2.exists())
- pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
+ pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.fileName()+".png")));
else
{
bool mode = false;
@@ -494,11 +496,10 @@
{
QImage img = im.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
- img.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")), "PNG");
+ img.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.fileName()+".png")), "PNG");
pm = QPixmap::fromImage(img);
}
}
- AddObj(fi.baseName(), QDir::cleanPath(QDir::convertSeparators(name + "/" + d5[dc])), pm);
}
}
}
@@ -581,6 +582,8 @@
fileCount += d5.count();
}
QProgressDialog *pgDia = NULL;
+ QStringList previewFiles;
+ previewFiles.clear();
if (ScCore->initialized())
{
pgDia = new QProgressDialog("Reading Files...", QString(), 0, fileCount, this);
@@ -601,21 +604,28 @@
continue;
QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(name + "/" + d[dc])));
QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
+ QFileInfo fi3(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")));
if (fi2.exists())
pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
else
{
- QString f;
- if (cf.left(16) == "<SCRIBUSELEMUTF8")
- f = QString::fromUtf8(cf.data());
+ if (fi3.exists())
+ pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")));
else
- f = cf.data();
- ScPreview *pre = new ScPreview();
- pm = QPixmap::fromImage(pre->createPreview(f));
- if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
- pm.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")), "PNG");
- delete pre;
- }
+ {
+ QString f;
+ if (cf.left(16) == "<SCRIBUSELEMUTF8")
+ f = QString::fromUtf8(cf.data());
+ else
+ f = cf.data();
+ ScPreview *pre = new ScPreview();
+ pm = QPixmap::fromImage(pre->createPreview(f));
+ if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
+ pm.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")), "PNG");
+ delete pre;
+ }
+ }
+ previewFiles.append(fi.baseName()+".png");
AddObj(fi.baseName(), QDir::cleanPath(QDir::convertSeparators(name + "/" + d[dc])), pm);
}
}
@@ -633,18 +643,25 @@
if (!loadRawText(QDir::cleanPath(QDir::convertSeparators(name + "/" + d2[dc])), cf))
continue;
QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(name + "/" + d2[dc])));
- QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")));
+ QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
+ QFileInfo fi3(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")));
if (fi2.exists())
- pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")));
+ pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
else
{
- QString f = QString::fromUtf8(cf.data());
- StencilReader *pre = new StencilReader();
- pm = pre->createPreview(f);
- if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
- pm.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")), "PNG");
- delete pre;
- }
+ if (fi3.exists())
+ pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")));
+ else
+ {
+ QString f = QString::fromUtf8(cf.data());
+ StencilReader *pre = new StencilReader();
+ pm = pre->createPreview(f);
+ if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
+ pm.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")), "PNG");
+ delete pre;
+ }
+ }
+ previewFiles.append(fi.baseName()+".png");
AddObj(fi.baseName(), QDir::cleanPath(QDir::convertSeparators(name + "/" + d2[dc])), pm);
}
}
@@ -664,12 +681,24 @@
QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(name + "/" + d3[dc])));
QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")));
QFileInfo fi2p(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".xpm")));
- if ((fi2.exists()) || (fi2p.exists()))
- {
- if (fi2.exists())
+ QFileInfo fi3(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
+ if ((fi2.exists()) || (fi2p.exists()) || (fi3.exists()))
+ {
+ if (fi3.exists())
+ {
+ pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
+ previewFiles.append(fi.baseName()+".png");
+ }
+ else if (fi2.exists())
+ {
pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")));
- else
+ previewFiles.append(fi.baseName()+".png");
+ }
+ else if (fi2p.exists())
+ {
pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".xpm")));
+ previewFiles.append(fi.baseName()+".xpm");
+ }
}
else
{
@@ -679,7 +708,7 @@
ScPreview *pre2 = new ScPreview();
pm = QPixmap::fromImage(pre2->createPreview(f2));
if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
- pm.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")), "PNG");
+ pm.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")), "PNG");
delete pre;
delete pre2;
}
@@ -701,9 +730,9 @@
}
QPixmap pm;
QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(name + "/" + d4[dc])));
- QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
+ QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.fileName()+".png")));
if (fi2.exists())
- pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
+ pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.fileName()+".png")));
else
{
FileLoader *fileLoader = new FileLoader(QDir::cleanPath(QDir::convertSeparators(name + "/" + d4[dc])));
@@ -717,12 +746,12 @@
QImage im = fmt->readThumbnail(QDir::cleanPath(QDir::convertSeparators(name + "/" + d4[dc])));
im = im.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
- im.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")), "PNG");
+ im.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.fileName()+".png")), "PNG");
pm = QPixmap::fromImage(im);
}
}
}
- AddObj(fi.baseName(), QDir::cleanPath(QDir::convertSeparators(name + "/" + d4[dc])), pm);
+ AddObj(fi.fileName(), QDir::cleanPath(QDir::convertSeparators(name + "/" + d4[dc])), pm);
}
}
}
@@ -739,11 +768,13 @@
pgDia->setValue(readCount);
readCount++;
}
+ if (previewFiles.contains(d5[dc]))
+ continue;
QPixmap pm;
QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(name + "/" + d5[dc])));
- QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
+ QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.fileName()+".png")));
if (fi2.exists())
- pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
+ pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.fileName()+".png")));
else
{
bool mode = false;
@@ -754,11 +785,11 @@
{
QImage img = im.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
- img.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")), "PNG");
+ img.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.fileName()+".png")), "PNG");
pm = QPixmap::fromImage(img);
}
}
- AddObj(fi.baseName(), QDir::cleanPath(QDir::convertSeparators(name + "/" + d5[dc])), pm);
+ AddObj(fi.fileName(), QDir::cleanPath(QDir::convertSeparators(name + "/" + d5[dc])), pm, false, true);
}
}
}
@@ -867,7 +898,7 @@
activeBView->ReadContents(fileName);
activeBView->ScFilename = fileName;
activeBView->visibleName = d.dirName();
- ScCore->fileWatcher->addDir(d.absolutePath());
+ ScCore->fileWatcher->addDir(d.absolutePath(), true);
activeBView->scrollToTop();
}
}
@@ -948,6 +979,48 @@
}
void Biblio::NewLib()
+{
+ PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
+ QString fileName = QFileDialog::getExistingDirectory(this, tr("Choose a Scrapbook Directory"), dirs->get("scrap_load", "."));
+ if (!fileName.isEmpty())
+ {
+ for (int a = 0; a < Frame3->count(); a++)
+ {
+ BibView* bv = (BibView*)Frame3->widget(a);
+ if (fileName == bv->ScFilename)
+ return;
+ }
+ disconnect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
+ disconnect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
+ disconnect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
+ disconnect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
+ disconnect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
+ QDir d(fileName);
+ activeBView = new BibView(this);
+ QFileInfo fd(fileName);
+ activeBView->canWrite = fd.isWritable();
+ activeBView->setAcceptDrops(activeBView->canWrite);
+ if (activeBView->canWrite)
+ Frame3->addItem(activeBView, d.dirName());
+ else
+ Frame3->addItem(activeBView, QIcon(loadIcon("16/lock.png")), d.dirName());
+ activeBView->ReadContents(fileName);
+ activeBView->ScFilename = fileName;
+ activeBView->visibleName = d.dirName();
+ Frame3->setCurrentWidget(activeBView);
+ ScCore->fileWatcher->addDir(d.absolutePath(), true);
+ d.cdUp();
+ dirs->set("scrap_load", d.absolutePath());
+ activeBView->scrollToTop();
+ connect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
+ connect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
+ connect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
+ connect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
+ connect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
+ }
+}
+/*
+void Biblio::Load()
{
PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
QString fileName = QFileDialog::getExistingDirectory(this, tr("Choose a Scrapbook Directory"), dirs->get("scrap_load", "."));
@@ -988,48 +1061,6 @@
connect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
}
}
-/*
-void Biblio::Load()
-{
- PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
- QString fileName = QFileDialog::getExistingDirectory(this, tr("Choose a Scrapbook Directory"), dirs->get("scrap_load", "."));
- if (!fileName.isEmpty())
- {
- for (int a = 0; a < Frame3->count(); a++)
- {
- BibView* bv = (BibView*)Frame3->widget(a);
- if (fileName == bv->ScFilename)
- return;
- }
- disconnect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
- disconnect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
- disconnect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
- disconnect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
- disconnect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
- QDir d(fileName);
- activeBView = new BibView(this);
- QFileInfo fd(fileName);
- activeBView->canWrite = fd.isWritable();
- activeBView->setAcceptDrops(activeBView->canWrite);
- if (activeBView->canWrite)
- Frame3->addItem(activeBView, d.dirName());
- else
- Frame3->addItem(activeBView, QIcon(loadIcon("16/lock.png")), d.dirName());
- activeBView->ReadContents(fileName);
- activeBView->ScFilename = fileName;
- activeBView->visibleName = d.dirName();
- Frame3->setCurrentWidget(activeBView);
- ScCore->fileWatcher->addDir(d.absolutePath());
- d.cdUp();
- dirs->set("scrap_load", d.absolutePath());
- activeBView->scrollToTop();
- connect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
- connect(activeBView, SIGNAL(objDropped(QString)), this, SLOT(ObjFromMenu(QString)));
- connect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
- connect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
- connect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
- }
-}
*/
void Biblio::Import()
{
@@ -1112,6 +1143,34 @@
connect(activeBView, SIGNAL(fileDropped(QString, int)), this, SLOT(ObjFromFile(QString, int)));
connect(activeBView, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleMouse(QPoint)));
connect(activeBView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
+}
+
+void Biblio::closeOnDel(QString libName)
+{
+ BibView* bv = NULL;
+ int libIndex = 0;
+ for (int a = 0; a < Frame3->count(); a++)
+ {
+ bv = (BibView*)Frame3->widget(a);
+ if (libName == bv->ScFilename)
+ {
+ libIndex = a;
+ break;
+ }
+ }
+ if ((libIndex == 0) || (libIndex == 1))
+ return;
+ if (bv == activeBView)
+ closeLib();
+ else
+ {
+ disconnect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
+ QFileInfo fi(bv->ScFilename);
+ ScCore->fileWatcher->removeDir(fi.absolutePath());
+ Frame3->removeItem(Frame3->indexOf(bv));
+ delete bv;
+ connect(Frame3, SIGNAL(currentChanged(int)), this, SLOT(libChanged(int )));
+ }
}
void Biblio::reloadLib(QString fileName)
Modified: trunk/Scribus/scribus/ui/scrapbookpalette.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15527&path=/trunk/Scribus/scribus/ui/scrapbookpalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/scrapbookpalette.h (original)
+++ trunk/Scribus/scribus/ui/scrapbookpalette.h Tue Oct 12 21:48:08 2010
@@ -32,13 +32,15 @@
public:
BibView( QWidget* parent);
~BibView() {};
- void AddObj(QString name, QString daten, QPixmap Bild);
+ void AddObj(QString name, QString daten, QPixmap Bild, bool isDir = false, bool isRaster = false);
void checkAndChange(QString &text, QString nam, QString dir);
void SaveContents(QString name, QString oldName);
void ReadOldContents(QString, QString newName);
void ReadContents(QString name);
struct Elem
{
+ bool isDir;
+ bool isRaster;
QString Data;
QPixmap Preview;
};
@@ -95,6 +97,7 @@
void ObjFromFile(QString path, int testResult);
void ObjFromMenu(QString text);
void ObjFromMainMenu(QString text, int scrapID);
+ void closeOnDel(QString libName);
void reloadLib(QString fileName);
private slots:
More information about the scribus-commit
mailing list